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 xbt_assert(pm0, "Host node-0.acme2.org does not seem to exist");
109 XBT_INFO("## Test 4 (started): check computation on 2 cores PMs");
111 XBT_INFO("### Put a task on a PM");
112 MSG_process_create("compute", computation_fun, NULL, pm0);
113 MSG_process_sleep(2);
115 XBT_INFO("### Put two tasks on a PM");
116 MSG_process_create("compute", computation_fun, NULL, pm0);
117 MSG_process_create("compute", computation_fun, NULL, pm0);
118 MSG_process_sleep(2);
120 XBT_INFO("### Put three tasks on a PM");
121 MSG_process_create("compute", computation_fun, NULL, pm0);
122 MSG_process_create("compute", computation_fun, NULL, pm0);
123 MSG_process_create("compute", computation_fun, NULL, pm0);
124 MSG_process_sleep(2);
126 XBT_INFO("## Test 4 (ended)");
128 XBT_INFO("# TEST ON TWO-CORE PMs AND SINGLE-CORE VMs");
130 XBT_INFO("## Test 5 (started): check impact of a single VM (there is no degradation for the moment)");
132 XBT_INFO("### Put a VM on a PM, and put a task to the VM");
133 vm0 = MSG_vm_create_core(pm0, "VM0");
135 MSG_process_create("compute", computation_fun, NULL, vm0);
136 MSG_process_sleep(2);
139 XBT_INFO("### Put a VM on a PM, and put two tasks to the VM");
140 vm0 = MSG_vm_create_core(pm0, "VM0");
142 MSG_process_create("compute", computation_fun, NULL, vm0);
143 MSG_process_create("compute", computation_fun, NULL, vm0);
144 MSG_process_sleep(2);
147 XBT_INFO("### Put a VM on a PM, and put a task to the PM");
148 vm0 = MSG_vm_create_core(pm0, "VM0");
150 MSG_process_create("compute", computation_fun, NULL, pm0);
151 MSG_process_sleep(2);
154 XBT_INFO("### Put a VM on a PM, put a task to the PM and a task to the VM");
155 vm0 = MSG_vm_create_core(pm0, "VM0");
157 MSG_process_create("compute", computation_fun, NULL, pm0);
158 MSG_process_create("compute", computation_fun, NULL, vm0);
159 MSG_process_sleep(2);
162 XBT_INFO("## Test 5 (ended)");
164 XBT_INFO("## Test 6 (started): check impact of a several VMs (there is no degradation for the moment)");
166 XBT_INFO("### Put two VMs on a PM, and put a task to one VM");
167 vm0 = MSG_vm_create_core(pm0, "VM0");
168 msg_vm_t vm1 = MSG_vm_create_core(pm0, "VM1");
171 MSG_process_create("compute", computation_fun, NULL, vm0);
172 MSG_process_sleep(2);
176 XBT_INFO("### Put two VMs on a PM, and put a task to each VM");
177 vm0 = MSG_vm_create_core(pm0, "VM0");
178 vm1 = MSG_vm_create_core(pm0, "VM1");
181 MSG_process_create("compute", computation_fun, NULL, vm0);
182 MSG_process_create("compute", computation_fun, NULL, vm1);
183 MSG_process_sleep(2);
187 XBT_INFO("### Put three VMs on a PM, and put a task to two VMs");
188 vm0 = MSG_vm_create_core(pm0, "VM0");
189 vm1 = MSG_vm_create_core(pm0, "VM1");
190 msg_vm_t vm2 = MSG_vm_create_core(pm0, "VM2");
194 MSG_process_create("compute", computation_fun, NULL, vm0);
195 MSG_process_create("compute", computation_fun, NULL, vm1);
196 MSG_process_sleep(2);
201 XBT_INFO("### Put three VMs on a PM, and put a task to each VM");
202 vm0 = MSG_vm_create_core(pm0, "VM0");
203 vm1 = MSG_vm_create_core(pm0, "VM1");
204 vm2 = MSG_vm_create_core(pm0, "VM2");
208 MSG_process_create("compute", computation_fun, NULL, vm0);
209 MSG_process_create("compute", computation_fun, NULL, vm1);
210 MSG_process_create("compute", computation_fun, NULL, vm2);
211 MSG_process_sleep(2);
216 XBT_INFO("## Test 6 (ended)");
218 XBT_INFO("# TEST ON TWO-CORE PMs AND TWO-CORE VMs");
220 XBT_INFO("## Test 7 (started): check impact of a single VM (there is no degradation for the moment)");
222 XBT_INFO("### Put a VM on a PM, and put a task to the VM");
223 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
225 MSG_process_create("compute", computation_fun, NULL, vm0);
226 MSG_process_sleep(2);
229 XBT_INFO("### Put a VM on a PM, and put two tasks to the VM");
230 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
232 MSG_process_create("compute", computation_fun, NULL, vm0);
233 MSG_process_create("compute", computation_fun, NULL, vm0);
234 MSG_process_sleep(2);
237 XBT_INFO("### Put a VM on a PM, and put three tasks to the VM");
238 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
240 MSG_process_create("compute", computation_fun, NULL, vm0);
241 MSG_process_create("compute", computation_fun, NULL, vm0);
242 MSG_process_create("compute", computation_fun, NULL, vm0);
243 MSG_process_sleep(2);
246 XBT_INFO("## Test 7 (ended)");
248 XBT_INFO("## Test 8 (started): check impact of a single VM collocated with a task (there is no degradation for the moment)");
250 XBT_INFO("### Put a VM on a PM, and put a task to the PM");
251 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
253 MSG_process_create("compute", computation_fun, NULL, pm0);
254 MSG_process_sleep(2);
257 XBT_INFO("### Put a VM on a PM, put one task to the PM and one task to the VM");
258 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
260 MSG_process_create("compute", computation_fun, NULL, pm0);
261 MSG_process_create("compute", computation_fun, NULL, vm0);
262 MSG_process_sleep(2);
265 XBT_INFO("### Put a VM on a PM, put one task to the PM and two tasks to the VM");
266 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
268 MSG_process_create("compute", computation_fun, NULL, pm0);
269 MSG_process_create("compute", computation_fun, NULL, vm0);
270 MSG_process_create("compute", computation_fun, NULL, vm0);
271 MSG_process_sleep(2);
274 XBT_INFO("### Put a VM on a PM, put one task to the PM and three tasks to the VM");
275 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
277 MSG_process_create("compute", computation_fun, NULL, pm0);
278 MSG_process_create("compute", computation_fun, NULL, vm0);
279 MSG_process_create("compute", computation_fun, NULL, vm0);
280 MSG_process_create("compute", computation_fun, NULL, vm0);
281 MSG_process_sleep(2);
284 XBT_INFO("## Test 8 (ended)");
286 XBT_INFO("# TEST ON FOUR-CORE PMs AND TWO-CORE VMs");
288 pm0 = MSG_host_by_name("node-0.acme4.org");
289 xbt_assert(pm0, "Host node-0.acme4.org does not seem to exist");
291 XBT_INFO("## Test 9 (started): check impact of a single VM");
293 XBT_INFO("### Put a VM on a PM, and put a task to the VM");
294 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
296 MSG_process_create("compute", computation_fun, NULL, vm0);
297 MSG_process_sleep(2);
300 XBT_INFO("### Put a VM on a PM, and put two tasks to the VM");
301 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
303 MSG_process_create("compute", computation_fun, NULL, vm0);
304 MSG_process_create("compute", computation_fun, NULL, vm0);
305 MSG_process_sleep(2);
308 XBT_INFO("### Put a VM on a PM, and put three tasks to the VM");
309 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
311 MSG_process_create("compute", computation_fun, NULL, vm0);
312 MSG_process_create("compute", computation_fun, NULL, vm0);
313 MSG_process_create("compute", computation_fun, NULL, vm0);
314 MSG_process_sleep(2);
317 XBT_INFO("## Test 9 (ended)");
319 XBT_INFO("## Test 10 (started): check impact of a single emtpy VM collocated with tasks");
321 XBT_INFO("### Put a VM on a PM, and put a task to the PM");
322 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
324 MSG_process_create("compute", computation_fun, NULL, pm0);
325 MSG_process_sleep(2);
328 XBT_INFO("### Put a VM on a PM, and put two tasks to the PM");
329 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
331 MSG_process_create("compute", computation_fun, NULL, pm0);
332 MSG_process_create("compute", computation_fun, NULL, pm0);
333 MSG_process_sleep(2);
336 XBT_INFO("### Put a VM on a PM, and put three tasks to the PM");
337 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
339 MSG_process_create("compute", computation_fun, NULL, pm0);
340 MSG_process_create("compute", computation_fun, NULL, pm0);
341 MSG_process_create("compute", computation_fun, NULL, pm0);
342 MSG_process_sleep(2);
345 XBT_INFO("### Put a VM on a PM, and put four tasks to the PM");
346 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
348 MSG_process_create("compute", computation_fun, NULL, pm0);
349 MSG_process_create("compute", computation_fun, NULL, pm0);
350 MSG_process_create("compute", computation_fun, NULL, pm0);
351 MSG_process_create("compute", computation_fun, NULL, pm0);
352 MSG_process_sleep(2);
355 XBT_INFO("## Test 10 (ended)");
357 XBT_INFO("## Test 11 (started): check impact of a single working VM collocated with tasks");
359 XBT_INFO("### Put a VM on a PM, and put one task to the PM and one task to the VM");
360 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
362 MSG_process_create("compute", computation_fun, NULL, vm0);
363 MSG_process_create("compute", computation_fun, NULL, pm0);
364 MSG_process_sleep(2);
367 XBT_INFO("### Put a VM on a PM, and put two tasks to the PM and one task to the VM");
368 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
370 MSG_process_create("compute", computation_fun, NULL, vm0);
371 MSG_process_create("compute", computation_fun, NULL, pm0);
372 MSG_process_create("compute", computation_fun, NULL, pm0);
373 MSG_process_sleep(2);
376 XBT_INFO("### Put a VM on a PM, and put two tasks to the PM and two tasks to the VM");
377 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
379 MSG_process_create("compute", computation_fun, NULL, vm0);
380 MSG_process_create("compute", computation_fun, NULL, vm0);
381 MSG_process_create("compute", computation_fun, NULL, pm0);
382 MSG_process_create("compute", computation_fun, NULL, pm0);
383 MSG_process_sleep(2);
386 XBT_INFO("### Put a VM on a PM, and put three tasks to the PM and one tasks to the VM");
387 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
389 MSG_process_create("compute", computation_fun, NULL, vm0);
390 MSG_process_create("compute", computation_fun, NULL, pm0);
391 MSG_process_create("compute", computation_fun, NULL, pm0);
392 MSG_process_create("compute", computation_fun, NULL, pm0);
393 MSG_process_sleep(2);
396 XBT_INFO("### Put a VM on a PM, and put three tasks to the PM and two tasks to the VM");
397 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
399 MSG_process_create("compute", computation_fun, NULL, vm0);
400 MSG_process_create("compute", computation_fun, NULL, vm0);
401 MSG_process_create("compute", computation_fun, NULL, pm0);
402 MSG_process_create("compute", computation_fun, NULL, pm0);
403 MSG_process_create("compute", computation_fun, NULL, pm0);
404 MSG_process_sleep(2);
407 XBT_INFO("### Put a VM on a PM, and put three tasks to the PM and three tasks to the VM");
408 vm0 = MSG_vm_create_multicore(pm0, "VM0",2);
410 MSG_process_create("compute", computation_fun, NULL, vm0);
411 MSG_process_create("compute", computation_fun, NULL, vm0);
412 MSG_process_create("compute", computation_fun, NULL, vm0);
413 MSG_process_create("compute", computation_fun, NULL, pm0);
414 MSG_process_create("compute", computation_fun, NULL, pm0);
415 MSG_process_create("compute", computation_fun, NULL, pm0);
416 MSG_process_sleep(2);
419 XBT_INFO("## Test 11 (ended)");
424 int main(int argc, char* argv[])
426 /* Get the arguments */
427 MSG_init(&argc, argv);
429 /* load the platform file */
430 const char* platform = "../../../platforms/cloud-sharing.xml";
433 MSG_create_environment(platform);
435 msg_host_t pm0 = MSG_host_by_name("node-0.acme.org");
436 xbt_assert(pm0, "Host 'node-0.acme.org' not found");
437 MSG_process_create("master", master_main, NULL, pm0);
439 return MSG_main() != MSG_OK;