--- /dev/null
+cmake_minimum_required(VERSION 2.6)
+
+set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
+
+add_executable(e1 e1.c)
+
+### Add definitions for compile
+target_link_libraries(e1 simgrid )
+
+set(xml_files
+ ${xml_files}
+ ${CMAKE_CURRENT_SOURCE_DIR}/deployment_e1.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/platform_e1.xml
+ PARENT_SCOPE
+ )
+
+set(bin_files
+ ${bin_files}
+ PARENT_SCOPE
+ )
--- /dev/null
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+
+ <process host="MyHost1" function="dvfs_test" />
+
+</platform>
--- /dev/null
+/* Copyright (c) 2007, 2008, 2009, 2010. 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<stdio.h>
+
+#include "msg/msg.h"
+#include "xbt/sysdep.h" /* calloc */
+
+/* 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");
+
+int dvfs(int argc, char *argv[]);
+
+
+int dvfs(int argc, char *argv[])
+{
+ msg_host_t host = NULL;
+ msg_task_t task1 = NULL;
+ double task_time = 0;
+ host = MSG_get_host_by_name("MyHost1");
+
+ XBT_INFO("dvfs start");
+
+ int nb = MSG_get_host_nb_pstates(host);
+ XBT_INFO("Number of Processor states=%d", nb);
+
+ double current_peak = MSG_get_host_current_power_peak(host);
+ XBT_INFO("Current power peak=%lf", current_peak);
+
+ // Run a task
+ task1 = MSG_task_create ("t1", 100E6, 0, NULL);
+ MSG_task_execute (task1);
+ MSG_task_destroy(task1);
+
+ task_time = MSG_get_clock();
+ XBT_INFO("Task1 simulation time: %le", task_time);
+
+ // ========= Change power peak =========
+ int peak_index=2;
+ double peak_at = MSG_get_host_power_peak_at(host, peak_index);
+ XBT_INFO("=========Changing power peak value to %lf (at index %d)", peak_at, peak_index);
+
+ MSG_set_host_power_peak_at(host, peak_index);
+
+ current_peak = MSG_get_host_current_power_peak(host);
+ XBT_INFO("Current power peak=%lf", current_peak);
+
+ // Run a second task
+ task1 = MSG_task_create ("t1", 100E6, 0, NULL);
+ MSG_task_execute (task1);
+ MSG_task_destroy(task1);
+
+ task_time = MSG_get_clock() - task_time;
+ XBT_INFO("Task2 simulation time: %le", task_time);
+
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ msg_error_t res = MSG_OK;
+
+ 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: %le", MSG_get_clock());
+
+ if (res == MSG_OK)
+ return 0;
+ else
+ return 1;
+}
+
--- /dev/null
+<?xml version='1.0'?>
+ <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+ <platform version="3">
+ <AS id="AS0" routing="Full">
+ <host id="MyHost1" power="100.0Mf,50.0Mf,20.0Mf, 10Gf" pstate="3">
+ <!-- in Watts -->
+ <prop id="power_per_state" value="200:250,200:220,100.0:150.0,120:250" />
+ </host>
+ </AS>
+ </platform>
--- /dev/null
+cmake_minimum_required(VERSION 2.6)
+
+set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
+
+add_executable(e2 e2.c)
+
+### Add definitions for compile
+target_link_libraries(e2 simgrid )
+
+set(xml_files
+ ${xml_files}
+ ${CMAKE_CURRENT_SOURCE_DIR}/deployment_e2.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/platform_e2.xml
+ PARENT_SCOPE
+ )
+
+set(bin_files
+ ${bin_files}
+ PARENT_SCOPE
+ )
--- /dev/null
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+
+ <process host="MyHost1" function="dvfs_test" />
+
+</platform>
--- /dev/null
+/* Copyright (c) 2007, 2008, 2009, 2010. 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<stdio.h>
+
+#include "msg/msg.h"
+#include "xbt/sysdep.h" /* calloc */
+
+/* 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");
+
+int dvfs(int argc, char *argv[]);
+
+
+int dvfs(int argc, char *argv[])
+{
+ msg_host_t host = NULL;
+ msg_task_t task1 = NULL;
+ double task_time = 0;
+ host = MSG_get_host_by_name("MyHost1");
+
+
+ double current_peak = MSG_get_host_current_power_peak(host);
+ XBT_INFO("Current power peak=%lf", current_peak);
+
+ double consumed_energy = MSG_get_host_consumed_energy(host);
+ XBT_INFO("Total energy (Joules): %lf", consumed_energy);
+
+ // Run a task
+ task1 = MSG_task_create ("t1", 100E6, 0, NULL);
+ MSG_task_execute (task1);
+ MSG_task_destroy(task1);
+
+ task_time = MSG_get_clock();
+ XBT_INFO("Task1 simulation time: %le", task_time);
+ consumed_energy = MSG_get_host_consumed_energy(host);
+ XBT_INFO("Total energy (Joules): %lf", consumed_energy);
+
+ // ========= Change power peak =========
+ int peak_index=2;
+ double peak_at = MSG_get_host_power_peak_at(host, peak_index);
+ XBT_INFO("=========Changing power peak value to %lf (at index %d)", peak_at, peak_index);
+
+ MSG_set_host_power_peak_at(host, peak_index);
+
+ // Run a second task
+ task1 = MSG_task_create ("t2", 100E6, 0, NULL);
+ MSG_task_execute (task1);
+ MSG_task_destroy(task1);
+
+ task_time = MSG_get_clock() - task_time;
+ XBT_INFO("Task2 simulation time: %le", task_time);
+
+ consumed_energy = MSG_get_host_consumed_energy(host);
+ XBT_INFO("Total energy (Joules): %lf", consumed_energy);
+
+
+ MSG_process_sleep(3);
+
+ task_time = MSG_get_clock() - task_time;
+ XBT_INFO("Task3 (sleep) simulation time: %le", task_time);
+ consumed_energy = MSG_get_host_consumed_energy(host);
+ XBT_INFO("Total energy (Joules): %lf", consumed_energy);
+
+
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ msg_error_t res = MSG_OK;
+
+ 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: %le", MSG_get_clock());
+
+ if (res == MSG_OK)
+ return 0;
+ else
+ return 1;
+}
+
--- /dev/null
+<?xml version='1.0'?>
+ <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+ <platform version="3">
+ <AS id="AS0" routing="Full">
+ <host id="MyHost1" power="100.0Mf,50.0Mf,20.0Mf, 10Gf" >
+ <!-- in Watts -->
+ <prop id="power_per_state" value="200:250, 200:220,100.0:150.0, 95:130" />
+ </host>
+ </AS>
+ </platform>
--- /dev/null
+cmake_minimum_required(VERSION 2.6)
+
+set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
+
+add_executable(e3 e3.c)
+
+### Add definitions for compile
+target_link_libraries(e3 simgrid )
+
+set(xml_files
+ ${xml_files}
+ ${CMAKE_CURRENT_SOURCE_DIR}/deployment_e3.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/platform_e3.xml
+ PARENT_SCOPE
+ )
+
+set(bin_files
+ ${bin_files}
+ PARENT_SCOPE
+ )
--- /dev/null
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+
+ <process host="MyHost1" function="dvfs_test" />
+
+</platform>
--- /dev/null
+/* Copyright (c) 2007, 2008, 2009, 2010. 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<stdio.h>
+
+#include "msg/msg.h"
+#include "xbt/sysdep.h" /* calloc */
+
+/* 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 int dvfs(int argc, char *argv[]);
+static int process_code(int argc, char *argv[]);
+
+static int process_code(int argc, char *argv[])
+{
+ msg_task_t task1 = NULL;
+ double cpu_task = 0;
+ double task_time = MSG_get_clock();
+
+ if (argc == 2)
+ {
+ /* Run a sleep task */
+ double sleep_task = atof(argv[1]);
+
+ MSG_process_sleep(sleep_task);
+ task_time = MSG_get_clock() - task_time;
+ XBT_INFO("Process %s executed task sleep cpu=%lf, duration = %lf",
+ MSG_process_get_name(MSG_process_self()), 0.0, task_time);
+ XBT_INFO("==================================================");
+ }
+
+
+ // Run a task
+ cpu_task = atof(argv[0]);
+ task1 = MSG_task_create ("task", cpu_task, 0, NULL);
+ MSG_task_execute (task1);
+ MSG_task_destroy(task1);
+
+ task_time = MSG_get_clock() - task_time;
+ XBT_INFO("Process %s executed task cpu=%lf, duration = %lf",
+ MSG_process_get_name(MSG_process_self()), cpu_task, task_time);
+ XBT_INFO("==================================================");
+ return 0;
+}
+
+
+static int dvfs(int argc, char *argv[])
+{
+ msg_host_t host = NULL;
+ double task_time = 0;
+ host = MSG_host_self();
+
+ double current_peak = MSG_get_host_current_power_peak(host);
+
+ XBT_INFO("Current power peak=%lf", current_peak);
+ double consumed_energy = MSG_get_host_consumed_energy(host);
+ XBT_INFO("Total energy (Joules): %lf", consumed_energy);
+
+ // Process 1 - long CPU task
+ int argc1 = 1;
+ char** params1 = xbt_malloc0(sizeof(char *) * argc1);
+ params1[0] = xbt_strdup("400.0E6");
+ MSG_process_create_with_arguments("proc1", process_code, NULL, host, argc1, params1);
+
+ // Process 2 - sleep 2 sec + CPU task
+ int argc2 = 2;
+ char** params2 = xbt_malloc0(sizeof(char *) * argc2);
+ params2[0] = xbt_strdup("100.0E6");
+ params2[1] = xbt_strdup("2");
+ MSG_process_create_with_arguments("proc2", process_code, NULL, host, argc2, params2);
+
+ // Process 3 - sleep 2 sec + CPU task
+ int argc3 = 2;
+ char** params3 = xbt_malloc0(sizeof(char *) * argc3);
+ params3[0] = xbt_strdup("100.0E6");
+ params3[1] = xbt_strdup("2");
+ MSG_process_create_with_arguments("proc3", process_code, NULL, host, argc3, params3);
+
+
+ // Main process
+ MSG_process_sleep(8);
+
+ task_time = MSG_get_clock() - task_time;
+ XBT_INFO("Task simulation time: %le", task_time);
+ consumed_energy = MSG_get_host_consumed_energy(host);
+ XBT_INFO("Total energy (Joules): %lf", consumed_energy);
+
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ msg_error_t res = MSG_OK;
+
+ 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: %le", MSG_get_clock());
+
+ if (res == MSG_OK)
+ return 0;
+ else
+ return 1;
+}
+
--- /dev/null
+<?xml version='1.0'?>
+ <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+ <platform version="3">
+ <AS id="AS0" routing="Full">
+ <host id="MyHost1" power="100.0Mf,50.0Mf,20.0Mf, 10Gf" >
+ <!-- in Watts -->
+ <prop id="power_per_state" value="200:250, 200:220,100.0:150.0, 95:130" />
+ </host>
+ </AS>
+ </platform>
--- /dev/null
+
+/* Copyright (c) 2009, 2010. 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. */
+
+#ifndef _SURF_CPU_CAS01_PRIVATE_H
+#define _SURF_CPU_CAS01_PRIVATE_H
+
+#undef GENERIC_LMM_ACTION
+#undef GENERIC_ACTION
+#undef ACTION_GET_CPU
+#define GENERIC_LMM_ACTION(action) action->generic_lmm_action
+#define GENERIC_ACTION(action) GENERIC_LMM_ACTION(action).generic_action
+#define ACTION_GET_CPU(action) ((surf_action_cpu_Cas01_t) action)->cpu
+
+typedef struct surf_action_cpu_cas01 {
+ s_surf_action_lmm_t generic_lmm_action;
+} s_surf_action_cpu_Cas01_t, *surf_action_cpu_Cas01_t;
+
+
+typedef struct energy_cpu_cas01 {
+ xbt_dynar_t power_range_watts_list;
+ double total_energy;
+ double last_updated;
+} s_energy_cpu_cas01_t, *energy_cpu_cas01_t;
+
+
+typedef struct cpu_Cas01 {
+ s_surf_resource_t generic_resource;
+ s_xbt_swag_hookup_t modified_cpu_hookup;
+ double power_peak;
+ double power_scale;
+ tmgr_trace_event_t power_event;
+ int core;
+ e_surf_resource_state_t state_current;
+ tmgr_trace_event_t state_event;
+ lmm_constraint_t constraint;
+
+ xbt_dynar_t power_peak_list;
+ int pstate;
+ energy_cpu_cas01_t energy;
+
+} s_cpu_Cas01_t, *cpu_Cas01_t;
+
+xbt_dynar_t cpu_get_watts_range_list(cpu_Cas01_t cpu_model);
+void cpu_update_energy(cpu_Cas01_t cpu_model, double cpu_load);
+
+#endif /* _SURF_CPU_CAS01_PRIVATE_H */