1 /* Copyright (c) 2007-2019. 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"
12 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this msg example");
14 const int FAIL_ON_ERROR = 0;
15 const int flop_amount = 100000000; // 100Mf, so that computing this on a 1Gf core takes exactly 0.1s
20 static int computation_fun(std::vector<std::string> argv)
22 int size = std::stoi(argv[0]);
24 double begin = simgrid::s4u::Engine::get_clock();
25 simgrid::s4u::this_actor::execute(size);
26 double end = simgrid::s4u::Engine::get_clock();
28 if (0.1 - (end - begin) > 0.001) {
29 xbt_assert(! FAIL_ON_ERROR, "%s with %.4g load (%dflops) took %.4fs instead of 0.1s",
30 simgrid::s4u::this_actor::get_name().c_str(), ((double)size/flop_amount),size, (end-begin));
31 XBT_INFO("FAILED TEST: %s with %.4g load (%dflops) took %.4fs instead of 0.1s",
32 simgrid::s4u::this_actor::get_name().c_str(),((double)size/flop_amount), size, (end-begin));
35 XBT_INFO("Passed: %s with %.4g load (%dflops) took 0.1s as expected",
36 simgrid::s4u::this_actor::get_name().c_str(), ((double)size/flop_amount), size);
42 static void run_test_process(const std::string& name, simgrid::s4u::Host* location, int size)
44 std::vector<std::string> arg = {std::to_string(size)};
45 simgrid::s4u::Actor::create(std::move(name), location, computation_fun, arg);
48 static void test_energy_consumption(const std::string& name, int nb_cores)
50 double new_energy = 0;
52 for (simgrid::s4u::Host *pm : simgrid::s4u::Engine::get_instance()->get_all_hosts() ){
53 if(!dynamic_cast<simgrid::s4u::VirtualMachine *>(pm))
54 new_energy += sg_host_get_consumed_energy(pm);
57 double expected_consumption = 0.1 * nb_cores;
58 double actual_consumption = new_energy - energy;
62 if (std::abs(expected_consumption - actual_consumption) > 0.001) {
63 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 );
66 XBT_INFO("Passed: %s consumed %f J (i.e. %i cores used) ", name.c_str(), actual_consumption, nb_cores);
70 static void run_test(const std::string& chooser)
72 simgrid::s4u::Host *pm0 = simgrid::s4u::Host::by_name("node-0.1core.org");
73 simgrid::s4u::Host *pm1 = simgrid::s4u::Host::by_name("node-1.1core.org");
74 simgrid::s4u::Host *pm2 = simgrid::s4u::Host::by_name("node-0.2cores.org"); // 2 cores
75 simgrid::s4u::Host *pm4 = simgrid::s4u::Host::by_name("node-0.4cores.org");
77 simgrid::s4u::VirtualMachine *vm0;
78 xbt_assert(pm0, "Host node-0.1core.org does not seem to exist");
79 xbt_assert(pm2, "Host node-0.2cores.org does not seem to exist");
80 xbt_assert(pm4, "Host node-0.4cores.org does not seem to exist");
82 // syntax of the process name:
83 // "( )1" means PM with one core; "( )2" means PM with 2 cores
84 // "( [ ]2 )4" means a VM with 2 cores, on a PM with 4 cores.
85 // "o" means another process is there
86 // "X" means the process which holds this name
88 if (chooser == "(o)1") {
89 XBT_INFO("### Test '%s'. A task on a regular PM", chooser.c_str());
90 run_test_process("(X)1", pm0, flop_amount);
91 simgrid::s4u::this_actor::sleep_for(2);
92 test_energy_consumption(chooser,1);
94 } else if (chooser == "(oo)1") {
95 XBT_INFO("### Test '%s'. 2 tasks on a regular PM", chooser.c_str());
96 run_test_process("(Xo)1", pm0, flop_amount / 2);
97 run_test_process("(oX)1", pm0, flop_amount / 2);
98 simgrid::s4u::this_actor::sleep_for(2);
99 test_energy_consumption(chooser,1);
101 } else if (chooser == "(o)1 (o)1") {
102 XBT_INFO("### Test '%s'. 2 regular PMs, with a task each.", chooser.c_str());
103 run_test_process("(X)1 (o)1", pm0, flop_amount);
104 run_test_process("(o)1 (X)1", pm1, flop_amount);
105 simgrid::s4u::this_actor::sleep_for(2);
106 test_energy_consumption(chooser,2);
108 } else if (chooser == "( [o]1 )1") {
109 XBT_INFO("### Test '%s'. A task in a VM on a PM.", chooser.c_str());
110 vm0 = new simgrid::s4u::VirtualMachine("VM0",pm0,1);
111 run_test_process("( [X]1 )1", vm0, flop_amount);
112 simgrid::s4u::this_actor::sleep_for(2);
113 test_energy_consumption(chooser,1);
116 } else if (chooser == "( [oo]1 )1") {
117 XBT_INFO("### Test '%s'. 2 tasks co-located in a VM on a PM.", chooser.c_str());
118 vm0 = new simgrid::s4u::VirtualMachine("VM0",pm0,1);
119 run_test_process("( [Xo]1 )1", vm0, flop_amount / 2);
120 run_test_process("( [oX]1 )1", vm0, flop_amount / 2);
121 simgrid::s4u::this_actor::sleep_for(2);
122 test_energy_consumption(chooser,1);
125 } else if (chooser == "( [ ]1 o )1") {
126 XBT_INFO("### Test '%s'. 1 task collocated with an empty VM", chooser.c_str());
127 vm0 = new simgrid::s4u::VirtualMachine("VM0",pm0,1);
128 run_test_process("( [ ]1 X )1", pm0, flop_amount);
129 simgrid::s4u::this_actor::sleep_for(2);
130 test_energy_consumption(chooser,1);
133 } else if (chooser == "( [o]1 o )1") {
134 XBT_INFO("### Test '%s'. A task in a VM, plus a task", chooser.c_str());
135 vm0 = new simgrid::s4u::VirtualMachine("VM0",pm0,1);
136 run_test_process("( [X]1 o )1", vm0, flop_amount / 2);
137 run_test_process("( [o]1 X )1", pm0, flop_amount / 2);
138 simgrid::s4u::this_actor::sleep_for(2);
139 test_energy_consumption(chooser,1);
142 } else if (chooser == "( [oo]1 o )1") {
143 XBT_INFO("### Test '%s'. 2 tasks in a VM, plus a task", chooser.c_str());
144 vm0 = new simgrid::s4u::VirtualMachine("VM0",pm0,1);
145 run_test_process("( [Xo]1 o )1", vm0, flop_amount / 4);
146 run_test_process("( [oX]1 o )1", vm0, flop_amount / 4);
147 run_test_process("( [oo]1 X )1", pm0, flop_amount / 2);
148 simgrid::s4u::this_actor::sleep_for(2);
149 test_energy_consumption(chooser,1);
152 } else if (chooser == "( o )2") {
153 XBT_INFO("### Test '%s'. A task on bicore PM", chooser.c_str());
154 run_test_process("(X)2", pm2, flop_amount);
155 simgrid::s4u::this_actor::sleep_for(2);
156 test_energy_consumption(chooser,1);
158 } else if (chooser == "( oo )2") {
159 XBT_INFO("### Test '%s'. 2 tasks on a bicore PM", chooser.c_str());
160 run_test_process("(Xx)2", pm2, flop_amount);
161 run_test_process("(xX)2", pm2, flop_amount);
162 simgrid::s4u::this_actor::sleep_for(2);
163 test_energy_consumption(chooser,2);
165 } else if (chooser == "( ooo )2") {
166 XBT_INFO("### Test '%s'. 3 tasks on a bicore PM", chooser.c_str());
167 run_test_process("(Xxx)2", pm2, flop_amount * 2 / 3);
168 run_test_process("(xXx)2", pm2, flop_amount * 2 / 3);
169 run_test_process("(xxX)2", pm2, flop_amount * 2 / 3);
170 simgrid::s4u::this_actor::sleep_for(2);
171 test_energy_consumption(chooser,2);
173 } else if (chooser == "( [o]1 )2") {
174 XBT_INFO("### Test '%s'. A task in a VM on a bicore PM", chooser.c_str());
175 vm0 = new simgrid::s4u::VirtualMachine("VM0",pm2,1);
176 run_test_process("( [X]1 )2", vm0, flop_amount);
177 simgrid::s4u::this_actor::sleep_for(2);
178 test_energy_consumption(chooser,1);
181 } else if (chooser == "( [oo]1 )2") {
182 XBT_INFO("### Test '%s'. 2 tasks in a VM on a bicore PM", chooser.c_str());
183 vm0 = new simgrid::s4u::VirtualMachine("VM0",pm2,1);
184 run_test_process("( [Xx]1 )2", vm0, flop_amount / 2);
185 run_test_process("( [xX]1 )2", vm0, flop_amount / 2);
186 simgrid::s4u::this_actor::sleep_for(2);
187 test_energy_consumption(chooser,1);
190 } else if (chooser == "( [ ]1 o )2") {
191 XBT_INFO("### Put a VM on a PM, and put a task to the PM");
192 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2,1);
193 run_test_process("( [ ]1 X )2", pm2, flop_amount);
194 simgrid::s4u::this_actor::sleep_for(2);
195 test_energy_consumption(chooser,1);
198 } else if (chooser == "( [o]1 o )2") {
199 XBT_INFO("### Put a VM on a PM, put a task to the PM and a task to the VM");
200 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2,1);
201 run_test_process("( [X]1 x )2", vm0, flop_amount);
202 run_test_process("( [x]1 X )2", pm2, flop_amount);
203 simgrid::s4u::this_actor::sleep_for(2);
204 test_energy_consumption(chooser,2);
207 } else if (chooser == "( [o]1 [ ]1 )2") {
208 XBT_INFO("### Put two VMs on a PM, and put a task to one VM");
209 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2,1);
210 simgrid::s4u::VirtualMachine *vm1 = new simgrid::s4u::VirtualMachine("VM1", pm2,1);
211 run_test_process("( [X]1 [ ]1 )2", vm0, flop_amount);
212 simgrid::s4u::this_actor::sleep_for(2);
213 test_energy_consumption(chooser,1);
217 } else if (chooser == "( [o]1 [o]1 )2") {
218 XBT_INFO("### Put two VMs on a PM, and put a task to each VM");
219 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2,1);
220 simgrid::s4u::VirtualMachine *vm1 = new simgrid::s4u::VirtualMachine("VM1", pm2,1);
221 run_test_process("( [X]1 [x]1 )2", vm0, flop_amount);
222 run_test_process("( [x]1 [X]1 )2", vm1, flop_amount);
223 simgrid::s4u::this_actor::sleep_for(2);
224 test_energy_consumption(chooser,2);
228 } else if (chooser == "( [o]1 [o]1 [ ]1 )2") {
229 XBT_INFO("### Put three VMs on a PM, and put a task to two VMs");
230 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2,1);
231 simgrid::s4u::VirtualMachine *vm1 = new simgrid::s4u::VirtualMachine("VM1", pm2,1);
232 simgrid::s4u::VirtualMachine *vm2 = new simgrid::s4u::VirtualMachine("VM2", pm2,1);
233 run_test_process("( [X]1 [x]1 [ ]1 )2", vm0, flop_amount);
234 run_test_process("( [x]1 [X]1 [ ]1 )2", vm1, flop_amount);
235 simgrid::s4u::this_actor::sleep_for(2);
236 test_energy_consumption(chooser,2);
241 } else if (chooser == "( [o]1 [o]1 [o]1 )2") {
242 XBT_INFO("### Put three VMs on a PM, and put a task to each VM");
243 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2,1);
244 simgrid::s4u::VirtualMachine *vm1 = new simgrid::s4u::VirtualMachine("VM1", pm2,1);
245 simgrid::s4u::VirtualMachine *vm2 = new simgrid::s4u::VirtualMachine("VM2", pm2,1);
246 run_test_process("( [X]1 [o]1 [o]1 )2", vm0, flop_amount * 2 / 3);
247 run_test_process("( [o]1 [X]1 [o]1 )2", vm1, flop_amount * 2 / 3);
248 run_test_process("( [o]1 [o]1 [X]1 )2", vm2, flop_amount * 2 / 3);
249 simgrid::s4u::this_actor::sleep_for(2);
250 test_energy_consumption(chooser,2);
255 } else if (chooser == "( [o]2 )2") {
256 XBT_INFO("### Put a VM on a PM, and put a task to the VM");
257 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
258 run_test_process("( [X]2 )2", vm0, flop_amount);
259 simgrid::s4u::this_actor::sleep_for(2);
260 test_energy_consumption(chooser,1);
263 } else if (chooser == "( [oo]2 )2") {
264 XBT_INFO("### Put a VM on a PM, and put two tasks to the VM");
265 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
266 run_test_process("( [Xo]2 )2", vm0, flop_amount);
267 run_test_process("( [oX]2 )2", vm0, flop_amount);
268 simgrid::s4u::this_actor::sleep_for(2);
269 test_energy_consumption(chooser,2);
272 } else if (chooser == "( [ooo]2 )2") {
273 XBT_INFO("### Put a VM on a PM, and put three tasks to the VM");
274 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
275 run_test_process("( [Xoo]2 )2", vm0, flop_amount * 2 / 3);
276 run_test_process("( [oXo]2 )2", vm0, flop_amount * 2 / 3);
277 run_test_process("( [ooX]2 )2", vm0, flop_amount * 2 / 3);
278 simgrid::s4u::this_actor::sleep_for(2);
279 test_energy_consumption(chooser,2);
282 } else if (chooser == "( [ ]2 o )2") {
283 XBT_INFO("### Put a VM on a PM, and put a task to the PM");
284 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
285 run_test_process("( [ ]2 X )2", pm2, flop_amount);
286 simgrid::s4u::this_actor::sleep_for(2);
287 test_energy_consumption(chooser,1);
290 } else if (chooser == "( [o]2 o )2") {
291 XBT_INFO("### Put a VM on a PM, put one task to the PM and one task to the VM");
292 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
293 run_test_process("( [o]2 X )2", pm2, flop_amount);
294 run_test_process("( [X]2 o )2", vm0, flop_amount);
295 simgrid::s4u::this_actor::sleep_for(2);
296 test_energy_consumption(chooser,2);
299 } else if (chooser == "( [oo]2 o )2") {
300 XBT_INFO("### Put a VM on a PM, put one task to the PM and two tasks to the VM");
301 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
302 run_test_process("( [oo]2 X )2", pm2, flop_amount * 2 / 3);
303 run_test_process("( [Xo]2 o )2", vm0, flop_amount * 2 / 3);
304 run_test_process("( [oX]2 o )2", vm0, flop_amount * 2 / 3);
305 simgrid::s4u::this_actor::sleep_for(2);
306 test_energy_consumption(chooser,2);
309 } else if (chooser == "( [ooo]2 o )2") {
310 XBT_INFO("### Put a VM on a PM, put one task to the PM and three tasks to the VM");
311 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
312 run_test_process("( [ooo]2 X )2", pm2, flop_amount * 2 / 3);
313 run_test_process("( [Xoo]2 o )2", vm0, flop_amount * (2. / 3 * 2) / 3); // VM_share/3
314 run_test_process("( [oXo]2 o )2", vm0, flop_amount * (2. / 3 * 2) / 3); // VM_share/3
315 run_test_process("( [ooX]2 o )2", vm0, flop_amount * (2. / 3 * 2) / 3); // VM_share/3
316 simgrid::s4u::this_actor::sleep_for(2);
317 test_energy_consumption(chooser,2);
320 } else if (chooser == "( [ ]2 oo )2") {
321 XBT_INFO("### Put a VM on a PM, and put two tasks to the PM");
322 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
323 run_test_process("( [ ]2 Xo )2", pm2, flop_amount);
324 run_test_process("( [ ]2 oX )2", pm2, flop_amount);
325 simgrid::s4u::this_actor::sleep_for(2);
326 test_energy_consumption(chooser,2);
329 } else if (chooser == "( [o]2 oo )2") {
330 XBT_INFO("### Put a VM on a PM, put one task to the PM and one task to the VM");
331 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
332 run_test_process("( [o]2 Xo )2", pm2, flop_amount * 2 / 3);
333 run_test_process("( [o]2 oX )2", pm2, flop_amount * 2 / 3);
334 run_test_process("( [X]2 oo )2", vm0, flop_amount * 2 / 3);
335 simgrid::s4u::this_actor::sleep_for(2);
336 test_energy_consumption(chooser,2);
339 } else if (chooser == "( [oo]2 oo )2") {
340 XBT_INFO("### Put a VM on a PM, put one task to the PM and two tasks to the VM");
341 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
342 run_test_process("( [oo]2 Xo )2", pm2, flop_amount / 2);
343 run_test_process("( [oo]2 oX )2", pm2, flop_amount / 2);
344 run_test_process("( [Xo]2 oo )2", vm0, flop_amount / 2);
345 run_test_process("( [oX]2 oo )2", vm0, flop_amount / 2);
346 simgrid::s4u::this_actor::sleep_for(2);
347 test_energy_consumption(chooser,2);
350 } else if (chooser == "( [ooo]2 oo )2") {
351 XBT_INFO("### Put a VM on a PM, put one task to the PM and three tasks to the VM");
352 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
353 run_test_process("( [ooo]2 Xo )2", pm2, flop_amount * 2 / 4);
354 run_test_process("( [ooo]2 oX )2", pm2, flop_amount * 2 / 4);
355 run_test_process("( [Xoo]2 oo )2", vm0, flop_amount / 3);
356 run_test_process("( [oXo]2 oo )2", vm0, flop_amount / 3);
357 run_test_process("( [ooX]2 oo )2", vm0, flop_amount / 3);
358 simgrid::s4u::this_actor::sleep_for(2);
359 test_energy_consumption(chooser,2);
362 } else if (chooser == "( [o]2 )4") {
363 XBT_INFO("### Put a VM on a PM, and put a task to the VM");
364 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
365 run_test_process("( [X]2 )4", vm0, flop_amount);
366 simgrid::s4u::this_actor::sleep_for(2);
367 test_energy_consumption(chooser,1);
370 } else if (chooser == "( [oo]2 )4") {
371 XBT_INFO("### Put a VM on a PM, and put two tasks to the VM");
372 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
373 run_test_process("( [Xo]2 )4", vm0, flop_amount);
374 run_test_process("( [oX]2 )4", vm0, flop_amount);
375 simgrid::s4u::this_actor::sleep_for(2);
376 test_energy_consumption(chooser,2);
379 } else if (chooser == "( [ooo]2 )4") {
380 XBT_INFO("### ( [ooo]2 )4: Put a VM on a PM, and put three tasks to the VM");
381 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
382 run_test_process("( [Xoo]2 )4", vm0, flop_amount * 2 / 3);
383 run_test_process("( [oXo]2 )4", vm0, flop_amount * 2 / 3);
384 run_test_process("( [ooX]2 )4", vm0, flop_amount * 2 / 3);
385 simgrid::s4u::this_actor::sleep_for(2);
386 test_energy_consumption(chooser,2);
389 } else if (chooser == "( [ ]2 o )4") {
390 XBT_INFO("### Put a VM on a PM, and put a task to the PM");
391 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
392 run_test_process("( [ ]2 X )4", pm4, flop_amount);
393 simgrid::s4u::this_actor::sleep_for(2);
394 test_energy_consumption(chooser,1);
397 } else if (chooser == "( [ ]2 oo )4") {
398 XBT_INFO("### Put a VM on a PM, and put two tasks to the PM");
399 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
400 run_test_process("( [ ]2 Xo )4", pm4, flop_amount);
401 run_test_process("( [ ]2 oX )4", pm4, flop_amount);
402 simgrid::s4u::this_actor::sleep_for(2);
403 test_energy_consumption(chooser,2);
406 } else if (chooser == "( [ ]2 ooo )4") {
407 XBT_INFO("### Put a VM on a PM, and put three tasks to the PM");
408 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
409 run_test_process("( [ ]2 Xoo )4", pm4, flop_amount);
410 run_test_process("( [ ]2 oXo )4", pm4, flop_amount);
411 run_test_process("( [ ]2 ooX )4", pm4, flop_amount);
412 simgrid::s4u::this_actor::sleep_for(2);
413 test_energy_consumption(chooser,3);
416 } else if (chooser == "( [ ]2 oooo )4") {
417 XBT_INFO("### Put a VM on a PM, and put four tasks to the PM");
418 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
419 run_test_process("( [ ]2 Xooo )4", pm4, flop_amount);
420 run_test_process("( [ ]2 oXoo )4", pm4, flop_amount);
421 run_test_process("( [ ]2 ooXo )4", pm4, flop_amount);
422 run_test_process("( [ ]2 oooX )4", pm4, flop_amount);
423 simgrid::s4u::this_actor::sleep_for(2);
424 test_energy_consumption(chooser,4);
427 } else if (chooser == "( [o]2 o )4") {
428 XBT_INFO("### Put a VM on a PM, and put one task to the PM and one task to the VM");
429 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
430 run_test_process("( [X]2 o )4", vm0, flop_amount);
431 run_test_process("( [o]2 X )4", pm4, flop_amount);
432 simgrid::s4u::this_actor::sleep_for(2);
433 test_energy_consumption(chooser,2);
436 } else if (chooser == "( [o]2 oo )4") {
437 XBT_INFO("### Put a VM on a PM, and put two tasks to the PM and one task to the VM");
438 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
439 run_test_process("( [X]2 oo )4", vm0, flop_amount);
440 run_test_process("( [o]2 Xo )4", pm4, flop_amount);
441 run_test_process("( [o]2 oX )4", pm4, flop_amount);
442 simgrid::s4u::this_actor::sleep_for(2);
443 test_energy_consumption(chooser,3);
446 } else if (chooser == "( [oo]2 oo )4") {
447 XBT_INFO("### Put a VM on a PM, and put two tasks to the PM and two tasks to the VM");
448 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
449 run_test_process("( [Xo]2 oo )4", vm0, flop_amount);
450 run_test_process("( [oX]2 oo )4", vm0, flop_amount);
451 run_test_process("( [oo]2 Xo )4", pm4, flop_amount);
452 run_test_process("( [oo]2 oX )4", pm4, flop_amount);
453 simgrid::s4u::this_actor::sleep_for(2);
454 test_energy_consumption(chooser,4);
457 } else if (chooser == "( [o]2 ooo )4") {
458 XBT_INFO("### Put a VM on a PM, and put three tasks to the PM and one tasks to the VM");
459 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
460 run_test_process("( [X]2 ooo )4", vm0, flop_amount);
461 run_test_process("( [o]2 Xoo )4", pm4, flop_amount);
462 run_test_process("( [o]2 oXo )4", pm4, flop_amount);
463 run_test_process("( [o]2 ooX )4", pm4, flop_amount);
464 simgrid::s4u::this_actor::sleep_for(2);
465 test_energy_consumption(chooser,4);
468 } else if (chooser == "( [oo]2 ooo )4") {
469 XBT_INFO("### Put a VM on a PM, and put three tasks to the PM and two tasks to the VM");
470 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
471 run_test_process("( [Xo]2 ooo )4", vm0, flop_amount * 4 / 5);
472 run_test_process("( [oX]2 ooo )4", vm0, flop_amount * 4 / 5);
473 run_test_process("( [oo]2 Xoo )4", pm4, flop_amount * 4 / 5);
474 run_test_process("( [oo]2 oXo )4", pm4, flop_amount * 4 / 5);
475 run_test_process("( [oo]2 ooX )4", pm4, flop_amount * 4 / 5);
476 simgrid::s4u::this_actor::sleep_for(2);
477 test_energy_consumption(chooser,4);
480 } else if (chooser == "( [ooo]2 ooo )4") {
481 XBT_INFO("### Put a VM on a PM, and put three tasks to the PM and three tasks to the VM");
482 vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
483 run_test_process("( [Xoo]2 ooo )4", vm0, flop_amount * (8. / 5) * 1 / 3); // The VM has 8/5 of the PM
484 run_test_process("( [oXo]2 ooo )4", vm0, flop_amount * (8. / 5) * 1 / 3);
485 run_test_process("( [ooX]2 ooo )4", vm0, flop_amount * (8. / 5) * 1 / 3);
487 run_test_process("( [ooo]2 Xoo )4", pm4, flop_amount * 4 / 5);
488 run_test_process("( [ooo]2 oXo )4", pm4, flop_amount * 4 / 5);
489 run_test_process("( [ooo]2 ooX )4", pm4, flop_amount * 4 / 5);
490 simgrid::s4u::this_actor::sleep_for(2);
491 test_energy_consumption(chooser,4);
495 xbt_die("Unknown chooser: %s", chooser.c_str());
498 static int master_main()
500 XBT_INFO("# TEST ON SINGLE-CORE PMs");
501 XBT_INFO("## Check computation on regular PMs");
504 run_test("(o)1 (o)1");
505 XBT_INFO("# TEST ON SINGLE-CORE PMs AND SINGLE-CORE VMs");
507 XBT_INFO("## Check the impact of running tasks inside a VM (no degradation for the moment)");
508 run_test("( [o]1 )1");
509 run_test("( [oo]1 )1");
511 XBT_INFO("## Check impact of running tasks collocated with VMs (no VM noise for the moment)");
512 run_test("( [ ]1 o )1");
513 run_test("( [o]1 o )1");
514 run_test("( [oo]1 o )1");
516 XBT_INFO("# TEST ON TWO-CORE PMs");
517 XBT_INFO("## Check computation on 2 cores PMs");
520 run_test("( ooo )2");
522 XBT_INFO("# TEST ON TWO-CORE PMs AND SINGLE-CORE VMs");
523 XBT_INFO("## Check impact of a single VM (no degradation for the moment)");
524 run_test("( [o]1 )2");
525 run_test("( [oo]1 )2");
526 run_test("( [ ]1 o )2");
527 run_test("( [o]1 o )2");
529 XBT_INFO("## Check impact of a several VMs (there is no degradation for the moment)");
530 run_test("( [o]1 [ ]1 )2");
531 run_test("( [o]1 [o]1 )2");
532 run_test("( [o]1 [o]1 [ ]1 )2");
533 run_test("( [o]1 [o]1 [o]1 )2");
535 XBT_INFO("# TEST ON TWO-CORE PMs AND TWO-CORE VMs");
537 XBT_INFO("## Check impact of a single VM (there is no degradation for the moment)");
538 run_test("( [o]2 )2");
539 run_test("( [oo]2 )2");
540 run_test("( [ooo]2 )2");
542 XBT_INFO("## Check impact of a single VM collocated with a task (there is no degradation for the moment)");
543 run_test("( [ ]2 o )2");
544 run_test("( [o]2 o )2");
545 run_test("( [oo]2 o )2");
546 run_test("( [ooo]2 o )2");
547 run_test("( [ ]2 oo )2");
548 run_test("( [o]2 oo )2");
549 run_test("( [oo]2 oo )2");
550 run_test("( [ooo]2 oo )2");
552 XBT_INFO("# TEST ON FOUR-CORE PMs AND TWO-CORE VMs");
554 XBT_INFO("## Check impact of a single VM");
555 run_test("( [o]2 )4");
556 run_test("( [oo]2 )4");
557 run_test("( [ooo]2 )4");
559 XBT_INFO("## Check impact of a single empty VM collocated with tasks");
560 run_test("( [ ]2 o )4");
561 run_test("( [ ]2 oo )4");
562 run_test("( [ ]2 ooo )4");
563 run_test("( [ ]2 oooo )4");
565 XBT_INFO("## Check impact of a single working VM collocated with tasks");
566 run_test("( [o]2 o )4");
567 run_test("( [o]2 oo )4");
568 run_test("( [oo]2 oo )4");
569 run_test("( [o]2 ooo )4");
570 run_test("( [oo]2 ooo )4");
571 run_test("( [ooo]2 ooo )4");
575 XBT_INFO("## %d test failed", failed_test);
579 int main(int argc, char* argv[])
581 /* Get the arguments */
582 simgrid::s4u::Engine e(&argc, argv);
583 sg_host_energy_plugin_init();
585 /* load the platform file */
586 const char* platform = "../../../platforms/cloud-sharing.xml";
589 e.load_platform(platform);
591 simgrid::s4u::Host *pm0 = simgrid::s4u::Host::by_name("node-0.1core.org");
592 xbt_assert(pm0, "Host 'node-0.1core.org' not found");
593 simgrid::s4u::Actor::create("master", pm0, master_main);