ADD_TEST(java-priority ${TESH_COMMAND} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/priority/priority.tesh)
ADD_TEST(java-reservation-surf-plugin ${TESH_COMMAND} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/reservationSurfPlugin/reservation_surf_plugin.tesh)
ADD_TEST(java-startKillTime ${TESH_COMMAND} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/startKillTime/startKillTime.tesh)
+ ADD_TEST(java-surf-cpu-model ${TESH_COMMAND} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/surfCpuModel/surf_cpu_model.tesh)
ADD_TEST(java-surf-plugin ${TESH_COMMAND} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/surfPlugin/surf_plugin.tesh)
ADD_TEST(java-suspend ${TESH_COMMAND} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/suspend/suspend.tesh)
if(HAVE_TRACING)
${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/SurfJNI.java
${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/Plugin.java
${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/Model.java
+ ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/CpuModel.java
${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/Resource.java
${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/Action.java
${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/Cpu.java
${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/NetworkAction.java
${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/RoutingEdge.java
+ ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/TmgrTraceEvent.java
+ ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/TmgrTrace.java
+ #enums
${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/ActionState.java
${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/ResourceState.java
examples/java/priority/CMakeLists.txt
examples/java/reservationSurfPlugin/CMakeLists.txt
examples/java/startKillTime/CMakeLists.txt
+ examples/java/surfCpuModel/CMakeLists.txt
examples/java/surfPlugin/CMakeLists.txt
examples/java/suspend/CMakeLists.txt
examples/java/tracing/CMakeLists.txt
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/priority)
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/reservationSurfPlugin)
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/startKillTime)
+add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/surfCpuModel)
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/surfPlugin)
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/suspend)
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/tracing)
--- /dev/null
+cmake_minimum_required(VERSION 2.6)
+
+set(example java_surf_cpu_model)
+set(sources
+ ${CMAKE_CURRENT_SOURCE_DIR}/TestCpuModel.java
+ ${CMAKE_CURRENT_SOURCE_DIR}/CpuConstantModel.java
+ ${CMAKE_CURRENT_SOURCE_DIR}/Sender.java
+ ${CMAKE_CURRENT_SOURCE_DIR}/Receiver.java
+ )
+
+if(enable_java)
+ add_custom_command(
+ COMMENT "Building ${example}..."
+ OUTPUT ${example}_compiled
+ DEPENDS ${sources} simgrid-java_jar ${SIMGRID_JAR}
+ COMMAND ${JAVA_COMPILE} -classpath ${SIMGRID_JAR}
+ -d ${CMAKE_CURRENT_BINARY_DIR}/.. ${sources}
+ COMMAND ${CMAKE_COMMAND} -E remove ${example}_compiled
+ COMMAND ${CMAKE_COMMAND} -E touch ${example}_compiled
+ )
+ add_custom_target(${example} ALL DEPENDS ${example}_compiled)
+endif()
+
+set(tesh_files
+ ${tesh_files}
+ ${CMAKE_CURRENT_SOURCE_DIR}/surf_cpu_model.tesh
+ PARENT_SCOPE
+ )
+set(xml_files
+ ${xml_files}
+ ${CMAKE_CURRENT_SOURCE_DIR}/surfCpuModelPlatform.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/surfCpuModelDeployment.xml
+ PARENT_SCOPE
+ )
+set(examples_src
+ ${examples_src}
+ ${sources}
+ PARENT_SCOPE
+ )
+set(bin_files
+ ${bin_files}
+ PARENT_SCOPE
+ )
+set(txt_files
+ ${txt_files}
+ PARENT_SCOPE
+ )
--- /dev/null
+package surfCpuModel;
+
+import org.simgrid.surf.*;
+import org.simgrid.msg.Msg;
+import java.util.List;
+import java.util.ArrayList;
+
+public class CpuConstantModel extends CpuModel {
+
+ private List<CpuConstant> cpus = new ArrayList<CpuConstant>();
+ private List<CpuConstantAction> actions = new ArrayList<CpuConstantAction>();
+
+ public CpuConstantModel() {
+ super("Cpu Constant");
+ Msg.info("Initialize Cpu Constant Model");
+ }
+
+ public Cpu createResource(String name, double[] power_peak, int pstate, double power_scale, TmgrTrace power_trace, int core, ResourceState state_initial, TmgrTrace state_trace, XbtDict cpu_properties) {
+ Msg.info("Create Resource Name: "+name);
+ CpuConstant res = new CpuConstant(this, name, cpu_properties, actions, 1, 1000, 1000);
+ cpus.add(res);
+ Surf.setCpu(name, res);
+ return res;
+ }
+
+ public void setState(ResourceState state) {
+ Msg.info("setState");
+ }
+
+ public double shareResources(double now) {
+ Msg.info("shareResource of "+cpus.size()+" cpu and "+actions.size()+" actions");
+ return now+1;
+ }
+
+ public void updateActionsState(double now, double delta) {
+ Msg.info("updateActionState of "+cpus.size()+" cpu and "+actions.size()+" actions");
+ }
+
+ public void addTraces() {
+ }
+
+public class CpuConstant extends Cpu {
+ private List<CpuConstantAction> actions;
+
+ public CpuConstant(CpuConstantModel model, String name, XbtDict props,
+ List<CpuConstantAction> actions,
+ int core, double powerPeak, double powerScale) {
+ super(model, name, props, core, powerPeak, powerScale);
+ this.actions = actions;
+ }
+
+ public CpuAction execute(double size) {
+ CpuConstantAction res = new CpuConstantAction(getModel(), size, false);
+ Msg.info("Execute action of size "+size);
+ actions.add(res);
+ return res;
+ }
+
+ public CpuAction sleep(double duration) {
+ CpuConstantAction res = new CpuConstantAction(getModel(), duration, false);
+ Msg.info("Sleep action of duration "+duration);
+ actions.add(res);
+ return res;
+ }
+
+ public ResourceState getState(){
+ return ResourceState.SURF_RESOURCE_ON;
+ }
+}
+
+public class CpuConstantAction extends CpuAction {
+ public CpuConstantAction(Model model, double cost, boolean failed) {
+ super(model, cost, failed);
+ }
+}
+}
+
--- /dev/null
+/* Copyright (c) 2006-2014. 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 surfCpuModel;
+import org.simgrid.msg.Host;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Task;
+import org.simgrid.msg.Process;
+
+public class Receiver extends Process {
+ public Receiver(Host host, String name, String[]args) {
+ super(host,name,args);
+ }
+ final double commSizeLat = 1;
+ final double commSizeBw = 100000000;
+
+ public void main(String[] args) throws MsgException {
+
+ Msg.info("helloo!");
+
+ Task task;
+ task = Task.receive(getHost().getName());
+ task = Task.receive(getHost().getName());
+ task = Task.receive(getHost().getName());
+
+ Msg.info("goodbye!");
+ }
+}
--- /dev/null
+/* Copyright (c) 2006-2014. 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 surfCpuModel;
+import org.simgrid.msg.Host;
+import org.simgrid.msg.HostNotFoundException;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Process;
+import org.simgrid.msg.Task;
+
+public class Sender extends Process {
+ public Sender(Host host, String name, String[] args) {
+ super(host,name,args);
+ }
+ private final double commSizeLat = 1;
+ final double commSizeBw = 100000000;
+
+ public void main(String[] args) throws MsgException {
+
+ Msg.info("helloo!");
+
+ String receiverName = args[0];
+ double oldTime, curTime;
+ double computeDuration = 10000;
+ Task task;
+
+ oldTime = Msg.getClock();
+ task = new Task("no name",computeDuration,commSizeLat);
+ task.send(receiverName);
+ curTime = Msg.getClock();
+ Msg.info("Send duration: " + (curTime - oldTime));
+
+ oldTime = curTime;
+ task = new Task("no name",computeDuration,commSizeLat);
+ task.send(receiverName);
+ curTime = Msg.getClock();
+ Msg.info("Send duration with update bandwidth: " + (curTime - oldTime));
+
+ oldTime = curTime;
+ task = new Task("no name",computeDuration,commSizeLat);
+ task.send(receiverName);
+ curTime = Msg.getClock();
+ Msg.info("Send normal duration with limited bandwidth: " + (curTime - oldTime));
+
+ Msg.info("goodbye!");
+ }
+}
--- /dev/null
+/* Copyright (c) 2006-2014. 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 surfCpuModel;
+
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.NativeException;
+import org.simgrid.surf.Surf;
+import org.simgrid.surf.Cpu;
+import org.simgrid.surf.CpuModel;
+
+public class TestCpuModel {
+
+ /* This only contains the launcher. If you do nothing more than than you can run
+ * java simgrid.msg.Msg
+ * which also contains such a launcher
+ */
+
+ public static void main(String[] args) throws NativeException {
+ /* initialize the MSG simulation. Must be done before anything else (even logging). */
+ CpuModel cm = new CpuConstantModel();
+ Surf.setCpuModel(cm);
+ //Msg.info(Surf.getCpuModel().getName());
+ //Msg.info(cm.getName());
+ Msg.init(args);
+ //Msg.info("Cpu Loaded: "+Surf.getCpuModel().getName());
+
+ if(args.length < 2) {
+ Msg.info("Usage : TestPlugin platform_file deployment_file");
+ Msg.info("example : TestPlugin ping_pong_platform.xml ping_pong_deployment.xml");
+ System.exit(1);
+ }
+
+ /* construct the platform and deploy the application */
+ Msg.createEnvironment(args[0]);
+ Msg.deployApplication(args[1]);
+ //Msg.info("Cpu Loaded: "+Surf.getCpuModel().getName());
+ //Msg.info("Cpu Loaded: "+cm.getName());
+
+ // getName());
+ /* execute the simulation. */
+ Msg.run();
+ }
+}
--- /dev/null
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+ <process host="Jacquelin" function="surfCpuModel.Sender">
+ <argument value="Boivin"/>
+ </process>
+<process host="Boivin" function="surfCpuModel.Receiver"/>
+</platform>
--- /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="Jacquelin" power="137.333Mf"/>
+ <host id="Boivin" power="98.095Mf"/>
+ <host id="TeX" power="68.667Mf"/>
+ <link id="link0" bandwidth="1MBps" latency="1ms"/>
+ <link id="link1" bandwidth="1MBps" latency="1ms"/>
+ <link id="link2" bandwidth="1MBps" latency="1ms"/>
+ <route src="Jacquelin" dst="Boivin">
+ <link_ctn id="link0"/>
+ <link_ctn id="link1"/>
+ </route>
+ <route src="Jacquelin" dst="TeX">
+ <link_ctn id="link0"/>
+ <link_ctn id="link2"/>
+ </route>
+
+ </AS>
+ </platform>
--- /dev/null
+#! tesh
+
+$ java -classpath ${classpath:=.} surfCpuModel/TestCpuModel ${srcdir:=.}/surfCpuModel/surfCpuModelPlatform.xml ${srcdir:=.}/surfCpuModel/surfCpuModelDeployment.xml --cfg=workstation/model:compound
+> [0.000000] [jmsg/INFO] Initialize Cpu Constant Model
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'workstation/model' to 'compound'
+> [0.000000] [jmsg/INFO] Using regular java threads. Coroutines could speed your simulation up.
+> [0.000000] [jmsg/INFO] Create Resource Name: Jacquelin
+> [0.000000] [jmsg/INFO] Create Resource Name: Boivin
+> [0.000000] [jmsg/INFO] Create Resource Name: TeX
+> [0.000000] [jmsg/INFO] updateActionState of 3 cpu and 0 actions
+> [Jacquelin:surfCpuModel.Sender:(1) 0.000000] [jmsg/INFO] helloo!
+> [Boivin:surfCpuModel.Receiver:(2) 0.000000] [jmsg/INFO] helloo!
+> [0.000000] [jmsg/INFO] Sleep action of duration -1.0
+> [0.000000] [jmsg/INFO] Sleep action of duration -1.0
+> [0.000000] [jmsg/INFO] shareResource of 3 cpu and 2 actions
+> [0.000000] [jmsg/INFO] shareResource of 3 cpu and 2 actions
+> [0.026020] [jmsg/INFO] updateActionState of 3 cpu and 2 actions
+> [0.026020] [jmsg/INFO] shareResource of 3 cpu and 2 actions
+> [0.026020] [jmsg/INFO] shareResource of 3 cpu and 2 actions
+> [0.026021] [jmsg/INFO] updateActionState of 3 cpu and 2 actions
+> [Jacquelin:surfCpuModel.Sender:(1) 0.026021] [jmsg/INFO] Send duration: 0.026021030927835052
+> [0.026021] [jmsg/INFO] Sleep action of duration -1.0
+> [0.026021] [jmsg/INFO] Sleep action of duration -1.0
+> [0.026021] [jmsg/INFO] shareResource of 3 cpu and 4 actions
+> [0.026021] [jmsg/INFO] shareResource of 3 cpu and 4 actions
+> [0.052041] [jmsg/INFO] updateActionState of 3 cpu and 4 actions
+> [0.052041] [jmsg/INFO] shareResource of 3 cpu and 4 actions
+> [0.052041] [jmsg/INFO] shareResource of 3 cpu and 4 actions
+> [0.052042] [jmsg/INFO] updateActionState of 3 cpu and 4 actions
+> [Jacquelin:surfCpuModel.Sender:(1) 0.052042] [jmsg/INFO] Send duration with update bandwidth: 0.026021030927835052
+> [0.052042] [jmsg/INFO] Sleep action of duration -1.0
+> [0.052042] [jmsg/INFO] Sleep action of duration -1.0
+> [0.052042] [jmsg/INFO] shareResource of 3 cpu and 6 actions
+> [0.052042] [jmsg/INFO] shareResource of 3 cpu and 6 actions
+> [0.078062] [jmsg/INFO] updateActionState of 3 cpu and 6 actions
+> [0.078062] [jmsg/INFO] shareResource of 3 cpu and 6 actions
+> [0.078062] [jmsg/INFO] shareResource of 3 cpu and 6 actions
+> [0.078063] [jmsg/INFO] updateActionState of 3 cpu and 6 actions
+> [Boivin:surfCpuModel.Receiver:(2) 0.078063] [jmsg/INFO] goodbye!
+> [Jacquelin:surfCpuModel.Sender:(1) 0.078063] [jmsg/INFO] Send normal duration with limited bandwidth: 0.02602103092783506
+> [Jacquelin:surfCpuModel.Sender:(1) 0.078063] [jmsg/INFO] goodbye!
+> [0.078063] [jmsg/INFO] MSG_main finished; Cleaning up the simulation...
%module(directors="1") Surf
%include "arrays_java.i"
+%include "std_string.i"
%pragma(java) jniclassimports=%{
import org.simgrid.NativeLib;
%{
#include "src/surf/cpu_interface.hpp"
#include "src/surf/network_interface.hpp"
+#include "src/surf/trace_mgr_private.h"
#include "src/bindings/java/surf_swig.hpp"
#include "src/xbt/dict_private.h"
typedef struct lmm_constraint *lmm_constraint_t;
+typedef xbt_dynar_t DoubleDynar;
+/*class CpuModel : public CpuModel {
+
+};*/
%}
/* Handle xbt_dynar_t of NetworkLink */
xbt_dynar_free(&$1);
}
+/*%typemap(out) DoubleDynar {
+ $result = (double[])$1;
+}*/
+
+//typedef xbt_dynar_t DoubleDynar;
+%nodefault DoubleDynar;
+%typemap(jni) DoubleDynar "jdoubleArray"
+%rename(DoubleDynar) Double[];
+%typemap(jtype) DoubleDynar "double[]"
+%typemap(jstype) DoubleDynar "double[]"
+%typemap(out) DoubleDynar {
+ long l = xbt_dynar_length($1);
+ $result = jenv->NewDoubleArray(l);
+ double *lout = (double *)xbt_dynar_to_array($1);
+ jenv->SetDoubleArrayRegion($result, 0, l, (const jdouble*)lout);
+ free(lout);
+}
+%typemap(javadirectorin) DoubleDynar "$jniinput"
+%typemap(directorin,descriptor="[D") DoubleDynar %{
+ long l = xbt_dynar_length($1);
+ $input = jenv->NewDoubleArray(l);
+ double *lout = (double *)xbt_dynar_to_array($1);
+ jenv->SetDoubleArrayRegion($input, 0, l, (const jdouble*)lout);
+ free(lout);
+%}
+%typemap(javain) DoubleDynar "$javainput"
+%typemap(javaout) DoubleDynar {return $jnicall}
+
/* Allow to subclass Plugin and send java object to C++ code */
%feature("director") Plugin;
%include "src/bindings/java/surf_swig.hpp"
+%rename tmgr_trace TmgrTrace;
+%nodefaultctor tmgr_trace;
+struct tmgr_trace {
+ //enum e_trace_type type;
+ /*union {
+ struct {
+ xbt_dynar_t event_list;
+ } s_list;
+ struct {
+ probabilist_event_generator_t event_generator[2];
+ int is_state_trace;
+ int next_event;
+ } s_probabilist;
+ };*/
+ %extend {
+ }
+};
+
+%rename tmgr_trace_event TmgrTraceEvent;
+%nodefaultctor tmgr_trace_event;
+struct tmgr_trace_event {
+ //tmgr_trace_t trace;
+ //unsigned int idx;
+ //void *model;
+ //int free_me;
+ %extend {
+ unsigned int getIdx() {return 0;}//$self->idx;}
+ }
+};
+
+
%nodefaultctor Model;
class Model {
public:
+ Model(const char *name);
const char *getName();
+ virtual double shareResources(double now);
+ virtual double shareResourcesLazy(double now);
+ virtual double shareResourcesFull(double now);
+
+ virtual void updateActionsState(double now, double delta);
+ virtual void updateActionsStateLazy(double now, double delta);
+ virtual void updateActionsStateFull(double now, double delta);
};
+%feature("director") CpuModel;
+class CpuModel : public Model {
+public:
+ CpuModel(const char *name);
+ virtual ~CpuModel();
+ virtual Cpu *createResource(const char *name, DoubleDynar power_peak,
+ int pstate, double power_scale,
+ tmgr_trace *power_trace, int core,
+ e_surf_resource_state_t state_initial,
+ tmgr_trace *state_trace,
+ s_xbt_dict *cpu_properties)=0;
+ void setState(e_surf_resource_state_t state);
+ virtual void addTraces()=0;
+};
+
+
class Resource {
public:
Resource();
const char *getName();
virtual bool isUsed()=0;
+ Model *getModel();
+
+ virtual e_surf_resource_state_t getState();
lmm_constraint *getConstraint();
s_xbt_dict *getProperties();
+ virtual void updateState(tmgr_trace_event *event_type, double value, double date)=0;
};
+%feature("director") Cpu;
class Cpu : public Resource {
public:
- Cpu();
- ~Cpu();
- double getCurrentPowerPeak();
+ Cpu(Model *model, const char *name, s_xbt_dict *props,
+ lmm_constraint *constraint, int core, double powerPeak, double powerScale);
+ Cpu(Model *model, const char *name, s_xbt_dict *props,
+ int core, double powerPeak, double powerScale);
+ virtual ~Cpu();
+ virtual double getCurrentPowerPeak()=0;
+ virtual CpuAction *execute(double size)=0;
+ virtual CpuAction *sleep(double duration)=0;
+ virtual int getCore();
+ virtual double getSpeed(double load);
+ virtual double getAvailableSpeed();
+ virtual double getPowerPeakAt(int pstate_index)=0;
+ virtual int getNbPstates()=0;
+ virtual void setPowerPeakAt(int pstate_index)=0;
+ void setState(e_surf_resource_state_t state);
};
class NetworkLink : public Resource {
};
%nodefaultctor CpuAction;
+%feature("director") CpuAction;
class CpuAction : public Action {
public:
+CpuAction(Model *model, double cost, bool failed);
%extend {
Cpu *getCpu() {return getActionCpu($self);}
}
}
};
+
%nodefaultctor RoutingEdge;
class RoutingEdge {
public:
#include "surf_swig.hpp"
#include "src/simix/smx_private.h"
-
double getClock() {
return surf_get_clock();
}
SIMIX_clean();
}
-/*NetworkModel *getNetworkModel()
-{
- return surf_network_model;
-}*/
+CpuModel *getCpuModel(){
+ return surf_cpu_model_pm;
+}
+
+CpuModel *java_cpu_model;
+static void java_cpu_model_init_preparse() {
+ surf_cpu_model_pm = java_cpu_model;
+ xbt_dynar_push(model_list, &java_cpu_model);
+ xbt_dynar_push(model_list_invoke, &java_cpu_model);
+ sg_platf_host_add_cb(parse_cpu_init);
+}
+
+void setCpuModel(CpuModel *cpuModel){
+ java_cpu_model = cpuModel;
+ surf_cpu_model_init_preparse = java_cpu_model_init_preparse;
+}
+
+void setCpu(char *name, Cpu *cpu) {
+ xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
+}
NetworkLinkDynar getRoute(char *srcName, char *dstName) {
RoutingEdge *src = (RoutingEdge*)xbt_lib_get_or_null(host_lib, srcName, ROUTING_HOST_LEVEL);
#include "src/surf/maxmin_private.hpp"
typedef xbt_dynar_t NetworkLinkDynar;
-
double getClock();
void clean();
+CpuModel *getCpuModel();
+void setCpuModel(CpuModel *cpuModel);
+
+void setCpu(char *name, Cpu *cpu);
+
+
NetworkLinkDynar getRoute(char *srcName, char *dstName);
class Plugin {
typedef NetworkCm02Link *surf_network_link_t;
typedef Cpu *surf_cpu_t;
-/** @ingroup SURF_c_bindings
+/** @ingroup SURF_c_bindings
* \brief Action structure
*
* Never create s_surf_action_t by yourself ! The actions are created
} e_surf_action_state_t;
/** @ingroup SURF_vm_interface
- *
- *
+ *
+ *
*/
/* FIXME: Where should the VM state be defined? */
typedef enum {
/** @{ @ingroup SURF_c_bindings */
-/**
+/**
* @brief Get the name of a surf model
- *
+ *
* @param model A model
* @return The name of the model
*/
/**
* @brief Pop an action from the done actions set
- *
+ *
* @param model The model from which the action is extracted
* @return An action in done state
*/
/**
* @brief Pop an action from the failed actions set
- *
+ *
* @param model The model from which the action is extracted
* @return An action in failed state
*/
/**
* @brief Pop an action from the ready actions set
- *
+ *
* @param model The model from which the action is extracted
* @return An action in ready state
*/
/**
* @brief Pop an action from the running actions set
- *
+ *
* @param model The model from which the action is extracted
* @return An action in running state
*/
/**
* @brief Get the size of the running action set of a model
- *
+ *
* @param model The model
* @return The size of the running action set
*/
/**
* @brief Execute a parallel task
* @details [long description]
- *
+ *
* @param model The model which handle the parallelisation
- * @param workstation_nb The number of workstations
+ * @param workstation_nb The number of workstations
* @param workstation_list The list of workstations on which the task is executed
* @param computation_amount The processing amount (in flop) needed to process
* @param communication_amount The amount of data (in bytes) needed to transfer
/**
* @brief Create a communication between two hosts
- *
+ *
* @param model The model which handle the communication
* @param src The source host
* @param dst The destination host
/**
* @brief Get the route between two hosts
* @details [long description]
- *
+ *
* @param model The model which handle the routes
* @param src The source host
* @param dst The destination host
/**
* @brief Create a new VM on the specified host
- *
+ *
* @param name The name of the workstation
* @param ind_phys_host The host on which the VM is created
*/
/**
* @brief Create a communication between two routing edges [TODO]
* @details [long description]
- *
+ *
* @param model The model which handle the communication
* @param src The source host
* @param dst The destination host
/**
* @brief Get the name of a surf resource (cpu, workstation, network, …)
- *
+ *
* @param resource The surf resource
* @return The name of the surf resource
*/
/**
* @brief Get the properties of a surf resource (cpu, workstation, network, …)
- *
+ *
* @param resource The surf resource
* @return The properties of the surf resource
*/
/**
* @brief Get the state of a surf resource (cpu, workstation, network, …)
- *
+ *
* @param resource The surf resource
* @return The state of the surf resource
*/
/**
* @brief Set the state of a surf resource (cpu, workstation, network, …)
- *
+ *
* @param resource The surf resource
* @param state The new state of the surf resource
*/
/**
* @brief Get the speed of the cpu associtated to a workstation
- *
+ *
* @param resource The surf workstation
* @param load [description]
- *
+ *
* @return [description]
*/
XBT_PUBLIC(double) surf_workstation_get_speed(surf_resource_t resource, double load);
/**
* @brief Get the available speed of cpu associtated to a workstation
- *
+ *
* @param resource The surf workstation
* @return [description]
*/
/**
* @brief Get the number of cores of the cpu associated to a workstation
- *
+ *
* @param resource The surf workstation
* @return The number of cores
*/
*
* @param resource The surf workstation
* @param size The value of the processing amount (in flop) needed to process
- *
+ *
* @return The surf action corresponding to the processing
*/
XBT_PUBLIC(surf_action_t) surf_workstation_execute(surf_resource_t resource, double size);
/**
* @brief Make the workstation sleep
- *
+ *
* @param resource The surf workstation
* @param duration The number of seconds to sleep
* @return The surf action corresponding to the sleep
/**
* @brief Open a file on a workstation
- *
+ *
* @param workstation The surf workstation
* @param fullpath The path to the file
* @return The surf action corresponding to the openning
/**
* @brief Close a file descriptor on a workstation
- *
+ *
* @param workstation The surf workstation
* @param fd The file descriptor
- *
+ *
* @return The surf action corresponding to the closing
*/
XBT_PUBLIC(surf_action_t) surf_workstation_close(surf_resource_t workstation, surf_file_t fd);
/**
* @brief Read a file
- *
+ *
* @param resource The surf workstation
* @param fd The file descriptor to read
* @param size The size in bytes to read
/**
* @brief Write a file
- *
+ *
* @param resource The surf workstation
* @param fd The file descriptor to write
* @param size The size in bytes to write
* - the storage name,
* - the storage typeId,
* - the storage content type
- *
+ *
* @param resource The surf workstation
* @param fd The file descriptor
* @return An xbt_dynar_t with the file informations
/**
* @brief Get the available space of the storage at the mount point
- *
+ *
* @param resource The surf workstation
* @param name The mount point
* @return The amount of availble space in bytes
/**
* @brief Get the used space of the storage at the mount point
- *
+ *
* @param resource The surf workstation
* @param name The mount point
* @return The amount of used space in bytes
/**
* @brief Get the VMs hosted on the workstation
- *
+ *
* @param resource The surf workstation
* @return The list of VMs on the workstation
*/
/**
* @brief [brief description]
* @details [long description]
- *
+ *
* @param resource [description]
* @param params [description]
*/
/**
* @brief [brief description]
* @details [long description]
- *
+ *
* @param resource [description]
* @param params [description]
*/
/**
* @brief Destroy a Workstation VM
- *
+ *
* @param resource The surf workstation vm
*/
XBT_PUBLIC(void) surf_vm_workstation_destroy(surf_resource_t resource);
/**
* @brief Suspend a Workstation VM
- *
+ *
* @param resource The surf workstation vm
*/
XBT_PUBLIC(void) surf_vm_workstation_suspend(surf_resource_t resource);
/**
* @brief Resume a Workstation VM
- *
+ *
* @param resource The surf workstation vm
*/
XBT_PUBLIC(void) surf_vm_workstation_resume(surf_resource_t resource);
/**
* @brief Save the Workstation VM (Not yet implemented)
- *
+ *
* @param resource The surf workstation vm
*/
XBT_PUBLIC(void) surf_vm_workstation_save(surf_resource_t resource);
/**
* @brief Restore the Workstation VM (Not yet implemented)
- *
+ *
* @param resource The surf workstation vm
*/
XBT_PUBLIC(void) surf_vm_workstation_restore(surf_resource_t resource);
/**
* @brief Migrate the VM to the destination host
- *
+ *
* @param resource The surf workstation vm
* @param ind_vm_ws_dest The destination host
*/
/**
* @brief Get the physical machine hosting the VM
- *
+ *
* @param resource The surf workstation vm
* @return The physical machine hosting the VM
*/
/**
* @brief [brief description]
* @details [long description]
- *
+ *
* @param resource [description]
* @param bound [description]
*/
/**
* @brief [brief description]
* @details [long description]
- *
+ *
* @param resource [description]
* @param cpu [description]
* @param mask [description]
/**
* @brief Execute some quantity of computation
- *
+ *
* @param cpu The surf cpu
* @param size The value of the processing amount (in flop) needed to process
* @return The surf action corresponding to the processing
/**
* @brief Make the cpu sleep for duration (in seconds)
* @details [long description]
- *
+ *
* @param cpu The surf cpu
* @param duration The number of seconds to sleep
* @return The surf action corresponding to the sleeping
/**
* @brief Get the workstation power peak
* @details [long description]
- *
+ *
* @param host The surf workstation
* @return The power peak
*/
/**
* @brief [brief description]
* @details [long description]
- *
+ *
* @param host [description]
* @param pstate_index [description]
- *
+ *
* @return [description]
*/
XBT_PUBLIC(double) surf_workstation_get_power_peak_at(surf_resource_t host, int pstate_index);
/**
* @brief [brief description]
* @details [long description]
- *
+ *
* @param host [description]
* @return [description]
*/
/**
* @brief [brief description]
* @details [long description]
- *
+ *
* @param host [description]
* @param pstate_index [description]
*/
/**
* @brief Get the consumed energy (in joules) of a workstation
- *
+ *
* @param host The surf workstation
* @return The consumed energy
*/
/**
* @brief Get the list of storages mounted on a workstation
- *
+ *
* @param workstation The surf workstation
* @return Dictionary of mount point, Storage
*/
/**
* @brief Unlink a file descriptor
- *
+ *
* @param workstation The surf workstation
* @param fd The file descriptor
- *
+ *
* @return 0 if failed to unlink, 1 otherwise
*/
XBT_PUBLIC(int) surf_workstation_unlink(surf_resource_t workstation, surf_file_t fd);
/**
* @brief Get the size of a file on a workstation
- *
+ *
* @param workstation The surf workstation
* @param fd The file descriptor
- *
+ *
* @return The size in bytes of the file
*/
XBT_PUBLIC(size_t) surf_workstation_get_size(surf_resource_t workstation, surf_file_t fd);
/**
* @brief Get the current position of the file descriptor
- *
+ *
* @param workstation The surf workstation
* @param fd The file descriptor
* @return The current position of the file descriptor
/**
* @brief Set the position indictator assiociated with the file descriptor to a new position
* @details [long description]
- *
+ *
* @param workstation The surf workstation
* @param fd The file descriptor
* @param offset The offset from the origin
/**
* @brief [brief description]
* @details [long description]
- *
+ *
* @param link [description]
* @return [description]
*/
/**
* @brief Get the bandwidth of a link in bytes per second
- *
+ *
* @param link The surf link
* @return The bandwidth in bytes per second
*/
/**
* @brief Get the latency of a link in seconds
- *
+ *
* @param link The surf link
* @return The latency in seconds
*/
/**
* @brief Get the content of a storage
- *
+ *
* @param resource The surf storage
* @return A xbt_dict_t with path as keys and size in bytes as values
*/
/**
* @brief Get the size in bytes of a storage
- *
+ *
* @param resource The surf storage
* @return The size in bytes of the storage
*/
/**
* @brief Get the data associated to the action
- *
+ *
* @param action The surf action
* @return The data associated to the action
*/
/**
* @brief Set the data associated to the action
* @details [long description]
- *
+ *
* @param action The surf action
* @param data The new data associated to the action
*/
/**
* @brief Unreference an action
- *
+ *
* @param action The surf action
*/
XBT_PUBLIC(void) surf_action_unref(surf_action_t action);
/**
* @brief Get the start time of an action
- *
+ *
* @param action The surf action
* @return The start time in seconds from the beginning of the simulation
*/
/**
* @brief Get the finish time of an action
- *
+ *
* @param action The surf action
* @return The finish time in seconds from the beginning of the simulation
*/
/**
* @brief Get the remains amount of work to do of an action
- *
+ *
* @param action The surf action
* @return The remains amount of work to do
*/
/**
* @brief Suspend an action
- *
+ *
* @param action The surf action
*/
XBT_PUBLIC(void) surf_action_suspend(surf_action_t action);
/**
* @brief Resume an action
- *
+ *
* @param action The surf action
*/
XBT_PUBLIC(void) surf_action_resume(surf_action_t action);
/**
* @brief Cancel an action
- *
+ *
* @param action The surf action
*/
XBT_PUBLIC(void) surf_action_cancel(surf_action_t action);
/**
* @brief Set the priority of an action
* @details [long description]
- *
+ *
* @param action The surf action
* @param priority The new priority [TODO]
*/
/**
* @brief Set the category of an action
* @details [long description]
- *
+ *
* @param action The surf action
* @param category The new category of the action
*/
XBT_PUBLIC(void) surf_action_set_category(surf_action_t action, const char *category);
/**
- * @brief Get the state of an action
- *
+ * @brief Get the state of an action
+ *
* @param action The surf action
* @return The state of the action
*/
/**
* @brief Get the cost of an action
- *
+ *
* @param action The surf action
* @return The cost of the action
*/
/**
* @brief [brief desrciption]
* @details [long description]
- *
+ *
* @param action The surf cpu action
* @param cpu [description]
* @param mask [description]
/**
* @brief [brief description]
* @details [long description]
- *
+ *
* @param action The surf cpu action
* @param bound [description]
*/
/**
* @brief Get the file associated to a storage action
- *
+ *
* @param action The surf storage action
* @return The file associated to a storage action
*/
/**
* @brief Get the result dictionary of an ls action
- *
+ *
* @param action The surf storage action
* @return The dictionry listing a path
*/
/* Implementations of model object */
/**************************************/
+XBT_PUBLIC_DATA(int) autoload_surf_cpu_model;
+extern void_f_void_t surf_cpu_model_init_preparse;
+
/** \ingroup SURF_models
* \brief The CPU model object for the physical machine layer
*/
/*******************************************/
/*** SURF Platform *************************/
/*******************************************/
-XBT_PUBLIC_DATA(AS_t) surf_AS_get_routing_root(void);
+XBT_PUBLIC_DATA(AS_t) surf_AS_get_routing_root(void);
XBT_PUBLIC_DATA(const char *) surf_AS_get_name(AS_t as);
XBT_PUBLIC_DATA(xbt_dict_t) surf_AS_get_routing_sons(AS_t as);
XBT_PUBLIC_DATA(const char *) surf_AS_get_model(AS_t as);
*
* This function has to be called to initialize the common
* structures. Then you will have to create the environment by
- * calling
+ * calling
* e.g. surf_workstation_model_init_CM02()
*
* \see surf_workstation_model_init_CM02(), surf_workstation_model_init_compound(), surf_exit()
xbt_assert(network_model_name,
"Set a network model to use with the 'compound' workstation model");
+ if(surf_cpu_model_init_preparse){
+ surf_cpu_model_init_preparse();
+ } else {
+ cpu_id =
+ find_model_description(surf_cpu_model_description, cpu_model_name);
+ surf_cpu_model_description[cpu_id].model_init_preparse();
+ }
+
network_id =
find_model_description(surf_network_model_description,
network_model_name);
- cpu_id =
- find_model_description(surf_cpu_model_description, cpu_model_name);
-
- surf_cpu_model_description[cpu_id].model_init_preparse();
surf_network_model_description[network_id].model_init_preparse();
}
* CallBacks *
*************/
-static void parse_cpu_init(sg_platf_host_cbarg_t host){
- ((CpuCas01ModelPtr)surf_cpu_model_pm)->parseInit(host);
-}
-
-static void cpu_add_traces_cpu(){
- surf_cpu_model_pm->addTraces();
-}
-
static void cpu_define_callbacks()
{
sg_platf_host_add_cb(parse_cpu_init);
- sg_platf_postparse_add_cb(cpu_add_traces_cpu);
+ sg_platf_postparse_add_cb(add_traces_cpu);
}
/*********
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu, surf,
"Logging specific to the SURF cpu module");
+int autoload_surf_cpu_model = 1;
+void_f_void_t surf_cpu_model_init_preparse = NULL;
+
CpuModelPtr surf_cpu_model_pm;
CpuModelPtr surf_cpu_model_vm;
-
/*************
* Callbacks *
*************/
surf_callback(void, CpuPtr, e_surf_resource_state_t, e_surf_resource_state_t) cpuStateChangedCallbacks;
surf_callback(void, CpuActionPtr, e_surf_action_state_t, e_surf_action_state_t) cpuActionStateChangedCallbacks;
+void parse_cpu_init(sg_platf_host_cbarg_t host){
+ surf_cpu_model_pm->parseInit(host);
+}
+
+void add_traces_cpu(){
+ surf_cpu_model_pm->addTraces();
+}
+
/*********
* Model *
*********/
+void CpuModel::parseInit(sg_platf_host_cbarg_t host)
+{
+ createResource(host->id,
+ host->power_peak,
+ host->pstate,
+ host->power_scale,
+ host->power_trace,
+ host->core_amount,
+ host->initial_state,
+ host->state_trace,
+ host->properties);
+}
void CpuModel::updateActionsStateLazy(double now, double /*delta*/)
{
*/
XBT_PUBLIC_DATA( surf_callback(void, CpuActionPtr, e_surf_action_state_t, e_surf_action_state_t)) cpuActionStateChangedCallbacks;
+void parse_cpu_init(sg_platf_host_cbarg_t host);
+
+void add_traces_cpu();
+
/*********
* Model *
*********/
*
* @return The created Cpu
*/
- CpuPtr createResource(string name);
-
+ void parseInit(sg_platf_host_cbarg_t host);
+
+ virtual CpuPtr createResource(const char *name, xbt_dynar_t power_peak,
+ int pstate, double power_scale,
+ tmgr_trace_t power_trace, int core,
+ e_surf_resource_state_t state_initial,
+ tmgr_trace_t state_trace,
+ xbt_dict_t cpu_properties)=0;
void setState(e_surf_resource_state_t state);
void updateActionsStateLazy(double now, double delta);
/**
* \brief Auxiliary function to calculate the integral between a and b.
- * It simply calculates the integral at point a and b and returns the difference
+ * It simply calculates the integral at point a and b and returns the difference
* between them.
* \param trace Trace structure
* \param a Initial point
* It returns the date when the requested amount of flops is available
* \param trace Trace structure
* \param a Initial point
- * \param amount Amount of flops
+ * \param amount Amount of flops
* \return The date when amount is available.
*/
double CpuTiTrace::solveSimple(double a, double amount)
/**
* \brief Binary search in array.
- * It returns the first point of the interval in which "a" is.
+ * It returns the first point of the interval in which "a" is.
* \param array Array
* \param a Value to search
* \param low Low bound to search in array
* CallBacks *
*************/
-static void parse_cpu_ti_init(sg_platf_host_cbarg_t host){
- ((CpuTiModelPtr)surf_cpu_model_pm)->parseInit(host);
-}
-
-static void add_traces_cpu_ti(){
- surf_cpu_model_pm->addTraces();
-}
-
static void cpu_ti_define_callbacks()
{
- sg_platf_host_add_cb(parse_cpu_ti_init);
- sg_platf_postparse_add_cb(add_traces_cpu_ti);
+ sg_platf_host_add_cb(parse_cpu_init);
+ sg_platf_postparse_add_cb(add_traces_cpu);
}
/*********
xbt_heap_free(p_tiActionHeap);
}
-void CpuTiModel::parseInit(sg_platf_host_cbarg_t host)
-{
- createResource(host->id,
- host->power_peak,
- host->pstate,
- host->power_scale,
- host->power_trace,
- host->core_amount,
- host->initial_state,
- host->state_trace,
- host->properties);
-}
-
-CpuTiPtr CpuTiModel::createResource(const char *name,
+CpuPtr CpuTiModel::createResource(const char *name,
xbt_dynar_t powerPeak,
int pstate,
double powerScale,
setState(stateInitial);
m_powerScale = powerScale;
m_core = core;
- tmgr_trace_t empty_trace;
- s_tmgr_event_t val;
+ tmgr_trace_t empty_trace;
+ s_tmgr_event_t val;
xbt_assert(core==1,"Multi-core not handled with this model yet");
XBT_DEBUG("power scale %f", powerScale);
p_availTrace = new CpuTiTgmr(powerTrace, powerScale);
if (stateTrace)
p_stateEvent = tmgr_history_add_trace(history, stateTrace, 0.0, 0, static_cast<ResourcePtr>(this));
if (powerTrace && xbt_dynar_length(powerTrace->s_list.event_list) > 1) {
- // add a fake trace event if periodicity == 0
+ // add a fake trace event if periodicity == 0
xbt_dynar_get_cpy(powerTrace->s_list.event_list,
xbt_dynar_length(powerTrace->s_list.event_list) - 1, &val);
if (val.delta == 0) {
void CpuTiAction::setState(e_surf_action_state_t state)
{
- Action::setState(state);
+ CpuAction::setState(state);
xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(getModel())->p_modifiedCpu);
}
};
enum trace_type {
-
+
TRACE_FIXED, /*< Trace fixed, no availability file */
TRACE_DYNAMIC /*< Dynamic, availability file disponible */
};
~CpuTiModel();
void parseInit(sg_platf_host_cbarg_t host);
- CpuTiPtr createResource(const char *name, xbt_dynar_t powerPeak,
+ CpuPtr createResource(const char *name, xbt_dynar_t powerPeak,
int pstate, double power_scale,
tmgr_trace_t power_trace, int core,
e_surf_resource_state_t state_initial,
xbt_dict_t properties) ;
~CpuTi();
- void updateState(tmgr_trace_event_t event_type, double value, double date);
+ void updateState(tmgr_trace_event_t event_type, double value, double date);
void updateActionsFinishTime(double now);
bool isUsed();
void printCpuTiModel();
return route;
}
-ResourcePtr CpuL07Model::createResource(const char *name, double power_scale,
- double power_initial,
- tmgr_trace_t power_trace,
- e_surf_resource_state_t state_initial,
- tmgr_trace_t state_trace,
- xbt_dict_t cpu_properties)
+CpuPtr CpuL07Model::createResource(const char *name, xbt_dynar_t powerPeak,
+ int pstate, double power_scale,
+ tmgr_trace_t power_trace, int core,
+ e_surf_resource_state_t state_initial,
+ tmgr_trace_t state_trace,
+ xbt_dict_t cpu_properties)
{
+ double power_initial = xbt_dynar_get_as(powerPeak, pstate, double);
+
xbt_assert(!surf_workstation_resource_priv(surf_workstation_resource_by_name(name)),
"Host '%s' declared several times in the platform file.",
name);
CpuL07Ptr cpu = new CpuL07(this, name, cpu_properties,
- power_scale, power_initial, power_trace,state_initial, state_trace);
+ power_initial, power_scale, power_trace,state_initial, state_trace);
xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, static_cast<ResourcePtr>(cpu));
host->properties);
}
-static void ptask_parse_cpu_init(sg_platf_host_cbarg_t host)
-{
- double power_peak = xbt_dynar_get_as(host->power_peak, host->pstate, double);
- static_cast<CpuL07ModelPtr>(surf_cpu_model_pm)->createResource(
- host->id,
- power_peak,
- host->power_scale,
- host->power_trace,
- host->initial_state,
- host->state_trace,
- host->properties);
-}
-
-
-
static void ptask_parse_link_init(sg_platf_link_cbarg_t link)
{
if (link->policy == SURF_LINK_FULLDUPLEX) {
static void ptask_define_callbacks()
{
- sg_platf_host_add_cb(ptask_parse_cpu_init);
+ sg_platf_host_add_cb(parse_cpu_init);
sg_platf_host_add_cb(ptask_parse_workstation_init);
sg_platf_link_add_cb(ptask_parse_link_init);
sg_platf_postparse_add_cb(ptask_add_traces);
e_surf_resource_state_t state_initial,
tmgr_trace_t state_trace,
xbt_dict_t cpu_properties);
+ CpuPtr createResource(const char *name, xbt_dynar_t powerPeak,
+ int pstate, double power_scale,
+ tmgr_trace_t power_trace, int core,
+ e_surf_resource_state_t state_initial,
+ tmgr_trace_t state_trace,
+ xbt_dict_t cpu_properties);
void addTraces() {DIE_IMPOSSIBLE;};
WorkstationL07ModelPtr p_workstationModel;
if (parse_cmdline(&timings, &downgrade, &platformFile, argc, argv) || !platformFile) {
xbt_die("Invalid command line arguments: expected [--timings|--downgrade] platformFile");
}
-
+
XBT_DEBUG("%d,%d,%s", timings, downgrade, platformFile);
if (downgrade) {