Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
9fa9a4446a50b9d3b3392681c66eb78416ecf480
[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 const int FAIL_ON_ERROR = 0;
11 const int flop_amount = 100000000;
12 int failed_test = 0;
13
14 static int computation_fun(int argc, char* argv[])
15 {
16   int *size = MSG_process_get_data(MSG_process_self());
17   msg_task_t task = MSG_task_create("Task", *size, 0, NULL);
18
19   double begin = MSG_get_clock();
20   MSG_task_execute(task);
21   MSG_task_destroy(task);
22   double end = MSG_get_clock();
23
24   if (0.1 - (end - begin) > 0.001) {
25     xbt_assert(! FAIL_ON_ERROR, "%s with %.4g load (%dflops) took %.4fs instead of 0.1s",
26         MSG_process_get_name(MSG_process_self()), ((double)*size/flop_amount),*size, (end-begin));
27     XBT_INFO("FAILED TEST: %s with %.4g load (%dflops) took %.4fs instead of 0.1s",
28         MSG_process_get_name(MSG_process_self()),((double)*size/flop_amount), *size, (end-begin));
29     failed_test ++;
30   } else {
31     XBT_INFO("Passed: %s with %.4g load (%dflops) took 0.1s as expected",
32         MSG_process_get_name(MSG_process_self()), ((double)*size/flop_amount), *size);
33   }
34
35   free(size);
36
37   return 0;
38 }
39
40 static void run_test_process(const char* name, msg_host_t location, int size)
41 {
42   int* data = xbt_new(int, 1);
43   *data = size;
44   MSG_process_create(name, computation_fun, data, location);
45 }
46
47 static void run_test(const char* chooser)
48 {
49   msg_host_t pm0 = MSG_host_by_name("node-0.1core.org");
50   msg_host_t pm1 = MSG_host_by_name("node-1.1core.org");
51   msg_host_t pm2 = MSG_host_by_name("node-0.2cores.org"); // 2 cores
52   msg_host_t pm4 = MSG_host_by_name("node-0.4cores.org");
53
54   msg_host_t vm0;
55   xbt_assert(pm0, "Host node-0.1core.org does not seem to exist");
56   xbt_assert(pm2, "Host node-0.2cores.org does not seem to exist");
57   xbt_assert(pm4, "Host node-0.4cores.org does not seem to exist");
58
59   // syntax of the process name:
60   // "( )1" means PM with one core; "( )2" means PM with 2 cores
61   // "(  [  ]2  )4" means a VM with 2 cores, on a PM with 4 cores.
62   // "o" means another process is there
63   // "X" means the process which holds this name
64
65   if (!strcmp(chooser, "(o)1")) {
66     XBT_INFO("### Test '%s'. A task on a regular PM", chooser);
67     run_test_process("(X)1", pm0, flop_amount);
68     MSG_process_sleep(2);
69
70   } else if (!strcmp(chooser, "(oo)1")) {
71     XBT_INFO("### Test '%s'. 2 tasks on a regular PM", chooser);
72     run_test_process("(Xo)1", pm0, flop_amount / 2);
73     run_test_process("(oX)1", pm0, flop_amount / 2);
74     MSG_process_sleep(2);
75
76   } else if (!strcmp(chooser, "(o)1 (o)1")) {
77     XBT_INFO("### Test '%s'. 2 regular PMs, with a task each.", chooser);
78     run_test_process("(X)1 (o)1", pm0, flop_amount);
79     run_test_process("(o)1 (X)1", pm1, flop_amount);
80     MSG_process_sleep(2);
81
82   } else if (!strcmp(chooser, "( [o]1 )1")) {
83     XBT_INFO("### Test '%s'. A task in a VM on a PM.", chooser);
84     vm0 = MSG_vm_create_core(pm0, "VM0");
85     MSG_vm_start(vm0);
86     run_test_process("( [X]1 )1", vm0, flop_amount);
87     MSG_process_sleep(2);
88     MSG_vm_destroy(vm0);
89
90   } else if (!strcmp(chooser, "( [oo]1 )1")) {
91     XBT_INFO("### Test '%s'. 2 tasks co-located in a VM on a PM.", chooser);
92     vm0 = MSG_vm_create_core(pm0, "VM0");
93     MSG_vm_start(vm0);
94     run_test_process("( [Xo]1 )1", vm0, flop_amount / 2);
95     run_test_process("( [oX]1 )1", vm0, flop_amount / 2);
96     MSG_process_sleep(2);
97     MSG_vm_destroy(vm0);
98
99   } else if (!strcmp(chooser, "( [ ]1 o )1")) {
100     XBT_INFO("### Test '%s'. 1 task collocated with an empty VM", chooser);
101     vm0 = MSG_vm_create_core(pm0, "VM0");
102     MSG_vm_start(vm0);
103     run_test_process("( [ ]1 X )1", pm0, flop_amount);
104     MSG_process_sleep(2);
105     MSG_vm_destroy(vm0);
106
107   } else if (!strcmp(chooser, "( [o]1 o )1")) {
108     XBT_INFO("### Test '%s'. A task in a VM, plus a task", chooser);
109     vm0 = MSG_vm_create_core(pm0, "VM0");
110     MSG_vm_start(vm0);
111     run_test_process("( [X]1 o )1", vm0, flop_amount / 2);
112     run_test_process("( [o]1 X )1", pm0, flop_amount / 2);
113     MSG_process_sleep(2);
114     MSG_vm_destroy(vm0);
115
116   } else if (!strcmp(chooser, "( [oo]1 o )1")) {
117     XBT_INFO("### Test '%s'. 2 tasks in a VM, plus a task", chooser);
118     vm0 = MSG_vm_create_core(pm0, "VM0");
119     MSG_vm_start(vm0);
120     run_test_process("( [Xo]1 o )1", vm0, flop_amount / 4);
121     run_test_process("( [oX]1 o )1", vm0, flop_amount / 4);
122     run_test_process("( [oo]1 X )1", pm0, flop_amount / 2);
123     MSG_process_sleep(2);
124     MSG_vm_destroy(vm0);
125
126   } else if (!strcmp(chooser, "( o )2")) {
127     XBT_INFO("### Test '%s'. A task on bicore PM", chooser);
128     run_test_process("(X)2", pm2, flop_amount);
129     MSG_process_sleep(2);
130
131   } else if (!strcmp(chooser, "( oo )2")) {
132     XBT_INFO("### Test '%s'. 2 tasks on a bicore PM", chooser);
133     run_test_process("(Xx)2", pm2, flop_amount);
134     run_test_process("(xX)2", pm2, flop_amount);
135     MSG_process_sleep(2);
136
137   } else if (!strcmp(chooser, "( ooo )2")) {
138     XBT_INFO("### Test '%s'. 3 tasks on a bicore PM", chooser);
139     run_test_process("(Xxx)2", pm2, flop_amount * 2 / 3);
140     run_test_process("(xXx)2", pm2, flop_amount * 2 / 3);
141     run_test_process("(xxX)2", pm2, flop_amount * 2 / 3);
142     MSG_process_sleep(2);
143
144   } else if (!strcmp(chooser, "( [o]1 )2")) {
145     XBT_INFO("### Test '%s'. A task in a VM on a bicore PM", chooser);
146     vm0 = MSG_vm_create_core(pm2, "VM0");
147     MSG_vm_start(vm0);
148     run_test_process("( [X]1 )2", vm0, flop_amount);
149     MSG_process_sleep(2);
150     MSG_vm_destroy(vm0);
151
152   } else if (!strcmp(chooser, "( [oo]1 )2")) {
153     XBT_INFO("### Test '%s'. 2 tasks in a VM on a bicore PM", chooser);
154     vm0 = MSG_vm_create_core(pm2, "VM0");
155     MSG_vm_start(vm0);
156     run_test_process("( [Xx]1 )2", vm0, flop_amount / 2);
157     run_test_process("( [xX]1 )2", vm0, flop_amount / 2);
158     MSG_process_sleep(2);
159     MSG_vm_destroy(vm0);
160
161   } else if (!strcmp(chooser, "( [ ]1 o )2")) {
162     XBT_INFO("### Put a VM on a PM, and put a task to the PM");
163     vm0 = MSG_vm_create_core(pm2, "VM0");
164     MSG_vm_start(vm0);
165     run_test_process("( [ ]1 X )2", pm2, flop_amount);
166     MSG_process_sleep(2);
167     MSG_vm_destroy(vm0);
168
169   } else if (!strcmp(chooser, "( [o]1 o )2")) {
170     XBT_INFO("### Put a VM on a PM, put a task to the PM and a task to the VM");
171     vm0 = MSG_vm_create_core(pm2, "VM0");
172     MSG_vm_start(vm0);
173     run_test_process("( [X]1 x )2", vm0, flop_amount);
174     run_test_process("( [x]1 X )2", pm2, flop_amount);
175     MSG_process_sleep(2);
176     MSG_vm_destroy(vm0);
177
178   } else if (!strcmp(chooser, "( [o]1 [ ]1 )2")) {
179     XBT_INFO("### Put two VMs on a PM, and put a task to one VM");
180     vm0          = MSG_vm_create_core(pm2, "VM0");
181     msg_vm_t vm1 = MSG_vm_create_core(pm2, "VM1");
182     MSG_vm_start(vm0);
183     MSG_vm_start(vm1);
184     run_test_process("( [X]1 [ ]1 )2", vm0, flop_amount);
185     MSG_process_sleep(2);
186     MSG_vm_destroy(vm0);
187     MSG_vm_destroy(vm1);
188
189   } else if (!strcmp(chooser, "( [o]1 [o]1 )2")) {
190     XBT_INFO("### Put two VMs on a PM, and put a task to each VM");
191     vm0          = MSG_vm_create_core(pm2, "VM0");
192     msg_vm_t vm1 = MSG_vm_create_core(pm2, "VM1");
193     MSG_vm_start(vm0);
194     MSG_vm_start(vm1);
195     run_test_process("( [X]1 [x]1 )2", vm0, flop_amount);
196     run_test_process("( [x]1 [X]1 )2", vm1, flop_amount);
197     MSG_process_sleep(2);
198     MSG_vm_destroy(vm0);
199     MSG_vm_destroy(vm1);
200
201   } else if (!strcmp(chooser, "( [o]1 [o]1 [ ]1 )2")) {
202     XBT_INFO("### Put three VMs on a PM, and put a task to two VMs");
203     vm0          = MSG_vm_create_core(pm2, "VM0");
204     msg_vm_t vm1 = MSG_vm_create_core(pm2, "VM1");
205     msg_vm_t vm2 = MSG_vm_create_core(pm2, "VM2");
206     MSG_vm_start(vm0);
207     MSG_vm_start(vm1);
208     MSG_vm_start(vm2);
209     run_test_process("( [X]1 [x]1 [ ]1 )2", vm0, flop_amount);
210     run_test_process("( [x]1 [X]1 [ ]1 )2", vm1, flop_amount);
211     MSG_process_sleep(2);
212     MSG_vm_destroy(vm0);
213     MSG_vm_destroy(vm1);
214     MSG_vm_destroy(vm2);
215
216   } else if (!strcmp(chooser, "( [o]1 [o]1 [o]1 )2")) {
217     XBT_INFO("### Put three VMs on a PM, and put a task to each VM");
218     vm0          = MSG_vm_create_core(pm2, "VM0");
219     msg_vm_t vm1 = MSG_vm_create_core(pm2, "VM1");
220     msg_vm_t vm2 = MSG_vm_create_core(pm2, "VM2");
221     MSG_vm_start(vm0);
222     MSG_vm_start(vm1);
223     MSG_vm_start(vm2);
224     run_test_process("( [X]1 [o]1 [o]1 )2", vm0, flop_amount * 2 / 3);
225     run_test_process("( [o]1 [X]1 [o]1 )2", vm1, flop_amount * 2 / 3);
226     run_test_process("( [o]1 [o]1 [X]1 )2", vm2, flop_amount * 2 / 3);
227     MSG_process_sleep(2);
228     MSG_vm_destroy(vm0);
229     MSG_vm_destroy(vm1);
230     MSG_vm_destroy(vm2);
231
232   } else if (!strcmp(chooser, "( [o]2 )2")) {
233     XBT_INFO("### Put a VM on a PM, and put a task to the VM");
234     vm0 = MSG_vm_create_multicore(pm2, "VM0", 2);
235     MSG_vm_start(vm0);
236     run_test_process("( [X]2 )2", vm0, flop_amount);
237     MSG_process_sleep(2);
238     MSG_vm_destroy(vm0);
239
240   } else if (!strcmp(chooser, "( [oo]2 )2")) {
241     XBT_INFO("### Put a VM on a PM, and put two tasks to the VM");
242     vm0 = MSG_vm_create_multicore(pm2, "VM0", 2);
243     MSG_vm_start(vm0);
244     run_test_process("( [Xo]2 )2", vm0, flop_amount);
245     run_test_process("( [oX]2 )2", vm0, flop_amount);
246     MSG_process_sleep(2);
247     MSG_vm_destroy(vm0);
248
249   } else if (!strcmp(chooser, "( [ooo]2 )2")) {
250     XBT_INFO("### Put a VM on a PM, and put three tasks to the VM");
251     vm0 = MSG_vm_create_multicore(pm2, "VM0", 2);
252     MSG_vm_start(vm0);
253     run_test_process("( [Xoo]2 )2", vm0, flop_amount * 2 / 3);
254     run_test_process("( [oXo]2 )2", vm0, flop_amount * 2 / 3);
255     run_test_process("( [ooX]2 )2", vm0, flop_amount * 2 / 3);
256     MSG_process_sleep(2);
257     MSG_vm_destroy(vm0);
258
259   } else if (!strcmp(chooser, "( [ ]2 o )2")) {
260     XBT_INFO("### Put a VM on a PM, and put a task to the PM");
261     vm0 = MSG_vm_create_multicore(pm2, "VM0", 2);
262     MSG_vm_start(vm0);
263     run_test_process("( [ ]2 X )2", pm2, flop_amount);
264     MSG_process_sleep(2);
265     MSG_vm_destroy(vm0);
266
267   } else if (!strcmp(chooser, "( [o]2 o )2")) {
268     XBT_INFO("### Put a VM on a PM, put one task to the PM and one task to the VM");
269     vm0 = MSG_vm_create_multicore(pm2, "VM0", 2);
270     MSG_vm_start(vm0);
271     run_test_process("( [o]2 X )2", pm2, flop_amount);
272     run_test_process("( [X]2 o )2", vm0, flop_amount);
273     MSG_process_sleep(2);
274     MSG_vm_destroy(vm0);
275
276   } else if (!strcmp(chooser, "( [oo]2 o )2")) {
277     XBT_INFO("### Put a VM on a PM, put one task to the PM and two tasks to the VM");
278     vm0 = MSG_vm_create_multicore(pm2, "VM0", 2);
279     MSG_vm_start(vm0);
280     run_test_process("( [oo]2 X )2", pm2, flop_amount * 2 / 3);
281     run_test_process("( [Xo]2 o )2", vm0, flop_amount * 2 / 3);
282     run_test_process("( [oX]2 o )2", vm0, flop_amount * 2 / 3);
283     MSG_process_sleep(2);
284     MSG_vm_destroy(vm0);
285
286   } else if (!strcmp(chooser, "( [ooo]2 o )2")) {
287     XBT_INFO("### Put a VM on a PM, put one task to the PM and three tasks to the VM");
288     vm0 = MSG_vm_create_multicore(pm2, "VM0", 2);
289     MSG_vm_start(vm0);
290     run_test_process("( [ooo]2 X )2", pm2, flop_amount * 2 / 3);
291     run_test_process("( [Xoo]2 o )2", vm0, flop_amount * 2 / 9);
292     run_test_process("( [oXo]2 o )2", vm0, flop_amount * 2 / 9);
293     run_test_process("( [ooX]2 o )2", vm0, flop_amount * 2 / 9);
294     MSG_process_sleep(2);
295     MSG_vm_destroy(vm0);
296
297   } else if (!strcmp(chooser, "( [ ]2 oo )2")) {
298     XBT_INFO("### Put a VM on a PM, and put two tasks to the PM");
299     vm0 = MSG_vm_create_multicore(pm2, "VM0", 2);
300     MSG_vm_start(vm0);
301     run_test_process("( [ ]2 Xo )2", pm2, flop_amount);
302     run_test_process("( [ ]2 oX )2", pm2, flop_amount);
303     MSG_process_sleep(2);
304     MSG_vm_destroy(vm0);
305
306   } else if (!strcmp(chooser, "( [o]2 oo )2")) {
307     XBT_INFO("### Put a VM on a PM, put one task to the PM and one task to the VM");
308     vm0 = MSG_vm_create_multicore(pm2, "VM0", 2);
309     MSG_vm_start(vm0);
310     run_test_process("( [o]2 Xo )2", pm2, flop_amount * 2 / 3);
311     run_test_process("( [o]2 oX )2", pm2, flop_amount * 2 / 3);
312     run_test_process("( [X]2 oo )2", vm0, flop_amount * 2 / 3);
313     MSG_process_sleep(2);
314     MSG_vm_destroy(vm0);
315
316   } else if (!strcmp(chooser, "( [oo]2 oo )2")) {
317     XBT_INFO("### Put a VM on a PM, put one task to the PM and two tasks to the VM");
318     vm0 = MSG_vm_create_multicore(pm2, "VM0", 2);
319     MSG_vm_start(vm0);
320     run_test_process("( [oo]2 Xo )2", pm2, flop_amount / 2);
321     run_test_process("( [oo]2 oX )2", pm2, flop_amount / 2);
322     run_test_process("( [Xo]2 oo )2", vm0, flop_amount / 2);
323     run_test_process("( [oX]2 oo )2", vm0, flop_amount / 2);
324     MSG_process_sleep(2);
325     MSG_vm_destroy(vm0);
326
327   } else if (!strcmp(chooser, "( [ooo]2 oo )2")) {
328     XBT_INFO("### Put a VM on a PM, put one task to the PM and three tasks to the VM");
329     vm0 = MSG_vm_create_multicore(pm2, "VM0", 2);
330     MSG_vm_start(vm0);
331     run_test_process("( [ooo]2 Xo )2", pm2, flop_amount * 2 / 4);
332     run_test_process("( [ooo]2 oX )2", pm2, flop_amount * 2 / 4);
333     run_test_process("( [Xoo]2 oo )2", vm0, flop_amount / 3);
334     run_test_process("( [oXo]2 oo )2", vm0, flop_amount / 3);
335     run_test_process("( [ooX]2 oo )2", vm0, flop_amount / 3);
336     MSG_process_sleep(2);
337     MSG_vm_destroy(vm0);
338
339   } else if (!strcmp(chooser, "( [o]2 )4")) {
340     XBT_INFO("### Put a VM on a PM, and put a task to the VM");
341     vm0 = MSG_vm_create_multicore(pm4, "VM0", 2);
342     MSG_vm_start(vm0);
343     run_test_process("( [X]2 )4", vm0, flop_amount);
344     MSG_process_sleep(2);
345     MSG_vm_destroy(vm0);
346
347   } else if (!strcmp(chooser, "( [oo]2 )4")) {
348     XBT_INFO("### Put a VM on a PM, and put two tasks to the VM");
349     vm0 = MSG_vm_create_multicore(pm4, "VM0", 2);
350     MSG_vm_start(vm0);
351     run_test_process("( [Xo]2 )4", vm0, flop_amount);
352     run_test_process("( [oX]2 )4", vm0, flop_amount);
353     MSG_process_sleep(2);
354     MSG_vm_destroy(vm0);
355
356   } else if (!strcmp(chooser, "( [ooo]2 )4")) {
357     XBT_INFO("### ( [ooo]2 )4: Put a VM on a PM, and put three tasks to the VM");
358     vm0 = MSG_vm_create_multicore(pm4, "VM0", 2);
359     MSG_vm_start(vm0);
360     run_test_process("( [Xoo]2 )4", vm0, flop_amount * 2 / 3);
361     run_test_process("( [oXo]2 )4", vm0, flop_amount * 2 / 3);
362     run_test_process("( [ooX]2 )4", vm0, flop_amount * 2 / 3);
363     MSG_process_sleep(2);
364     MSG_vm_destroy(vm0);
365
366   } else if (!strcmp(chooser, "( [ ]2 o )4")) {
367     XBT_INFO("### Put a VM on a PM, and put a task to the PM");
368     vm0 = MSG_vm_create_multicore(pm4, "VM0", 2);
369     MSG_vm_start(vm0);
370     run_test_process("( [ ]2 X )4", pm4, flop_amount);
371     MSG_process_sleep(2);
372     MSG_vm_destroy(vm0);
373
374   } else if (!strcmp(chooser, "( [ ]2 oo )4")) {
375     XBT_INFO("### Put a VM on a PM, and put two tasks to the PM");
376     vm0 = MSG_vm_create_multicore(pm4, "VM0", 2);
377     MSG_vm_start(vm0);
378     run_test_process("( [ ]2 Xo )4", pm4, flop_amount);
379     run_test_process("( [ ]2 oX )4", pm4, flop_amount);
380     MSG_process_sleep(2);
381     MSG_vm_destroy(vm0);
382
383   } else if (!strcmp(chooser, "( [ ]2 ooo )4")) {
384     XBT_INFO("### Put a VM on a PM, and put three tasks to the PM");
385     vm0 = MSG_vm_create_multicore(pm4, "VM0", 2);
386     MSG_vm_start(vm0);
387     run_test_process("( [ ]2 Xoo )4", pm4, flop_amount);
388     run_test_process("( [ ]2 oXo )4", pm4, flop_amount);
389     run_test_process("( [ ]2 ooX )4", pm4, flop_amount);
390     MSG_process_sleep(2);
391     MSG_vm_destroy(vm0);
392
393   } else if (!strcmp(chooser, "( [ ]2 oooo )4")) {
394     XBT_INFO("### Put a VM on a PM, and put four tasks to the PM");
395     vm0 = MSG_vm_create_multicore(pm4, "VM0", 2);
396     MSG_vm_start(vm0);
397     run_test_process("( [ ]2 Xooo )4", pm4, flop_amount);
398     run_test_process("( [ ]2 oXoo )4", pm4, flop_amount);
399     run_test_process("( [ ]2 ooXo )4", pm4, flop_amount);
400     run_test_process("( [ ]2 oooX )4", pm4, flop_amount);
401     MSG_process_sleep(2);
402     MSG_vm_destroy(vm0);
403
404   } else if (!strcmp(chooser, "( [o]2 o )4")) {
405     XBT_INFO("### Put a VM on a PM, and put one task to the PM and one task to the VM");
406     vm0 = MSG_vm_create_multicore(pm4, "VM0", 2);
407     MSG_vm_start(vm0);
408     run_test_process("( [X]2 o )4", vm0, flop_amount);
409     run_test_process("( [o]2 X )4", pm4, flop_amount);
410     MSG_process_sleep(2);
411     MSG_vm_destroy(vm0);
412
413   } else if (!strcmp(chooser, "( [o]2 oo )4")) {
414     XBT_INFO("### Put a VM on a PM, and put two tasks to the PM and one task to the VM");
415     vm0 = MSG_vm_create_multicore(pm4, "VM0", 2);
416     MSG_vm_start(vm0);
417     run_test_process("( [X]2 oo )4", vm0, flop_amount);
418     run_test_process("( [o]2 Xo )4", pm4, flop_amount);
419     run_test_process("( [o]2 oX )4", pm4, flop_amount);
420     MSG_process_sleep(2);
421     MSG_vm_destroy(vm0);
422
423   } else if (!strcmp(chooser, "( [oo]2 oo )4")) {
424     XBT_INFO("### Put a VM on a PM, and put two tasks to the PM and two tasks to the VM");
425     vm0 = MSG_vm_create_multicore(pm4, "VM0", 2);
426     MSG_vm_start(vm0);
427     run_test_process("( [Xo]2 oo )4", vm0, flop_amount);
428     run_test_process("( [oX]2 oo )4", vm0, flop_amount);
429     run_test_process("( [oo]2 Xo )4", pm4, flop_amount);
430     run_test_process("( [oo]2 oX )4", pm4, flop_amount);
431     MSG_process_sleep(2);
432     MSG_vm_destroy(vm0);
433
434   } else if (!strcmp(chooser, "( [o]2 ooo )4")) {
435     XBT_INFO("### Put a VM on a PM, and put three tasks to the PM and one tasks to the VM");
436     vm0 = MSG_vm_create_multicore(pm4, "VM0", 2);
437     MSG_vm_start(vm0);
438     run_test_process("( [X]2 ooo )4", vm0, flop_amount);
439     run_test_process("( [o]2 Xoo )4", pm4, flop_amount);
440     run_test_process("( [o]2 oXo )4", pm4, flop_amount);
441     run_test_process("( [o]2 ooX )4", pm4, flop_amount);
442     MSG_process_sleep(2);
443     MSG_vm_destroy(vm0);
444
445   } else if (!strcmp(chooser, "( [oo]2 ooo )4")) {
446     XBT_INFO("### Put a VM on a PM, and put three tasks to the PM and two tasks to the VM");
447     vm0 = MSG_vm_create_multicore(pm4, "VM0", 2);
448     MSG_vm_start(vm0);
449     run_test_process("( [Xo]2 ooo )4", vm0, flop_amount * 4 / 5);
450     run_test_process("( [oX]2 ooo )4", vm0, flop_amount * 4 / 5);
451     run_test_process("( [oo]2 Xoo )4", pm4, flop_amount * 4 / 5);
452     run_test_process("( [oo]2 oXo )4", pm4, flop_amount * 4 / 5);
453     run_test_process("( [oo]2 ooX )4", pm4, flop_amount * 4 / 5);
454     MSG_process_sleep(2);
455     MSG_vm_destroy(vm0);
456
457   } else if (!strcmp(chooser, "( [ooo]2 ooo )4")) {
458     XBT_INFO("### Put a VM on a PM, and put three tasks to the PM and three tasks to the VM");
459     vm0 = MSG_vm_create_multicore(pm4, "VM0", 2);
460     MSG_vm_start(vm0);
461     run_test_process("( [Xoo]2 ooo )4", vm0, flop_amount * (8 / 5) * 1 / 3); // The VM has 8/5 of the PM
462     run_test_process("( [oXo]2 ooo )4", vm0, flop_amount * (8 / 5) * 1 / 3);
463     run_test_process("( [ooX]2 ooo )4", vm0, flop_amount * (8 / 5) * 1 / 3);
464
465     run_test_process("( [ooo]2 Xoo )4", pm4, flop_amount * 4 / 5);
466     run_test_process("( [ooo]2 oXo )4", pm4, flop_amount * 4 / 5);
467     run_test_process("( [ooo]2 ooX )4", pm4, flop_amount * 4 / 5);
468     MSG_process_sleep(2);
469     MSG_vm_destroy(vm0);
470
471   } else {
472     xbt_die("Unknown chooser: %s", chooser);
473   }
474 }
475 static int master_main(int argc, char* argv[])
476 {
477 #ifdef IGNORE_ME
478   XBT_INFO("# TEST ON SINGLE-CORE PMs");
479   XBT_INFO("## Check computation on regular PMs");
480   run_test("(o)1");
481   run_test("(oo)1");
482   run_test("(o)1 (o)1");
483   XBT_INFO("# TEST ON SINGLE-CORE PMs AND SINGLE-CORE VMs");
484
485   XBT_INFO("## Check the impact of running tasks inside a VM (no degradation for the moment)");
486   run_test("( [o]1 )1");
487   run_test("( [oo]1 )1");
488
489   XBT_INFO("## Check impact of running tasks collocated with VMs (no VM noise for the moment)");
490   run_test("( [ ]1 o )1");
491   run_test("( [o]1 o )1");
492   run_test("( [oo]1 o )1");
493
494   XBT_INFO("# TEST ON TWO-CORE PMs");
495   XBT_INFO("## Check computation on 2 cores PMs");
496   run_test("( o )2");
497   run_test("( oo )2");
498   run_test("( ooo )2");
499
500   XBT_INFO("# TEST ON TWO-CORE PMs AND SINGLE-CORE VMs");
501   XBT_INFO("## Check impact of a single VM (no degradation for the moment)");
502   run_test("( [o]1 )2");
503   run_test("( [oo]1 )2");
504   run_test("( [ ]1 o )2");
505   run_test("( [o]1 o )2");
506
507   XBT_INFO("## Check impact of a several VMs (there is no degradation for the moment)");
508   run_test("( [o]1 [ ]1 )2");
509   run_test("( [o]1 [o]1 )2");
510   run_test("( [o]1 [o]1 [ ]1 )2");
511   run_test("( [o]1 [o]1 [o]1 )2");
512
513   XBT_INFO("# TEST ON TWO-CORE PMs AND TWO-CORE VMs");
514
515   XBT_INFO("## Check impact of a single VM (there is no degradation for the moment)");
516   run_test("( [o]2 )2");
517   run_test("( [oo]2 )2");
518   run_test("( [ooo]2 )2");
519
520   XBT_INFO("## Check impact of a single VM collocated with a task (there is no degradation for the moment)");
521   run_test("( [ ]2 o )2");
522   run_test("( [o]2 o )2");
523 #endif
524   run_test("( [oo]2 o )2");
525 #ifdef IGNORE_ME
526   run_test("( [ooo]2 o )2");
527   run_test("( [ ]2 oo )2");
528   run_test("( [o]2 oo )2");
529   run_test("( [oo]2 oo )2");
530   run_test("( [ooo]2 oo )2");
531
532   XBT_INFO("# TEST ON FOUR-CORE PMs AND TWO-CORE VMs");
533   XBT_INFO("## Check impact of a single VM");
534   run_test("( [o]2 )4");
535   run_test("( [oo]2 )4");
536   run_test("( [ooo]2 )4");
537
538   XBT_INFO("## Check impact of a single empty VM collocated with tasks");
539   run_test("( [ ]2 o )4");
540   run_test("( [ ]2 oo )4");
541   run_test("( [ ]2 ooo )4");
542   run_test("( [ ]2 oooo )4");
543
544   XBT_INFO("## Check impact of a single working VM collocated with tasks");
545   run_test("( [o]2 o )4");
546   run_test("( [o]2 oo )4");
547   run_test("( [oo]2 oo )4");
548   run_test("( [o]2 ooo )4");
549   run_test("( [oo]2 ooo )4");
550   run_test("( [ooo]2 ooo )4");
551 #endif
552
553   XBT_INFO("   ");
554   XBT_INFO("   ");
555   XBT_INFO("## %d test failed", failed_test);
556   XBT_INFO("   ");
557   return 0;
558 }
559 int main(int argc, char* argv[])
560 {
561   /* Get the arguments */
562   MSG_init(&argc, argv);
563
564   /* load the platform file */
565   const char* platform = "../../../platforms/cloud-sharing.xml";
566   if (argc == 2)
567     platform = argv[1];
568   MSG_create_environment(platform);
569
570   msg_host_t pm0 = MSG_host_by_name("node-0.1core.org");
571   xbt_assert(pm0, "Host 'node-0.1core.org' not found");
572   MSG_process_create("master", master_main, NULL, pm0);
573
574   return MSG_main() != MSG_OK || failed_test;
575 }