From f34f8817d6436a1d9c5876a67e842ba38033816a Mon Sep 17 00:00:00 2001 From: "Ad(rien) L" Date: Tue, 20 Oct 2015 15:01:35 +0200 Subject: [PATCH] Add energy VM example (simple but should be sufficient) - Adrien --- examples/msg/energy/vm/1 | 1 + examples/msg/energy/vm/2.out | 0 examples/msg/energy/vm/README | 12 ++ .../msg/energy/vm/deployment_consumption.xml | 7 + examples/msg/energy/vm/energy_platform.xml | 22 ++++ examples/msg/energy/vm/vm | Bin 0 -> 10344 bytes examples/msg/energy/vm/vm.c | 123 ++++++++++++++++++ 7 files changed, 165 insertions(+) create mode 100644 examples/msg/energy/vm/1 create mode 100644 examples/msg/energy/vm/2.out create mode 100644 examples/msg/energy/vm/README create mode 100644 examples/msg/energy/vm/deployment_consumption.xml create mode 100644 examples/msg/energy/vm/energy_platform.xml create mode 100755 examples/msg/energy/vm/vm create mode 100644 examples/msg/energy/vm/vm.c diff --git a/examples/msg/energy/vm/1 b/examples/msg/energy/vm/1 new file mode 100644 index 0000000000..41fcfb81e7 --- /dev/null +++ b/examples/msg/energy/vm/1 @@ -0,0 +1 @@ +-bash: 2.out: command not found diff --git a/examples/msg/energy/vm/2.out b/examples/msg/energy/vm/2.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/msg/energy/vm/README b/examples/msg/energy/vm/README new file mode 100644 index 0000000000..6f0e6cb75b --- /dev/null +++ b/examples/msg/energy/vm/README @@ -0,0 +1,12 @@ +Fact 1: +Two hosts: one task on the PM, the two hosts have the same energyfootprint +Fact 2: +Two hosts: host1 hosts one VM, one task inside the VM (the same task as before), another task on the PM. the VM is correctly shutdowned at the end. Energy seems to consider the two tasks (that is the energyfootprint is equals to the energyfootprint to one host with two tasks. + +Issue 1: +If you kill the VM before terminating internal tasks you get warning and energy is not correct +[10.000000] [msg_test/INFO] Total simulation time: 10.00 +[10.000000] /Users/alebre/DEVELOPMENTS/SIMGRID/simgrid/src/msg/msg_host.c:157: [msg/WARNING] dp_objs: 1 pending task? +[10.000000] [surf_energy/INFO] Total energy of host MyHost1: 1300.000000 Joules +Issue 2: + diff --git a/examples/msg/energy/vm/deployment_consumption.xml b/examples/msg/energy/vm/deployment_consumption.xml new file mode 100644 index 0000000000..b9c8941609 --- /dev/null +++ b/examples/msg/energy/vm/deployment_consumption.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/examples/msg/energy/vm/energy_platform.xml b/examples/msg/energy/vm/energy_platform.xml new file mode 100644 index 0000000000..8009e81595 --- /dev/null +++ b/examples/msg/energy/vm/energy_platform.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/msg/energy/vm/vm b/examples/msg/energy/vm/vm new file mode 100755 index 0000000000000000000000000000000000000000..9b0e79bc8d169902c5848f6b7fdffa7a46be4a4e GIT binary patch literal 10344 zcmeHNeQX@X6`u=n;{+UEXiS63$C1V;h03uFsEE|64L;bkaWMIS0FB1yyS49>`_kQ> zb4GF%6Rfg5PI6VHQ2I}*_K%3RswJw*NktL}twBP7T2w(4(X^uBOigPcM5B<#{rzTV zeR~_H?H~QCy^&|$$Gmy--kY~OzL|aF{D&7;2obnKi2cii5NlA+Gzc*vLcoN$7S%wN zvcKoP@FU^v_mf*&0=49l6!mPx1XAt{@7`G}qQ(bnc|y~$O~4%S8Qm?VWfrZftY6}s6|HZb9z+_scGUGyz%5+lZM^l5Dq|92m%j$F0FyFj(aXr_1rk64q`B(aa7*G2S=`p0e`e@%Zx{pB0 zSj37{8Ge7Kw7%V1gtS**b)TTHW{EdCkbZh~t;c(%on0ZJ9_b)pH%PbihlHqLz?~4B1e3W&8~eW?#7%&W zHw!TU=9T23vhaQ2z7xpz#+CivGSDi-EnbGk`Iv-IuR`5a$mcdC6N8&#qsbU(md~To zj(6vO(7t(Dd+WirM^Aim|LeOpfQO|JV&y7Tsaw(Hp=^Y|95;z>Z{a+5qOy-Z1_D1r zss^faWBwhZdCN?--Q5N|5`z#z;kb5GcbsT)Rt*CAL~1yfh_&6;)^Xe75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@N`#7S`9XYoSh zfZ%W2+W}cS_%=i#j&#BQjRE|h$I+?;*1E`J+eM%l3&B8n$bAmxjF>ZqsnLhJzX=H5}2P>(=80{@E50Ih?=^7^V}sjk3lWCE6BE{-yE zuR7@g-LL6vE)&IJl(w3ZyL~^cd6euARJr+h!HQ+}DYKvS@_CL$&68xx;-KZO4(|7zHF&0`#~k6A6;_ag4zUYo zQ)b%C4Ugi?sxX{LFAhAcdq>P%o~z?VRVPY7;tqDX6dSxJaYc31Hl`x_ct9*m#gPlj zO?(j%VKP0ubQUch1McC$mRKfbG?PZ$3Q;SQlTzfxxA2L|ofa)ImaF(r*A%COh<1|fO&0gubie>*5|EU~> zsdzPJalb?1J@V?6XmAP0$v2b6-H>}9f48QCx_^tN*J*ki=;i=#Y@P9gq@iyLEb2Qz z8b}c5)uf--bT_W9NFUKO@1sc{*L1&@e+@MFG+UMT(0XYe;(O^;AiOk>gS~W{kG|JO z_xtFWkKX5_`7H?k7VUf1NB`7E|H?6e%PvA^AG)a6qS!JWZGK(kK6NY8D^; ze<$F7CrI_Ok?Lh5y>Fq*?Kz5n>29Og)qO^hH9L&r)a)&av&62V_>Mu`_k25v>UDX} z9->&@-J{BI_l+vY-7yrWx>va5;wG`kP`ktB!m2jzCH9OetGZb@JNjkz3bJcAiA(;4 G5aOTWX=!x; literal 0 HcmV?d00001 diff --git a/examples/msg/energy/vm/vm.c b/examples/msg/energy/vm/vm.c new file mode 100644 index 0000000000..9b0543eda1 --- /dev/null +++ b/examples/msg/energy/vm/vm.c @@ -0,0 +1,123 @@ +/* Copyright (c) 2007-2010, 2013-2015. The SimGrid Team. + * All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + +#include + +#include "simgrid/msg.h" +#include "xbt/sysdep.h" /* calloc */ +#include "simgrid/plugins.h" + +/* Create a log channel to have nice outputs. */ +#include "xbt/log.h" +#include "xbt/asserts.h" + +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, + "Messages specific for this msg example"); + +static msg_host_t host1 = NULL; +static msg_host_t host2 = NULL; +static msg_vm_t vm1 = NULL; +static double start; + +int dvfs(int argc, char *argv[]); +int shutdown_vm(void *ignored1, void *ignored2); + +int worker_func() { + //MSG_process_on_exit(shutdown_vm, NULL); + + msg_task_t task1 = MSG_task_create("t1", 300E6, 0, NULL); + MSG_task_execute (task1); + MSG_task_destroy(task1); + XBT_INFO("Worker fun done"); + return 0; +} + +/* +int shutdown_vm(void *ignored1, void *ignored2) { + start = MSG_get_clock(); + XBT_INFO("Shutting down the VM"); + MSG_vm_shutdown(vm1); + + + XBT_INFO("VM is now down (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J", + MSG_get_clock()-start, + MSG_host_get_current_power_peak(host), MSG_host_get_consumed_energy(host)); + + return 0; +} +*/ + +int dvfs(int argc, char *argv[]) +{ + host1 = MSG_host_by_name("MyHost1"); + host2 = MSG_host_by_name("MyHost2"); + + double start = MSG_get_clock(); + + /* Host 1 */ + XBT_INFO("Creating and starting a VM"); + vm1 = MSG_vm_create(host1, + "vm1", /* name */ + 4, /* number of cpus */ + 2048, /* ram size */ + 100, /* net cap */ + "", /* disk path */ + 1024 * 20, /* disk size */ + 10, /* mig netspeed */ + 50 /* dp intensity */ + ); + + // on Host1 create two tasks, one inside a VM the other one directly on the host + MSG_vm_start(vm1); + msg_process_t p11 = MSG_process_create("p11", worker_func, NULL, vm1); + msg_process_t p12 = MSG_process_create("p12", worker_func, NULL, host1); + //XBT_INFO("Task on Host started"); + + + // on Host2, create two tasks directlu on the host: Energy of host 1 and host 2 should be the same. + msg_process_t p21 = MSG_process_create("p21", worker_func, NULL, host2); + msg_process_t p22 = MSG_process_create("p22", worker_func, NULL, host2); + + /* Wait and see */ + MSG_process_sleep(5); + MSG_process_sleep(5); + MSG_vm_shutdown(vm1); + + return 0; +} + +int main(int argc, char *argv[]) +{ + msg_error_t res = MSG_OK; + sg_energy_plugin_init(); + MSG_init(&argc, argv); + + if (argc != 3) { + XBT_CRITICAL("Usage: %s platform_file deployment_file\n", + argv[0]); + XBT_CRITICAL + ("example: %s msg_platform.xml msg_deployment.xml\n", + argv[0]); + exit(1); + } + + MSG_create_environment(argv[1]); + + /* Application deployment */ + MSG_function_register("dvfs_test", dvfs); + + MSG_launch_application(argv[2]); + + res = MSG_main(); + + XBT_INFO("Total simulation time: %.2f", MSG_get_clock()); + + if (res == MSG_OK) + return 0; + else + return 1; +} + -- 2.20.1