async-waitany cloud-capping cloud-masterworker cloud-migration cloud-simple cloud-two-tasks
dht-chord dht-pastry energy-consumption energy-onoff energy-pstate energy-ptask energy-vm platform-failures
io-file io-remote io-storage task-priority
- process-create process-daemon process-join process-kill process-migration process-suspend
+ plugin-hostload process-create process-daemon process-join process-kill process-migration process-suspend
platform-properties process-startkilltime synchro-semaphore trace-categories
trace-route-user-variables trace-link-user-variables trace-masterworker trace-platform
trace-process-migration trace-host-user-variables)
ADD_TESH_FACTORIES(msg-energy-pstate-ptask "thread;ucontext;raw;boost" --cfg host/model:ptask_L07 --log xbt_cfg.threshold:critical --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/energy-pstate/energy-pstate.tesh)
ADD_TESH_FACTORIES(msg-energy-consumption-ptask "thread;ucontext;raw;boost" --cfg host/model:ptask_L07 --log xbt_cfg.threshold:critical --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/energy-consumption/energy-consumption.tesh)
ADD_TESH_FACTORIES(msg-energy-ptask "thread;ucontext;raw" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/energy-ptask/energy-ptask.tesh)
+ADD_TESH_FACTORIES(msg-plugin-hostload "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/ ${CMAKE_HOME_DIRECTORY}/examples/msg/plugin-hostload/plugin-hostload.tesh)
if(NOT WIN32)
ADD_TESH_FACTORIES(msg-maestro-set "thread" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/maestro-set/maestro-set.tesh)
else()
--- /dev/null
+/* 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 "simgrid/msg.h"
+#include "simgrid/plugins/load.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
+
+static int execute_load_test(int argc, char* argv[])
+{
+ msg_host_t host = MSG_host_by_name("MyHost1");
+
+ XBT_INFO("Initial peak speed: %.0E flop/s; number of flops computed so far: %.0E (should be 0)",
+ MSG_host_get_current_power_peak(host), MSG_host_get_computed_flops(host));
+
+ double start = MSG_get_clock();
+ XBT_INFO("Sleep for 10 seconds");
+ MSG_process_sleep(10);
+
+ XBT_INFO("Done sleeping %.2fs; peak speed: %.0E flop/s; number of flops computed so far: %.0E (nothing should have "
+ "changed)",
+ MSG_get_clock() - start, MSG_host_get_current_power_peak(host), MSG_host_get_computed_flops(host));
+
+ // Run a task
+ start = MSG_get_clock();
+ msg_task_t task1 = MSG_task_create("t1", 100E6, 0, NULL);
+ XBT_INFO("Run a task of %.0E flops", MSG_task_get_flops_amount(task1));
+ MSG_task_execute(task1);
+ MSG_task_destroy(task1);
+
+ XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s; number of flops computed so "
+ "far: %.0E",
+ MSG_get_clock() - start, MSG_host_get_current_power_peak(host), MSG_host_get_computed_flops(host));
+
+ // ========= Change power peak =========
+ int pstate = 2;
+ MSG_host_set_pstate(host, pstate);
+ XBT_INFO("========= Requesting pstate %d (speed should be of %.0E flop/s and is of %.0E flop/s)", pstate,
+ MSG_host_get_power_peak_at(host, pstate), MSG_host_get_current_power_peak(host));
+
+ // Run a second task
+ start = MSG_get_clock();
+ task1 = MSG_task_create("t2", 100E6, 0, NULL);
+ XBT_INFO("Run a task of %.0E flops", MSG_task_get_flops_amount(task1));
+ MSG_task_execute(task1);
+ MSG_task_destroy(task1);
+ XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s; number of flops computed so "
+ "far: %.0E",
+ MSG_get_clock() - start, MSG_host_get_current_power_peak(host), MSG_host_get_computed_flops(host));
+
+ start = MSG_get_clock();
+ XBT_INFO("========= Requesting a reset of the computation counter");
+ sg_host_load_reset(host);
+ XBT_INFO("Sleep for 4 seconds");
+ MSG_process_sleep(4);
+ XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E",
+ MSG_get_clock() - start, MSG_host_get_current_power_peak(host), MSG_host_get_computed_flops(host));
+
+ // =========== Turn the other host off ==========
+ XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 computed %.0f flops so far.",
+ MSG_host_get_computed_flops(MSG_host_by_name("MyHost2")));
+ MSG_host_off(MSG_host_by_name("MyHost2"));
+ start = MSG_get_clock();
+ MSG_process_sleep(10);
+ XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E",
+ MSG_get_clock() - start, MSG_host_get_current_power_peak(host), MSG_host_get_computed_flops(host));
+ return 0;
+}
+
+int main(int argc, char* argv[])
+{
+ sg_host_load_plugin_init();
+ MSG_init(&argc, argv);
+
+ xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
+
+ MSG_create_environment(argv[1]);
+ MSG_process_create("load_test", execute_load_test, NULL, MSG_get_host_by_name("MyHost1"));
+
+ msg_error_t res = MSG_main();
+
+ XBT_INFO("Total simulation time: %.2f", MSG_get_clock());
+
+ return res != MSG_OK;
+}
--- /dev/null
+#! ./tesh
+
+p This tests the HostLoad plugin (this allows the user to get the current load of a host and the computed flops)
+
+$ ${bindir:=.}/plugin-hostload/plugin-hostload$EXEEXT ${srcdir:=.}/../platforms/energy_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 0.000000] (1:load_test@MyHost1) Initial peak speed: 1E+08 flop/s; number of flops computed so far: 0E+00 (should be 0)
+> [ 0.000000] (1:load_test@MyHost1) Sleep for 10 seconds
+> [ 10.000000] (1:load_test@MyHost1) Done sleeping 10.00s; peak speed: 1E+08 flop/s; number of flops computed so far: 0E+00 (nothing should have changed)
+> [ 10.000000] (1:load_test@MyHost1) Run a task of 1E+08 flops
+> [ 11.000000] (1:load_test@MyHost1) Done working on my task; this took 1.00s; current peak speed: 1E+08 flop/s; number of flops computed so far: 1E+08
+> [ 11.000000] (1:load_test@MyHost1) ========= Requesting pstate 2 (speed should be of 2E+07 flop/s and is of 2E+07 flop/s)
+> [ 11.000000] (1:load_test@MyHost1) Run a task of 1E+08 flops
+> [ 16.000000] (1:load_test@MyHost1) Done working on my task; this took 5.00s; current peak speed: 2E+07 flop/s; number of flops computed so far: 2E+08
+> [ 16.000000] (1:load_test@MyHost1) ========= Requesting a reset of the computation counter
+> [ 16.000000] (1:load_test@MyHost1) Sleep for 4 seconds
+> [ 20.000000] (1:load_test@MyHost1) Done sleeping 4.00 s; peak speed: 2E+07 flop/s; number of flops computed so far: 0E+00
+> [ 20.000000] (1:load_test@MyHost1) Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 computed 0 flops so far.
+> [ 30.000000] (1:load_test@MyHost1) Done sleeping 10.00 s; peak speed: 2E+07 flop/s; number of flops computed so far: 0E+00
+> [ 30.000000] (0:maestro@) Total simulation time: 30.00