Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fixing codacy warnings on multi-core VM tests + using a dedicated platform file for...
[simgrid.git] / teshsuite / msg / cloud-sharing / cloud-sharing.c
1 /* Copyright (c) 2007-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #include "simgrid/msg.h"
8 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
9
10 static int computation_fun(int argc, char* argv[])
11 {
12   msg_task_t task = MSG_task_create("Task", 100000000, 0, NULL);
13
14   double clock_sta = MSG_get_clock();
15   MSG_task_execute(task);
16   double clock_end = MSG_get_clock();
17
18   XBT_INFO("Task took %gs to execute", clock_end - clock_sta);
19
20   MSG_task_destroy(task);
21
22   return 0;
23 }
24
25 static int master_main(int argc, char* argv[])
26 {
27         
28   XBT_INFO("# TEST ON SINGLE-CORE PMs");
29
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");
33   
34   XBT_INFO("## Test 1 (started): check computation on normal PMs");
35
36   XBT_INFO("### Put a task on a PM");
37   MSG_process_create("compute", computation_fun, NULL, pm0);
38   MSG_process_sleep(2);
39
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);
43   MSG_process_sleep(2);
44
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);
48   MSG_process_sleep(2);
49
50   XBT_INFO("## Test 1 (ended)");
51   
52   XBT_INFO("# TEST ON SINGLE-CORE PMs AND SINGLE-CORE VMs");
53
54   XBT_INFO("## Test 2 (started): check impact of running tasks inside a VM (there is no degradation for the moment)");
55
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");
58   MSG_vm_start(vm0);
59   MSG_process_create("compute", computation_fun, NULL, vm0);
60   MSG_process_sleep(2);
61   MSG_vm_destroy(vm0);
62   
63   XBT_INFO("### Put a VM on a PM, and put two task to the VM");
64   vm0 = MSG_vm_create_core(pm0, "VM0");
65   MSG_vm_start(vm0);
66   MSG_process_create("compute", computation_fun, NULL, vm0);
67   MSG_process_create("compute", computation_fun, NULL, vm0);
68   MSG_process_sleep(2);
69   MSG_vm_destroy(vm0);
70
71   XBT_INFO("## Test 2 (ended)");
72   
73   XBT_INFO("## Test 3 (started): check impact of running tasks collocated with VMs (there is no VM noise for the moment)");
74
75   XBT_INFO("### Put a task on a PM collocated with an empty VM");
76
77   vm0 = MSG_vm_create_core(pm0, "VM0");
78   MSG_vm_start(vm0);
79   MSG_process_create("compute", computation_fun, NULL, pm0);
80   MSG_process_sleep(2);
81   MSG_vm_destroy(vm0);
82   
83   XBT_INFO("### Put a VM on a PM, put a task to the PM and a task to the VM");
84
85   vm0 = MSG_vm_create_core(pm0, "VM0");
86   MSG_vm_start(vm0);
87   MSG_process_create("compute", computation_fun, NULL, pm0);
88   MSG_process_create("compute", computation_fun, NULL, vm0);
89   MSG_process_sleep(2);
90   MSG_vm_destroy(vm0);
91   
92   XBT_INFO("### Put a VM on a PM, put a task to the PM and two tasks to the VM");
93
94   vm0 = MSG_vm_create_core(pm0, "VM0");
95   MSG_vm_start(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);
99   MSG_process_sleep(2);
100   MSG_vm_destroy(vm0);
101
102   XBT_INFO("## Test 3 (ended)");
103   
104   XBT_INFO("# TEST ON TWO-CORE PMs");
105   
106   pm0 = MSG_host_by_name("node-0.acme2.org");
107   xbt_assert(pm0, "Host node-0.acme2.org does not seem to exist");
108   
109   XBT_INFO("## Test 4 (started): check computation on 2 cores PMs");
110
111   XBT_INFO("### Put a task on a PM");
112   MSG_process_create("compute", computation_fun, NULL, pm0);
113   MSG_process_sleep(2);
114
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);
119   
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);
125
126   XBT_INFO("## Test 4 (ended)");
127   
128   XBT_INFO("# TEST ON TWO-CORE PMs AND SINGLE-CORE VMs");
129   
130   XBT_INFO("## Test 5 (started): check impact of a single VM (there is no degradation for the moment)");
131
132   XBT_INFO("### Put a VM on a PM, and put a task to the VM");
133   vm0 = MSG_vm_create_core(pm0, "VM0");
134   MSG_vm_start(vm0);
135   MSG_process_create("compute", computation_fun, NULL, vm0);
136   MSG_process_sleep(2);
137   MSG_vm_destroy(vm0);
138   
139   XBT_INFO("### Put a VM on a PM, and put two tasks to the VM");
140   vm0 = MSG_vm_create_core(pm0, "VM0");
141   MSG_vm_start(vm0);
142   MSG_process_create("compute", computation_fun, NULL, vm0);
143   MSG_process_create("compute", computation_fun, NULL, vm0);
144   MSG_process_sleep(2);
145   MSG_vm_destroy(vm0);
146   
147   XBT_INFO("### Put a VM on a PM, and put a task to the PM");
148   vm0 = MSG_vm_create_core(pm0, "VM0");
149   MSG_vm_start(vm0);
150   MSG_process_create("compute", computation_fun, NULL, pm0);
151   MSG_process_sleep(2);
152   MSG_vm_destroy(vm0);
153   
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");
156   MSG_vm_start(vm0);
157   MSG_process_create("compute", computation_fun, NULL, pm0);
158   MSG_process_create("compute", computation_fun, NULL, vm0);
159   MSG_process_sleep(2);
160   MSG_vm_destroy(vm0);
161
162   XBT_INFO("## Test 5 (ended)");
163   
164   XBT_INFO("## Test 6 (started): check impact of a several VMs (there is no degradation for the moment)");
165
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");
169   MSG_vm_start(vm0);
170   MSG_vm_start(vm1);
171   MSG_process_create("compute", computation_fun, NULL, vm0);
172   MSG_process_sleep(2);
173   MSG_vm_destroy(vm0);
174   MSG_vm_destroy(vm1);
175   
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");
179   MSG_vm_start(vm0);
180   MSG_vm_start(vm1);
181   MSG_process_create("compute", computation_fun, NULL, vm0);
182   MSG_process_create("compute", computation_fun, NULL, vm1);
183   MSG_process_sleep(2);
184   MSG_vm_destroy(vm0);
185   MSG_vm_destroy(vm1);
186   
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");
191   MSG_vm_start(vm0);
192   MSG_vm_start(vm1);
193   MSG_vm_start(vm2);
194   MSG_process_create("compute", computation_fun, NULL, vm0);
195   MSG_process_create("compute", computation_fun, NULL, vm1);
196   MSG_process_sleep(2);
197   MSG_vm_destroy(vm0);
198   MSG_vm_destroy(vm1);
199   MSG_vm_destroy(vm2);
200   
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");
205   MSG_vm_start(vm0);
206   MSG_vm_start(vm1);
207   MSG_vm_start(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);
212   MSG_vm_destroy(vm0);
213   MSG_vm_destroy(vm1);
214   MSG_vm_destroy(vm2);
215   
216   XBT_INFO("## Test 6 (ended)");
217   
218   XBT_INFO("# TEST ON TWO-CORE PMs AND TWO-CORE VMs");
219   
220   XBT_INFO("## Test 7 (started): check impact of a single VM (there is no degradation for the moment)");
221   
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);
224   MSG_vm_start(vm0);
225   MSG_process_create("compute", computation_fun, NULL, vm0);
226   MSG_process_sleep(2);
227   MSG_vm_destroy(vm0);
228   
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);
231   MSG_vm_start(vm0);
232   MSG_process_create("compute", computation_fun, NULL, vm0);
233   MSG_process_create("compute", computation_fun, NULL, vm0);
234   MSG_process_sleep(2);
235   MSG_vm_destroy(vm0);
236   
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);
239   MSG_vm_start(vm0);
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);
244   MSG_vm_destroy(vm0);
245   
246   XBT_INFO("## Test 7 (ended)");
247   
248   XBT_INFO("## Test 8 (started): check impact of a single VM collocated with a task (there is no degradation for the moment)");
249   
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);
252   MSG_vm_start(vm0);
253   MSG_process_create("compute", computation_fun, NULL, pm0);
254   MSG_process_sleep(2);
255   MSG_vm_destroy(vm0);
256   
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);
259   MSG_vm_start(vm0);
260   MSG_process_create("compute", computation_fun, NULL, pm0);
261   MSG_process_create("compute", computation_fun, NULL, vm0);
262   MSG_process_sleep(2);
263   MSG_vm_destroy(vm0);
264   
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);
267   MSG_vm_start(vm0);
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);
272   MSG_vm_destroy(vm0);
273   
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);
276   MSG_vm_start(vm0);
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);
282   MSG_vm_destroy(vm0);
283   
284   XBT_INFO("## Test 8 (ended)");
285   
286   XBT_INFO("# TEST ON FOUR-CORE PMs AND TWO-CORE VMs");
287   
288   pm0 = MSG_host_by_name("node-0.acme4.org");
289   xbt_assert(pm0, "Host node-0.acme4.org does not seem to exist");
290   
291   XBT_INFO("## Test 9 (started): check impact of a single VM");
292   
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);
295   MSG_vm_start(vm0);
296   MSG_process_create("compute", computation_fun, NULL, vm0);
297   MSG_process_sleep(2);
298   MSG_vm_destroy(vm0);
299   
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);
302   MSG_vm_start(vm0);
303   MSG_process_create("compute", computation_fun, NULL, vm0);
304   MSG_process_create("compute", computation_fun, NULL, vm0);
305   MSG_process_sleep(2);
306   MSG_vm_destroy(vm0);
307   
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);
310   MSG_vm_start(vm0);
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);
315   MSG_vm_destroy(vm0);
316   
317   XBT_INFO("## Test 9 (ended)");
318   
319   XBT_INFO("## Test 10 (started): check impact of a single emtpy VM collocated with tasks");
320   
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);
323   MSG_vm_start(vm0);
324   MSG_process_create("compute", computation_fun, NULL, pm0);
325   MSG_process_sleep(2);
326   MSG_vm_destroy(vm0);
327   
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);
330   MSG_vm_start(vm0);
331   MSG_process_create("compute", computation_fun, NULL, pm0);
332   MSG_process_create("compute", computation_fun, NULL, pm0);
333   MSG_process_sleep(2);
334   MSG_vm_destroy(vm0);
335   
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);
338   MSG_vm_start(vm0);
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);
343   MSG_vm_destroy(vm0);
344   
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);
347   MSG_vm_start(vm0);
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);
353   MSG_vm_destroy(vm0);
354   
355   XBT_INFO("## Test 10 (ended)");
356   
357   XBT_INFO("## Test 11 (started): check impact of a single working VM collocated with tasks");
358   
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);
361   MSG_vm_start(vm0);
362   MSG_process_create("compute", computation_fun, NULL, vm0);
363   MSG_process_create("compute", computation_fun, NULL, pm0);
364   MSG_process_sleep(2);
365   MSG_vm_destroy(vm0);
366   
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);
369   MSG_vm_start(vm0);
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);
374   MSG_vm_destroy(vm0);
375   
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);
378   MSG_vm_start(vm0);
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);
384   MSG_vm_destroy(vm0);
385   
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);
388   MSG_vm_start(vm0);
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);
394   MSG_vm_destroy(vm0);
395   
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);
398   MSG_vm_start(vm0);
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);
405   MSG_vm_destroy(vm0);
406   
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);
409   MSG_vm_start(vm0);
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);
417   MSG_vm_destroy(vm0);
418   
419   XBT_INFO("## Test 11 (ended)");
420
421   return 0;
422 }
423
424 int main(int argc, char* argv[])
425 {
426   /* Get the arguments */
427   MSG_init(&argc, argv);
428
429   /* load the platform file */
430   const char* platform = "../../../platforms/cloud-sharing.xml";
431   if (argc == 2)
432     platform = argv[1];
433   MSG_create_environment(platform);
434
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);
438
439   return MSG_main() != MSG_OK;
440 }