1 /* Copyright (c) 2007-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "simgrid/msg.h"
8 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
10 static int computation_fun(int argc, char* argv[])
12 msg_task_t task = MSG_task_create("Task", 100000000, 0, NULL);
14 double clock_sta = MSG_get_clock();
15 MSG_task_execute(task);
16 double clock_end = MSG_get_clock();
18 XBT_INFO("Task took %gs to execute", clock_end - clock_sta);
20 MSG_task_destroy(task);
25 static int master_main(int argc, char* argv[])
28 XBT_INFO("# TEST ON SINGLE-CORE PMs");
30 msg_host_t pm0 = MSG_host_by_name("node-0.acme.org");
31 msg_host_t pm1 = MSG_host_by_name("node-1.acme.org");
32 xbt_assert(pm0, "Host node-0.acme.org does not seem to exist");
34 XBT_INFO("## Test 1 (started): check computation on normal PMs");
36 XBT_INFO("### Put a task on a PM");
37 MSG_process_create("compute", computation_fun, NULL, pm0);
40 XBT_INFO("### Put two tasks on a PM");
41 MSG_process_create("compute", computation_fun, NULL, pm0);
42 MSG_process_create("compute", computation_fun, NULL, pm0);
45 XBT_INFO("### Put a task on each PM");
46 MSG_process_create("compute", computation_fun, NULL, pm0);
47 MSG_process_create("compute", computation_fun, NULL, pm1);
50 XBT_INFO("## Test 1 (ended)");
52 XBT_INFO("# TEST ON SINGLE-CORE PMs AND SINGLE-CORE VMs");
54 XBT_INFO("## Test 2 (started): check impact of running tasks inside a VM (there is no degradation for the moment)");
56 XBT_INFO("### Put a VM on a PM, and put a task to the VM");
57 msg_vm_t vm0 = MSG_vm_create_core(pm0, "VM0");
59 MSG_process_create("compute", computation_fun, NULL, vm0);
63 XBT_INFO("### Put a VM on a PM, and put two task to the VM");
64 vm0 = MSG_vm_create_core(pm0, "VM0");
66 MSG_process_create("compute", computation_fun, NULL, vm0);
67 MSG_process_create("compute", computation_fun, NULL, vm0);
71 XBT_INFO("## Test 2 (ended)");
73 XBT_INFO("## Test 3 (started): check impact of running tasks collocated with VMs (there is no VM noise for the moment)");
75 XBT_INFO("### Put a task on a PM collocated with an empty VM");
77 vm0 = MSG_vm_create_core(pm0, "VM0");
79 MSG_process_create("compute", computation_fun, NULL, pm0);
83 XBT_INFO("### Put a VM on a PM, put a task to the PM and a task to the VM");
85 vm0 = MSG_vm_create_core(pm0, "VM0");
87 MSG_process_create("compute", computation_fun, NULL, pm0);
88 MSG_process_create("compute", computation_fun, NULL, vm0);
92 XBT_INFO("### Put a VM on a PM, put a task to the PM and two tasks to the VM");
94 vm0 = MSG_vm_create_core(pm0, "VM0");
96 MSG_process_create("compute", computation_fun, NULL, pm0);
97 MSG_process_create("compute", computation_fun, NULL, vm0);
98 MSG_process_create("compute", computation_fun, NULL, vm0);
102 XBT_INFO("## Test 3 (ended)");
104 XBT_INFO("# TEST ON TWO-CORE PMs");
106 pm0 = MSG_host_by_name("node-0.acme2.org");
107 pm1 = MSG_host_by_name("node-1.acme2.org");
108 xbt_assert(pm0, "Host node-0.acme2.org does not seem to exist");
110 XBT_INFO("## Test 4 (started): check computation on 2 cores PMs");
112 XBT_INFO("### Put a task on a PM");
113 MSG_process_create("compute", computation_fun, NULL, pm0);
114 MSG_process_sleep(2);
116 XBT_INFO("### Put two tasks on a PM");
117 MSG_process_create("compute", computation_fun, NULL, pm0);
118 MSG_process_create("compute", computation_fun, NULL, pm0);
119 MSG_process_sleep(2);
121 XBT_INFO("### Put three tasks on a PM");
122 MSG_process_create("compute", computation_fun, NULL, pm0);
123 MSG_process_create("compute", computation_fun, NULL, pm0);
124 MSG_process_create("compute", computation_fun, NULL, pm0);
125 MSG_process_sleep(2);
127 XBT_INFO("## Test 4 (ended)");
129 XBT_INFO("# TEST ON TWO-CORE PMs AND SINGLE-CORE VMs");
131 XBT_INFO("## Test 5 (started): check impact of a single VM (there is no degradation for the moment)");
133 XBT_INFO("### Put a VM on a PM, and put a task to the VM");
134 vm0 = MSG_vm_create_core(pm0, "VM0");
136 MSG_process_create("compute", computation_fun, NULL, vm0);
137 MSG_process_sleep(2);
140 XBT_INFO("### Put a VM on a PM, and put two tasks to the VM");
141 vm0 = MSG_vm_create_core(pm0, "VM0");
143 MSG_process_create("compute", computation_fun, NULL, vm0);
144 MSG_process_create("compute", computation_fun, NULL, vm0);
145 MSG_process_sleep(2);
148 XBT_INFO("### Put a VM on a PM, and put a task to the PM");
149 vm0 = MSG_vm_create_core(pm0, "VM0");
151 MSG_process_create("compute", computation_fun, NULL, pm0);
152 MSG_process_sleep(2);
155 XBT_INFO("### Put a VM on a PM, put a task to the PM and a task to the VM");
156 vm0 = MSG_vm_create_core(pm0, "VM0");
158 MSG_process_create("compute", computation_fun, NULL, pm0);
159 MSG_process_create("compute", computation_fun, NULL, vm0);
160 MSG_process_sleep(2);
163 XBT_INFO("## Test 5 (ended)");
165 XBT_INFO("## Test 6 (started): check impact of a several VMs (there is no degradation for the moment)");
167 XBT_INFO("### Put two VMs on a PM, and put a task to one VM");
168 vm0 = MSG_vm_create_core(pm0, "VM0");
169 msg_vm_t vm1 = MSG_vm_create_core(pm0, "VM1");
172 MSG_process_create("compute", computation_fun, NULL, vm0);
173 MSG_process_sleep(2);
177 XBT_INFO("### Put two VMs on a PM, and put a task to each VM");
178 vm0 = MSG_vm_create_core(pm0, "VM0");
179 vm1 = MSG_vm_create_core(pm0, "VM1");
182 MSG_process_create("compute", computation_fun, NULL, vm0);
183 MSG_process_create("compute", computation_fun, NULL, vm1);
184 MSG_process_sleep(2);
188 XBT_INFO("### Put three VMs on a PM, and put a task to two VMs");
189 vm0 = MSG_vm_create_core(pm0, "VM0");
190 vm1 = MSG_vm_create_core(pm0, "VM1");
191 msg_vm_t vm2 = MSG_vm_create_core(pm0, "VM2");
195 MSG_process_create("compute", computation_fun, NULL, vm0);
196 MSG_process_create("compute", computation_fun, NULL, vm1);
197 MSG_process_sleep(2);
202 XBT_INFO("### Put three VMs on a PM, and put a task to each VM");
203 vm0 = MSG_vm_create_core(pm0, "VM0");
204 vm1 = MSG_vm_create_core(pm0, "VM1");
205 vm2 = MSG_vm_create_core(pm0, "VM2");
209 MSG_process_create("compute", computation_fun, NULL, vm0);
210 MSG_process_create("compute", computation_fun, NULL, vm1);
211 MSG_process_create("compute", computation_fun, NULL, vm2);
212 MSG_process_sleep(2);
217 XBT_INFO("## Test 6 (ended)");
219 XBT_INFO("# TEST ON TWO-CORE PMs AND TWO-CORE VMs");
221 XBT_INFO("## Test 7 (started): check impact of a single VM (there is no degradation for the moment)");
223 XBT_INFO("### Put a VM on a PM, and put a task to the VM");
224 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
226 MSG_process_create("compute", computation_fun, NULL, vm0);
227 MSG_process_sleep(2);
230 XBT_INFO("### Put a VM on a PM, and put two tasks to the VM");
231 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
233 MSG_process_create("compute", computation_fun, NULL, vm0);
234 MSG_process_create("compute", computation_fun, NULL, vm0);
235 MSG_process_sleep(2);
238 XBT_INFO("### Put a VM on a PM, and put three tasks to the VM");
239 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
241 MSG_process_create("compute", computation_fun, NULL, vm0);
242 MSG_process_create("compute", computation_fun, NULL, vm0);
243 MSG_process_create("compute", computation_fun, NULL, vm0);
244 MSG_process_sleep(2);
247 XBT_INFO("## Test 7 (ended)");
249 XBT_INFO("## Test 8 (started): check impact of a single VM collocated with a task (there is no degradation for the moment)");
251 XBT_INFO("### Put a VM on a PM, and put a task to the PM");
252 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
254 MSG_process_create("compute", computation_fun, NULL, pm0);
255 MSG_process_sleep(2);
258 XBT_INFO("### Put a VM on a PM, put one task to the PM and one task to the VM");
259 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
261 MSG_process_create("compute", computation_fun, NULL, pm0);
262 MSG_process_create("compute", computation_fun, NULL, vm0);
263 MSG_process_sleep(2);
266 XBT_INFO("### Put a VM on a PM, put one task to the PM and two tasks to the VM");
267 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
269 MSG_process_create("compute", computation_fun, NULL, pm0);
270 MSG_process_create("compute", computation_fun, NULL, vm0);
271 MSG_process_create("compute", computation_fun, NULL, vm0);
272 MSG_process_sleep(2);
275 XBT_INFO("### Put a VM on a PM, put one task to the PM and three tasks to the VM");
276 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
278 MSG_process_create("compute", computation_fun, NULL, pm0);
279 MSG_process_create("compute", computation_fun, NULL, vm0);
280 MSG_process_create("compute", computation_fun, NULL, vm0);
281 MSG_process_create("compute", computation_fun, NULL, vm0);
282 MSG_process_sleep(2);
285 XBT_INFO("## Test 8 (ended)");
287 XBT_INFO("# TEST ON FOUR-CORE PMs AND TWO-CORE VMs");
289 pm0 = MSG_host_by_name("node-0.acme4.org");
290 pm1 = MSG_host_by_name("node-1.acme4.org");
291 xbt_assert(pm0, "Host node-0.acme4.org does not seem to exist");
293 XBT_INFO("## Test 9 (started): check impact of a single VM");
295 XBT_INFO("### Put a VM on a PM, and put a task to the VM");
296 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
298 MSG_process_create("compute", computation_fun, NULL, vm0);
299 MSG_process_sleep(2);
302 XBT_INFO("### Put a VM on a PM, and put two tasks to the VM");
303 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
305 MSG_process_create("compute", computation_fun, NULL, vm0);
306 MSG_process_create("compute", computation_fun, NULL, vm0);
307 MSG_process_sleep(2);
310 XBT_INFO("### Put a VM on a PM, and put three tasks to the VM");
311 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
313 MSG_process_create("compute", computation_fun, NULL, vm0);
314 MSG_process_create("compute", computation_fun, NULL, vm0);
315 MSG_process_create("compute", computation_fun, NULL, vm0);
316 MSG_process_sleep(2);
319 XBT_INFO("## Test 9 (ended)");
321 XBT_INFO("## Test 10 (started): check impact of a single emtpy VM collocated with tasks");
323 XBT_INFO("### Put a VM on a PM, and put a task to the PM");
324 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
326 MSG_process_create("compute", computation_fun, NULL, pm0);
327 MSG_process_sleep(2);
330 XBT_INFO("### Put a VM on a PM, and put two tasks to the PM");
331 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
333 MSG_process_create("compute", computation_fun, NULL, pm0);
334 MSG_process_create("compute", computation_fun, NULL, pm0);
335 MSG_process_sleep(2);
338 XBT_INFO("### Put a VM on a PM, and put three tasks to the PM");
339 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
341 MSG_process_create("compute", computation_fun, NULL, pm0);
342 MSG_process_create("compute", computation_fun, NULL, pm0);
343 MSG_process_create("compute", computation_fun, NULL, pm0);
344 MSG_process_sleep(2);
347 XBT_INFO("### Put a VM on a PM, and put four tasks to the PM");
348 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
350 MSG_process_create("compute", computation_fun, NULL, pm0);
351 MSG_process_create("compute", computation_fun, NULL, pm0);
352 MSG_process_create("compute", computation_fun, NULL, pm0);
353 MSG_process_create("compute", computation_fun, NULL, pm0);
354 MSG_process_sleep(2);
357 XBT_INFO("## Test 10 (ended)");
359 XBT_INFO("## Test 11 (started): check impact of a single working VM collocated with tasks");
361 XBT_INFO("### Put a VM on a PM, and put one task to the PM and one task to the VM");
362 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
364 MSG_process_create("compute", computation_fun, NULL, vm0);
365 MSG_process_create("compute", computation_fun, NULL, pm0);
366 MSG_process_sleep(2);
369 XBT_INFO("### Put a VM on a PM, and put two tasks to the PM and one task to the VM");
370 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
372 MSG_process_create("compute", computation_fun, NULL, vm0);
373 MSG_process_create("compute", computation_fun, NULL, pm0);
374 MSG_process_create("compute", computation_fun, NULL, pm0);
375 MSG_process_sleep(2);
378 XBT_INFO("### Put a VM on a PM, and put two tasks to the PM and two tasks to the VM");
379 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
381 MSG_process_create("compute", computation_fun, NULL, vm0);
382 MSG_process_create("compute", computation_fun, NULL, vm0);
383 MSG_process_create("compute", computation_fun, NULL, pm0);
384 MSG_process_create("compute", computation_fun, NULL, pm0);
385 MSG_process_sleep(2);
388 XBT_INFO("### Put a VM on a PM, and put three tasks to the PM and one tasks to the VM");
389 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
391 MSG_process_create("compute", computation_fun, NULL, vm0);
392 MSG_process_create("compute", computation_fun, NULL, pm0);
393 MSG_process_create("compute", computation_fun, NULL, pm0);
394 MSG_process_create("compute", computation_fun, NULL, pm0);
395 MSG_process_sleep(2);
398 XBT_INFO("### Put a VM on a PM, and put three tasks to the PM and two tasks to the VM");
399 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
401 MSG_process_create("compute", computation_fun, NULL, vm0);
402 MSG_process_create("compute", computation_fun, NULL, vm0);
403 MSG_process_create("compute", computation_fun, NULL, pm0);
404 MSG_process_create("compute", computation_fun, NULL, pm0);
405 MSG_process_create("compute", computation_fun, NULL, pm0);
406 MSG_process_sleep(2);
409 XBT_INFO("### Put a VM on a PM, and put three tasks to the PM and three tasks to the VM");
410 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
412 MSG_process_create("compute", computation_fun, NULL, vm0);
413 MSG_process_create("compute", computation_fun, NULL, vm0);
414 MSG_process_create("compute", computation_fun, NULL, vm0);
415 MSG_process_create("compute", computation_fun, NULL, pm0);
416 MSG_process_create("compute", computation_fun, NULL, pm0);
417 MSG_process_create("compute", computation_fun, NULL, pm0);
418 MSG_process_sleep(2);
421 XBT_INFO("## Test 11 (ended)");
426 int main(int argc, char* argv[])
428 /* Get the arguments */
429 MSG_init(&argc, argv);
431 /* load the platform file */
432 const char* platform = "../../platforms/cluster.xml";
435 MSG_create_environment(platform);
437 msg_host_t pm0 = MSG_host_by_name("node-0.acme.org");
438 xbt_assert(pm0, "Host 'node-0.acme.org' not found");
439 MSG_process_create("master", master_main, NULL, pm0);
441 return MSG_main() != MSG_OK;