From 0236bbc683363a58fdef428ce7de140909de5db1 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 17 Dec 2015 23:04:03 +0100 Subject: [PATCH] not all resources need a property set, only Host, Link and Storage So dupplicate the property-related code in these classes, and remove it from Resource. We may want to refactorize this code in a specific class, but I'm not confident with multiple inheritance yet. The reason of fixing that working feature is the bloat fight. A CPU or RoutingEdge don't need no properties. The Resource class contains too much things and should be split of. --- .../java/surfCpuModel/CpuConstantModel.java | 8 +- src/bindings/java/org/simgrid/surf/Cpu.java | 8 +- .../java/org/simgrid/surf/CpuModel.java | 4 +- src/bindings/java/org/simgrid/surf/Link.java | 5 ++ .../java/org/simgrid/surf/Resource.java | 5 -- .../java/org/simgrid/surf/SurfJNI.java | 12 +-- .../java/org/simgrid/surf/surfJAVA_wrap.cxx | 85 ++++++++----------- .../java/org/simgrid/surf/surfJAVA_wrap.h | 6 +- src/bindings/java/surf.i | 9 +- src/include/surf/surf.h | 9 +- src/simdag/sd_workstation.c | 2 +- src/simix/smx_host.cpp | 2 +- src/simix/smx_io.cpp | 4 +- src/surf/cpu_cas01.cpp | 10 +-- src/surf/cpu_cas01.hpp | 6 +- src/surf/cpu_interface.cpp | 16 ++-- src/surf/cpu_interface.hpp | 14 ++- src/surf/cpu_ti.cpp | 10 +-- src/surf/cpu_ti.hpp | 6 +- src/surf/host_clm03.cpp | 4 +- src/surf/host_clm03.hpp | 4 +- src/surf/host_interface.cpp | 13 +-- src/surf/host_interface.hpp | 3 +- src/surf/host_ptask_L07.cpp | 14 ++- src/surf/host_ptask_L07.hpp | 26 +++--- src/surf/network_interface.cpp | 14 ++- src/surf/network_interface.hpp | 5 ++ src/surf/sg_platf.cpp | 9 +- src/surf/storage_interface.cpp | 17 +++- src/surf/storage_interface.hpp | 6 ++ src/surf/surf_c_bindings.cpp | 12 ++- src/surf/surf_interface.cpp | 25 ++---- src/surf/surf_interface.hpp | 15 +--- src/surf/virtual_machine.hpp | 2 +- src/surf/vm_hl13.cpp | 3 +- 35 files changed, 193 insertions(+), 200 deletions(-) diff --git a/examples/java/surfCpuModel/CpuConstantModel.java b/examples/java/surfCpuModel/CpuConstantModel.java index 60d35dd26e..7118ff4c5e 100644 --- a/examples/java/surfCpuModel/CpuConstantModel.java +++ b/examples/java/surfCpuModel/CpuConstantModel.java @@ -13,10 +13,10 @@ public class CpuConstantModel extends CpuModel { Msg.info("Initialize Cpu Constant Model"); } - public Cpu createCpu(String name, double[] power_peak, int pstate, double power_scale, TmgrTrace power_trace, int core, ResourceState state_initial, TmgrTrace state_trace, XbtDict cpu_properties) { + public Cpu createCpu(String name, double[] power_peak, int pstate, double power_scale, TmgrTrace power_trace, int core, ResourceState state_initial, TmgrTrace state_trace) { Msg.info("New Cpu("+name+", "+power_peak[pstate]+", "+power_scale+")"); - CpuConstant res = new CpuConstant(this, name, cpu_properties, core, power_peak[pstate], power_scale); + CpuConstant res = new CpuConstant(this, name, core, power_peak[pstate], power_scale); cpus.add(res); return res; } @@ -54,9 +54,9 @@ public class CpuConstantModel extends CpuModel { public class CpuConstant extends Cpu { private List actions = new ArrayList(); - public CpuConstant(CpuConstantModel model, String name, XbtDict props, + public CpuConstant(CpuConstantModel model, String name, int core, double powerPeak, double powerScale) { - super(model, name, props, core, powerPeak, powerScale); + super(model, name, core, powerPeak, powerScale); } public void remove(CpuConstantAction action){ diff --git a/src/bindings/java/org/simgrid/surf/Cpu.java b/src/bindings/java/org/simgrid/surf/Cpu.java index d3745d3307..179c60f287 100644 --- a/src/bindings/java/org/simgrid/surf/Cpu.java +++ b/src/bindings/java/org/simgrid/surf/Cpu.java @@ -50,13 +50,13 @@ public class Cpu extends Resource { SurfJNI.Cpu_change_ownership(this, swigCPtr, true); } - public Cpu(Model model, String name, XbtDict props, LmmConstraint constraint, int core, double powerPeak, double powerScale) { - this(SurfJNI.new_Cpu__SWIG_0(Model.getCPtr(model), model, name, XbtDict.getCPtr(props), props, LmmConstraint.getCPtr(constraint), constraint, core, powerPeak, powerScale), true); + public Cpu(Model model, String name, LmmConstraint constraint, int core, double powerPeak, double powerScale) { + this(SurfJNI.new_Cpu__SWIG_0(Model.getCPtr(model), model, name, LmmConstraint.getCPtr(constraint), constraint, core, powerPeak, powerScale), true); SurfJNI.Cpu_director_connect(this, swigCPtr, swigCMemOwn, true); } - public Cpu(Model model, String name, XbtDict props, int core, double powerPeak, double powerScale) { - this(SurfJNI.new_Cpu__SWIG_1(Model.getCPtr(model), model, name, XbtDict.getCPtr(props), props, core, powerPeak, powerScale), true); + public Cpu(Model model, String name, int core, double powerPeak, double powerScale) { + this(SurfJNI.new_Cpu__SWIG_1(Model.getCPtr(model), model, name, core, powerPeak, powerScale), true); SurfJNI.Cpu_director_connect(this, swigCPtr, swigCMemOwn, true); } diff --git a/src/bindings/java/org/simgrid/surf/CpuModel.java b/src/bindings/java/org/simgrid/surf/CpuModel.java index 317b42eba1..4063ee137f 100644 --- a/src/bindings/java/org/simgrid/surf/CpuModel.java +++ b/src/bindings/java/org/simgrid/surf/CpuModel.java @@ -55,8 +55,8 @@ public class CpuModel extends Model { SurfJNI.CpuModel_director_connect(this, swigCPtr, swigCMemOwn, true); } - public Cpu createCpu(String name, double[] power_peak, int pstate, double power_scale, TmgrTrace power_trace, int core, ResourceState state_initial, TmgrTrace state_trace, XbtDict cpu_properties) { - long cPtr = SurfJNI.CpuModel_createCpu(swigCPtr, this, name, power_peak, pstate, power_scale, TmgrTrace.getCPtr(power_trace), power_trace, core, state_initial.swigValue(), TmgrTrace.getCPtr(state_trace), state_trace, XbtDict.getCPtr(cpu_properties), cpu_properties); + public Cpu createCpu(String name, double[] power_peak, int pstate, double power_scale, TmgrTrace power_trace, int core, ResourceState state_initial, TmgrTrace state_trace) { + long cPtr = SurfJNI.CpuModel_createCpu(swigCPtr, this, name, power_peak, pstate, power_scale, TmgrTrace.getCPtr(power_trace), power_trace, core, state_initial.swigValue(), TmgrTrace.getCPtr(state_trace), state_trace); return (cPtr == 0) ? null : new Cpu(cPtr, false); } diff --git a/src/bindings/java/org/simgrid/surf/Link.java b/src/bindings/java/org/simgrid/surf/Link.java index 12191f6902..e61699536d 100644 --- a/src/bindings/java/org/simgrid/surf/Link.java +++ b/src/bindings/java/org/simgrid/surf/Link.java @@ -73,4 +73,9 @@ public class Link extends Resource { SurfJNI.Link_updateLatency__SWIG_1(swigCPtr, this, value); } + public XbtDict getProperties() { + long cPtr = SurfJNI.Link_getProperties(swigCPtr, this); + return (cPtr == 0) ? null : new XbtDict(cPtr, false); + } + } diff --git a/src/bindings/java/org/simgrid/surf/Resource.java b/src/bindings/java/org/simgrid/surf/Resource.java index f21b7b50e7..dbac94f5b4 100644 --- a/src/bindings/java/org/simgrid/surf/Resource.java +++ b/src/bindings/java/org/simgrid/surf/Resource.java @@ -57,11 +57,6 @@ public class Resource { return (cPtr == 0) ? null : new LmmConstraint(cPtr, false); } - public XbtDict getProperties() { - long cPtr = SurfJNI.Resource_getProperties(swigCPtr, this); - return (cPtr == 0) ? null : new XbtDict(cPtr, false); - } - public void updateState(TmgrTraceEvent event_type, double value, double date) { SurfJNI.Resource_updateState(swigCPtr, this, TmgrTraceEvent.getCPtr(event_type), event_type, value, date); } diff --git a/src/bindings/java/org/simgrid/surf/SurfJNI.java b/src/bindings/java/org/simgrid/surf/SurfJNI.java index af1eff380a..d50a270340 100644 --- a/src/bindings/java/org/simgrid/surf/SurfJNI.java +++ b/src/bindings/java/org/simgrid/surf/SurfJNI.java @@ -82,7 +82,7 @@ public class SurfJNI { public final static native void delete_Model(long jarg1); public final static native long new_CpuModel(); public final static native void delete_CpuModel(long jarg1); - public final static native long CpuModel_createCpu(long jarg1, CpuModel jarg1_, String jarg2, double[] jarg3, int jarg4, double jarg5, long jarg6, TmgrTrace jarg6_, int jarg7, int jarg8, long jarg9, TmgrTrace jarg9_, long jarg10, XbtDict jarg10_); + public final static native long CpuModel_createCpu(long jarg1, CpuModel jarg1_, String jarg2, double[] jarg3, int jarg4, double jarg5, long jarg6, TmgrTrace jarg6_, int jarg7, int jarg8, long jarg9, TmgrTrace jarg9_); public final static native void CpuModel_director_connect(CpuModel obj, long cptr, boolean mem_own, boolean weak_global); public final static native void CpuModel_change_ownership(CpuModel obj, long cptr, boolean take_or_release); public final static native String Resource_getName(long jarg1, Resource jarg1_); @@ -90,11 +90,10 @@ public class SurfJNI { public final static native long Resource_getModel(long jarg1, Resource jarg1_); public final static native int Resource_getState(long jarg1, Resource jarg1_); public final static native long Resource_getConstraint(long jarg1, Resource jarg1_); - public final static native long Resource_getProperties(long jarg1, Resource jarg1_); public final static native void Resource_updateState(long jarg1, Resource jarg1_, long jarg2, TmgrTraceEvent jarg2_, double jarg3, double jarg4); public final static native void delete_Resource(long jarg1); - public final static native long new_Cpu__SWIG_0(long jarg1, Model jarg1_, String jarg2, long jarg3, XbtDict jarg3_, long jarg4, LmmConstraint jarg4_, int jarg5, double jarg6, double jarg7); - public final static native long new_Cpu__SWIG_1(long jarg1, Model jarg1_, String jarg2, long jarg3, XbtDict jarg3_, int jarg4, double jarg5, double jarg6); + public final static native long new_Cpu__SWIG_0(long jarg1, Model jarg1_, String jarg2, long jarg3, LmmConstraint jarg3_, int jarg4, double jarg5, double jarg6); + public final static native long new_Cpu__SWIG_1(long jarg1, Model jarg1_, String jarg2, int jarg3, double jarg4, double jarg5); public final static native void delete_Cpu(long jarg1); public final static native double Cpu_getCurrentPowerPeak(long jarg1, Cpu jarg1_); public final static native double Cpu_getCurrentPowerPeakSwigExplicitCpu(long jarg1, Cpu jarg1_); @@ -120,6 +119,7 @@ public class SurfJNI { public final static native double Link_getLatency(long jarg1, Link jarg1_); public final static native void Link_updateLatency__SWIG_0(long jarg1, Link jarg1_, double jarg2, double jarg3); public final static native void Link_updateLatency__SWIG_1(long jarg1, Link jarg1_, double jarg2); + public final static native long Link_getProperties(long jarg1, Link jarg1_); public final static native long new_Action(long jarg1, Model jarg1_, double jarg2, boolean jarg3); public final static native void delete_Action(long jarg1); public final static native long Action_getModel(long jarg1, Action jarg1_); @@ -210,8 +210,8 @@ public class SurfJNI { public static void SwigDirector_CpuModel_addTraces(CpuModel self) { self.addTraces(); } - public static long SwigDirector_CpuModel_createCpu(CpuModel self, String name, double[] power_peak, int pstate, double power_scale, long power_trace, int core, int state_initial, long state_trace, long cpu_properties) { - return Cpu.getCPtr(self.createCpu(name, power_peak, pstate, power_scale, (power_trace == 0) ? null : new TmgrTrace(power_trace, false), core, ResourceState.swigToEnum(state_initial), (state_trace == 0) ? null : new TmgrTrace(state_trace, false), (cpu_properties == 0) ? null : new XbtDict(cpu_properties, false))); + public static long SwigDirector_CpuModel_createCpu(CpuModel self, String name, double[] power_peak, int pstate, double power_scale, long power_trace, int core, int state_initial, long state_trace) { + return Cpu.getCPtr(self.createCpu(name, power_peak, pstate, power_scale, (power_trace == 0) ? null : new TmgrTrace(power_trace, false), core, ResourceState.swigToEnum(state_initial), (state_trace == 0) ? null : new TmgrTrace(state_trace, false))); } public static boolean SwigDirector_Cpu_isUsed(Cpu self) { return self.isUsed(); diff --git a/src/bindings/java/org/simgrid/surf/surfJAVA_wrap.cxx b/src/bindings/java/org/simgrid/surf/surfJAVA_wrap.cxx index 2bca0426b3..8701e69d71 100644 --- a/src/bindings/java/org/simgrid/surf/surfJAVA_wrap.cxx +++ b/src/bindings/java/org/simgrid/surf/surfJAVA_wrap.cxx @@ -1538,7 +1538,7 @@ SwigDirector_CpuModel::~SwigDirector_CpuModel() { } -simgrid::surf::Cpu *SwigDirector_CpuModel::createCpu(char const *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) { +simgrid::surf::Cpu *SwigDirector_CpuModel::createCpu(char const *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) { simgrid::surf::Cpu *c_result = 0 ; jlong jresult = 0 ; JNIEnvWrapper swigjnienv(this) ; @@ -1552,7 +1552,6 @@ simgrid::surf::Cpu *SwigDirector_CpuModel::createCpu(char const *name, DoubleDyn jint jcore ; jint jstate_initial ; jlong jstate_trace = 0 ; - jlong jcpu_properties = 0 ; if (!swig_override[8]) { SWIG_JavaThrowException(JNIEnvWrapper(this).getJNIEnv(), SWIG_JavaDirectorPureVirtual, "Attempted to invoke pure virtual method simgrid::surf::CpuModel::createCpu."); @@ -1577,8 +1576,7 @@ simgrid::surf::Cpu *SwigDirector_CpuModel::createCpu(char const *name, DoubleDyn jcore = (jint) core; jstate_initial = (jint) state_initial; *((tmgr_trace **)&jstate_trace) = (tmgr_trace *) state_trace; - *((s_xbt_dict **)&jcpu_properties) = (s_xbt_dict *) cpu_properties; - jresult = (jlong) jenv->CallStaticLongMethod(Swig::jclass_SurfJNI, Swig::director_methids[17], swigjobj, jname, jpower_peak, jpstate, jpower_scale, jpower_trace, jcore, jstate_initial, jstate_trace, jcpu_properties); + jresult = (jlong) jenv->CallStaticLongMethod(Swig::jclass_SurfJNI, Swig::director_methids[17], swigjobj, jname, jpower_peak, jpstate, jpower_scale, jpower_trace, jcore, jstate_initial, jstate_trace); if (jenv->ExceptionCheck() == JNI_TRUE) return c_result; c_result = *(simgrid::surf::Cpu **)&jresult; } else { @@ -1619,7 +1617,7 @@ void SwigDirector_CpuModel::swig_connect_director(JNIEnv *jenv, jobject jself, j "addTraces", "()V", NULL }, { - "createCpu", "(Ljava/lang/String;[DIDLorg/simgrid/surf/TmgrTrace;ILorg/simgrid/surf/ResourceState;Lorg/simgrid/surf/TmgrTrace;Lorg/simgrid/surf/XbtDict;)Lorg/simgrid/surf/Cpu;", NULL + "createCpu", "(Ljava/lang/String;[DIDLorg/simgrid/surf/TmgrTrace;ILorg/simgrid/surf/ResourceState;Lorg/simgrid/surf/TmgrTrace;)Lorg/simgrid/surf/Cpu;", NULL } }; @@ -1648,10 +1646,10 @@ void SwigDirector_CpuModel::swig_connect_director(JNIEnv *jenv, jobject jself, j } -SwigDirector_Cpu::SwigDirector_Cpu(JNIEnv *jenv, simgrid::surf::Model *model, char const *name, s_xbt_dict *props, lmm_constraint *constraint, int core, double powerPeak, double powerScale) : simgrid::surf::Cpu(model, name, props, constraint, core, powerPeak, powerScale), Swig::Director(jenv) { +SwigDirector_Cpu::SwigDirector_Cpu(JNIEnv *jenv, simgrid::surf::Model *model, char const *name, lmm_constraint *constraint, int core, double powerPeak, double powerScale) : simgrid::surf::Cpu(model, name, constraint, core, powerPeak, powerScale), Swig::Director(jenv) { } -SwigDirector_Cpu::SwigDirector_Cpu(JNIEnv *jenv, simgrid::surf::Model *model, char const *name, s_xbt_dict *props, int core, double powerPeak, double powerScale) : simgrid::surf::Cpu(model, name, props, core, powerPeak, powerScale), Swig::Director(jenv) { +SwigDirector_Cpu::SwigDirector_Cpu(JNIEnv *jenv, simgrid::surf::Model *model, char const *name, int core, double powerPeak, double powerScale) : simgrid::surf::Cpu(model, name, core, powerPeak, powerScale), Swig::Director(jenv) { } bool SwigDirector_Cpu::isUsed() { @@ -2990,7 +2988,7 @@ SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_delete_1CpuModel(JNIEnv *j } -SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_CpuModel_1createCpu(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jdoubleArray jarg3, jint jarg4, jdouble jarg5, jlong jarg6, jobject jarg6_, jint jarg7, jint jarg8, jlong jarg9, jobject jarg9_, jlong jarg10, jobject jarg10_) { +SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_CpuModel_1createCpu(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jdoubleArray jarg3, jint jarg4, jdouble jarg5, jlong jarg6, jobject jarg6_, jint jarg7, jint jarg8, jlong jarg9, jobject jarg9_) { jlong jresult = 0 ; simgrid::surf::CpuModel *arg1 = (simgrid::surf::CpuModel *) 0 ; char *arg2 = (char *) 0 ; @@ -3001,7 +2999,6 @@ SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_CpuModel_1createCpu(JNIEn int arg7 ; e_surf_resource_state_t arg8 ; tmgr_trace *arg9 = (tmgr_trace *) 0 ; - s_xbt_dict *arg10 = (s_xbt_dict *) 0 ; DoubleDynar *argp3 ; simgrid::surf::Cpu *result = 0 ; @@ -3010,7 +3007,6 @@ SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_CpuModel_1createCpu(JNIEn (void)jarg1_; (void)jarg6_; (void)jarg9_; - (void)jarg10_; arg1 = *(simgrid::surf::CpuModel **)&jarg1; arg2 = 0; if (jarg2) { @@ -3029,8 +3025,7 @@ SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_CpuModel_1createCpu(JNIEn arg7 = (int)jarg7; arg8 = (e_surf_resource_state_t)jarg8; arg9 = *(tmgr_trace **)&jarg9; - arg10 = *(s_xbt_dict **)&jarg10; - result = (simgrid::surf::Cpu *)(arg1)->createCpu((char const *)arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); + result = (simgrid::surf::Cpu *)(arg1)->createCpu((char const *)arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); *(simgrid::surf::Cpu **)&jresult = result; { @@ -3134,21 +3129,6 @@ SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_Resource_1getConstraint(J } -SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_Resource_1getProperties(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) { - jlong jresult = 0 ; - simgrid::surf::Resource *arg1 = (simgrid::surf::Resource *) 0 ; - s_xbt_dict *result = 0 ; - - (void)jenv; - (void)jcls; - (void)jarg1_; - arg1 = *(simgrid::surf::Resource **)&jarg1; - result = (s_xbt_dict *)(arg1)->getProperties(); - *(s_xbt_dict **)&jresult = result; - return jresult; -} - - SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Resource_1updateState(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_, jdouble jarg3, jdouble jarg4) { simgrid::surf::Resource *arg1 = (simgrid::surf::Resource *) 0 ; tmgr_trace_event *arg2 = (tmgr_trace_event *) 0 ; @@ -3177,34 +3157,31 @@ SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_delete_1Resource(JNIEnv *j } -SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_new_1Cpu_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jlong jarg3, jobject jarg3_, jlong jarg4, jobject jarg4_, jint jarg5, jdouble jarg6, jdouble jarg7) { +SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_new_1Cpu_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jlong jarg3, jobject jarg3_, jint jarg4, jdouble jarg5, jdouble jarg6) { jlong jresult = 0 ; simgrid::surf::Model *arg1 = (simgrid::surf::Model *) 0 ; char *arg2 = (char *) 0 ; - s_xbt_dict *arg3 = (s_xbt_dict *) 0 ; - lmm_constraint *arg4 = (lmm_constraint *) 0 ; - int arg5 ; + lmm_constraint *arg3 = (lmm_constraint *) 0 ; + int arg4 ; + double arg5 ; double arg6 ; - double arg7 ; simgrid::surf::Cpu *result = 0 ; (void)jenv; (void)jcls; (void)jarg1_; (void)jarg3_; - (void)jarg4_; arg1 = *(simgrid::surf::Model **)&jarg1; arg2 = 0; if (jarg2) { arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); if (!arg2) return 0; } - arg3 = *(s_xbt_dict **)&jarg3; - arg4 = *(lmm_constraint **)&jarg4; - arg5 = (int)jarg5; + arg3 = *(lmm_constraint **)&jarg3; + arg4 = (int)jarg4; + arg5 = (double)jarg5; arg6 = (double)jarg6; - arg7 = (double)jarg7; - result = (simgrid::surf::Cpu *)new SwigDirector_Cpu(jenv,arg1,(char const *)arg2,arg3,arg4,arg5,arg6,arg7); + result = (simgrid::surf::Cpu *)new SwigDirector_Cpu(jenv,arg1,(char const *)arg2,arg3,arg4,arg5,arg6); *(simgrid::surf::Cpu **)&jresult = result; { @@ -3213,31 +3190,28 @@ SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_new_1Cpu_1_1SWIG_10(JNIEn } -SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_new_1Cpu_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jlong jarg3, jobject jarg3_, jint jarg4, jdouble jarg5, jdouble jarg6) { +SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_new_1Cpu_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jint jarg3, jdouble jarg4, jdouble jarg5) { jlong jresult = 0 ; simgrid::surf::Model *arg1 = (simgrid::surf::Model *) 0 ; char *arg2 = (char *) 0 ; - s_xbt_dict *arg3 = (s_xbt_dict *) 0 ; - int arg4 ; + int arg3 ; + double arg4 ; double arg5 ; - double arg6 ; simgrid::surf::Cpu *result = 0 ; (void)jenv; (void)jcls; (void)jarg1_; - (void)jarg3_; arg1 = *(simgrid::surf::Model **)&jarg1; arg2 = 0; if (jarg2) { arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); if (!arg2) return 0; } - arg3 = *(s_xbt_dict **)&jarg3; - arg4 = (int)jarg4; + arg3 = (int)jarg3; + arg4 = (double)jarg4; arg5 = (double)jarg5; - arg6 = (double)jarg6; - result = (simgrid::surf::Cpu *)new SwigDirector_Cpu(jenv,arg1,(char const *)arg2,arg3,arg4,arg5,arg6); + result = (simgrid::surf::Cpu *)new SwigDirector_Cpu(jenv,arg1,(char const *)arg2,arg3,arg4,arg5); *(simgrid::surf::Cpu **)&jresult = result; { @@ -3603,6 +3577,21 @@ SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_Link_1updateLatency_1_1SWI } +SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_Link_1getProperties(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) { + jlong jresult = 0 ; + simgrid::surf::Link *arg1 = (simgrid::surf::Link *) 0 ; + s_xbt_dict *result = 0 ; + + (void)jenv; + (void)jcls; + (void)jarg1_; + arg1 = *(simgrid::surf::Link **)&jarg1; + result = (s_xbt_dict *)(arg1)->getProperties(); + *(s_xbt_dict **)&jresult = result; + return jresult; +} + + SWIGEXPORT jlong JNICALL Java_org_simgrid_surf_SurfJNI_new_1Action(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2, jboolean jarg3) { jlong jresult = 0 ; simgrid::surf::Model *arg1 = (simgrid::surf::Model *) 0 ; @@ -4141,7 +4130,7 @@ SWIGEXPORT void JNICALL Java_org_simgrid_surf_SurfJNI_swig_1module_1init(JNIEnv "SwigDirector_CpuModel_addTraces", "(Lorg/simgrid/surf/CpuModel;)V" }, { - "SwigDirector_CpuModel_createCpu", "(Lorg/simgrid/surf/CpuModel;Ljava/lang/String;[DIDJIIJJ)J" + "SwigDirector_CpuModel_createCpu", "(Lorg/simgrid/surf/CpuModel;Ljava/lang/String;[DIDJIIJ)J" }, { "SwigDirector_Cpu_isUsed", "(Lorg/simgrid/surf/Cpu;)Z" diff --git a/src/bindings/java/org/simgrid/surf/surfJAVA_wrap.h b/src/bindings/java/org/simgrid/surf/surfJAVA_wrap.h index 82b10b6b37..f7b1a1097d 100644 --- a/src/bindings/java/org/simgrid/surf/surfJAVA_wrap.h +++ b/src/bindings/java/org/simgrid/surf/surfJAVA_wrap.h @@ -48,7 +48,7 @@ public: virtual simgrid::surf::ActionList *getRunningActionSet(); virtual void addTraces(); virtual ~SwigDirector_CpuModel(); - virtual simgrid::surf::Cpu *createCpu(char const *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); + virtual simgrid::surf::Cpu *createCpu(char const *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); public: bool swig_overrides(int n) { return (n < 9 ? swig_override[n] : false); @@ -61,8 +61,8 @@ class SwigDirector_Cpu : public simgrid::surf::Cpu, public Swig::Director { public: void swig_connect_director(JNIEnv *jenv, jobject jself, jclass jcls, bool swig_mem_own, bool weak_global); - SwigDirector_Cpu(JNIEnv *jenv, simgrid::surf::Model *model, char const *name, s_xbt_dict *props, lmm_constraint *constraint, int core, double powerPeak, double powerScale); - SwigDirector_Cpu(JNIEnv *jenv, simgrid::surf::Model *model, char const *name, s_xbt_dict *props, int core, double powerPeak, double powerScale); + SwigDirector_Cpu(JNIEnv *jenv, simgrid::surf::Model *model, char const *name, lmm_constraint *constraint, int core, double powerPeak, double powerScale); + SwigDirector_Cpu(JNIEnv *jenv, simgrid::surf::Model *model, char const *name, int core, double powerPeak, double powerScale); virtual bool isUsed(); virtual e_surf_resource_state_t getState(); virtual void updateState(tmgr_trace_event *event_type, double value, double date); diff --git a/src/bindings/java/surf.i b/src/bindings/java/surf.i index a20d84c9a3..3b78ab2728 100644 --- a/src/bindings/java/surf.i +++ b/src/bindings/java/surf.i @@ -292,8 +292,7 @@ public: 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; + tmgr_trace *state_trace)=0; }; class Resource { @@ -305,16 +304,15 @@ public: 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(simgrid::surf::Model *model, const char *name, s_xbt_dict *props, + Cpu(simgrid::surf::Model *model, const char *name, lmm_constraint *constraint, int core, double powerPeak, double powerScale); - Cpu(simgrid::surf::Model *model, const char *name, s_xbt_dict *props, + Cpu(simgrid::surf::Model *model, const char *name, int core, double powerPeak, double powerScale); virtual ~Cpu(); virtual double getCurrentPowerPeak(); @@ -338,6 +336,7 @@ public: void updateBandwidth(double value, double date=surf_get_clock()); double getLatency(); void updateLatency(double value, double date=surf_get_clock()); + s_xbt_dict *getProperties(); }; %nodefaultctor Action; diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 1eee7b4e17..5e01fde734 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -300,11 +300,8 @@ static inline const char * surf_cpu_name(surf_cpu_t cpu) { return surf_resource_name((surf_cpp_resource_t)cpu); } -/** @brief Get the properties of a surf resource (cpu, host, network, …) */ -XBT_PUBLIC(xbt_dict_t) surf_resource_get_properties(surf_cpp_resource_t resource); -static XBT_INLINE xbt_dict_t surf_host_get_properties(surf_host_t host) { - return surf_resource_get_properties((surf_cpp_resource_t)host); -} +/** @brief Get the properties of an host */ +XBT_PUBLIC(xbt_dict_t) sg_host_get_properties(sg_host_t host); /** @brief Get the state of a surf resource (cpu, host, network, …) */ @@ -623,6 +620,8 @@ XBT_PUBLIC(sg_size_t) surf_storage_get_free_size(surf_resource_t resource); */ XBT_PUBLIC(sg_size_t) surf_storage_get_used_size(surf_resource_t resource); +/** @brief return the properties set associated to that storage */ +XBT_PUBLIC(xbt_dict_t) surf_storage_get_properties(surf_resource_t resource); /** * @brief Get the data associated to the action diff --git a/src/simdag/sd_workstation.c b/src/simdag/sd_workstation.c index 3b5c2ea7be..8162d2efbb 100644 --- a/src/simdag/sd_workstation.c +++ b/src/simdag/sd_workstation.c @@ -164,7 +164,7 @@ const char *SD_workstation_get_property_value(SD_workstation_t ws, */ xbt_dict_t SD_workstation_get_properties(SD_workstation_t workstation) { - return surf_host_get_properties(surf_host_resource_priv(workstation)); + return sg_host_get_properties(workstation); } diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index 45f48f907c..dce8607d21 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -162,7 +162,7 @@ const char* SIMIX_host_self_get_name(void) } xbt_dict_t SIMIX_host_get_properties(sg_host_t host){ - return surf_host_get_properties(surf_host_resource_priv(host)); + return sg_host_get_properties(host); } diff --git a/src/simix/smx_io.cpp b/src/simix/smx_io.cpp index 3866492b03..146a80acc2 100644 --- a/src/simix/smx_io.cpp +++ b/src/simix/smx_io.cpp @@ -273,9 +273,7 @@ sg_size_t SIMIX_storage_get_used_size(smx_process_t process, smx_storage_t stora } xbt_dict_t SIMIX_storage_get_properties(smx_storage_t storage){ - xbt_assert((storage != NULL), "Invalid parameters (simix storage is NULL)"); - return (xbt_dict_t) surf_resource_get_properties((surf_cpp_resource_t) - surf_storage_resource_priv(storage)); + return surf_storage_get_properties(storage); } const char* SIMIX_storage_get_name(smx_storage_t storage){ diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index afeb09aeae..0fe79819c2 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -103,13 +103,12 @@ Cpu *CpuCas01Model::createCpu(const char *name, xbt_dynar_t speedPeak, int pstate, double speedScale, tmgr_trace_t speedTrace, int core, e_surf_resource_state_t state_initial, - tmgr_trace_t state_trace, - xbt_dict_t cpu_properties) + tmgr_trace_t state_trace) { xbt_assert(xbt_dynar_getfirst_as(speedPeak, double) > 0.0, "Speed has to be >0.0. Did you forget to specify the mandatory power attribute?"); xbt_assert(core > 0, "Invalid number of cores %d. Must be larger than 0", core); - Cpu *cpu = new CpuCas01(this, name, speedPeak, pstate, speedScale, speedTrace, core, state_initial, state_trace, cpu_properties); + Cpu *cpu = new CpuCas01(this, name, speedPeak, pstate, speedScale, speedTrace, core, state_initial, state_trace); return cpu; } @@ -155,9 +154,8 @@ void CpuCas01Model::addTraces() ************/ CpuCas01::CpuCas01(CpuCas01Model *model, const char *name, xbt_dynar_t speedPeak, int pstate, double speedScale, tmgr_trace_t speedTrace, int core, - e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace, - xbt_dict_t properties) -: Cpu(model, name, properties, + e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace) +: Cpu(model, name, lmm_constraint_new(model->getMaxminSystem(), this, core * speedScale * xbt_dynar_get_as(speedPeak, pstate, double)), core, xbt_dynar_get_as(speedPeak, pstate, double), speedScale, stateInitial) { diff --git a/src/surf/cpu_cas01.hpp b/src/surf/cpu_cas01.hpp index b98fd237e6..8d53c81c39 100644 --- a/src/surf/cpu_cas01.hpp +++ b/src/surf/cpu_cas01.hpp @@ -35,8 +35,7 @@ public: double speedScale, tmgr_trace_t speedTrace, int core, e_surf_resource_state_t state_initial, - tmgr_trace_t state_trace, - xbt_dict_t cpu_properties); + tmgr_trace_t state_trace); double shareResourcesFull(double now); void addTraces(); ActionList *p_cpuRunningActionSetThatDoesNotNeedBeingChecked; @@ -50,8 +49,7 @@ class CpuCas01 : public Cpu { public: CpuCas01(CpuCas01Model *model, const char *name, xbt_dynar_t speedPeak, int pstate, double speedScale, tmgr_trace_t speedTrace, int core, - e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace, - xbt_dict_t properties) ; + e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace) ; ~CpuCas01(); void updateState(tmgr_trace_event_t event_type, double value, double date); CpuAction *execute(double size); diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index d99dad7aa3..0142878a73 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -145,10 +145,10 @@ Cpu::Cpu() } -Cpu::Cpu(Model *model, const char *name, xbt_dict_t props, +Cpu::Cpu(Model *model, const char *name, int core, double speedPeak, double speedScale, e_surf_resource_state_t stateInitial) - : Resource(model, name, props, stateInitial) + : Resource(model, name, stateInitial) , m_core(core) , m_speedPeak(speedPeak) , m_speedScale(speedScale) @@ -156,10 +156,10 @@ Cpu::Cpu(Model *model, const char *name, xbt_dict_t props, } -Cpu::Cpu(Model *model, const char *name, xbt_dict_t props, +Cpu::Cpu(Model *model, const char *name, lmm_constraint_t constraint, int core, double speedPeak, double speedScale, e_surf_resource_state_t stateInitial) - : Resource(model, name, props, constraint, stateInitial) + : Resource(model, name, constraint, stateInitial) , m_core(core) , m_speedPeak(speedPeak) , m_speedScale(speedScale) @@ -181,14 +181,14 @@ Cpu::Cpu(Model *model, const char *name, xbt_dict_t props, } } -Cpu::Cpu(Model *model, const char *name, xbt_dict_t props, +Cpu::Cpu(Model *model, const char *name, lmm_constraint_t constraint, int core, double speedPeak, double speedScale) -: Cpu(model, name, props, constraint, core, speedPeak, speedScale, SURF_RESOURCE_ON) +: Cpu(model, name, constraint, core, speedPeak, speedScale, SURF_RESOURCE_ON) {} -Cpu::Cpu(Model *model, const char *name, xbt_dict_t props, +Cpu::Cpu(Model *model, const char *name, int core, double speedPeak, double speedScale) -: Cpu(model, name, props, core, speedPeak, speedScale, SURF_RESOURCE_ON) +: Cpu(model, name, core, speedPeak, speedScale, SURF_RESOURCE_ON) {} Cpu::~Cpu(){ diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index e28d4d3913..8e5a7ce7b8 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -76,14 +76,12 @@ public: * @param core The number of core of this Cpu * @param state_initial [TODO] * @param state_trace [TODO] - * @param cpu_properties Dictionary of properties associated to this Cpu */ virtual Cpu *createCpu(const char *name, xbt_dynar_t speedPeak, int pstate, double speedScale, tmgr_trace_t speedTrace, int core, e_surf_resource_state_t state_initial, - tmgr_trace_t state_trace, - xbt_dict_t cpu_properties)=0; + tmgr_trace_t state_trace)=0; void updateActionsStateLazy(double now, double delta); void updateActionsStateFull(double now, double delta); @@ -109,14 +107,13 @@ public: * * @param model The CpuModel associated to this Cpu * @param name The name of the Cpu - * @param props Dictionary of properties associated to this Cpu * @param constraint The lmm constraint associated to this Cpu if it is part of a LMM component * @param core The number of core of this Cpu * @param speedPeak The speed peak of this Cpu in flops (max speed) * @param speedScale The speed scale of this Cpu in [0;1] (available amount) * @param stateInitial whether it is created running or crashed */ - Cpu(simgrid::surf::Model *model, const char *name, xbt_dict_t props, + Cpu(simgrid::surf::Model *model, const char *name, lmm_constraint_t constraint, int core, double speedPeak, double speedScale, e_surf_resource_state_t stateInitial); @@ -125,19 +122,18 @@ public: * * @param model The CpuModel associated to this Cpu * @param name The name of the Cpu - * @param props Dictionary of properties associated to this Cpu * @param core The number of core of this Cpu * @param speedPeak The speed peak of this Cpu in flops (max speed) * @param speedScale The speed scale of this Cpu in [0;1] (available amount) * @param stateInitial whether it is created running or crashed */ - Cpu(simgrid::surf::Model *model, const char *name, xbt_dict_t props, + Cpu(simgrid::surf::Model *model, const char *name, int core, double speedPeak, double speedScale, e_surf_resource_state_t stateInitial); - Cpu(simgrid::surf::Model *model, const char *name, xbt_dict_t props, + Cpu(simgrid::surf::Model *model, const char *name, lmm_constraint_t constraint, int core, double speedPeak, double speedScale); - Cpu(simgrid::surf::Model *model, const char *name, xbt_dict_t props, + Cpu(simgrid::surf::Model *model, const char *name, int core, double speedPeak, double speedScale); ~Cpu(); diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 352b1ea68a..dd729be66f 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -442,14 +442,13 @@ Cpu *CpuTiModel::createCpu(const char *name, tmgr_trace_t speedTrace, int core, e_surf_resource_state_t stateInitial, - tmgr_trace_t stateTrace, - xbt_dict_t cpuProperties) + tmgr_trace_t stateTrace) { xbt_assert(core==1,"Multi-core not handled with this model yet"); xbt_assert(xbt_dynar_getfirst_as(speedPeak, double) > 0.0, "Speed has to be >0.0. Did you forget to specify the mandatory speed attribute?"); CpuTi *cpu = new CpuTi(this, name, speedPeak, pstate, speedScale, speedTrace, - core, stateInitial, stateTrace, cpuProperties); + core, stateInitial, stateTrace); return cpu; } @@ -551,9 +550,8 @@ void CpuTiModel::addTraces() ************/ CpuTi::CpuTi(CpuTiModel *model, const char *name, xbt_dynar_t speedPeak, int pstate, double speedScale, tmgr_trace_t speedTrace, int core, - e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace, - xbt_dict_t properties) - : Cpu(model, name, properties, core, 0, speedScale, stateInitial) + e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace) + : Cpu(model, name, core, 0, speedScale, stateInitial) { p_speedEvent = NULL; m_speedScale = speedScale; diff --git a/src/surf/cpu_ti.hpp b/src/surf/cpu_ti.hpp index 75ffbf40e8..f95c819812 100644 --- a/src/surf/cpu_ti.hpp +++ b/src/surf/cpu_ti.hpp @@ -117,8 +117,7 @@ public: CpuTi() {}; CpuTi(CpuTiModel *model, const char *name, xbt_dynar_t speedPeak, int pstate, double speedScale, tmgr_trace_t speedTrace, int core, - e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace, - xbt_dict_t properties) ; + e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace) ; ~CpuTi(); void updateState(tmgr_trace_event_t event_type, double value, double date); @@ -165,8 +164,7 @@ public: int pstate, double speedScale, tmgr_trace_t speedTrace, int core, e_surf_resource_state_t state_initial, - tmgr_trace_t state_trace, - xbt_dict_t cpu_properties); + tmgr_trace_t state_trace); double shareResources(double now); void updateActionsState(double now, double delta); void addTraces(); diff --git a/src/surf/host_clm03.cpp b/src/surf/host_clm03.cpp index 3465f78b85..189f709860 100644 --- a/src/surf/host_clm03.cpp +++ b/src/surf/host_clm03.cpp @@ -47,8 +47,8 @@ void surf_host_model_init_compound() namespace simgrid { namespace surf { -Host *HostCLM03Model::createHost(const char *name,RoutingEdge *netElm, Cpu *cpu){ - Host *host = new simgrid::surf::HostCLM03(surf_host_model, name, NULL, +Host *HostCLM03Model::createHost(const char *name,RoutingEdge *netElm, Cpu *cpu, xbt_dict_t props){ + Host *host = new simgrid::surf::HostCLM03(surf_host_model, name, props, (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL), netElm, cpu); XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->p_storage)); diff --git a/src/surf/host_clm03.hpp b/src/surf/host_clm03.hpp index ea0218b88d..e8eeefd627 100644 --- a/src/surf/host_clm03.hpp +++ b/src/surf/host_clm03.hpp @@ -33,8 +33,8 @@ class HostCLM03Model : public HostModel { public: HostCLM03Model(): HostModel(){} ~HostCLM03Model() {} - Host *createHost(const char *name, RoutingEdge *netElm, Cpu *cpu); - double shareResources(double now); + Host *createHost(const char *name, RoutingEdge *netElm, Cpu *cpu, xbt_dict_t props) override; + double shareResources(double now) override; void updateActionsState(double now, double delta); diff --git a/src/surf/host_interface.cpp b/src/surf/host_interface.cpp index e2eb602a11..2d87c0dbcb 100644 --- a/src/surf/host_interface.cpp +++ b/src/surf/host_interface.cpp @@ -91,22 +91,23 @@ void Host::init() Host::Host(simgrid::surf::Model *model, const char *name, xbt_dict_t props, xbt_dynar_t storage, RoutingEdge *netElm, Cpu *cpu) - : Resource(model, name, props) - , p_storage(storage), p_netElm(netElm), p_cpu(cpu) + : Resource(model, name) + , p_storage(storage), p_netElm(netElm), p_cpu(cpu), p_properties(props) { p_params.ramsize = 0; } Host::Host(simgrid::surf::Model *model, const char *name, xbt_dict_t props, lmm_constraint_t constraint, xbt_dynar_t storage, RoutingEdge *netElm, Cpu *cpu) - : Resource(model, name, props, constraint) - , p_storage(storage), p_netElm(netElm), p_cpu(cpu) + : Resource(model, name, constraint) + , p_storage(storage), p_netElm(netElm), p_cpu(cpu), p_properties(props) { p_params.ramsize = 0; } Host::~Host(){ surf_callback_emit(hostDestructedCallbacks, this); + xbt_dict_free(&p_properties); } void Host::attach(simgrid::Host* host) @@ -127,7 +128,9 @@ void Host::setState(e_surf_resource_state_t state){ xbt_dict_t Host::getProperties() { - return p_cpu->getProperties(); + if (p_properties==NULL) + p_properties = xbt_dict_new(); + return p_properties; } simgrid::surf::Storage *Host::findStorageOnMountList(const char* mount) diff --git a/src/surf/host_interface.hpp b/src/surf/host_interface.hpp index 5c081d2b9a..090c2ed524 100644 --- a/src/surf/host_interface.hpp +++ b/src/surf/host_interface.hpp @@ -74,7 +74,7 @@ public: HostModel() : Model() {} ~HostModel() {} - virtual Host *createHost(const char *name, RoutingEdge *net, Cpu *cpu)=0; + virtual Host *createHost(const char *name, RoutingEdge *net, Cpu *cpu, xbt_dict_t props)=0; void addTraces(){DIE_IMPOSSIBLE;} virtual void adjustWeightOfDummyCpuActions(); @@ -269,6 +269,7 @@ public: RoutingEdge *p_netElm; Cpu *p_cpu; simgrid::Host* p_host = nullptr; + xbt_dict_t p_properties = NULL; /** @brief Get the list of virtual machines on the current Host */ xbt_dynar_t getVms(); diff --git a/src/surf/host_ptask_L07.cpp b/src/surf/host_ptask_L07.cpp index fea3be0a0e..75d589d84a 100644 --- a/src/surf/host_ptask_L07.cpp +++ b/src/surf/host_ptask_L07.cpp @@ -270,9 +270,9 @@ Action *HostL07Model::executeParallelTask(int host_nb, return action; } -Host *HostL07Model::createHost(const char *name,RoutingEdge *netElm, Cpu *cpu) +Host *HostL07Model::createHost(const char *name,RoutingEdge *netElm, Cpu *cpu, xbt_dict_t props) { - return new HostL07(this, name, NULL, netElm, cpu); + return new HostL07(this, name, props, netElm, cpu); } Action *NetworkL07Model::communicate(RoutingEdge *src, RoutingEdge *dst, @@ -305,12 +305,10 @@ Cpu *CpuL07Model::createCpu(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) + tmgr_trace_t state_trace) { double power_initial = xbt_dynar_get_as(powerPeak, pstate, double); - CpuL07 *cpu = new CpuL07(this, name, cpu_properties, - power_initial, power_scale, power_trace, + CpuL07 *cpu = new CpuL07(this, name, power_initial, power_scale, power_trace, core, state_initial, state_trace); return cpu; } @@ -407,10 +405,10 @@ HostL07::HostL07(HostModel *model, const char* name, xbt_dict_t props, RoutingEd { } -CpuL07::CpuL07(CpuL07Model *model, const char* name, xbt_dict_t props, +CpuL07::CpuL07(CpuL07Model *model, const char* name, double speedInitial, double speedScale, tmgr_trace_t speedTrace, int core, e_surf_resource_state_t state_initial, tmgr_trace_t state_trace) - : Cpu(model, name, props, lmm_constraint_new(ptask_maxmin_system, this, speedInitial * speedScale), + : Cpu(model, name, lmm_constraint_new(ptask_maxmin_system, this, speedInitial * speedScale), core, speedInitial, speedScale, state_initial) { xbt_assert(m_speedScale > 0, "Power has to be >0"); diff --git a/src/surf/host_ptask_L07.hpp b/src/surf/host_ptask_L07.hpp index b4c550916a..2c8f1db293 100644 --- a/src/surf/host_ptask_L07.hpp +++ b/src/surf/host_ptask_L07.hpp @@ -45,12 +45,12 @@ public: double shareResources(double now); void updateActionsState(double now, double delta); - Host *createHost(const char *name,RoutingEdge *netElm, Cpu *cpu); + Host *createHost(const char *name,RoutingEdge *netElm, Cpu *cpu, xbt_dict_t props) override; Action *executeParallelTask(int host_nb, sg_host_t *host_list, double *flops_amount, double *bytes_amount, - double rate); + double rate) override; xbt_dynar_t getRoute(Host *src, Host *dst); void addTraces(); }; @@ -63,8 +63,7 @@ public: int pstate, double speedScale, tmgr_trace_t speedTrace, int core, e_surf_resource_state_t state_initial, - tmgr_trace_t state_trace, - xbt_dict_t cpu_properties); + tmgr_trace_t state_trace) override; void addTraces() {DIE_IMPOSSIBLE;}; HostL07Model *p_hostModel; @@ -75,15 +74,14 @@ public: NetworkL07Model(HostL07Model *hmodel) : NetworkModel() {p_hostModel = hmodel;}; ~NetworkL07Model() {surf_network_model = NULL;}; Link* createLink(const char *name, - double bw_initial, - tmgr_trace_t bw_trace, - double lat_initial, - tmgr_trace_t lat_trace, - e_surf_resource_state_t - state_initial, - tmgr_trace_t state_trace, - e_surf_link_sharing_policy_t - policy, xbt_dict_t properties); + double bw_initial, + tmgr_trace_t bw_trace, + double lat_initial, + tmgr_trace_t lat_trace, + e_surf_resource_state_t state_initial, + tmgr_trace_t state_trace, + e_surf_link_sharing_policy_t policy, + xbt_dict_t properties) override; Action *communicate(RoutingEdge *src, RoutingEdge *dst, double size, double rate); void addTraces() {DIE_IMPOSSIBLE;}; @@ -111,7 +109,7 @@ class CpuL07 : public Cpu { tmgr_trace_event_t p_stateEvent; tmgr_trace_event_t p_speedEvent; public: - CpuL07(CpuL07Model *model, const char* name, xbt_dict_t properties, + CpuL07(CpuL07Model *model, const char* name, double power_scale, double power_initial, tmgr_trace_t power_trace, int core, e_surf_resource_state_t state_initial, tmgr_trace_t state_trace); bool isUsed(); diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index 14bd060176..a6b79372c6 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -194,7 +194,8 @@ double NetworkModel::shareResourcesFull(double now) ************/ Link::Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props) -: Resource(model, name, props) +: Resource(model, name), + p_properties(props) { links->insert({name, this}); @@ -205,7 +206,8 @@ Link::Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t prop lmm_constraint_t constraint, tmgr_history_t history, tmgr_trace_t state_trace) -: Resource(model, name, props, constraint) +: Resource(model, name, constraint), + p_properties(props) { if (state_trace) p_stateEvent = tmgr_history_add_trace(history, state_trace, 0.0, 0, this); @@ -218,6 +220,7 @@ Link::Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t prop Link::~Link() { surf_callback_emit(networkLinkDestructedCallbacks, this); + xbt_dict_free(&p_properties); } bool Link::isUsed() @@ -246,6 +249,13 @@ void Link::setState(e_surf_resource_state_t state){ surf_callback_emit(networkLinkStateChangedCallbacks, this, old, state); } +xbt_dict_t Link::getProperties() +{ + if (p_properties==NULL) + p_properties = xbt_dict_new(); + return p_properties; +} + /********** * Action * **********/ diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index 0bbd3dab2c..dcd3136bd3 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -252,6 +252,11 @@ public: private: void *userData = NULL; +public: + xbt_dict_t getProperties(); +protected: + xbt_dict_t p_properties = NULL; + /* List of all links */ private: static boost::unordered_map *links; diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index bc674ce914..b1896426e4 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -69,10 +69,9 @@ void sg_platf_new_host(sg_platf_host_cbarg_t host) host->speed_trace, host->core_amount, host->initial_state, - host->state_trace, - host->properties); + host->state_trace); cpu->plug(h); - surf_host_model->createHost(host->id, net, cpu)->attach(h); + surf_host_model->createHost(host->id, net, cpu, host->properties)->attach(h); if (TRACE_is_enabled() && TRACE_needs_platform()) sg_instr_new_host(host); } @@ -182,13 +181,13 @@ void sg_platf_new_storage(sg_platf_storage_cbarg_t storage) ((storage_type_t) stype)->type_id, storage->content, storage->content_type, - storage->properties); + storage->properties); surf_storage_model->createStorage(storage->id, ((storage_type_t) stype)->type_id, storage->content, storage->content_type, - storage->properties, + storage->properties, storage->attach); } void sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type){ diff --git a/src/surf/storage_interface.cpp b/src/surf/storage_interface.cpp index a723966c52..8b64c56daa 100644 --- a/src/surf/storage_interface.cpp +++ b/src/surf/storage_interface.cpp @@ -58,11 +58,12 @@ StorageModel::~StorageModel(){ Storage::Storage(Model *model, const char *name, xbt_dict_t props, const char* type_id, char *content_name, char *content_type, sg_size_t size) - : Resource(model, name, props) + : Resource(model, name) , p_contentType(content_type) , m_size(size), m_usedSize(0) , p_typeId(xbt_strdup(type_id)) , p_writeActions(xbt_dynar_new(sizeof(Action*),NULL)) + , p_properties(props) { p_content = parseContent(content_name); setState(SURF_RESOURCE_ON); @@ -72,11 +73,13 @@ Storage::Storage(Model *model, const char *name, xbt_dict_t props, lmm_system_t maxminSystem, double bread, double bwrite, double bconnection, const char* type_id, char *content_name, char *content_type, sg_size_t size, char *attach) - : Resource(model, name, props, lmm_constraint_new(maxminSystem, this, bconnection)) + : Resource(model, name, lmm_constraint_new(maxminSystem, this, bconnection)) , p_contentType(content_type) , m_size(size), m_usedSize(0) , p_typeId(xbt_strdup(type_id)) - , p_writeActions(xbt_dynar_new(sizeof(Action*),NULL)) { + , p_writeActions(xbt_dynar_new(sizeof(Action*),NULL)) + , p_properties(props) +{ p_content = parseContent(content_name); p_attach = xbt_strdup(attach); setState(SURF_RESOURCE_ON); @@ -88,6 +91,7 @@ Storage::Storage(Model *model, const char *name, xbt_dict_t props, Storage::~Storage(){ surf_callback_emit(storageDestructedCallbacks, this); xbt_dict_free(&p_content); + xbt_dict_free(&p_properties); xbt_dynar_free(&p_writeActions); free(p_typeId); free(p_contentType); @@ -176,6 +180,13 @@ sg_size_t Storage::getUsedSize(){ return m_usedSize; } +xbt_dict_t Storage::getProperties() +{ + if (p_properties==NULL) + p_properties = xbt_dict_new(); + return p_properties; +} + /********** * Action * **********/ diff --git a/src/surf/storage_interface.hpp b/src/surf/storage_interface.hpp index 4d30a14c15..3be52e96e6 100644 --- a/src/surf/storage_interface.hpp +++ b/src/surf/storage_interface.hpp @@ -241,6 +241,12 @@ public: lmm_constraint_t p_constraintWrite; /* Constraint for maximum write bandwidth*/ lmm_constraint_t p_constraintRead; /* Constraint for maximum write bandwidth*/ + +public: + xbt_dict_t getProperties(); +protected: + xbt_dict_t p_properties = NULL; + }; /********** diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index 4b6ca5a63a..bc658f3a80 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -242,10 +242,6 @@ const char *surf_resource_name(surf_cpp_resource_t resource){ return resource->getName(); } -xbt_dict_t surf_resource_get_properties(surf_cpp_resource_t resource){ - return resource->getProperties(); -} - e_surf_resource_state_t surf_resource_get_state(surf_cpp_resource_t resource){ return resource->getState(); } @@ -258,6 +254,10 @@ surf_action_t surf_host_sleep(sg_host_t host, double duration){ return get_casted_host(host)->sleep(duration); } +xbt_dict_t sg_host_get_properties(sg_host_t host) { + return get_casted_host(host)->getProperties(); +} + double surf_host_get_speed(sg_host_t host, double load){ return sg_host_surfcpu(host)->getSpeed(load); } @@ -447,6 +447,10 @@ sg_size_t surf_storage_get_used_size(surf_resource_t resource){ return static_cast(surf_storage_resource_priv(resource))->getUsedSize(); } +xbt_dict_t surf_storage_get_properties(surf_resource_t resource){ + return static_cast(surf_storage_resource_priv(resource))->getProperties(); +} + const char* surf_storage_get_host(surf_resource_t resource){ return static_cast(surf_storage_resource_priv(resource))->p_attach; } diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 0f43bcf638..3f7d33a191 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -591,32 +591,31 @@ namespace simgrid { namespace surf { Resource::Resource() -: p_name(NULL), p_properties(NULL), p_model(NULL) +: p_name(NULL), p_model(NULL) {} -Resource::Resource(Model *model, const char *name, xbt_dict_t props) - : Resource(model, name, props, SURF_RESOURCE_ON) +Resource::Resource(Model *model, const char *name) + : Resource(model, name, SURF_RESOURCE_ON) {} -Resource::Resource(Model *model, const char *name, xbt_dict_t props, lmm_constraint_t constraint) - : Resource(model, name, props, constraint, SURF_RESOURCE_ON) +Resource::Resource(Model *model, const char *name, lmm_constraint_t constraint) + : Resource(model, name, constraint, SURF_RESOURCE_ON) {} Resource::Resource( - Model *model, const char *name, xbt_dict_t props, + Model *model, const char *name, lmm_constraint_t constraint, e_surf_resource_state_t stateInit) - : p_name(xbt_strdup(name)), p_properties(props), p_model(model) + : p_name(xbt_strdup(name)), p_model(model) , m_running(true), m_stateCurrent(stateInit), p_constraint(constraint) {} -Resource::Resource(Model *model, const char *name, xbt_dict_t props, e_surf_resource_state_t stateInit) - : p_name(xbt_strdup(name)), p_properties(props), p_model(model) +Resource::Resource(Model *model, const char *name, e_surf_resource_state_t stateInit) + : p_name(xbt_strdup(name)), p_model(model) , m_running(true), m_stateCurrent(stateInit) {} Resource::~Resource() { xbt_free((void*)p_name); - xbt_dict_free(&p_properties); } e_surf_resource_state_t Resource::getState() @@ -656,12 +655,6 @@ const char *Resource::getName() { return p_name; } -xbt_dict_t Resource::getProperties() { - if (p_properties==NULL) - p_properties = xbt_dict_new(); - return p_properties; -} - lmm_constraint_t Resource::getConstraint() { return p_constraint; } diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index 3bccf4d1eb..ae7266f778 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -432,31 +432,28 @@ public: * * @param model Model associated to this Resource * @param name The name of the Resource - * @param props Dictionary of properties associated to this Resource */ - Resource(Model *model, const char *name, xbt_dict_t props); + Resource(Model *model, const char *name); /** * @brief Constructor of LMM Resources * * @param model Model associated to this Resource * @param name The name of the Resource - * @param props Dictionary of properties associated to this Resource * @param constraint The lmm constraint associated to this Resource if it is part of a LMM component */ - Resource(Model *model, const char *name, xbt_dict_t props, lmm_constraint_t constraint); + Resource(Model *model, const char *name, lmm_constraint_t constraint); - Resource(Model *model, const char *name, xbt_dict_t props, lmm_constraint_t constraint, e_surf_resource_state_t stateInit); + Resource(Model *model, const char *name, lmm_constraint_t constraint, e_surf_resource_state_t stateInit); /** * @brief Resource constructor * * @param model Model associated to this Resource * @param name The name of the Resource - * @param props Dictionary of properties associated to this Resource * @param stateInit the initial state of the Resource */ - Resource(Model *model, const char *name, xbt_dict_t props, e_surf_resource_state_t stateInit); + Resource(Model *model, const char *name, e_surf_resource_state_t stateInit); virtual ~Resource(); @@ -466,9 +463,6 @@ public: /** @brief Get the name of the current Resource */ const char *getName(); - /** @brief Get the properties of the current Resource */ - virtual xbt_dict_t getProperties(); - /** * @brief Update the state of the current Resource * @details [TODO] @@ -496,7 +490,6 @@ public: private: const char *p_name; - xbt_dict_t p_properties; Model *p_model; bool m_running; e_surf_resource_state_t m_stateCurrent; diff --git a/src/surf/virtual_machine.hpp b/src/surf/virtual_machine.hpp index a7d99e458a..2de593b911 100644 --- a/src/surf/virtual_machine.hpp +++ b/src/surf/virtual_machine.hpp @@ -111,7 +111,7 @@ public: VMModel() :HostModel(){} ~VMModel(){}; - Host *createHost(const char *name, RoutingEdge *netElm, Cpu *cpu){DIE_IMPOSSIBLE;} + Host *createHost(const char *name, RoutingEdge *netElm, Cpu *cpu,xbt_dict_t props) override {DIE_IMPOSSIBLE;} /** * @brief Create a new VM diff --git a/src/surf/vm_hl13.cpp b/src/surf/vm_hl13.cpp index f0c0ce8baa..428c515234 100644 --- a/src/surf/vm_hl13.cpp +++ b/src/surf/vm_hl13.cpp @@ -197,8 +197,7 @@ VMHL13::VMHL13(VMModel *model, const char* name, xbt_dict_t props, NULL, // host->power_trace, 1, // host->core_amount, SURF_RESOURCE_ON, // host->initial_state, - NULL, // host->state_trace, - NULL); // host->properties, + NULL); // host->state_trace, p_cpu->plug(host); /* We create cpu_action corresponding to a VM process on the host operating system. */ -- 2.20.1