Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
e44126a908671bceb13c3d5f3070a40456f6dd5b
[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   pm1 = MSG_host_by_name("node-1.acme2.org");
108   xbt_assert(pm0, "Host node-0.acme2.org does not seem to exist");
109   
110   XBT_INFO("## Test 4 (started): check computation on 2 cores PMs");
111
112   XBT_INFO("### Put a task on a PM");
113   MSG_process_create("compute", computation_fun, NULL, pm0);
114   MSG_process_sleep(2);
115
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);
120   
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);
126
127   XBT_INFO("## Test 4 (ended)");
128   
129   XBT_INFO("# TEST ON TWO-CORE PMs AND SINGLE-CORE VMs");
130   
131   XBT_INFO("## Test 5 (started): check impact of a single VM (there is no degradation for the moment)");
132
133   XBT_INFO("### Put a VM on a PM, and put a task to the VM");
134   vm0 = MSG_vm_create_core(pm0, "VM0");
135   MSG_vm_start(vm0);
136   MSG_process_create("compute", computation_fun, NULL, vm0);
137   MSG_process_sleep(2);
138   MSG_vm_destroy(vm0);
139   
140   XBT_INFO("### Put a VM on a PM, and put two tasks to the VM");
141   vm0 = MSG_vm_create_core(pm0, "VM0");
142   MSG_vm_start(vm0);
143   MSG_process_create("compute", computation_fun, NULL, vm0);
144   MSG_process_create("compute", computation_fun, NULL, vm0);
145   MSG_process_sleep(2);
146   MSG_vm_destroy(vm0);
147   
148   XBT_INFO("### Put a VM on a PM, and put a task to the PM");
149   vm0 = MSG_vm_create_core(pm0, "VM0");
150   MSG_vm_start(vm0);
151   MSG_process_create("compute", computation_fun, NULL, pm0);
152   MSG_process_sleep(2);
153   MSG_vm_destroy(vm0);
154   
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");
157   MSG_vm_start(vm0);
158   MSG_process_create("compute", computation_fun, NULL, pm0);
159   MSG_process_create("compute", computation_fun, NULL, vm0);
160   MSG_process_sleep(2);
161   MSG_vm_destroy(vm0);
162
163   XBT_INFO("## Test 5 (ended)");
164   
165   XBT_INFO("## Test 6 (started): check impact of a several VMs (there is no degradation for the moment)");
166
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");
170   MSG_vm_start(vm0);
171   MSG_vm_start(vm1);
172   MSG_process_create("compute", computation_fun, NULL, vm0);
173   MSG_process_sleep(2);
174   MSG_vm_destroy(vm0);
175   MSG_vm_destroy(vm1);
176   
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");
180   MSG_vm_start(vm0);
181   MSG_vm_start(vm1);
182   MSG_process_create("compute", computation_fun, NULL, vm0);
183   MSG_process_create("compute", computation_fun, NULL, vm1);
184   MSG_process_sleep(2);
185   MSG_vm_destroy(vm0);
186   MSG_vm_destroy(vm1);
187   
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");
192   MSG_vm_start(vm0);
193   MSG_vm_start(vm1);
194   MSG_vm_start(vm2);
195   MSG_process_create("compute", computation_fun, NULL, vm0);
196   MSG_process_create("compute", computation_fun, NULL, vm1);
197   MSG_process_sleep(2);
198   MSG_vm_destroy(vm0);
199   MSG_vm_destroy(vm1);
200   MSG_vm_destroy(vm2);
201   
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");
206   MSG_vm_start(vm0);
207   MSG_vm_start(vm1);
208   MSG_vm_start(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);
213   MSG_vm_destroy(vm0);
214   MSG_vm_destroy(vm1);
215   MSG_vm_destroy(vm2);
216   
217   XBT_INFO("## Test 6 (ended)");
218   
219   XBT_INFO("# TEST ON TWO-CORE PMs AND TWO-CORE VMs");
220   
221   XBT_INFO("## Test 7 (started): check impact of a single VM (there is no degradation for the moment)");
222   
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);
225   MSG_vm_start(vm0);
226   MSG_process_create("compute", computation_fun, NULL, vm0);
227   MSG_process_sleep(2);
228   MSG_vm_destroy(vm0);
229   
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);
232   MSG_vm_start(vm0);
233   MSG_process_create("compute", computation_fun, NULL, vm0);
234   MSG_process_create("compute", computation_fun, NULL, vm0);
235   MSG_process_sleep(2);
236   MSG_vm_destroy(vm0);
237   
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);
240   MSG_vm_start(vm0);
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);
245   MSG_vm_destroy(vm0);
246   
247   XBT_INFO("## Test 7 (ended)");
248   
249   XBT_INFO("## Test 8 (started): check impact of a single VM collocated with a task (there is no degradation for the moment)");
250   
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);
253   MSG_vm_start(vm0);
254   MSG_process_create("compute", computation_fun, NULL, pm0);
255   MSG_process_sleep(2);
256   MSG_vm_destroy(vm0);
257   
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);
260   MSG_vm_start(vm0);
261   MSG_process_create("compute", computation_fun, NULL, pm0);
262   MSG_process_create("compute", computation_fun, NULL, vm0);
263   MSG_process_sleep(2);
264   MSG_vm_destroy(vm0);
265   
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);
268   MSG_vm_start(vm0);
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);
273   MSG_vm_destroy(vm0);
274   
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);
277   MSG_vm_start(vm0);
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);
283   MSG_vm_destroy(vm0);
284   
285   XBT_INFO("## Test 8 (ended)");
286   
287   XBT_INFO("# TEST ON FOUR-CORE PMs AND TWO-CORE VMs");
288   
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");
292   
293   XBT_INFO("## Test 9 (started): check impact of a single VM");
294   
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);
297   MSG_vm_start(vm0);
298   MSG_process_create("compute", computation_fun, NULL, vm0);
299   MSG_process_sleep(2);
300   MSG_vm_destroy(vm0);
301   
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);
304   MSG_vm_start(vm0);
305   MSG_process_create("compute", computation_fun, NULL, vm0);
306   MSG_process_create("compute", computation_fun, NULL, vm0);
307   MSG_process_sleep(2);
308   MSG_vm_destroy(vm0);
309   
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);
312   MSG_vm_start(vm0);
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);
317   MSG_vm_destroy(vm0);
318   
319   XBT_INFO("## Test 9 (ended)");
320   
321   XBT_INFO("## Test 10 (started): check impact of a single emtpy VM collocated with tasks");
322   
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);
325   MSG_vm_start(vm0);
326   MSG_process_create("compute", computation_fun, NULL, pm0);
327   MSG_process_sleep(2);
328   MSG_vm_destroy(vm0);
329   
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);
332   MSG_vm_start(vm0);
333   MSG_process_create("compute", computation_fun, NULL, pm0);
334   MSG_process_create("compute", computation_fun, NULL, pm0);
335   MSG_process_sleep(2);
336   MSG_vm_destroy(vm0);
337   
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);
340   MSG_vm_start(vm0);
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);
345   MSG_vm_destroy(vm0);
346   
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);
349   MSG_vm_start(vm0);
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);
355   MSG_vm_destroy(vm0);
356   
357   XBT_INFO("## Test 10 (ended)");
358   
359   XBT_INFO("## Test 11 (started): check impact of a single working VM collocated with tasks");
360   
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);
363   MSG_vm_start(vm0);
364   MSG_process_create("compute", computation_fun, NULL, vm0);
365   MSG_process_create("compute", computation_fun, NULL, pm0);
366   MSG_process_sleep(2);
367   MSG_vm_destroy(vm0);
368   
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);
371   MSG_vm_start(vm0);
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);
376   MSG_vm_destroy(vm0);
377   
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);
380   MSG_vm_start(vm0);
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);
386   MSG_vm_destroy(vm0);
387   
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);
390   MSG_vm_start(vm0);
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);
396   MSG_vm_destroy(vm0);
397   
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);
400   MSG_vm_start(vm0);
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);
407   MSG_vm_destroy(vm0);
408   
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);
411   MSG_vm_start(vm0);
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);
419   MSG_vm_destroy(vm0);
420   
421   XBT_INFO("## Test 11 (ended)");
422
423   return 0;
424 }
425
426 int main(int argc, char* argv[])
427 {
428   /* Get the arguments */
429   MSG_init(&argc, argv);
430
431   /* load the platform file */
432   const char* platform = "../../platforms/cluster.xml";
433   if (argc == 2)
434     platform = argv[1];
435   MSG_create_environment(platform);
436
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);
440
441   return MSG_main() != MSG_OK;
442 }