examples/java/cloud/masterworker/java_cloud_masterworker_compiled
examples/java/cloud/migration/java_cloud_migration_compiled
examples/java/energy/consumption/java_energy_consumption_compiled
+examples/java/energy/pstate/java_energy_pstate_compiled
examples/java/energy/vm/java_energy_vm_compiled
examples/java/io/file/java_io_file_compiled
examples/java/io/storage/java_io_storage_compiled
set (srcdir ${CMAKE_CURRENT_SOURCE_DIR}/energy/consumption)
set(energy_consumption_sources ${srcdir}/Main.java ${srcdir}/EnergyConsumer.java)
+set (srcdir ${CMAKE_CURRENT_SOURCE_DIR}/energy/pstate)
+set(energy_pstate_sources ${srcdir}/Main.java ${srcdir}/PstateRunner.java)
+
set (srcdir ${CMAKE_CURRENT_SOURCE_DIR}/energy/vm)
set(energy_vm_sources ${srcdir}/Main.java ${srcdir}/EnergyVMRunner.java)
set(task_priority_sources ${srcdir}/Main.java ${srcdir}/Test.java)
foreach (example app_bittorrent app_centralizedmutex app_masterworker app_pingpong app_tokenring async_waitall async_dsend
- cloud_migration cloud_masterworker dht_chord dht_kademlia energy_consumption energy_vm io_file io_storage
+ cloud_migration cloud_masterworker dht_chord dht_kademlia energy_consumption energy_pstate energy_vm io_file io_storage
process_kill process_migration process_startkilltime process_suspend task_priority trace_pingpong)
string (REPLACE "_" "/" example_dir ${example})
if(enable_java)
if(enable_java)
foreach (example app_bittorrent app_centralizedmutex app_masterworker app_pingpong app_tokenring async_waitall async_dsend
- cloud_migration cloud_masterworker dht_chord dht_kademlia energy_consumption energy_vm io_file io_storage
+ cloud_migration cloud_masterworker dht_chord dht_kademlia energy_consumption energy_pstate energy_vm io_file io_storage
process_kill process_migration process_startkilltime process_suspend task_priority trace_pingpong)
string (REPLACE "_" "/" example_dir ${example})
- ADD_TESH(java-${example} --setenv
-srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/${example_dir}/${example}.tesh)
+ ADD_TESH(java-${example} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/${example_dir}/${example}.tesh)
endforeach()
endif()
--- /dev/null
+/* Copyright (c) 2016. 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. */
+
+package energy.pstate;
+
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.Host;
+import org.simgrid.msg.HostNotFoundException;
+import org.simgrid.msg.NativeException;
+
+class Main {
+ private Main() {
+ throw new IllegalAccessError("Utility class");
+ }
+
+ public static void main(String[] args) throws NativeException, HostNotFoundException {
+ Msg.energyInit();
+ Msg.init(args);
+
+ if (args.length < 1) {
+ Msg.info("Usage: Main ../platforms/energy_platform_file.xml");
+ System.exit(1);
+ }
+
+ /* construct the platform */
+ Msg.createEnvironment(args[0]);
+
+ /* Create and start a runner for the experiment */
+ new PstateRunner(Host.all()[0],"pstate runner",null).start();
+
+ Msg.run();
+ }
+}
--- /dev/null
+/* Copyright (c) 2016. 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. */
+
+package energy.pstate;
+
+import org.simgrid.msg.Host;
+import org.simgrid.msg.HostFailureException;
+import org.simgrid.msg.HostNotFoundException;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.NativeException;
+import org.simgrid.msg.Process;
+import org.simgrid.msg.Task;
+import org.simgrid.msg.TaskCancelledException;
+
+/* This class is a process in charge of running the test. It creates and starts the VMs, and fork processes within VMs */
+public class PstateRunner extends Process {
+
+ public class DVFS extends Process {
+ public DVFS (Host host, String name) {
+ super(host, name);
+ }
+
+ @Override
+ public void main(String[] strings) throws HostNotFoundException, HostFailureException, TaskCancelledException {
+ double workload = 100E6;
+ int new_peak_index=2;
+ Host host = getHost();
+
+ int nb = host.getPstatesCount();
+ Msg.info("Count of Processor states="+ nb);
+
+ double current_peak = host.getCurrentPowerPeak();
+ Msg.info("Current power peak=" + current_peak);
+
+ // Run a task
+ Task task1 = new Task("t1", workload, 0);
+ task1.execute();
+
+ double task_time = Msg.getClock();
+ Msg.info("Task1 simulation time: "+ task_time);
+
+ // Change power peak
+ if ((new_peak_index >= nb) || (new_peak_index < 0)){
+ Msg.info("Cannot set pstate "+new_peak_index+"%d, host supports only "+nb+" pstates.");
+ return;
+ }
+
+ double peak_at = host.getPowerPeakAt(new_peak_index);
+ Msg.info("Changing power peak value to "+peak_at+" (at index "+new_peak_index+")");
+
+ host.setPstate(new_peak_index);
+
+ current_peak = host.getCurrentPowerPeak();
+ Msg.info("Current power peak="+ current_peak);
+
+ // Run a second task
+ task1 = new Task("t1", workload, 0);
+
+ task_time = Msg.getClock() - task_time;
+ Msg.info("Task2 simulation time: "+ task_time);
+
+ // Verify the default pstate is set to 0
+ host = Host.getByName("MyHost2");
+ int nb2 = host.getPstatesCount();
+ Msg.info("Count of Processor states="+ nb2);
+
+ double current_peak2 = host.getCurrentPowerPeak();
+ Msg.info("Current power peak=" + current_peak2);
+ return ;
+ }
+ }
+
+ PstateRunner(Host host, String name, String[] args) throws HostNotFoundException, NativeException {
+ super(host, name, args);
+ }
+
+ @Override
+ public void main(String[] strings) throws HostNotFoundException, HostFailureException {
+
+ new DVFS (Host.getByName("MyHost1"), "dvfs_test").start();
+ new DVFS (Host.getByName("MyHost2"), "dvfs_test").start();
+
+ }
+}
--- /dev/null
+#! tesh
+
+$ java -classpath ${classpath:=.} energy/pstate/Main ${srcdir:=.}/../platforms/energy_platform.xml
+> [0.000000] [jmsg/INFO] Using regular java threads.
+> [MyHost1:dvfs_test:(2) 0.000000] [jmsg/INFO] Count of Processor states=3
+> [MyHost1:dvfs_test:(2) 0.000000] [jmsg/INFO] Current power peak=1.0E8
+> [MyHost2:dvfs_test:(3) 0.000000] [jmsg/INFO] Count of Processor states=3
+> [MyHost2:dvfs_test:(3) 0.000000] [jmsg/INFO] Current power peak=1.0E8
+> [MyHost1:dvfs_test:(2) 1.000000] [jmsg/INFO] Task1 simulation time: 1.0
+> [MyHost2:dvfs_test:(3) 1.000000] [jmsg/INFO] Task1 simulation time: 1.0
+> [MyHost1:dvfs_test:(2) 1.000000] [jmsg/INFO] Changing power peak value to 2.0E7 (at index 2)
+> [MyHost2:dvfs_test:(3) 1.000000] [jmsg/INFO] Changing power peak value to 2.0E7 (at index 2)
+> [MyHost1:dvfs_test:(2) 1.000000] [jmsg/INFO] Current power peak=2.0E7
+> [MyHost1:dvfs_test:(2) 1.000000] [jmsg/INFO] Task2 simulation time: 0.0
+> [MyHost1:dvfs_test:(2) 1.000000] [jmsg/INFO] Count of Processor states=3
+> [MyHost2:dvfs_test:(3) 1.000000] [jmsg/INFO] Current power peak=2.0E7
+> [MyHost2:dvfs_test:(3) 1.000000] [jmsg/INFO] Task2 simulation time: 0.0
+> [MyHost2:dvfs_test:(3) 1.000000] [jmsg/INFO] Count of Processor states=3
+> [MyHost1:dvfs_test:(2) 1.000000] [jmsg/INFO] Current power peak=2.0E7
+> [MyHost2:dvfs_test:(3) 1.000000] [jmsg/INFO] Current power peak=2.0E7
+> [1.000000] [jmsg/INFO] MSG_main finished; Cleaning up the simulation...
+> [1.000000] [surf_energy/INFO] Total energy of host MyHost1: 120.000000 Joules
+> [1.000000] [surf_energy/INFO] Total energy of host MyHost2: 120.000000 Joules
+> [1.000000] [surf_energy/INFO] Total energy of host MyHost3: 100.000000 Joules
/** @addtogroup MSG_examples
*
- * - <b>energy/e1/e1.c</b> Shows how a set of pstates can be defined for a host and how the current pstate can be
+ * - <b>energy-pstate/energy-pstate.c</b> Shows how a set of pstates can be defined for a host and how the current
+ * pstate can be
* accessed/changed with @ref MSG_get_host_current_power_peak and @ref MSG_set_host_pstate.
* Make sure to read the platform XML file for details on how to declare the CPU capacity for each pstate.
*/
return MSG_host_get_consumed_energy(host);
}
+
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_setPstate(JNIEnv* env, jobject jhost, jint pstate)
+{
+ msg_host_t host = jhost_get_native(env, jhost);
+ MSG_host_set_pstate(host, pstate);
+}
+JNIEXPORT jint JNICALL Java_org_simgrid_msg_Host_getPstate(JNIEnv* env, jobject jhost)
+{
+ msg_host_t host = jhost_get_native(env, jhost);
+ return MSG_host_get_pstate(host);
+}
+JNIEXPORT jint JNICALL Java_org_simgrid_msg_Host_getPstatesCount(JNIEnv* env, jobject jhost)
+{
+ msg_host_t host = jhost_get_native(env, jhost);
+ return MSG_host_get_nb_pstates(host);
+}
+JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCurrentPowerPeak(JNIEnv* env, jobject jhost)
+{
+ msg_host_t host = jhost_get_native(env, jhost);
+ return MSG_host_get_current_power_peak(host);
+}
+JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getPowerPeakAt(JNIEnv* env, jobject jhost, jint pstate)
+{
+ msg_host_t host = jhost_get_native(env, jhost);
+ return MSG_host_get_power_peak_at(host, pstate);
+}
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getConsumedEnergy (JNIEnv *env, jobject jhost);
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_setPstate(JNIEnv* env, jobject jhost, jint pstate);
+JNIEXPORT jint JNICALL Java_org_simgrid_msg_Host_getPstate(JNIEnv* env, jobject jhost);
+JNIEXPORT jint JNICALL Java_org_simgrid_msg_Host_getPstatesCount(JNIEnv* env, jobject jhost);
+JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCurrentPowerPeak(JNIEnv* env, jobject jhost);
+JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getPowerPeakAt(JNIEnv* env, jobject jhost, jint pstate);
+
SG_END_DECL()
#endif /*!MSG_JHOST_H */
/** Returns the amount of Joules consumed by that host so far */
public native double getConsumedEnergy();
+
+ /** Returns the current pstate */
+ public native int getPstate();
+ /** Changes the current pstate */
+ public native void setPstate(int pstate);
+ public native int getPstatesCount();
+ /** Returns the speed of the processor (in flop/s) at the current pstate. See also @ref SURF_plugin_energy. */
+ public native double getCurrentPowerPeak();
+ /** Returns the speed of the processor (in flop/s) at a given pstate. See also @ref SURF_plugin_energy. */
+ public native double getPowerPeakAt(int pstate);
+
/** Class initializer, to initialize various JNI stuff */
public static native void nativeInit();