1 /* Copyright (c) 2007-2018. 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/s4u.hpp"
8 #include "simgrid/plugins/energy.h"
9 #include "simgrid/s4u/VirtualMachine.hpp"
11 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this msg example");
13 const int FAIL_ON_ERROR = 0;
14 const int flop_amount = 100000000;
19 static int computation_fun(std::vector<std::string> argv)
21 int size = std::stoi(argv[0]);
23 double begin = simgrid::s4u::Engine::get_clock();
24 simgrid::s4u::this_actor::execute(size);
25 double end = simgrid::s4u::Engine::get_clock();
27 if (0.1 - (end - begin) > 0.001) {
28 xbt_assert(! FAIL_ON_ERROR, "%s with %.4g load (%dflops) took %.4fs instead of 0.1s",
29 simgrid::s4u::this_actor::get_name().c_str(), ((double)size/flop_amount),size, (end-begin));
30 XBT_INFO("FAILED TEST: %s with %.4g load (%dflops) took %.4fs instead of 0.1s",
31 simgrid::s4u::this_actor::get_name().c_str(),((double)size/flop_amount), size, (end-begin));
34 XBT_INFO("Passed: %s with %.4g load (%dflops) took 0.1s as expected",
35 simgrid::s4u::this_actor::get_name().c_str(), ((double)size/flop_amount), size);
41 static void run_test_process(std::string name, simgrid::s4u::Host *location, int size)
43 std::vector<std::string> arg = {std::to_string(size)};
44 simgrid::s4u::Actor::create(name, location, computation_fun, arg);
47 static void test_energy_consumption(std::string name, int nb_cores)
49 double new_energy = 0;
51 for (simgrid::s4u::Host *pm : simgrid::s4u::Engine::get_instance()->get_all_hosts() ){
52 if(!dynamic_cast<simgrid::s4u::VirtualMachine *>(pm))
53 new_energy += sg_host_get_consumed_energy(pm);
56 double expected_consumption = 0.1 * nb_cores;
57 double actual_consumption = new_energy - energy;
61 if (std::abs(expected_consumption - actual_consumption) > 0.001) {
62 XBT_INFO("FAILED TEST: %s consumed %f instead of %f J (i.e. %i cores should have been used)", name.c_str(), actual_consumption, expected_consumption, nb_cores );
65 XBT_INFO("Passed: %s consumed %f J (i.e. %i cores used) ", name.c_str(), actual_consumption, nb_cores);
69 static void run_test(std::string chooser)
71 simgrid::s4u::Host *pm0 = simgrid::s4u::Host::by_name("node-0.1core.org");
72 simgrid::s4u::Host *pm1 = simgrid::s4u::Host::by_name("node-1.1core.org");
73 simgrid::s4u::Host *pm2 = simgrid::s4u::Host::by_name("node-0.2cores.org"); // 2 cores
74 simgrid::s4u::Host *pm4 = simgrid::s4u::Host::by_name("node-0.4cores.org");
76 simgrid::s4u::VirtualMachine *vm0;
77 xbt_assert(pm0, "Host node-0.1core.org does not seem to exist");
78 xbt_assert(pm2, "Host node-0.2cores.org does not seem to exist");
79 xbt_assert(pm4, "Host node-0.4cores.org does not seem to exist");
81 // syntax of the process name:
82 // "( )1" means PM with one core; "( )2" means PM with 2 cores
83 // "( [ ]2 )4" means a VM with 2 cores, on a PM with 4 cores.
84 // "o" means another process is there
85 // "X" means the process which holds this name
87 if (chooser == "(o)1") {
88 XBT_INFO("### Test '%s'. A task on a regular PM", chooser.c_str());
89 run_test_process("(X)1", pm0, flop_amount);
90 simgrid::s4u::this_actor::sleep_for(2);
91 test_energy_consumption(chooser,1);
93 } else if (chooser == "(oo)1") {
94 XBT_INFO("### Test '%s'. 2 tasks on a regular PM", chooser.c_str());
95 run_test_process("(Xo)1", pm0, flop_amount / 2);
96 run_test_process("(oX)1", pm0, flop_amount / 2);
97 simgrid::s4u::this_actor::sleep_for(2);
98 test_energy_consumption(chooser,1);
100 } else if (chooser == "(o)1 (o)1") {
101 XBT_INFO("### Test '%s'. 2 regular PMs, with a task each.", chooser.c_str());
102 run_test_process("(X)1 (o)1", pm0, flop_amount);
103 run_test_process("(o)1 (X)1", pm1, flop_amount);
104 simgrid::s4u::this_actor::sleep_for(2);
105 test_energy_consumption(chooser,2);
107 } else if (chooser == "( [o]1 )1") {
108 XBT_INFO("### Test '%s'. A task in a VM on a PM.", chooser.c_str());
109 vm0 = new simgrid::s4u::VirtualMachine("VM0",pm0,1);
110 run_test_process("( [X]1 )1", vm0, flop_amount);
111 simgrid::s4u::this_actor::sleep_for(2);
112 test_energy_consumption(chooser,1);
115 } else if (chooser == "( [oo]1 )1") {
116 XBT_INFO("### Test '%s'. 2 tasks co-located in a VM on a PM.", chooser.c_str());
117 vm0 = new simgrid::s4u::VirtualMachine("VM0",pm0,1);
118 run_test_process("( [Xo]1 )1", vm0, flop_amount / 2);
119 run_test_process("( [oX]1 )1", vm0, flop_amount / 2);
120 simgrid::s4u::this_actor::sleep_for(2);
121 test_energy_consumption(chooser,1);
124 } else if (chooser == "( [ ]1 o )1") {
125 XBT_INFO("### Test '%s'. 1 task collocated with an empty VM", chooser.c_str());
126 vm0 = new simgrid::s4u::VirtualMachine("VM0",pm0,1);
127 run_test_process("( [ ]1 X )1", pm0, flop_amount);
128 simgrid::s4u::this_actor::sleep_for(2);
129 test_energy_consumption(chooser,1);
132 } else if (chooser == "( [o]1 o )1") {
133 XBT_INFO("### Test '%s'. A task in a VM, plus a task", chooser.c_str());
134 vm0 = new simgrid::s4u::VirtualMachine("VM0",pm0,1);
135 run_test_process("( [X]1 o )1", vm0, flop_amount / 2);
136 run_test_process("( [o]1 X )1", pm0, flop_amount / 2);
137 simgrid::s4u::this_actor::sleep_for(2);
138 test_energy_consumption(chooser,1);
141 } else if (chooser == "( [oo]1 o )1") {
142 XBT_INFO("### Test '%s'. 2 tasks in a VM, plus a task", chooser.c_str());
143 vm0 = new simgrid::s4u::VirtualMachine("VM0",pm0,1);
144 run_test_process("( [Xo]1 o )1", vm0, flop_amount / 4);
145 run_test_process("( [oX]1 o )1", vm0, flop_amount / 4);
146 run_test_process("( [oo]1 X )1", pm0, flop_amount / 2);
147 simgrid::s4u::this_actor::sleep_for(2);
148 test_energy_consumption(chooser,1);
151 } else if (chooser == "( o )2") {
152 XBT_INFO("### Test '%s'. A task on bicore PM", chooser.c_str());
153 run_test_process("(X)2", pm2, flop_amount);
154 simgrid::s4u::this_actor::sleep_for(2);
155 test_energy_consumption(chooser,1);
157 } else if (chooser == "( oo )2") {
158 XBT_INFO("### Test '%s'. 2 tasks on a bicore PM", chooser.c_str());
159 run_test_process("(Xx)2", pm2, flop_amount);
160 run_test_process("(xX)2", pm2, flop_amount);
161 simgrid::s4u::this_actor::sleep_for(2);
162 test_energy_consumption(chooser,2);
164 } else if (chooser == "( ooo )2") {
165 XBT_INFO("### Test '%s'. 3 tasks on a bicore PM", chooser.c_str());
166 run_test_process("(Xxx)2", pm2, flop_amount * 2 / 3);
167 run_test_process("(xXx)2", pm2, flop_amount * 2 / 3);
168 run_test_process("(xxX)2", pm2, flop_amount * 2 / 3);
169 simgrid::s4u::this_actor::sleep_for(2);
170 test_energy_consumption(chooser,2);
172 } else if (chooser == "( [o]1 )2") {
173 XBT_INFO("### Test '%s'. A task in a VM on a bicore PM", chooser.c_str());
174 vm0 = new simgrid::s4u::VirtualMachine("VM0",pm2,1);
175 run_test_process("( [X]1 )2", vm0, flop_amount);
176 simgrid::s4u::this_actor::sleep_for(2);
177 test_energy_consumption(chooser,1);
180 } else if (chooser == "( [oo]1 )2") {
181 XBT_INFO("### Test '%s'. 2 tasks in a VM on a bicore PM", chooser.c_str());
182 vm0 = new simgrid::s4u::VirtualMachine("VM0",pm2,1);
183 run_test_process("( [Xx]1 )2", vm0, flop_amount / 2);
184 run_test_process("( [xX]1 )2", vm0, flop_amount / 2);
185 simgrid::s4u::this_actor::sleep_for(2);
186 test_energy_consumption(chooser,1);
189 } else if (chooser == "( [ ]1 o )2") {
190 XBT_INFO("### Put a VM on a PM, and put a task to the PM");
191 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2,1);
192 run_test_process("( [ ]1 X )2", pm2, flop_amount);
193 simgrid::s4u::this_actor::sleep_for(2);
194 test_energy_consumption(chooser,1);
197 } else if (chooser == "( [o]1 o )2") {
198 XBT_INFO("### Put a VM on a PM, put a task to the PM and a task to the VM");
199 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2,1);
200 run_test_process("( [X]1 x )2", vm0, flop_amount);
201 run_test_process("( [x]1 X )2", pm2, flop_amount);
202 simgrid::s4u::this_actor::sleep_for(2);
203 test_energy_consumption(chooser,2);
206 } else if (chooser == "( [o]1 [ ]1 )2") {
207 XBT_INFO("### Put two VMs on a PM, and put a task to one VM");
208 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2,1);
209 simgrid::s4u::VirtualMachine *vm1 = new simgrid::s4u::VirtualMachine("VM1", pm2,1);
210 run_test_process("( [X]1 [ ]1 )2", vm0, flop_amount);
211 simgrid::s4u::this_actor::sleep_for(2);
212 test_energy_consumption(chooser,1);
216 } else if (chooser == "( [o]1 [o]1 )2") {
217 XBT_INFO("### Put two VMs on a PM, and put a task to each VM");
218 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2,1);
219 simgrid::s4u::VirtualMachine *vm1 = new simgrid::s4u::VirtualMachine("VM1", pm2,1);
220 run_test_process("( [X]1 [x]1 )2", vm0, flop_amount);
221 run_test_process("( [x]1 [X]1 )2", vm1, flop_amount);
222 simgrid::s4u::this_actor::sleep_for(2);
223 test_energy_consumption(chooser,2);
227 } else if (chooser == "( [o]1 [o]1 [ ]1 )2") {
228 XBT_INFO("### Put three VMs on a PM, and put a task to two VMs");
229 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2,1);
230 simgrid::s4u::VirtualMachine *vm1 = new simgrid::s4u::VirtualMachine("VM1", pm2,1);
231 simgrid::s4u::VirtualMachine *vm2 = new simgrid::s4u::VirtualMachine("VM2", pm2,1);
232 run_test_process("( [X]1 [x]1 [ ]1 )2", vm0, flop_amount);
233 run_test_process("( [x]1 [X]1 [ ]1 )2", vm1, flop_amount);
234 simgrid::s4u::this_actor::sleep_for(2);
235 test_energy_consumption(chooser,2);
240 } else if (chooser == "( [o]1 [o]1 [o]1 )2") {
241 XBT_INFO("### Put three VMs on a PM, and put a task to each VM");
242 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2,1);
243 simgrid::s4u::VirtualMachine *vm1 = new simgrid::s4u::VirtualMachine("VM1", pm2,1);
244 simgrid::s4u::VirtualMachine *vm2 = new simgrid::s4u::VirtualMachine("VM2", pm2,1);
245 run_test_process("( [X]1 [o]1 [o]1 )2", vm0, flop_amount * 2 / 3);
246 run_test_process("( [o]1 [X]1 [o]1 )2", vm1, flop_amount * 2 / 3);
247 run_test_process("( [o]1 [o]1 [X]1 )2", vm2, flop_amount * 2 / 3);
248 simgrid::s4u::this_actor::sleep_for(2);
249 test_energy_consumption(chooser,2);
254 } else if (chooser == "( [o]2 )2") {
255 XBT_INFO("### Put a VM on a PM, and put a task to the VM");
256 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
257 run_test_process("( [X]2 )2", vm0, flop_amount);
258 simgrid::s4u::this_actor::sleep_for(2);
259 test_energy_consumption(chooser,1);
262 } else if (chooser == "( [oo]2 )2") {
263 XBT_INFO("### Put a VM on a PM, and put two tasks to the VM");
264 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
265 run_test_process("( [Xo]2 )2", vm0, flop_amount);
266 run_test_process("( [oX]2 )2", vm0, flop_amount);
267 simgrid::s4u::this_actor::sleep_for(2);
268 test_energy_consumption(chooser,2);
271 } else if (chooser == "( [ooo]2 )2") {
272 XBT_INFO("### Put a VM on a PM, and put three tasks to the VM");
273 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
274 run_test_process("( [Xoo]2 )2", vm0, flop_amount * 2 / 3);
275 run_test_process("( [oXo]2 )2", vm0, flop_amount * 2 / 3);
276 run_test_process("( [ooX]2 )2", vm0, flop_amount * 2 / 3);
277 simgrid::s4u::this_actor::sleep_for(2);
278 test_energy_consumption(chooser,2);
281 } else if (chooser == "( [ ]2 o )2") {
282 XBT_INFO("### Put a VM on a PM, and put a task to the PM");
283 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
284 run_test_process("( [ ]2 X )2", pm2, flop_amount);
285 simgrid::s4u::this_actor::sleep_for(2);
286 test_energy_consumption(chooser,1);
289 } else if (chooser == "( [o]2 o )2") {
290 XBT_INFO("### Put a VM on a PM, put one task to the PM and one task to the VM");
291 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
292 run_test_process("( [o]2 X )2", pm2, flop_amount);
293 run_test_process("( [X]2 o )2", vm0, flop_amount);
294 simgrid::s4u::this_actor::sleep_for(2);
295 test_energy_consumption(chooser,2);
298 } else if (chooser == "( [oo]2 o )2") {
299 XBT_INFO("### Put a VM on a PM, put one task to the PM and two tasks to the VM");
300 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
301 run_test_process("( [oo]2 X )2", pm2, flop_amount * 2 / 3);
302 run_test_process("( [Xo]2 o )2", vm0, flop_amount * 2 / 3);
303 run_test_process("( [oX]2 o )2", vm0, flop_amount * 2 / 3);
304 simgrid::s4u::this_actor::sleep_for(2);
305 test_energy_consumption(chooser,2);
308 } else if (chooser == "( [ooo]2 o )2") {
309 XBT_INFO("### Put a VM on a PM, put one task to the PM and three tasks to the VM");
310 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
311 run_test_process("( [ooo]2 X )2", pm2, flop_amount * 2 / 3);
312 run_test_process("( [Xoo]2 o )2", vm0, flop_amount * (2. / 3 * 2) / 3); // VM_share/3
313 run_test_process("( [oXo]2 o )2", vm0, flop_amount * (2. / 3 * 2) / 3); // VM_share/3
314 run_test_process("( [ooX]2 o )2", vm0, flop_amount * (2. / 3 * 2) / 3); // VM_share/3
315 simgrid::s4u::this_actor::sleep_for(2);
316 test_energy_consumption(chooser,2);
319 } else if (chooser == "( [ ]2 oo )2") {
320 XBT_INFO("### Put a VM on a PM, and put two tasks to the PM");
321 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
322 run_test_process("( [ ]2 Xo )2", pm2, flop_amount);
323 run_test_process("( [ ]2 oX )2", pm2, flop_amount);
324 simgrid::s4u::this_actor::sleep_for(2);
325 test_energy_consumption(chooser,2);
328 } else if (chooser == "( [o]2 oo )2") {
329 XBT_INFO("### Put a VM on a PM, put one task to the PM and one task to the VM");
330 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
331 run_test_process("( [o]2 Xo )2", pm2, flop_amount * 2 / 3);
332 run_test_process("( [o]2 oX )2", pm2, flop_amount * 2 / 3);
333 run_test_process("( [X]2 oo )2", vm0, flop_amount * 2 / 3);
334 simgrid::s4u::this_actor::sleep_for(2);
335 test_energy_consumption(chooser,2);
338 } else if (chooser == "( [oo]2 oo )2") {
339 XBT_INFO("### Put a VM on a PM, put one task to the PM and two tasks to the VM");
340 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
341 run_test_process("( [oo]2 Xo )2", pm2, flop_amount / 2);
342 run_test_process("( [oo]2 oX )2", pm2, flop_amount / 2);
343 run_test_process("( [Xo]2 oo )2", vm0, flop_amount / 2);
344 run_test_process("( [oX]2 oo )2", vm0, flop_amount / 2);
345 simgrid::s4u::this_actor::sleep_for(2);
346 test_energy_consumption(chooser,2);
349 } else if (chooser == "( [ooo]2 oo )2") {
350 XBT_INFO("### Put a VM on a PM, put one task to the PM and three tasks to the VM");
351 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
352 run_test_process("( [ooo]2 Xo )2", pm2, flop_amount * 2 / 4);
353 run_test_process("( [ooo]2 oX )2", pm2, flop_amount * 2 / 4);
354 run_test_process("( [Xoo]2 oo )2", vm0, flop_amount / 3);
355 run_test_process("( [oXo]2 oo )2", vm0, flop_amount / 3);
356 run_test_process("( [ooX]2 oo )2", vm0, flop_amount / 3);
357 simgrid::s4u::this_actor::sleep_for(2);
358 test_energy_consumption(chooser,2);
361 } else if (chooser == "( [o]2 )4") {
362 XBT_INFO("### Put a VM on a PM, and put a task to the VM");
363 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
364 run_test_process("( [X]2 )4", vm0, flop_amount);
365 simgrid::s4u::this_actor::sleep_for(2);
366 test_energy_consumption(chooser,1);
369 } else if (chooser == "( [oo]2 )4") {
370 XBT_INFO("### Put a VM on a PM, and put two tasks to the VM");
371 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
372 run_test_process("( [Xo]2 )4", vm0, flop_amount);
373 run_test_process("( [oX]2 )4", vm0, flop_amount);
374 simgrid::s4u::this_actor::sleep_for(2);
375 test_energy_consumption(chooser,2);
378 } else if (chooser == "( [ooo]2 )4") {
379 XBT_INFO("### ( [ooo]2 )4: Put a VM on a PM, and put three tasks to the VM");
380 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
381 run_test_process("( [Xoo]2 )4", vm0, flop_amount * 2 / 3);
382 run_test_process("( [oXo]2 )4", vm0, flop_amount * 2 / 3);
383 run_test_process("( [ooX]2 )4", vm0, flop_amount * 2 / 3);
384 simgrid::s4u::this_actor::sleep_for(2);
385 test_energy_consumption(chooser,2);
388 } else if (chooser == "( [ ]2 o )4") {
389 XBT_INFO("### Put a VM on a PM, and put a task to the PM");
390 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
391 run_test_process("( [ ]2 X )4", pm4, flop_amount);
392 simgrid::s4u::this_actor::sleep_for(2);
393 test_energy_consumption(chooser,1);
396 } else if (chooser == "( [ ]2 oo )4") {
397 XBT_INFO("### Put a VM on a PM, and put two tasks to the PM");
398 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
399 run_test_process("( [ ]2 Xo )4", pm4, flop_amount);
400 run_test_process("( [ ]2 oX )4", pm4, flop_amount);
401 simgrid::s4u::this_actor::sleep_for(2);
402 test_energy_consumption(chooser,2);
405 } else if (chooser == "( [ ]2 ooo )4") {
406 XBT_INFO("### Put a VM on a PM, and put three tasks to the PM");
407 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
408 run_test_process("( [ ]2 Xoo )4", pm4, flop_amount);
409 run_test_process("( [ ]2 oXo )4", pm4, flop_amount);
410 run_test_process("( [ ]2 ooX )4", pm4, flop_amount);
411 simgrid::s4u::this_actor::sleep_for(2);
412 test_energy_consumption(chooser,3);
415 } else if (chooser == "( [ ]2 oooo )4") {
416 XBT_INFO("### Put a VM on a PM, and put four tasks to the PM");
417 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
418 run_test_process("( [ ]2 Xooo )4", pm4, flop_amount);
419 run_test_process("( [ ]2 oXoo )4", pm4, flop_amount);
420 run_test_process("( [ ]2 ooXo )4", pm4, flop_amount);
421 run_test_process("( [ ]2 oooX )4", pm4, flop_amount);
422 simgrid::s4u::this_actor::sleep_for(2);
423 test_energy_consumption(chooser,4);
426 } else if (chooser == "( [o]2 o )4") {
427 XBT_INFO("### Put a VM on a PM, and put one task to the PM and one task to the VM");
428 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
429 run_test_process("( [X]2 o )4", vm0, flop_amount);
430 run_test_process("( [o]2 X )4", pm4, flop_amount);
431 simgrid::s4u::this_actor::sleep_for(2);
432 test_energy_consumption(chooser,2);
435 } else if (chooser == "( [o]2 oo )4") {
436 XBT_INFO("### Put a VM on a PM, and put two tasks to the PM and one task to the VM");
437 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
438 run_test_process("( [X]2 oo )4", vm0, flop_amount);
439 run_test_process("( [o]2 Xo )4", pm4, flop_amount);
440 run_test_process("( [o]2 oX )4", pm4, flop_amount);
441 simgrid::s4u::this_actor::sleep_for(2);
442 test_energy_consumption(chooser,3);
445 } else if (chooser == "( [oo]2 oo )4") {
446 XBT_INFO("### Put a VM on a PM, and put two tasks to the PM and two tasks to the VM");
447 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
448 run_test_process("( [Xo]2 oo )4", vm0, flop_amount);
449 run_test_process("( [oX]2 oo )4", vm0, flop_amount);
450 run_test_process("( [oo]2 Xo )4", pm4, flop_amount);
451 run_test_process("( [oo]2 oX )4", pm4, flop_amount);
452 simgrid::s4u::this_actor::sleep_for(2);
453 test_energy_consumption(chooser,4);
456 } else if (chooser == "( [o]2 ooo )4") {
457 XBT_INFO("### Put a VM on a PM, and put three tasks to the PM and one tasks to the VM");
458 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
459 run_test_process("( [X]2 ooo )4", vm0, flop_amount);
460 run_test_process("( [o]2 Xoo )4", pm4, flop_amount);
461 run_test_process("( [o]2 oXo )4", pm4, flop_amount);
462 run_test_process("( [o]2 ooX )4", pm4, flop_amount);
463 simgrid::s4u::this_actor::sleep_for(2);
464 test_energy_consumption(chooser,4);
467 } else if (chooser == "( [oo]2 ooo )4") {
468 XBT_INFO("### Put a VM on a PM, and put three tasks to the PM and two tasks to the VM");
469 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
470 run_test_process("( [Xo]2 ooo )4", vm0, flop_amount * 4 / 5);
471 run_test_process("( [oX]2 ooo )4", vm0, flop_amount * 4 / 5);
472 run_test_process("( [oo]2 Xoo )4", pm4, flop_amount * 4 / 5);
473 run_test_process("( [oo]2 oXo )4", pm4, flop_amount * 4 / 5);
474 run_test_process("( [oo]2 ooX )4", pm4, flop_amount * 4 / 5);
475 simgrid::s4u::this_actor::sleep_for(2);
476 test_energy_consumption(chooser,4);
479 } else if (chooser == "( [ooo]2 ooo )4") {
480 XBT_INFO("### Put a VM on a PM, and put three tasks to the PM and three tasks to the VM");
481 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
482 run_test_process("( [Xoo]2 ooo )4", vm0, flop_amount * (8. / 5) * 1 / 3); // The VM has 8/5 of the PM
483 run_test_process("( [oXo]2 ooo )4", vm0, flop_amount * (8. / 5) * 1 / 3);
484 run_test_process("( [ooX]2 ooo )4", vm0, flop_amount * (8. / 5) * 1 / 3);
486 run_test_process("( [ooo]2 Xoo )4", pm4, flop_amount * 4 / 5);
487 run_test_process("( [ooo]2 oXo )4", pm4, flop_amount * 4 / 5);
488 run_test_process("( [ooo]2 ooX )4", pm4, flop_amount * 4 / 5);
489 simgrid::s4u::this_actor::sleep_for(2);
490 test_energy_consumption(chooser,4);
494 xbt_die("Unknown chooser: %s", chooser.c_str());
497 static int master_main()
499 XBT_INFO("# TEST ON SINGLE-CORE PMs");
500 XBT_INFO("## Check computation on regular PMs");
503 run_test("(o)1 (o)1");
504 XBT_INFO("# TEST ON SINGLE-CORE PMs AND SINGLE-CORE VMs");
506 XBT_INFO("## Check the impact of running tasks inside a VM (no degradation for the moment)");
507 run_test("( [o]1 )1");
508 run_test("( [oo]1 )1");
510 XBT_INFO("## Check impact of running tasks collocated with VMs (no VM noise for the moment)");
511 run_test("( [ ]1 o )1");
512 run_test("( [o]1 o )1");
513 run_test("( [oo]1 o )1");
515 XBT_INFO("# TEST ON TWO-CORE PMs");
516 XBT_INFO("## Check computation on 2 cores PMs");
519 run_test("( ooo )2");
521 XBT_INFO("# TEST ON TWO-CORE PMs AND SINGLE-CORE VMs");
522 XBT_INFO("## Check impact of a single VM (no degradation for the moment)");
523 run_test("( [o]1 )2");
524 run_test("( [oo]1 )2");
525 run_test("( [ ]1 o )2");
526 run_test("( [o]1 o )2");
528 XBT_INFO("## Check impact of a several VMs (there is no degradation for the moment)");
529 run_test("( [o]1 [ ]1 )2");
530 run_test("( [o]1 [o]1 )2");
531 run_test("( [o]1 [o]1 [ ]1 )2");
532 run_test("( [o]1 [o]1 [o]1 )2");
534 XBT_INFO("# TEST ON TWO-CORE PMs AND TWO-CORE VMs");
536 XBT_INFO("## Check impact of a single VM (there is no degradation for the moment)");
537 run_test("( [o]2 )2");
538 run_test("( [oo]2 )2");
539 run_test("( [ooo]2 )2");
541 XBT_INFO("## Check impact of a single VM collocated with a task (there is no degradation for the moment)");
542 run_test("( [ ]2 o )2");
543 run_test("( [o]2 o )2");
544 run_test("( [oo]2 o )2");
545 run_test("( [ooo]2 o )2");
546 run_test("( [ ]2 oo )2");
547 run_test("( [o]2 oo )2");
548 run_test("( [oo]2 oo )2");
549 run_test("( [ooo]2 oo )2");
551 XBT_INFO("# TEST ON FOUR-CORE PMs AND TWO-CORE VMs");
553 XBT_INFO("## Check impact of a single VM");
554 run_test("( [o]2 )4");
555 run_test("( [oo]2 )4");
556 run_test("( [ooo]2 )4");
558 XBT_INFO("## Check impact of a single empty VM collocated with tasks");
559 run_test("( [ ]2 o )4");
560 run_test("( [ ]2 oo )4");
561 run_test("( [ ]2 ooo )4");
562 run_test("( [ ]2 oooo )4");
564 XBT_INFO("## Check impact of a single working VM collocated with tasks");
565 run_test("( [o]2 o )4");
566 run_test("( [o]2 oo )4");
567 run_test("( [oo]2 oo )4");
568 run_test("( [o]2 ooo )4");
569 run_test("( [oo]2 ooo )4");
570 run_test("( [ooo]2 ooo )4");
574 XBT_INFO("## %d test failed", failed_test);
578 int main(int argc, char* argv[])
580 /* Get the arguments */
581 simgrid::s4u::Engine e(&argc, argv);
582 sg_host_energy_plugin_init();
584 /* load the platform file */
585 const char* platform = "../../../platforms/cloud-sharing.xml";
588 e.load_platform(platform);
590 simgrid::s4u::Host *pm0 = simgrid::s4u::Host::by_name("node-0.1core.org");
591 xbt_assert(pm0, "Host 'node-0.1core.org' not found");
592 simgrid::s4u::Actor::create("master", pm0, master_main);