Java:
- Due to an internal bug, Msg.run() must now be your last line.
We hope to fix it in a future release, and we are sorry for the inconvenience.
+ - Expose host load plugin (i.e. loadInit, getCurrentLoad, getComputedFlops,getAvgLoad)
Fixed bugs:
- #22: Process autorestart seem to only work with CAS01 cpus
set(process-startkilltime_files Main Sleeper)
set(process-suspend_files Main DreamMaster LazyGuy)
set(task-priority_files Main Test)
+set(hostload_files Main LoadRunner)
if(enable_java)
add_custom_target(java-all
endif()
foreach (example app-bittorrent app-centralizedmutex app-masterworker app-pingpong app-tokenring async-yield async-waitall async-dsend
- cloud-migration cloud-masterworker dht-chord dht-kademlia energy-consumption energy-pstate energy-vm io-file io-storage
+ cloud-migration cloud-masterworker dht-chord dht-kademlia energy-consumption energy-pstate energy-vm hostload io-file io-storage
process-kill process-migration process-startkilltime process-suspend task-priority trace-pingpong)
string (REPLACE "-" "/" example_dir ${example})
set (srcdir ${CMAKE_CURRENT_SOURCE_DIR}/${example_dir})
if(enable_java)
foreach (example app-bittorrent app-centralizedmutex app-masterworker app-pingpong app-tokenring async-yield async-waitall async-dsend
- cloud-migration cloud-masterworker dht-chord dht-kademlia energy-consumption energy-pstate energy-vm io-file io-storage
+ cloud-migration cloud-masterworker dht-chord dht-kademlia energy-consumption energy-pstate energy-vm hostload 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/${example_dir} ${CMAKE_HOME_DIRECTORY}/examples/java/${example_dir}/${example}.tesh)
return this.daemon;
}
- public int getLoad(){
+ public double getLoad(){
Msg.info("Remaining comp:" + this.daemon.getRemaining());
return this.currentLoad;
}
--- /dev/null
+/* Copyright (c) 2016-2018. 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 hostload;
+
+import org.simgrid.msg.*;
+import org.simgrid.msg.Process;
+
+
+public class LoadRunner extends Process {
+
+ public LoadRunner(Host host, String s) {
+ super(host, s);
+ }
+
+ public void display(){
+ Msg.info("Speed="+getHost().getSpeed()+" flop/s");
+ Msg.info("Computed Flops "+ getHost().getComputedFlops());
+ Msg.info("AvgLoad "+ getHost().getAvgLoad());
+ }
+ @Override
+ public void main(String[] strings) throws MsgException {
+ Host host = getHost();
+ display();
+ Msg.info("Sleep for 10 seconds");
+ waitFor(10);
+ display();
+
+ // Run a task
+ Task task1 = new Task("t1", 200E6, 0);
+ task1.execute();
+ display();
+ double taskTime = Msg.getClock();
+ Msg.info("Task1 simulation time: "+ taskTime);
+
+ // Run a second task
+ new Task("t1", 200E6, 0).execute();
+
+ taskTime = Msg.getClock() - taskTime;
+ Msg.info("Task2 simulation time: "+ taskTime);
+ display();
+
+ }
+
+
+}
\ No newline at end of file
--- /dev/null
+/* Copyright (c) 2012-2018. 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 hostload;
+
+import org.simgrid.msg.Host;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+
+public class Main {
+ private Main() {
+ throw new IllegalAccessError("Utility class");
+ }
+
+ public static void main(String[] args) throws MsgException {
+ Msg.loadInit();
+ Msg.init(args);
+
+ if (args.length < 1) {
+ Msg.info("Usage : Load platform_file");
+ Msg.info("Usage : Load ../platforms/small_platform.xml");
+ System.exit(1);
+ }
+ /* Construct the platform */
+ Msg.createEnvironment(args[0]);
+ new LoadRunner(Host.all()[0], "").start();
+
+ Msg.run();
+
+ }
+}
--- /dev/null
+#!/usr/bin/env tesh
+
+$ java -classpath ${classpath:=.} hostload/Main ${srcdir:=.}/../platforms/small_platform.xml
+> [0.000000] [java/INFO] Using regular java threads.
+> [Boivin::(1) 0.000000] [java/INFO] Speed=9.8095E7 flop/s
+> [Boivin::(1) 0.000000] [java/INFO] Computed Flops 0.0
+> [Boivin::(1) 0.000000] [java/INFO] AvgLoad 0.0
+> [Boivin::(1) 0.000000] [java/INFO] Sleep for 10 seconds
+> [Boivin::(1) 10.000000] [java/INFO] Speed=9.8095E7 flop/s
+> [Boivin::(1) 10.000000] [java/INFO] Computed Flops 0.0
+> [Boivin::(1) 10.000000] [java/INFO] AvgLoad 0.0
+> [Boivin::(1) 12.038840] [java/INFO] Speed=9.8095E7 flop/s
+> [Boivin::(1) 12.038840] [java/INFO] Computed Flops 2.0E8
+> [Boivin::(1) 12.038840] [java/INFO] AvgLoad 0.1693551801515729
+> [Boivin::(1) 12.038840] [java/INFO] Task1 simulation time: 12.038839900096844
+> [Boivin::(1) 14.077680] [java/INFO] Task2 simulation time: 2.0388399000968445
+> [Boivin::(1) 14.077680] [java/INFO] Speed=9.8095E7 flop/s
+> [Boivin::(1) 14.077680] [java/INFO] Computed Flops 4.0E8
+> [Boivin::(1) 14.077680] [java/INFO] AvgLoad 0.2896556718201238
+> [14.077680] [java/INFO] MSG_main finished; Terminating the simulation...
\ No newline at end of file
XBT_PUBLIC int sg_host_core_count(sg_host_t host);
+/** @ingroup m_host_management
+ * @brief Returns the current computation load (in flops per second).
+ * @param host a host
+ */
+XBT_PUBLIC double sg_host_load(sg_host_t host);
+
/** @ingroup m_process_management
* @brief Return the location on which a process is running.
* @return the sg_host_t corresponding to the location on which @a process is running.
/** @brief Return the location on which the current process is executed */
XBT_PUBLIC sg_host_t MSG_host_self();
+XBT_PUBLIC double MSG_host_get_load(sg_host_t host);
/* ******************************** VMs ************************************* */
typedef sg_vm_t msg_vm_t;
#define MSG_host_load_plugin_init() sg_host_load_plugin_init()
#define MSG_host_get_current_load(host) sg_host_get_current_load(host)
#define MSG_host_get_computed_flops(host) sg_host_get_computed_flops(host)
+#define MSG_host_get_avg_load(host) sg_host_get_avg_load(host)
SG_END_DECL()
#include "simgrid/plugins/energy.h"
#include "simgrid/plugins/file_system.h"
#include "simgrid/plugins/live_migration.h"
+#include "simgrid/plugins/load.h"
#include "simgrid/simix.h"
#include "simgrid/s4u/Host.hpp"
sg_storage_file_system_init();
}
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_loadInit() {
+ sg_host_load_plugin_init();
+}
/** Run a Java org.simgrid.msg.Process
*
* If needed, this waits for the process starting time.
JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_energyInit();
JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_liveMigrationInit();
JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_fileSystemInit();
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_loadInit();
JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_debug(JNIEnv* env, jclass cls, jstring jargs);
JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_verb(JNIEnv* env, jclass cls, jstring jargs);
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "simgrid/plugins/energy.h"
+#include "simgrid/plugins/load.h"
#include "simgrid/s4u/Host.hpp"
#include "simgrid/s4u/Storage.hpp"
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_getLoad(JNIEnv* env, jobject jhost)
+{
+ msg_host_t host = jhost_get_native(env, jhost);
+ return MSG_host_get_load(host);
+}
+
+JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCurrentLoad (JNIEnv *env, jobject jhost)
+{
+ msg_host_t host = jhost_get_native(env, jhost);
+
+ if (not host) {
+ jxbt_throw_notbound(env, "host", jhost);
+ return 0;
+ }
+
+ return MSG_host_get_current_load(host);
+}
+
+JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getComputedFlops (JNIEnv *env, jobject jhost)
+{
+ msg_host_t host = jhost_get_native(env, jhost);
+
+ if (not host) {
+ jxbt_throw_notbound(env, "host", jhost);
+ return 0;
+ }
+
+ return MSG_host_get_computed_flops(host);
+}
+
+JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getAvgLoad (JNIEnv *env, jobject jhost)
+{
+ msg_host_t host = jhost_get_native(env, jhost);
+
+ if (not host) {
+ jxbt_throw_notbound(env, "host", jhost);
+ return 0;
+ }
+
+ return MSG_host_get_avg_load(host);
+}
\ No newline at end of file
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);
+JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getLoad(JNIEnv* env, jobject jhost);
+JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCurrentLoad(JNIEnv *env, jobject jhost);
+JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getAvgLoad(JNIEnv *env, jobject jhost);
+JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getComputedFlops (JNIEnv *env, jobject jhost);
SG_END_DECL()
#endif
* the value will be updated in kernel mode before returning the control to the requesting actor.
*/
public native double getConsumedEnergy();
-
+
+ /** Returns the current load of the host */
+ public native double getCurrentLoad();
+ /** Returns the number of flops computed of the host */
+ public native double getComputedFlops();
+ /** Returns the average load of the host */
+ public native double getAvgLoad();
/** Returns the current pstate */
public native int getPstate();
/** Changes the current pstate */
public native double getCurrentPowerPeak();
/** Returns the speed of the processor (in flop/s) at a given pstate. See also @ref plugin_energy. */
public native double getPowerPeakAt(int pstate);
-
+
+ /** Returns the current computation load (in flops per second) */
+ public native double getLoad();
/** Class initializer, to initialize various JNI stuff */
private static native void nativeInit();
/** Tell the kernel that you want to use the energy plugin */
public static final native void energyInit();
+
+ /** Tell the kernel that you want to use the filesystem plugin. */
public static final native void fileSystemInit();
+ /** Initializes the HostLoad plugin.
+ *
+ * The HostLoad plugin provides an API to get the current load of each host.
+ */
+ public static final native void loadInit();
+
/** Run the MSG simulation.
*
* After the simulation, you can freely retrieve the information that you want..
{
return sg_host_self();
}
+
+double MSG_host_get_load(sg_host_t host)
+{
+ return sg_host_load(host);
+}
/* ************************** Virtual Machines *************************** */
sg_vm_t MSG_vm_create_core(sg_host_t pm, const char* name)
{
smx_actor_t process = SIMIX_process_self();
return (process == nullptr) ? nullptr : process->host_;
}
+
+double sg_host_load(sg_host_t host)
+{
+ return host->get_load();
+}
\ No newline at end of file