1 /* Copyright (c) 2007-2023. 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/plugins/energy.h"
8 #include "simgrid/s4u.hpp"
9 #include "simgrid/s4u/VirtualMachine.hpp"
12 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this test");
14 constexpr double FLOP_AMOUNT = 100e6; // 100Mf, so that computing this on a 1Gf core takes exactly 0.1s
17 static void computation_fun(double size)
19 double begin = simgrid::s4u::Engine::get_clock();
20 simgrid::s4u::this_actor::execute(size);
21 double end = simgrid::s4u::Engine::get_clock();
23 if (double duration = end - begin; 0.1 - duration > 0.001) {
24 XBT_INFO("FAILED TEST: %s with %.4g load (%.0f flops) took %.4fs instead of 0.1s",
25 simgrid::s4u::this_actor::get_name().c_str(), (size / FLOP_AMOUNT), size, duration);
28 XBT_INFO("Passed: %s with %.4g load (%.0f flops) took 0.1s as expected",
29 simgrid::s4u::this_actor::get_name().c_str(), (size / FLOP_AMOUNT), size);
33 static void run_test_process(const std::string& name, simgrid::s4u::Host* location, double size)
35 simgrid::s4u::Actor::create(name, location, computation_fun, floor(size));
38 static void test_energy_consumption(const std::string& name, int nb_cores)
40 static double current_energy = 0;
41 double new_energy = 0;
43 for (simgrid::s4u::Host* pm : simgrid::s4u::Engine::get_instance()->get_all_hosts()) {
44 if (not dynamic_cast<simgrid::s4u::VirtualMachine*>(pm))
45 new_energy += sg_host_get_consumed_energy(pm);
48 double expected_consumption = 0.1 * nb_cores;
49 double actual_consumption = new_energy - current_energy;
51 current_energy = new_energy;
53 if (std::abs(expected_consumption - actual_consumption) > 0.001) {
54 XBT_INFO("FAILED TEST: %s consumed %f instead of %f J (i.e. %i cores should have been used)", name.c_str(),
55 actual_consumption, expected_consumption, nb_cores);
58 XBT_INFO("Passed: %s consumed %f J (i.e. %i cores used)", name.c_str(), actual_consumption, nb_cores);
62 static void run_test(const std::string& chooser)
64 simgrid::s4u::Host* pm0 = simgrid::s4u::Host::by_name("node-0.1core.org");
65 simgrid::s4u::Host* pm1 = simgrid::s4u::Host::by_name("node-1.1core.org");
66 simgrid::s4u::Host* pm2 = simgrid::s4u::Host::by_name("node-0.2cores.org"); // 2 cores
67 simgrid::s4u::Host* pm4 = simgrid::s4u::Host::by_name("node-0.4cores.org");
69 simgrid::s4u::VirtualMachine* vm0;
70 xbt_assert(pm0, "Host node-0.1core.org does not seem to exist");
71 xbt_assert(pm2, "Host node-0.2cores.org does not seem to exist");
72 xbt_assert(pm4, "Host node-0.4cores.org does not seem to exist");
74 // syntax of the process name:
75 // "( )1" means PM with one core; "( )2" means PM with 2 cores
76 // "( [ ]2 )4" means a VM with 2 cores, on a PM with 4 cores.
77 // "o" means another process is there
78 // "X" means the process which holds this name
80 if (chooser == "(o)1") {
81 XBT_INFO("### Test '%s'. A task on a regular PM", chooser.c_str());
82 run_test_process("(X)1", pm0, FLOP_AMOUNT);
83 simgrid::s4u::this_actor::sleep_for(2);
84 test_energy_consumption(chooser, 1);
86 } else if (chooser == "(oo)1") {
87 XBT_INFO("### Test '%s'. 2 tasks on a regular PM", chooser.c_str());
88 run_test_process("(Xo)1", pm0, FLOP_AMOUNT / 2);
89 run_test_process("(oX)1", pm0, FLOP_AMOUNT / 2);
90 simgrid::s4u::this_actor::sleep_for(2);
91 test_energy_consumption(chooser, 1);
93 } else if (chooser == "(o)1 (o)1") {
94 XBT_INFO("### Test '%s'. 2 regular PMs, with a task each.", chooser.c_str());
95 run_test_process("(X)1 (o)1", pm0, FLOP_AMOUNT);
96 run_test_process("(o)1 (X)1", pm1, FLOP_AMOUNT);
97 simgrid::s4u::this_actor::sleep_for(2);
98 test_energy_consumption(chooser, 2);
100 } else if (chooser == "( [o]1 )1") {
101 XBT_INFO("### Test '%s'. A task in a VM on a PM.", chooser.c_str());
102 vm0 = pm0->create_vm("VM0", 1);
103 run_test_process("( [X]1 )1", vm0, FLOP_AMOUNT);
104 simgrid::s4u::this_actor::sleep_for(2);
105 test_energy_consumption(chooser, 1);
108 } else if (chooser == "( [oo]1 )1") {
109 XBT_INFO("### Test '%s'. 2 tasks co-located in a VM on a PM.", chooser.c_str());
110 vm0 = pm0->create_vm("VM0", 1);
111 run_test_process("( [Xo]1 )1", vm0, FLOP_AMOUNT / 2);
112 run_test_process("( [oX]1 )1", vm0, FLOP_AMOUNT / 2);
113 simgrid::s4u::this_actor::sleep_for(2);
114 test_energy_consumption(chooser, 1);
117 } else if (chooser == "( [ ]1 o )1") {
118 XBT_INFO("### Test '%s'. 1 task collocated with an empty VM", chooser.c_str());
119 vm0 = pm0->create_vm("VM0", 1);
120 run_test_process("( [ ]1 X )1", pm0, FLOP_AMOUNT);
121 simgrid::s4u::this_actor::sleep_for(2);
122 test_energy_consumption(chooser, 1);
125 } else if (chooser == "( [o]1 o )1") {
126 XBT_INFO("### Test '%s'. A task in a VM, plus a task", chooser.c_str());
127 vm0 = pm0->create_vm("VM0", 1);
128 run_test_process("( [X]1 o )1", vm0, FLOP_AMOUNT / 2);
129 run_test_process("( [o]1 X )1", pm0, FLOP_AMOUNT / 2);
130 simgrid::s4u::this_actor::sleep_for(2);
131 test_energy_consumption(chooser, 1);
134 } else if (chooser == "( [oo]1 o )1") {
135 XBT_INFO("### Test '%s'. 2 tasks in a VM, plus a task", chooser.c_str());
136 vm0 = pm0->create_vm("VM0", 1);
137 run_test_process("( [Xo]1 o )1", vm0, FLOP_AMOUNT / 4);
138 run_test_process("( [oX]1 o )1", vm0, FLOP_AMOUNT / 4);
139 run_test_process("( [oo]1 X )1", pm0, FLOP_AMOUNT / 2);
140 simgrid::s4u::this_actor::sleep_for(2);
141 test_energy_consumption(chooser, 1);
144 } else if (chooser == "( o )2") {
145 XBT_INFO("### Test '%s'. A task on bicore PM", chooser.c_str());
146 run_test_process("(X)2", pm2, FLOP_AMOUNT);
147 simgrid::s4u::this_actor::sleep_for(2);
148 test_energy_consumption(chooser, 1);
150 } else if (chooser == "( oo )2") {
151 XBT_INFO("### Test '%s'. 2 tasks on a bicore PM", chooser.c_str());
152 run_test_process("(Xx)2", pm2, FLOP_AMOUNT);
153 run_test_process("(xX)2", pm2, FLOP_AMOUNT);
154 simgrid::s4u::this_actor::sleep_for(2);
155 test_energy_consumption(chooser, 2);
157 } else if (chooser == "( ooo )2") {
158 XBT_INFO("### Test '%s'. 3 tasks on a bicore PM", chooser.c_str());
159 run_test_process("(Xxx)2", pm2, FLOP_AMOUNT * 2 / 3);
160 run_test_process("(xXx)2", pm2, FLOP_AMOUNT * 2 / 3);
161 run_test_process("(xxX)2", pm2, FLOP_AMOUNT * 2 / 3);
162 simgrid::s4u::this_actor::sleep_for(2);
163 test_energy_consumption(chooser, 2);
165 } else if (chooser == "( [o]1 )2") {
166 XBT_INFO("### Test '%s'. A task in a VM on a bicore PM", chooser.c_str());
167 vm0 = pm2->create_vm("VM0", 1);
168 run_test_process("( [X]1 )2", vm0, FLOP_AMOUNT);
169 simgrid::s4u::this_actor::sleep_for(2);
170 test_energy_consumption(chooser, 1);
173 } else if (chooser == "( [oo]1 )2") {
174 XBT_INFO("### Test '%s'. 2 tasks in a VM on a bicore PM", chooser.c_str());
175 vm0 = pm2->create_vm("VM0", 1);
176 run_test_process("( [Xx]1 )2", vm0, FLOP_AMOUNT / 2);
177 run_test_process("( [xX]1 )2", vm0, FLOP_AMOUNT / 2);
178 simgrid::s4u::this_actor::sleep_for(2);
179 test_energy_consumption(chooser, 1);
182 } else if (chooser == "( [ ]1 o )2") {
183 XBT_INFO("### Put a VM on a PM, and put a task to the PM");
184 vm0 = pm2->create_vm("VM0", 1);
185 run_test_process("( [ ]1 X )2", pm2, FLOP_AMOUNT);
186 simgrid::s4u::this_actor::sleep_for(2);
187 test_energy_consumption(chooser, 1);
190 } else if (chooser == "( [o]1 o )2") {
191 XBT_INFO("### Put a VM on a PM, put a task to the PM and a task to the VM");
192 vm0 = pm2->create_vm("VM0", 1);
193 run_test_process("( [X]1 x )2", vm0, FLOP_AMOUNT);
194 run_test_process("( [x]1 X )2", pm2, FLOP_AMOUNT);
195 simgrid::s4u::this_actor::sleep_for(2);
196 test_energy_consumption(chooser, 2);
199 } else if (chooser == "( [o]1 [ ]1 )2") {
200 XBT_INFO("### Put two VMs on a PM, and put a task to one VM");
201 vm0 = pm2->create_vm("VM0", 1);
202 auto* vm1 = pm2->create_vm("VM1", 1);
203 run_test_process("( [X]1 [ ]1 )2", vm0, FLOP_AMOUNT);
204 simgrid::s4u::this_actor::sleep_for(2);
205 test_energy_consumption(chooser, 1);
209 } else if (chooser == "( [o]1 [o]1 )2") {
210 XBT_INFO("### Put two VMs on a PM, and put a task to each VM");
211 vm0 = pm2->create_vm("VM0", 1);
212 auto* vm1 = pm2->create_vm("VM1", 1);
213 run_test_process("( [X]1 [x]1 )2", vm0, FLOP_AMOUNT);
214 run_test_process("( [x]1 [X]1 )2", vm1, FLOP_AMOUNT);
215 simgrid::s4u::this_actor::sleep_for(2);
216 test_energy_consumption(chooser, 2);
220 } else if (chooser == "( [o]1 [o]1 [ ]1 )2") {
221 XBT_INFO("### Put three VMs on a PM, and put a task to two VMs");
222 vm0 = pm2->create_vm("VM0", 1);
223 auto* vm1 = pm2->create_vm("VM1", 1);
224 auto* vm2 = pm2->create_vm("VM2", 1);
225 run_test_process("( [X]1 [x]1 [ ]1 )2", vm0, FLOP_AMOUNT);
226 run_test_process("( [x]1 [X]1 [ ]1 )2", vm1, FLOP_AMOUNT);
227 simgrid::s4u::this_actor::sleep_for(2);
228 test_energy_consumption(chooser, 2);
233 } else if (chooser == "( [o]1 [o]1 [o]1 )2") {
234 XBT_INFO("### Put three VMs on a PM, and put a task to each VM");
235 vm0 = pm2->create_vm("VM0", 1);
236 auto* vm1 = pm2->create_vm("VM1", 1);
237 auto* vm2 = pm2->create_vm("VM2", 1);
238 run_test_process("( [X]1 [o]1 [o]1 )2", vm0, FLOP_AMOUNT * 2 / 3);
239 run_test_process("( [o]1 [X]1 [o]1 )2", vm1, FLOP_AMOUNT * 2 / 3);
240 run_test_process("( [o]1 [o]1 [X]1 )2", vm2, FLOP_AMOUNT * 2 / 3);
241 simgrid::s4u::this_actor::sleep_for(2);
242 test_energy_consumption(chooser, 2);
247 } else if (chooser == "( [o]2 )2") {
248 XBT_INFO("### Put a VM on a PM, and put a task to the VM");
249 vm0 = pm2->create_vm("VM0", 2);
250 run_test_process("( [X]2 )2", vm0, FLOP_AMOUNT);
251 simgrid::s4u::this_actor::sleep_for(2);
252 test_energy_consumption(chooser, 1);
255 } else if (chooser == "( [oo]2 )2") {
256 XBT_INFO("### Put a VM on a PM, and put two tasks to the VM");
257 vm0 = pm2->create_vm("VM0", 2);
258 run_test_process("( [Xo]2 )2", vm0, FLOP_AMOUNT);
259 run_test_process("( [oX]2 )2", vm0, FLOP_AMOUNT);
260 simgrid::s4u::this_actor::sleep_for(2);
261 test_energy_consumption(chooser, 2);
264 } else if (chooser == "( [ooo]2 )2") {
265 XBT_INFO("### Put a VM on a PM, and put three tasks to the VM");
266 vm0 = pm2->create_vm("VM0", 2);
267 run_test_process("( [Xoo]2 )2", vm0, FLOP_AMOUNT * 2 / 3);
268 run_test_process("( [oXo]2 )2", vm0, FLOP_AMOUNT * 2 / 3);
269 run_test_process("( [ooX]2 )2", vm0, FLOP_AMOUNT * 2 / 3);
270 simgrid::s4u::this_actor::sleep_for(2);
271 test_energy_consumption(chooser, 2);
274 } else if (chooser == "( [ ]2 o )2") {
275 XBT_INFO("### Put a VM on a PM, and put a task to the PM");
276 vm0 = pm2->create_vm("VM0", 2);
277 run_test_process("( [ ]2 X )2", pm2, FLOP_AMOUNT);
278 simgrid::s4u::this_actor::sleep_for(2);
279 test_energy_consumption(chooser, 1);
282 } else if (chooser == "( [o]2 o )2") {
283 XBT_INFO("### Put a VM on a PM, put one task to the PM and one task to the VM");
284 vm0 = pm2->create_vm("VM0", 2);
285 run_test_process("( [o]2 X )2", pm2, FLOP_AMOUNT);
286 run_test_process("( [X]2 o )2", vm0, FLOP_AMOUNT);
287 simgrid::s4u::this_actor::sleep_for(2);
288 test_energy_consumption(chooser, 2);
291 } else if (chooser == "( [oo]2 o )2") {
292 XBT_INFO("### Put a VM on a PM, put one task to the PM and two tasks to the VM");
293 vm0 = pm2->create_vm("VM0", 2);
294 run_test_process("( [oo]2 X )2", pm2, FLOP_AMOUNT * 2 / 3);
295 run_test_process("( [Xo]2 o )2", vm0, FLOP_AMOUNT * 2 / 3);
296 run_test_process("( [oX]2 o )2", vm0, FLOP_AMOUNT * 2 / 3);
297 simgrid::s4u::this_actor::sleep_for(2);
298 test_energy_consumption(chooser, 2);
301 } else if (chooser == "( [ooo]2 o )2") {
302 XBT_INFO("### Put a VM on a PM, put one task to the PM and three tasks to the VM");
303 vm0 = pm2->create_vm("VM0", 2);
304 run_test_process("( [ooo]2 X )2", pm2, FLOP_AMOUNT * 2 / 3);
305 run_test_process("( [Xoo]2 o )2", vm0, (FLOP_AMOUNT * 4 / 3) / 3); // VM_share/3
306 run_test_process("( [oXo]2 o )2", vm0, (FLOP_AMOUNT * 4 / 3) / 3); // VM_share/3
307 run_test_process("( [ooX]2 o )2", vm0, (FLOP_AMOUNT * 4 / 3) / 3); // VM_share/3
308 simgrid::s4u::this_actor::sleep_for(2);
309 test_energy_consumption(chooser, 2);
312 } else if (chooser == "( [ ]2 oo )2") {
313 XBT_INFO("### Put a VM on a PM, and put two tasks to the PM");
314 vm0 = pm2->create_vm("VM0", 2);
315 run_test_process("( [ ]2 Xo )2", pm2, FLOP_AMOUNT);
316 run_test_process("( [ ]2 oX )2", pm2, FLOP_AMOUNT);
317 simgrid::s4u::this_actor::sleep_for(2);
318 test_energy_consumption(chooser, 2);
321 } else if (chooser == "( [o]2 oo )2") {
322 XBT_INFO("### Put a VM on a PM, put one task to the PM and one task to the VM");
323 vm0 = pm2->create_vm("VM0", 2);
324 run_test_process("( [o]2 Xo )2", pm2, FLOP_AMOUNT * 2 / 3);
325 run_test_process("( [o]2 oX )2", pm2, FLOP_AMOUNT * 2 / 3);
326 run_test_process("( [X]2 oo )2", vm0, FLOP_AMOUNT * 2 / 3);
327 simgrid::s4u::this_actor::sleep_for(2);
328 test_energy_consumption(chooser, 2);
331 } else if (chooser == "( [oo]2 oo )2") {
332 XBT_INFO("### Put a VM on a PM, put one task to the PM and two tasks to the VM");
333 vm0 = pm2->create_vm("VM0", 2);
334 run_test_process("( [oo]2 Xo )2", pm2, FLOP_AMOUNT / 2);
335 run_test_process("( [oo]2 oX )2", pm2, FLOP_AMOUNT / 2);
336 run_test_process("( [Xo]2 oo )2", vm0, FLOP_AMOUNT / 2);
337 run_test_process("( [oX]2 oo )2", vm0, FLOP_AMOUNT / 2);
338 simgrid::s4u::this_actor::sleep_for(2);
339 test_energy_consumption(chooser, 2);
342 } else if (chooser == "( [ooo]2 oo )2") {
343 XBT_INFO("### Put a VM on a PM, put one task to the PM and three tasks to the VM");
344 vm0 = pm2->create_vm("VM0", 2);
345 run_test_process("( [ooo]2 Xo )2", pm2, FLOP_AMOUNT * 2 / 4);
346 run_test_process("( [ooo]2 oX )2", pm2, FLOP_AMOUNT * 2 / 4);
347 run_test_process("( [Xoo]2 oo )2", vm0, FLOP_AMOUNT / 3);
348 run_test_process("( [oXo]2 oo )2", vm0, FLOP_AMOUNT / 3);
349 run_test_process("( [ooX]2 oo )2", vm0, FLOP_AMOUNT / 3);
350 simgrid::s4u::this_actor::sleep_for(2);
351 test_energy_consumption(chooser, 2);
354 } else if (chooser == "( [o]2 )4") {
355 XBT_INFO("### Put a VM on a PM, and put a task to the VM");
356 vm0 = pm4->create_vm("VM0", 2);
357 run_test_process("( [X]2 )4", vm0, FLOP_AMOUNT);
358 simgrid::s4u::this_actor::sleep_for(2);
359 test_energy_consumption(chooser, 1);
362 } else if (chooser == "( [oo]2 )4") {
363 XBT_INFO("### Put a VM on a PM, and put two tasks to the VM");
364 vm0 = pm4->create_vm("VM0", 2);
365 run_test_process("( [Xo]2 )4", vm0, FLOP_AMOUNT);
366 run_test_process("( [oX]2 )4", vm0, FLOP_AMOUNT);
367 simgrid::s4u::this_actor::sleep_for(2);
368 test_energy_consumption(chooser, 2);
371 } else if (chooser == "( [ooo]2 )4") {
372 XBT_INFO("### ( [ooo]2 )4: Put a VM on a PM, and put three tasks to the VM");
373 vm0 = pm4->create_vm("VM0", 2);
374 run_test_process("( [Xoo]2 )4", vm0, FLOP_AMOUNT * 2 / 3);
375 run_test_process("( [oXo]2 )4", vm0, FLOP_AMOUNT * 2 / 3);
376 run_test_process("( [ooX]2 )4", vm0, FLOP_AMOUNT * 2 / 3);
377 simgrid::s4u::this_actor::sleep_for(2);
378 test_energy_consumption(chooser, 2);
381 } else if (chooser == "( [ ]2 o )4") {
382 XBT_INFO("### Put a VM on a PM, and put a task to the PM");
383 vm0 = pm4->create_vm("VM0", 2);
384 run_test_process("( [ ]2 X )4", pm4, FLOP_AMOUNT);
385 simgrid::s4u::this_actor::sleep_for(2);
386 test_energy_consumption(chooser, 1);
389 } else if (chooser == "( [ ]2 oo )4") {
390 XBT_INFO("### Put a VM on a PM, and put two tasks to the PM");
391 vm0 = pm4->create_vm("VM0", 2);
392 run_test_process("( [ ]2 Xo )4", pm4, FLOP_AMOUNT);
393 run_test_process("( [ ]2 oX )4", pm4, FLOP_AMOUNT);
394 simgrid::s4u::this_actor::sleep_for(2);
395 test_energy_consumption(chooser, 2);
398 } else if (chooser == "( [ ]2 ooo )4") {
399 XBT_INFO("### Put a VM on a PM, and put three tasks to the PM");
400 vm0 = pm4->create_vm("VM0", 2);
401 run_test_process("( [ ]2 Xoo )4", pm4, FLOP_AMOUNT);
402 run_test_process("( [ ]2 oXo )4", pm4, FLOP_AMOUNT);
403 run_test_process("( [ ]2 ooX )4", pm4, FLOP_AMOUNT);
404 simgrid::s4u::this_actor::sleep_for(2);
405 test_energy_consumption(chooser, 3);
408 } else if (chooser == "( [ ]2 oooo )4") {
409 XBT_INFO("### Put a VM on a PM, and put four tasks to the PM");
410 vm0 = pm4->create_vm("VM0", 2);
411 run_test_process("( [ ]2 Xooo )4", pm4, FLOP_AMOUNT);
412 run_test_process("( [ ]2 oXoo )4", pm4, FLOP_AMOUNT);
413 run_test_process("( [ ]2 ooXo )4", pm4, FLOP_AMOUNT);
414 run_test_process("( [ ]2 oooX )4", pm4, FLOP_AMOUNT);
415 simgrid::s4u::this_actor::sleep_for(2);
416 test_energy_consumption(chooser, 4);
419 } else if (chooser == "( [o]2 o )4") {
420 XBT_INFO("### Put a VM on a PM, and put one task to the PM and one task to the VM");
421 vm0 = pm4->create_vm("VM0", 2);
422 run_test_process("( [X]2 o )4", vm0, FLOP_AMOUNT);
423 run_test_process("( [o]2 X )4", pm4, FLOP_AMOUNT);
424 simgrid::s4u::this_actor::sleep_for(2);
425 test_energy_consumption(chooser, 2);
428 } else if (chooser == "( [o]2 oo )4") {
429 XBT_INFO("### Put a VM on a PM, and put two tasks to the PM and one task to the VM");
430 vm0 = pm4->create_vm("VM0", 2);
431 run_test_process("( [X]2 oo )4", vm0, FLOP_AMOUNT);
432 run_test_process("( [o]2 Xo )4", pm4, FLOP_AMOUNT);
433 run_test_process("( [o]2 oX )4", pm4, FLOP_AMOUNT);
434 simgrid::s4u::this_actor::sleep_for(2);
435 test_energy_consumption(chooser, 3);
438 } else if (chooser == "( [oo]2 oo )4") {
439 XBT_INFO("### Put a VM on a PM, and put two tasks to the PM and two tasks to the VM");
440 vm0 = pm4->create_vm("VM0", 2);
441 run_test_process("( [Xo]2 oo )4", vm0, FLOP_AMOUNT);
442 run_test_process("( [oX]2 oo )4", vm0, FLOP_AMOUNT);
443 run_test_process("( [oo]2 Xo )4", pm4, FLOP_AMOUNT);
444 run_test_process("( [oo]2 oX )4", pm4, FLOP_AMOUNT);
445 simgrid::s4u::this_actor::sleep_for(2);
446 test_energy_consumption(chooser, 4);
449 } else if (chooser == "( [o]2 ooo )4") {
450 XBT_INFO("### Put a VM on a PM, and put three tasks to the PM and one tasks to the VM");
451 vm0 = pm4->create_vm("VM0", 2);
452 run_test_process("( [X]2 ooo )4", vm0, FLOP_AMOUNT);
453 run_test_process("( [o]2 Xoo )4", pm4, FLOP_AMOUNT);
454 run_test_process("( [o]2 oXo )4", pm4, FLOP_AMOUNT);
455 run_test_process("( [o]2 ooX )4", pm4, FLOP_AMOUNT);
456 simgrid::s4u::this_actor::sleep_for(2);
457 test_energy_consumption(chooser, 4);
460 } else if (chooser == "( [oo]2 ooo )4") {
461 XBT_INFO("### Put a VM on a PM, and put three tasks to the PM and two tasks to the VM");
462 vm0 = pm4->create_vm("VM0", 2);
463 run_test_process("( [Xo]2 ooo )4", vm0, FLOP_AMOUNT * 4 / 5);
464 run_test_process("( [oX]2 ooo )4", vm0, FLOP_AMOUNT * 4 / 5);
465 run_test_process("( [oo]2 Xoo )4", pm4, FLOP_AMOUNT * 4 / 5);
466 run_test_process("( [oo]2 oXo )4", pm4, FLOP_AMOUNT * 4 / 5);
467 run_test_process("( [oo]2 ooX )4", pm4, FLOP_AMOUNT * 4 / 5);
468 simgrid::s4u::this_actor::sleep_for(2);
469 test_energy_consumption(chooser, 4);
472 } else if (chooser == "( [ooo]2 ooo )4") {
473 XBT_INFO("### Put a VM on a PM, and put three tasks to the PM and three tasks to the VM");
474 vm0 = pm4->create_vm("VM0", 2);
475 run_test_process("( [Xoo]2 ooo )4", vm0, (FLOP_AMOUNT * 8 / 5) / 3); // The VM has 8/5 of the PM
476 run_test_process("( [oXo]2 ooo )4", vm0, (FLOP_AMOUNT * 8 / 5) / 3);
477 run_test_process("( [ooX]2 ooo )4", vm0, (FLOP_AMOUNT * 8 / 5) / 3);
479 run_test_process("( [ooo]2 Xoo )4", pm4, FLOP_AMOUNT * 4 / 5);
480 run_test_process("( [ooo]2 oXo )4", pm4, FLOP_AMOUNT * 4 / 5);
481 run_test_process("( [ooo]2 ooX )4", pm4, FLOP_AMOUNT * 4 / 5);
482 simgrid::s4u::this_actor::sleep_for(2);
483 test_energy_consumption(chooser, 4);
487 xbt_die("Unknown chooser: %s", chooser.c_str());
491 static void master_main()
493 XBT_INFO("# TEST ON SINGLE-CORE PMs");
494 XBT_INFO("## Check computation on regular PMs");
497 run_test("(o)1 (o)1");
498 XBT_INFO("# TEST ON SINGLE-CORE PMs AND SINGLE-CORE VMs");
500 XBT_INFO("## Check the impact of running tasks inside a VM (no degradation for the moment)");
501 run_test("( [o]1 )1");
502 run_test("( [oo]1 )1");
504 XBT_INFO("## Check impact of running tasks collocated with VMs (no VM noise for the moment)");
505 run_test("( [ ]1 o )1");
506 run_test("( [o]1 o )1");
507 run_test("( [oo]1 o )1");
509 XBT_INFO("# TEST ON TWO-CORE PMs");
510 XBT_INFO("## Check computation on 2 cores PMs");
513 run_test("( ooo )2");
515 XBT_INFO("# TEST ON TWO-CORE PMs AND SINGLE-CORE VMs");
516 XBT_INFO("## Check impact of a single VM (no degradation for the moment)");
517 run_test("( [o]1 )2");
518 run_test("( [oo]1 )2");
519 run_test("( [ ]1 o )2");
520 run_test("( [o]1 o )2");
522 XBT_INFO("## Check impact of a several VMs (there is no degradation for the moment)");
523 run_test("( [o]1 [ ]1 )2");
524 run_test("( [o]1 [o]1 )2");
525 run_test("( [o]1 [o]1 [ ]1 )2");
526 run_test("( [o]1 [o]1 [o]1 )2");
528 XBT_INFO("# TEST ON TWO-CORE PMs AND TWO-CORE VMs");
530 XBT_INFO("## Check impact of a single VM (there is no degradation for the moment)");
531 run_test("( [o]2 )2");
532 run_test("( [oo]2 )2");
533 run_test("( [ooo]2 )2");
535 XBT_INFO("## Check impact of a single VM collocated with a task (there is no degradation for the moment)");
536 run_test("( [ ]2 o )2");
537 run_test("( [o]2 o )2");
538 run_test("( [oo]2 o )2");
539 run_test("( [ooo]2 o )2");
540 run_test("( [ ]2 oo )2");
541 run_test("( [o]2 oo )2");
542 run_test("( [oo]2 oo )2");
543 run_test("( [ooo]2 oo )2");
545 XBT_INFO("# TEST ON FOUR-CORE PMs AND TWO-CORE VMs");
547 XBT_INFO("## Check impact of a single VM");
548 run_test("( [o]2 )4");
549 run_test("( [oo]2 )4");
550 run_test("( [ooo]2 )4");
552 XBT_INFO("## Check impact of a single empty VM collocated with tasks");
553 run_test("( [ ]2 o )4");
554 run_test("( [ ]2 oo )4");
555 run_test("( [ ]2 ooo )4");
556 run_test("( [ ]2 oooo )4");
558 XBT_INFO("## Check impact of a single working VM collocated with tasks");
559 run_test("( [o]2 o )4");
560 run_test("( [o]2 oo )4");
561 run_test("( [oo]2 oo )4");
562 run_test("( [o]2 ooo )4");
563 run_test("( [oo]2 ooo )4");
564 run_test("( [ooo]2 ooo )4");
567 XBT_INFO("## %d test failed", failed_test);
571 int main(int argc, char* argv[])
573 /* Get the arguments */
574 simgrid::s4u::Engine e(&argc, argv);
575 sg_host_energy_plugin_init();
577 /* load the platform file */
578 const char* platform = "../../../platforms/cloud-sharing.xml";
581 e.load_platform(platform);
583 simgrid::s4u::Host* pm0 = e.host_by_name("node-0.1core.org");
584 xbt_assert(pm0, "Host 'node-0.1core.org' not found");
585 simgrid::s4u::Actor::create("master", pm0, master_main);