Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #57 from fabienchaix/oldstyle_element_set
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Mon, 1 Feb 2016 06:40:53 +0000 (07:40 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Mon, 1 Feb 2016 06:40:53 +0000 (07:40 +0100)
Adding concurrency to SURF LMM, with oldstyle element set

38 files changed:
ChangeLog
appveyor.yml
doc/doxygen/options.doc
examples/msg/mc/bugged1_liveness_sparse.tesh
examples/msg/mc/bugged1_liveness_visited_sparse.tesh
examples/smpi/replay_multiple/generate_multiple_deployment.sh
examples/smpi/replay_multiple/replay_multiple.tesh
include/simgrid/forward.h
src/bindings/java/org/simgrid/NativeLib.java
src/bindings/lua/lua_platf.c
src/include/surf/surf.h
src/mc/AddressSpace.hpp
src/mc/mc_compare.cpp
src/simdag/sd_global.cpp
src/simgrid/sg_config.c
src/surf/cpu_cas01.cpp
src/surf/cpu_cas01.hpp
src/surf/cpu_interface.cpp
src/surf/cpu_interface.hpp
src/surf/cpu_ti.cpp
src/surf/cpu_ti.hpp
src/surf/host_ptask_L07.cpp
src/surf/host_ptask_L07.hpp
src/surf/network_cm02.cpp
src/surf/network_interface.cpp
src/surf/network_interface.hpp
src/surf/surf_c_bindings.cpp
src/surf/surf_interface.hpp
src/surf/surf_routing.cpp
src/surf/surfxml_parse.c
src/surf/surfxml_parseplatf.cpp [moved from src/surf/surfxml_parseplatf.c with 77% similarity]
src/surf/trace_mgr.cpp
src/surf/trace_mgr.hpp
teshsuite/smpi/mpich3-test/pt2pt/testlist
teshsuite/smpi/struct/struct_test.c
teshsuite/surf/trace_usage/trace_usage.cpp
tools/cmake/DefinePackages.cmake
tools/cmake/Java.cmake

index 5fe765c..b1d4706 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,12 @@ SimGrid (3.13) UNRELEASED; urgency=low
     the lambda or closure passed as a parameter will run in kernel mode.
    Every callbacks should be rewritten to that interface at some point.
    
+ MC
+ * BC breaks:
+   - The option "model-check/sparse-checkpoint" was renamed to
+     "model-check/sparse_checkpoint" as we attempt to unify our naming
+     schemes.
+
  Surf
  * Reorganizing and cleaning the internals all around the place.
 
index 5fd78d3..c1c921f 100644 (file)
@@ -84,6 +84,8 @@ build_script:
 artifacts:
 - path: simgrid.jar
   name: jarfile
+- path: C:/mingw64/bin/libwinpthread-1.dll
+  name: libwinpthread-1.dll
 
 # notifications:
 # - irc: "irc.debian.org#simgrid" # Not implemented by AppVeyor yet :(
index c01adfc..a690ad3 100644 (file)
@@ -439,7 +439,7 @@ reach GiB ou Tib of memory. However, for many workloads, the memory does not
 change much between different snapshots and taking a complete copy of each
 snapshot is a waste of memory.
 
-The \b model-check/sparse-checkpoint option item can be set to \b yes in order
+The \b model-check/sparse_checkpoint option item can be set to \b yes in order
 to avoid making a complete copy of each snapshot: instead, each snapshot will be
 decomposed in blocks which will be stored separately.
 If multiple snapshots share the same block (or if the same block
@@ -465,7 +465,7 @@ really meaningful: you should expect the contribution of the memory
 consumption of the snapshots to be \f$ \mbox{number of processes}
 \times \mbox{stack size} \times \mbox{number of states} \f$.
 
-The \b model-check/sparse-checkpoint can be used to reduce the memory
+The \b model-check/sparse_checkpoint can be used to reduce the memory
 consumption by trying to share memory between the different snapshots.
 
 When compiled against the model checker, the stacks are not
@@ -1092,7 +1092,7 @@ silently overflow on other parts of the memory.
 - \c model-check/reduction: \ref options_modelchecking_reduction
 - \c model-check/replay: \ref options_modelchecking_recordreplay
 - \c model-check/send_determinism: \ref options_modelchecking_sparse_checkpoint
-- \c model-check/sparse-checkpoint: \ref options_modelchecking_sparse_checkpoint
+- \c model-check/sparse_checkpoint: \ref options_modelchecking_sparse_checkpoint
 - \c model-check/termination: \ref options_modelchecking_termination
 - \c model-check/timeout: \ref options_modelchecking_timeout
 - \c model-check/visited: \ref options_modelchecking_visited
index fec3097..2cb31c9 100644 (file)
@@ -2,7 +2,7 @@
 
 ! expect return 2
 ! timeout 10
-$ ${bindir:=.}/../../../bin/simgrid-mc ${bindir:=.}/bugged1_liveness ${srcdir:=.}/../../platforms/platform.xml ${srcdir:=.}/deploy_bugged1_liveness.xml --log=xbt_cfg.thresh:warning "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:ucontext --cfg=contexts/stack_size:256 --cfg=model-check/sparse-checkpoint:yes --cfg=model-check/property:promela_bugged1_liveness
+$ ${bindir:=.}/../../../bin/simgrid-mc ${bindir:=.}/bugged1_liveness ${srcdir:=.}/../../platforms/platform.xml ${srcdir:=.}/deploy_bugged1_liveness.xml --log=xbt_cfg.thresh:warning "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:ucontext --cfg=contexts/stack_size:256 --cfg=model-check/sparse_checkpoint:yes --cfg=model-check/property:promela_bugged1_liveness
 > [  0.000000] (0:maestro@) Check the liveness property promela_bugged1_liveness
 > [  0.000000] (2:client@Boivin) Ask the request
 > [  0.000000] (3:client@Fafard) Ask the request
index 58993e3..8e42ec9 100644 (file)
@@ -2,7 +2,7 @@
 
 ! expect return 2
 ! timeout 10
-$ ${bindir:=.}/../../../bin/simgrid-mc ${bindir:=.}/bugged1_liveness ${srcdir:=.}/../../platforms/platform.xml ${srcdir:=.}/deploy_bugged1_liveness_visited.xml --log=xbt_cfg.thresh:warning "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:ucontext --cfg=model-check/visited:100 --cfg=contexts/stack_size:256 --cfg=model-check/sparse-checkpoint:yes  --cfg=model-check/property:promela_bugged1_liveness
+$ ${bindir:=.}/../../../bin/simgrid-mc ${bindir:=.}/bugged1_liveness ${srcdir:=.}/../../platforms/platform.xml ${srcdir:=.}/deploy_bugged1_liveness_visited.xml --log=xbt_cfg.thresh:warning "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=contexts/factory:ucontext --cfg=model-check/visited:100 --cfg=contexts/stack_size:256 --cfg=model-check/sparse_checkpoint:yes  --cfg=model-check/property:promela_bugged1_liveness
 > [  0.000000] (0:maestro@) Check the liveness property promela_bugged1_liveness
 > [  0.000000] (2:client@Boivin) Ask the request
 > [  0.000000] (3:client@Fafard) Ask the request
index 9916e88..2818e9b 100755 (executable)
@@ -116,7 +116,7 @@ fi
 
 ##-------------------------------- DEFAULT APPLICATION --------------------------------------
 
-APPLICATIONTMP=$(echo ${PROC_ARGS}|cut -d' ' -f2)
+APPLICATIONTMP=$(echo ${PROC_ARGS}|cut -d' ' -f2 -s)
 
 cat > ${APPLICATIONTMP} <<APPLICATIONHEAD
 <?xml version='1.0'?>
index b552fc2..f617815 100644 (file)
@@ -1,7 +1,7 @@
 p Test the replay with multiple instances 
 
 p first generate the deployment file
-$ ${srcdir:=.}/generate_multiple_deployment.sh -platform ${srcdir:=.}/../../platforms/small_platform_with_routers.xml -hostfile ${srcdir:=.}/../hostfile  ${srcdir:=.}/description_file deployment.xml
+$ ${srcdir:=.}/generate_multiple_deployment.sh -platform ${srcdir:=.}/../../platforms/small_platform_with_routers.xml -hostfile ${srcdir:=.}/../hostfile  ${srcdir:=.}/description_file ${srcdir:=.}/deployment.xml
 
 ! timeout 120
 $ ./replay_multiple description_file ${srcdir:=.}/../../platforms/small_platform_with_routers.xml deployment.xml --log=smpi.:info
index b910d90..ecab7aa 100644 (file)
@@ -16,6 +16,7 @@ namespace simgrid {
     class Host;
   }
   namespace surf {
+    class Resource;
     class Cpu;
     class NetCard;
     class As;
@@ -27,26 +28,29 @@ namespace simgrid {
 }
 
 typedef simgrid::s4u::Host simgrid_Host;
+typedef simgrid::surf::As surf_As;
 typedef simgrid::surf::Cpu surf_Cpu;
 typedef simgrid::surf::NetCard surf_NetCard;
-typedef simgrid::surf::As surf_As;
 typedef simgrid::surf::Link Link;
+typedef simgrid::surf::Resource surf_Resource;
 typedef simgrid::trace_mgr::future_evt_set sg_future_evt_set;
 
 #else
 
 typedef struct simgrid_Host simgrid_Host;
+typedef struct surf_As surf_As;
 typedef struct surf_Cpu surf_Cpu;
 typedef struct surf_NetCard surf_NetCard;
-typedef struct surf_As surf_As;
+typedef struct surf_Resource surf_Resource;
 typedef struct Link Link;
 typedef struct future_evt_set sg_future_evt_set;
 #endif
 
 typedef simgrid_Host* sg_host_t;
+typedef surf_As *AS_t;
 typedef surf_Cpu *surf_cpu_t;
 typedef surf_NetCard *sg_netcard_t;
-typedef surf_As *AS_t;
+typedef surf_Resource *sg_resource_t;
 typedef sg_future_evt_set *sg_future_evt_set_t;
 
 // Types which are in fact dictelmt:
index e7a94e5..c89c57f 100644 (file)
@@ -19,7 +19,10 @@ public final class NativeLib {
        public static void nativeInit() {
                if (isNativeInited)
                        return;
-               
+
+               if (System.getProperty("os.name").toLowerCase().startsWith("win"))
+                       NativeLib.nativeInit("winpthread-1");
+
                NativeLib.nativeInit("simgrid");
                NativeLib.nativeInit("simgrid-java");      
                isNativeInited = true;
index 1462c54..4f7507b 100644 (file)
@@ -182,7 +182,7 @@ int console_add_host(lua_State *L) {
     XBT_ERROR("Attribute 'speed' must be specified for host and must either be a string (in the correct format; check documentation) or a number.");
   }
   host.speed_peak = xbt_dynar_new(sizeof(double), NULL);
-  xbt_dynar_push_as(host.speed_peak, double, get_cpu_speed(lua_tostring(L, -1)));
+  xbt_dynar_push_as(host.speed_peak, double, parse_cpu_speed(lua_tostring(L, -1)));
   lua_pop(L, 1);
 
   // get core
index 0cc2122..52a2e56 100644 (file)
@@ -975,20 +975,15 @@ XBT_PUBLIC(void) parse_platform_file(const char *file);
 
 /* For the trace and trace:connect tag (store their content till the end of the parsing) */
 XBT_PUBLIC_DATA(xbt_dict_t) traces_set_list;
-XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_host_avail;
-XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_power;
+XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_host_speed;
 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_avail;
-XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_bandwidth;
-XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_latency;
+XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_bw;
+XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_lat;
 
-
-XBT_PUBLIC(double) get_cpu_speed(const char *power);
+XBT_PUBLIC(double) parse_cpu_speed(const char *str_speed);
 
 XBT_PUBLIC(xbt_dict_t) get_as_router_properties(const char* name);
 
-int surf_get_nthreads(void);
-void surf_set_nthreads(int nthreads);
-
 /*
  * Returns the initial path. On Windows the initial path is
  * the current directory for the current process in the other
index 5b55a31..d0c92b5 100644 (file)
@@ -50,12 +50,12 @@ public:
   {
     return remote_ptr<T>(address_ - n * sizeof(T));
   }
-  remote_ptr<T>& operator+=(std::uint64_t n) const
+  remote_ptr<T>& operator+=(std::uint64_t n)
   {
     address_ += n * sizeof(T);
     return *this;
   }
-  remote_ptr<T>& operator-=(std::uint64_t n) const
+  remote_ptr<T>& operator-=(std::uint64_t n)
   {
     address_ -= n * sizeof(T);
     return *this;
index 5740b04..daf84c8 100644 (file)
@@ -321,7 +321,7 @@ static int compare_local_variables(int process_index,
       current_var1 = &stack1->local_variables[cursor];
       current_var2 = &stack1->local_variables[cursor];
       if (current_var1->name != current_var2->name
-          || current_var1->subprogram != current_var1->subprogram
+          || current_var1->subprogram != current_var2->subprogram
           || current_var1->ip != current_var2->ip) {
         // TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram
         XBT_VERB
@@ -469,7 +469,7 @@ int snapshot_compare(void *state1, void *state2)
   mc_snapshot_stack_t stack1, stack2;
   while (cursor < s1->stacks.size()) {
     stack1 = &s1->stacks[cursor];
-    stack2 = &s1->stacks[cursor];
+    stack2 = &s2->stacks[cursor];
 
     if (stack1->process_index != stack2->process_index) {
       diff_local = 1;
index 053a0fc..eeb898c 100644 (file)
@@ -273,7 +273,7 @@ xbt_dynar_t SD_simulate(double how_long) {
 
   if (!sd_global->watch_point_reached && how_long<0){
     if (!xbt_dynar_is_empty(sd_global->initial_task_set)) {
-        XBT_WARN("Simulation is finished but %zu tasks are still not done",
+        XBT_WARN("Simulation is finished but %lu tasks are still not done",
             xbt_dynar_length(sd_global->initial_task_set));
         static const char* state_names[] =
           { "SD_NOT_SCHEDULED", "SD_SCHEDULABLE", "SD_SCHEDULED", "SD_RUNNABLE", "SD_RUNNING", "SD_DONE","SD_FAILED" };
index c6316bb..760acb6 100644 (file)
@@ -614,10 +614,10 @@ void sg_config_init(int *argc, char **argv)
     xbt_cfg_setdefault_int(_sg_cfg_set, "model-check/checkpoint", 0);
 
     /* do stateful model-checking */
-    xbt_cfg_register(&_sg_cfg_set, "model-check/sparse-checkpoint",
+    xbt_cfg_register(&_sg_cfg_set, "model-check/sparse_checkpoint",
                      "Use sparse per-page snapshots.",
                      xbt_cfgelm_boolean, 1, 1, _mc_cfg_cb_sparse_checkpoint, NULL);
-    xbt_cfg_setdefault_boolean(_sg_cfg_set, "model-check/sparse-checkpoint", "no");
+    xbt_cfg_setdefault_boolean(_sg_cfg_set, "model-check/sparse_checkpoint", "no");
 
     /* do stateful model-checking */
     xbt_cfg_register(&_sg_cfg_set, "model-check/soft-dirty",
index ff78c5c..79d0c91 100644 (file)
@@ -115,25 +115,15 @@ void CpuCas01Model::addTraces()
     return;
   called = 1;
 
-  /* connect all traces relative to hosts */
-  xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
+  /* connect host speed traces */
+  xbt_dict_foreach(trace_connect_list_host_speed, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuCas01 *host = static_cast<CpuCas01*>(sg_host_by_name(elm)->pimpl_cpu);
+    Cpu *cpu = sg_host_by_name(elm)->pimpl_cpu;
 
-    xbt_assert(host, "Host %s undefined", elm);
+    xbt_assert(cpu, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
-    host->p_stateEvent = future_evt_set->add_trace(trace, 0.0, host);
-  }
-
-  xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
-    tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuCas01 *host = static_cast<CpuCas01*>(sg_host_by_name(elm)->pimpl_cpu);
-
-    xbt_assert(host, "Host %s undefined", elm);
-    xbt_assert(trace, "Trace %s undefined", trace_name);
-
-    host->p_speedEvent = future_evt_set->add_trace(trace, 0.0, host);
+    cpu->set_speed_trace(trace);
   }
 }
 
index 88c6386..59d9930 100644 (file)
@@ -42,7 +42,6 @@ public:
  ************/
 
 class CpuCas01 : public Cpu {
-  friend CpuCas01Model;
 public:
   CpuCas01(CpuCas01Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeak,
         int pstate, double speedScale, tmgr_trace_t speedTrace, int core,
@@ -58,11 +57,6 @@ public:
 
 protected:
   void onSpeedChange() override;
-
-private:
-
-  tmgr_trace_iterator_t p_stateEvent = nullptr;
-  tmgr_trace_iterator_t p_speedEvent = nullptr;
 };
 
 /**********
index 5b31783..475e236 100644 (file)
@@ -245,6 +245,20 @@ int Cpu::getCore()
   return m_core;
 }
 
+void Cpu::set_state_trace(tmgr_trace_t trace)
+{
+  xbt_assert(p_stateEvent==NULL,"Cannot set a second state trace to Host %s", m_host->name().c_str());
+
+  p_stateEvent = future_evt_set->add_trace(trace, 0.0, this);
+}
+void Cpu::set_speed_trace(tmgr_trace_t trace)
+{
+  xbt_assert(p_speedEvent==NULL,"Cannot set a second speed trace to Host %s", m_host->name().c_str());
+
+  p_speedEvent = future_evt_set->add_trace(trace, 0.0, this);
+}
+
+
 /**********
  * Action *
  **********/
index a0d9860..27bcee0 100644 (file)
@@ -149,7 +149,6 @@ public:
   virtual void setPState(int pstate_index);
   virtual int  getPState();
 
-  void addTraces(void);
   simgrid::s4u::Host* getHost() { return m_host; }
 
 public:
@@ -165,6 +164,12 @@ public:
   lmm_constraint_t *p_constraintCore=NULL;
   void **p_constraintCoreId=NULL;
 
+public:
+  void set_state_trace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF) */
+  void set_speed_trace(tmgr_trace_t trace); /*< setup the trace file with availability events (peak speed changes due to external load) */
+protected:
+  tmgr_trace_iterator_t p_stateEvent = nullptr;
+  tmgr_trace_iterator_t p_speedEvent = nullptr;
 };
 
 /**********
index d309542..63701e2 100644 (file)
@@ -385,17 +385,6 @@ int CpuTiTrace::binarySearch(double *array, double a, int low, int high)
 }
 }
 
-/*************
- * CallBacks *
- *************/
-
-static void cpu_ti_define_callbacks()
-{
-  simgrid::surf::on_postparse.connect([]() {
-    surf_cpu_model_pm->addTraces();
-  });
-}
-
 /*********
  * Model *
  *********/
@@ -406,13 +395,14 @@ void surf_cpu_model_init_ti()
   xbt_assert(!surf_cpu_model_vm,"CPU model already initialized. This should not happen.");
 
   surf_cpu_model_pm = new simgrid::surf::CpuTiModel();
+  xbt_dynar_push(all_existing_models, &surf_cpu_model_pm);
+
   surf_cpu_model_vm = new simgrid::surf::CpuTiModel();
+  xbt_dynar_push(all_existing_models, &surf_cpu_model_vm);
 
-  cpu_ti_define_callbacks();
-  simgrid::surf::Model *model_pm = static_cast<simgrid::surf::Model*>(surf_cpu_model_pm);
-  simgrid::surf::Model *model_vm = static_cast<simgrid::surf::Model*>(surf_cpu_model_vm);
-  xbt_dynar_push(all_existing_models, &model_pm);
-  xbt_dynar_push(all_existing_models, &model_vm);
+  simgrid::surf::on_postparse.connect([]() {
+    surf_cpu_model_pm->addTraces();
+  });
 }
 
 namespace simgrid {
@@ -502,23 +492,7 @@ void CpuTiModel::addTraces()
   called = 1;
 
 /* connect all traces relative to hosts */
-  xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
-    tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuTi *cpu = static_cast<CpuTi*>(sg_host_by_name(elm)->pimpl_cpu);
-
-    xbt_assert(cpu, "Host %s undefined", elm);
-    xbt_assert(trace, "Trace %s undefined", trace_name);
-
-    if (cpu->p_stateEvent) {
-      XBT_DEBUG("Trace already configured for this CPU(%s), ignoring it",
-             elm);
-      continue;
-    }
-    XBT_DEBUG("Add state trace: %s to CPU(%s)", trace_name, elm);
-    cpu->p_stateEvent = future_evt_set->add_trace(trace, 0.0, cpu);
-  }
-
-  xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
+  xbt_dict_foreach(trace_connect_list_host_speed, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
     CpuTi *cpu = static_cast<CpuTi*>(sg_host_by_name(elm)->pimpl_cpu);
 
@@ -537,8 +511,7 @@ void CpuTiModel::addTraces()
       xbt_dynar_get_cpy(trace->s_list.event_list,
                         xbt_dynar_length(trace->s_list.event_list) - 1, &val);
       if (val.delta == 0) {
-        cpu->p_speedEvent =
-            future_evt_set->add_trace(tmgr_empty_trace_new(), cpu->p_availTrace->m_lastTime, cpu);
+        cpu->set_speed_trace(tmgr_empty_trace_new());
       }
     }
   }
index 9df68f4..9c46c46 100644 (file)
@@ -128,8 +128,6 @@ public:
   void modified(bool modified);
 
   CpuTiTgmr *p_availTrace;       /*< Structure with data needed to integrate trace file */
-  tmgr_trace_iterator_t p_stateEvent = NULL; /*< trace file with states events (ON or OFF) */
-  tmgr_trace_iterator_t p_speedEvent = NULL; /*< trace file with availability events */
   ActionTiList *p_actionSet;        /*< set with all actions running on cpu */
   double m_sumPriority;          /*< the sum of actions' priority that are running on cpu */
   double m_lastUpdate = 0;       /*< last update of actions' remaining amount done */
index 7e46744..9197c4d 100644 (file)
@@ -202,7 +202,6 @@ L07Action::L07Action(Model *model, int host_nb,
   int nb_used_host = 0; /* Only the hosts with something to compute (>0 flops) are counted) */
   double latency = 0.0;
 
-  xbt_dict_t ptask_parallel_task_link_set = xbt_dict_new_homogeneous(NULL);
 
   this->p_netcardList->reserve(host_nb);
   for (int i = 0; i<host_nb; i++)
@@ -210,6 +209,8 @@ L07Action::L07Action(Model *model, int host_nb,
 
   /* Compute the number of affected resources... */
   if(bytes_amount != NULL) {
+    xbt_dict_t ptask_parallel_task_link_set = xbt_dict_new_homogeneous(NULL);
+
     for (int i = 0; i < host_nb; i++) {
       for (int j = 0; j < host_nb; j++) {
         xbt_dynar_t route=NULL;
@@ -231,33 +232,31 @@ L07Action::L07Action(Model *model, int host_nb,
         }
       }
     }
-  }
 
-  nb_link = xbt_dict_length(ptask_parallel_task_link_set);
-  xbt_dict_free(&ptask_parallel_task_link_set);
+    nb_link = xbt_dict_length(ptask_parallel_task_link_set);
+    xbt_dict_free(&ptask_parallel_task_link_set);
+  }
 
   for (int i = 0; i < host_nb; i++)
     if (flops_amount[i] > 0)
       nb_used_host++;
 
-  XBT_DEBUG("Creating a parallel task (%p) with %d cpus and %d links.",
-         this, host_nb, nb_link);
+  XBT_DEBUG("Creating a parallel task (%p) with %d hosts and %d unique links.", this, host_nb, nb_link);
   this->p_computationAmount = flops_amount;
   this->p_communicationAmount = bytes_amount;
   this->m_latency = latency;
   this->m_rate = rate;
 
   this->p_variable = lmm_variable_new(model->getMaxminSystem(), this, 1.0,
-                                        (rate > 0 ? rate : -1.0),
-                                                                               host_nb + nb_link);
+      (rate > 0 ? rate : -1.0),
+      host_nb + nb_link);
 
   if (this->m_latency > 0)
     lmm_update_variable_weight(model->getMaxminSystem(), this->getVariable(), 0.0);
 
   for (int i = 0; i < host_nb; i++)
-    lmm_expand(model->getMaxminSystem(),
-              host_list[i]->pimpl_cpu->getConstraint(),
-               this->getVariable(), flops_amount[i]);
+    lmm_expand(model->getMaxminSystem(), host_list[i]->pimpl_cpu->getConstraint(),
+        this->getVariable(), flops_amount[i]);
 
   if(bytes_amount != NULL) {
     for (int i = 0; i < host_nb; i++) {
@@ -298,9 +297,7 @@ Action *NetworkL07Model::communicate(NetCard *src, NetCard *dst,
   host_list[1] = sg_host_by_name(dst->getName());
   bytes_amount[1] = size;
 
-  res = p_hostModel->executeParallelTask(2, host_list,
-                                    flops_amount,
-                                    bytes_amount, rate);
+  res = p_hostModel->executeParallelTask(2, host_list, flops_amount, bytes_amount, rate);
 
   return res;
 }
@@ -343,28 +340,18 @@ void HostL07Model::addTraces()
   xbt_dict_cursor_t cursor = NULL;
   char *trace_name, *elm;
 
-  if (!trace_connect_list_host_avail)
+  if (!trace_connect_list_host_speed)
     return;
 
   /* Connect traces relative to cpu */
-  xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
-    tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuL07 *host = static_cast<CpuL07*>(sg_host_by_name(elm)->pimpl_cpu);
-
-    xbt_assert(host, "Host %s undefined", elm);
-    xbt_assert(trace, "Trace %s undefined", trace_name);
-
-    host->p_stateEvent = future_evt_set->add_trace(trace, 0.0, host);
-  }
-
-  xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
+  xbt_dict_foreach(trace_connect_list_host_speed, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuL07 *host = static_cast<CpuL07*>(sg_host_by_name(elm)->pimpl_cpu);
+    Cpu *cpu = sg_host_by_name(elm)->pimpl_cpu;
 
-    xbt_assert(host, "Host %s undefined", elm);
+    xbt_assert(cpu, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
-    host->p_speedEvent = future_evt_set->add_trace(trace, 0.0, host);
+    cpu->set_speed_trace(trace);
   }
 
   /* Connect traces relative to network */
@@ -378,7 +365,7 @@ void HostL07Model::addTraces()
     link->p_stateEvent = future_evt_set->add_trace(trace, 0.0, link);
   }
 
-  xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
+  xbt_dict_foreach(trace_connect_list_link_bw, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
     LinkL07 *link = static_cast<LinkL07*>(Link::byName(elm));
 
@@ -388,7 +375,7 @@ void HostL07Model::addTraces()
     link->p_bwEvent = future_evt_set->add_trace(trace, 0.0, link);
   }
 
-  xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
+  xbt_dict_foreach(trace_connect_list_link_lat, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
     LinkL07 *link = static_cast<LinkL07*>(Link::byName(elm));
 
@@ -454,13 +441,12 @@ Action *CpuL07::execution_start(double size)
 {
   sg_host_t*host_list = xbt_new0(sg_host_t, 1);
   double *flops_amount = xbt_new0(double, 1);
-  double *bytes_amount = xbt_new0(double, 1);
 
   host_list[0] = getHost();
   flops_amount[0] = size;
 
   return static_cast<CpuL07Model*>(getModel())->p_hostModel
-    ->executeParallelTask( 1, host_list, flops_amount, bytes_amount, -1);
+    ->executeParallelTask( 1, host_list, flops_amount, NULL, -1);
 }
 
 Action *CpuL07::sleep(double duration)
@@ -617,32 +603,5 @@ int L07Action::unref()
   return 0;
 }
 
-void L07Action::suspend()
-{
-  XBT_IN("(%p))", this);
-  if (m_suspended != 2) {
-    m_suspended = 1;
-    lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), 0.0);
-  }
-  XBT_OUT();
-}
-
-void L07Action::resume()
-{
-  XBT_IN("(%p)", this);
-  if (m_suspended != 2) {
-    lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), 1.0);
-    m_suspended = 0;
-  }
-  XBT_OUT();
-}
-
-double L07Action::getRemains()
-{
-  XBT_IN("(%p)", this);
-  XBT_OUT();
-  return m_remains;
-}
-
 }
 }
index 079058d..d811ddf 100644 (file)
@@ -93,9 +93,6 @@ public:
  ************/
 
 class CpuL07 : public Cpu {
-  friend void HostL07Model::addTraces();
-  tmgr_trace_iterator_t p_stateEvent = nullptr;
-  tmgr_trace_iterator_t p_speedEvent = nullptr;
 public:
   CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeakList, int pstate,
                 double power_scale, tmgr_trace_t power_trace,
@@ -152,9 +149,6 @@ public:
   void updateBound();
 
   int unref() override;
-  void suspend() override;
-  void resume() override;
-  double getRemains() override;
 
   std::vector<NetCard*> * p_netcardList = new std::vector<NetCard*>();
   double *p_computationAmount;
index 0bd306f..3f7a944 100644 (file)
@@ -483,7 +483,7 @@ void NetworkCm02Model::addTraces(){
     link->p_stateEvent = future_evt_set->add_trace(trace, 0.0, link);
   }
 
-  xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
+  xbt_dict_foreach(trace_connect_list_link_bw, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
     NetworkCm02Link *link = static_cast<NetworkCm02Link*>( Link::byName(elm) );
 
@@ -496,7 +496,7 @@ void NetworkCm02Model::addTraces(){
     link->p_speed.event = future_evt_set->add_trace(trace, 0.0, link);
   }
 
-  xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
+  xbt_dict_foreach(trace_connect_list_link_lat, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
     NetworkCm02Link *link = static_cast<NetworkCm02Link*>(Link::byName(elm));;
 
index 0996ae3..14cde62 100644 (file)
@@ -97,7 +97,7 @@ void Link::linksExit() {
 
 simgrid::xbt::signal<void(simgrid::surf::Link*)> Link::onCreation;
 simgrid::xbt::signal<void(simgrid::surf::Link*)> Link::onDestruction;
-simgrid::xbt::signal<void(simgrid::surf::Link*, int, int)> Link::onStateChange; // signature: wasOn, currentlyOn
+simgrid::xbt::signal<void(simgrid::surf::Link*)> Link::onStateChange;
 
 simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, e_surf_action_state_t, e_surf_action_state_t)> networkActionStateChangedCallbacks;
 simgrid::xbt::signal<void(simgrid::surf::NetworkAction*, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst, double size, double rate)> networkCommunicateCallbacks;
@@ -254,13 +254,13 @@ int Link::sharingPolicy()
 void Link::turnOn(){
   if (isOff()) {
     Resource::turnOn();
-    onStateChange(this, 0, 1);
+    onStateChange(this);
   }
 }
 void Link::turnOff(){
   if (isOn()) {
     Resource::turnOff();
-    onStateChange(this, 1, 0);
+    onStateChange(this);
   }
 }
 
index 5e26f23..0ead107 100644 (file)
@@ -211,9 +211,9 @@ public:
    *  Signature: void(Link*) */
   static simgrid::xbt::signal<void(simgrid::surf::Link*)> onDestruction;
 
-  /** @brief Callback signal fired when the state of a Link changes
-   *  Signature: `void(LinkAction *action, int previouslyOn, int currentlyOn)` */
-  static simgrid::xbt::signal<void(simgrid::surf::Link*, int, int)> onStateChange;
+  /** @brief Callback signal fired when the state of a Link changes (when it is turned on or off)
+   *  Signature: `void(Link*)` */
+  static simgrid::xbt::signal<void(simgrid::surf::Link*)> onStateChange;
 
 
   /** @brief Get the bandwidth in bytes per second of current Link */
index ce621b9..8d3fe2c 100644 (file)
@@ -41,9 +41,8 @@ void surf_presolve(void)
   while ((next_event_date = future_evt_set->next_date()) != -1.0) {
     if (next_event_date > NOW)
       break;
-    while ((event = future_evt_set->pop_leq(next_event_date,
-                                            &value,
-                                            (void **) &resource))) {
+
+    while ((event = future_evt_set->pop_leq(next_event_date, &value, &resource))) {
       if (value >= 0){
         resource->updateState(event, value, NOW);
       }
@@ -86,23 +85,22 @@ double surf_solve(double max_date)
                  surf_min = next_event_virt;
   }
 
-  XBT_DEBUG("Min for resources (remember that NS3 don't update that value) : %f", surf_min);
+  XBT_DEBUG("Min for resources (remember that NS3 don't update that value): %f", surf_min);
 
   XBT_DEBUG("Looking for next trace event");
 
-  do {
-    XBT_DEBUG("Next TRACE event : %f", next_event_date);
-
+  while (1) { // Handle next occurring events until none remains
     next_event_date = future_evt_set->next_date();
+    XBT_DEBUG("Next TRACE event: %f", next_event_date);
 
     if(! surf_network_model->shareResourcesIsIdempotent()){ // NS3, I see you
-      if(next_event_date!=-1.0 && surf_min!=-1.0) {
+      if (next_event_date!=-1.0 && surf_min!=-1.0) {
         surf_min = MIN(next_event_date - NOW, surf_min);
       } else{
         surf_min = MAX(next_event_date - NOW, surf_min);
       }
 
-      XBT_DEBUG("Run for network at most %f", surf_min);
+      XBT_DEBUG("Run the NS3 network at most %fs", surf_min);
       // run until min or next flow
       model_next_action_end = surf_network_model->shareResources(surf_min);
 
@@ -116,39 +114,37 @@ double surf_solve(double max_date)
       break;
     }
 
-    if ((surf_min == -1.0) || (next_event_date > NOW + surf_min)) break;
+    if ((surf_min == -1.0) || (next_event_date > NOW + surf_min))
+      break; // next event occurs after the next resource change, bail out
 
     XBT_DEBUG("Updating models (min = %g, NOW = %g, next_event_date = %g)", surf_min, NOW, next_event_date);
-    while ((event = future_evt_set->pop_leq(next_event_date,
-                                            &value,
-                                            (void **) &resource))) {
+
+    while ((event = future_evt_set->pop_leq(next_event_date, &value, &resource))) {
       if (resource->isUsed() || xbt_dict_get_or_null(watched_hosts_lib, resource->getName())) {
         surf_min = next_event_date - NOW;
-        XBT_DEBUG
-            ("This event will modify model state. Next event set to %f",
-             surf_min);
+        XBT_DEBUG("This event will modify model state. Next event set to %f", surf_min);
       }
-      /* update state of model_obj according to new value. Does not touch lmm.
+      /* update state of the corresponding resource to the new value. Does not touch lmm.
          It will be modified if needed when updating actions */
-      XBT_DEBUG("Calling update_resource_state for resource %s with min %f",
-             resource->getName(), surf_min);
+      XBT_DEBUG("Calling update_resource_state for resource %s with min %f", resource->getName(), surf_min);
       resource->updateState(event, value, next_event_date);
     }
-  } while (1);
+  }
 
   /* FIXME: Moved this test to here to avoid stopping simulation if there are actions running on cpus and all cpus are with availability = 0.
    * This may cause an infinite loop if one cpu has a trace with periodicity = 0 and the other a trace with periodicity > 0.
    * The options are: all traces with same periodicity(0 or >0) or we need to change the way how the events are managed */
   if (surf_min == -1.0) {
-  XBT_DEBUG("No next event at all. Bail out now.");
+    XBT_DEBUG("No next event at all. Bail out now.");
     return -1.0;
   }
 
   XBT_DEBUG("Duration set to %f", surf_min);
 
+  // Bump the time: jump into the future
   NOW = NOW + surf_min;
-  /* FIXME: model_list or model_list_invoke? revisit here later */
-  /* sequential version */
+
+  // Inform the models of the date change
   xbt_dynar_foreach(all_existing_models, iter, model) {
          model->updateActionsState(NOW, surf_min);
   }
index 3ca6f61..85fc8e0 100644 (file)
@@ -74,10 +74,10 @@ enum heap_action_type{
 /* For the trace and trace:connect tag (store their content till the end of the parsing) */
 XBT_PUBLIC_DATA(xbt_dict_t) traces_set_list;
 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_host_avail;
-XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_power;
+XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_host_speed;
 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_avail;
-XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_bandwidth;
-XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_latency;
+XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_bw;
+XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_lat;
 
 /**********
  * Action *
index 8ff7606..7ce56b2 100644 (file)
@@ -227,7 +227,7 @@ void sg_platf_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect)
         xbt_strdup(trace_connect->element), NULL);
     break;
   case SURF_TRACE_CONNECT_KIND_POWER:
-    xbt_dict_set(trace_connect_list_power, trace_connect->trace,
+    xbt_dict_set(trace_connect_list_host_speed, trace_connect->trace,
         xbt_strdup(trace_connect->element), NULL);
     break;
   case SURF_TRACE_CONNECT_KIND_LINK_AVAIL:
@@ -236,12 +236,12 @@ void sg_platf_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect)
         xbt_strdup(trace_connect->element), NULL);
     break;
   case SURF_TRACE_CONNECT_KIND_BANDWIDTH:
-    xbt_dict_set(trace_connect_list_bandwidth,
+    xbt_dict_set(trace_connect_list_link_bw,
         trace_connect->trace,
         xbt_strdup(trace_connect->element), NULL);
     break;
   case SURF_TRACE_CONNECT_KIND_LATENCY:
-    xbt_dict_set(trace_connect_list_latency, trace_connect->trace,
+    xbt_dict_set(trace_connect_list_link_lat, trace_connect->trace,
         xbt_strdup(trace_connect->element), NULL);
     break;
   default:
index 13002de..50c47f4 100644 (file)
@@ -443,7 +443,7 @@ void ETag_surfxml_host(void)    {
   XBT_DEBUG("Buffer: %s", buf);
   host.speed_peak = xbt_dynar_new(sizeof(double), NULL);
   if (strchr(buf, ',') == NULL){
-         double speed = get_cpu_speed(A_surfxml_host_power);
+         double speed = parse_cpu_speed(A_surfxml_host_power);
          xbt_dynar_push_as(host.speed_peak,double, speed);
   }
   else {
@@ -455,7 +455,7 @@ void ETag_surfxml_host(void)    {
 
                  xbt_dynar_get_cpy(pstate_list, i, &speed_str);
                  xbt_str_trim(speed_str, NULL);
-                 speed = get_cpu_speed(speed_str);
+                 speed = parse_cpu_speed(speed_str);
                  xbt_dynar_push_as(host.speed_peak, double, speed);
                  XBT_DEBUG("Speed value: %f", speed);
          }
@@ -1061,7 +1061,7 @@ int_f_void_t surf_parse = _surf_parse;
  * With XML parser
  */
 
-double get_cpu_speed(const char *str_speed)
+double parse_cpu_speed(const char *str_speed)
 {
   double speed = 0.0;
   const char *p, *q;
similarity index 77%
rename from src/surf/surfxml_parseplatf.c
rename to src/surf/surfxml_parseplatf.cpp
index 1bfcdf4..ab301e3 100644 (file)
@@ -10,6 +10,7 @@
 #include "xbt/dict.h"
 #include "simgrid/platf.h"
 #include "surf/surfxml_parse.h"
+#include "src/surf/cpu_interface.hpp"
 #include "src/surf/surf_private.h"
 
 #ifdef HAVE_LUA
@@ -36,9 +37,9 @@ static char *old_buff = NULL;
 XBT_IMPORT_NO_EXPORT(unsigned int) surfxml_buffer_stack_stack_ptr;
 XBT_IMPORT_NO_EXPORT(unsigned int) surfxml_buffer_stack_stack[1024];
 
-void surfxml_bufferstack_push(int new)
+void surfxml_bufferstack_push(int new_one)
 {
-  if (!new)
+  if (!new_one)
     old_buff = surfxml_bufferstack;
   else {
     xbt_dynar_push(surfxml_bufferstack_stack, &surfxml_bufferstack);
@@ -46,9 +47,9 @@ void surfxml_bufferstack_push(int new)
   }
 }
 
-void surfxml_bufferstack_pop(int new)
+void surfxml_bufferstack_pop(int new_one)
 {
-  if (!new)
+  if (!new_one)
     surfxml_bufferstack = old_buff;
   else {
     free(surfxml_bufferstack);
@@ -62,10 +63,10 @@ void surfxml_bufferstack_pop(int new)
 
 xbt_dict_t traces_set_list = NULL;
 xbt_dict_t trace_connect_list_host_avail = NULL;
-xbt_dict_t trace_connect_list_power = NULL;
+xbt_dict_t trace_connect_list_host_speed = NULL;
 xbt_dict_t trace_connect_list_link_avail = NULL;
-xbt_dict_t trace_connect_list_bandwidth = NULL;
-xbt_dict_t trace_connect_list_latency = NULL;
+xbt_dict_t trace_connect_list_link_bw = NULL;
+xbt_dict_t trace_connect_list_link_lat = NULL;
 
 /* ***************************************** */
 
@@ -123,10 +124,10 @@ void parse_platform_file(const char *file)
 
     traces_set_list = xbt_dict_new_homogeneous(NULL);
     trace_connect_list_host_avail = xbt_dict_new_homogeneous(free);
-    trace_connect_list_power = xbt_dict_new_homogeneous(free);
+    trace_connect_list_host_speed = xbt_dict_new_homogeneous(free);
     trace_connect_list_link_avail = xbt_dict_new_homogeneous(free);
-    trace_connect_list_bandwidth = xbt_dict_new_homogeneous(free);
-    trace_connect_list_latency = xbt_dict_new_homogeneous(free);
+    trace_connect_list_link_bw = xbt_dict_new_homogeneous(free);
+    trace_connect_list_link_lat = xbt_dict_new_homogeneous(free);
 
     /* Init my data */
     if (!surfxml_bufferstack_stack)
@@ -135,12 +136,27 @@ void parse_platform_file(const char *file)
     /* Do the actual parsing */
     parse_status = surf_parse();
 
+    /* connect all traces relative to hosts */
+    xbt_dict_cursor_t cursor = NULL;
+    char *trace_name, *elm;
+
+    xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
+      tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
+      xbt_assert(trace, "Trace %s undefined", trace_name);
+
+      simgrid::s4u::Host *host = sg_host_by_name(elm);
+      xbt_assert(host, "Host %s undefined", elm);
+      simgrid::surf::Cpu *cpu = host->pimpl_cpu;
+
+      cpu->set_state_trace(trace);
+    }
+
     /* Free my data */
     xbt_dict_free(&trace_connect_list_host_avail);
-    xbt_dict_free(&trace_connect_list_power);
+    xbt_dict_free(&trace_connect_list_host_speed);
     xbt_dict_free(&trace_connect_list_link_avail);
-    xbt_dict_free(&trace_connect_list_bandwidth);
-    xbt_dict_free(&trace_connect_list_latency);
+    xbt_dict_free(&trace_connect_list_link_bw);
+    xbt_dict_free(&trace_connect_list_link_lat);
     xbt_dict_free(&traces_set_list);
     xbt_dict_free(&random_data_list);
     xbt_dynar_free(&surfxml_bufferstack_stack);
index 4726680..1b7b8fe 100644 (file)
@@ -369,11 +369,9 @@ void tmgr_trace_free(tmgr_trace_t trace)
   free(trace);
 }
 
-/** Register a new trace into the future event set, and get an iterator over the integrated trace  */
+/** @brief Registers a new trace into the future event set, and get an iterator over the integrated trace  */
 tmgr_trace_iterator_t simgrid::trace_mgr::future_evt_set::add_trace(
-    tmgr_trace_t trace,
-    double start_time,
-    void *resource)
+    tmgr_trace_t trace, double start_time, surf::Resource *resource)
 {
   tmgr_trace_iterator_t trace_iterator = NULL;
 
@@ -392,7 +390,8 @@ tmgr_trace_iterator_t simgrid::trace_mgr::future_evt_set::add_trace(
   return trace_iterator;
 }
 
-double simgrid::trace_mgr::future_evt_set::next_date()
+/** @brief returns the date of the next occurring event (pure function) */
+double simgrid::trace_mgr::future_evt_set::next_date() const
 {
   if (xbt_heap_size(p_heap))
     return (xbt_heap_maxkey(p_heap));
@@ -400,30 +399,24 @@ double simgrid::trace_mgr::future_evt_set::next_date()
     return -1.0;
 }
 
+/** @brief Retrieves the next occurring event, or NULL if none happens before #date */
 tmgr_trace_iterator_t simgrid::trace_mgr::future_evt_set::pop_leq(
-    double date,
-    double *value,
-    void** resource)
+    double date, double *value, simgrid::surf::Resource **resource)
 {
   double event_date = next_date();
-  tmgr_trace_iterator_t trace_iterator = NULL;
-  tmgr_event_t event = NULL;
-  tmgr_trace_t trace = NULL;
-  double event_delta;
-
   if (event_date > date)
     return NULL;
 
-  if (!(trace_iterator = (tmgr_trace_iterator_t)xbt_heap_pop(p_heap)))
+  tmgr_trace_iterator_t trace_iterator = (tmgr_trace_iterator_t)xbt_heap_pop(p_heap);
+  if (trace_iterator == NULL)
     return NULL;
 
-  trace = trace_iterator->trace;
+  tmgr_trace_t trace = trace_iterator->trace;
   *resource = trace_iterator->resource;
 
-  switch(trace->type) {
-    case e_trace_list:
+  if (trace->type == e_trace_list) {
 
-      event = (tmgr_event_t)xbt_dynar_get_ptr(trace->s_list.event_list, trace_iterator->idx);
+      tmgr_event_t event = (tmgr_event_t)xbt_dynar_get_ptr(trace->s_list.event_list, trace_iterator->idx);
 
       *value = event->value;
 
@@ -436,11 +429,9 @@ tmgr_trace_iterator_t simgrid::trace_mgr::future_evt_set::pop_leq(
       } else {                      /* We don't need this trace_event anymore */
         trace_iterator->free_me = 1;
       }
-      break;
-
-    case e_trace_probabilist:
 
-      //FIXME : not tested yet
+  } else if (trace->type == e_trace_probabilist) { //FIXME : not tested yet
+      double event_delta;
       if(trace->s_probabilist.is_state_trace) {
         *value = (double) trace->s_probabilist.next_event;
         if(trace->s_probabilist.next_event == 0) {
@@ -457,8 +448,8 @@ tmgr_trace_iterator_t simgrid::trace_mgr::future_evt_set::pop_leq(
       xbt_heap_push(p_heap, trace_iterator, event_date + event_delta);
       XBT_DEBUG("Generating a new event at date %f, with value %f", event_date + event_delta, *value);
 
-      break;
-  }
+  } else
+    THROW_IMPOSSIBLE;
 
   return trace_iterator;
 }
index d4115ab..ee06f3b 100644 (file)
@@ -71,7 +71,7 @@ typedef struct tmgr_trace {
 typedef struct tmgr_trace_iterator {
   tmgr_trace_t trace;
   unsigned int idx;
-  void *resource;
+  sg_resource_t resource;
   int free_me;
 } s_tmgr_trace_event_t;
 
@@ -103,12 +103,9 @@ XBT_PUBLIC_CLASS future_evt_set {
 public:
   future_evt_set();
   virtual ~future_evt_set();
-  double next_date();
-  tmgr_trace_iterator_t pop_leq(double date, double *value, void** resource);
-  tmgr_trace_iterator_t add_trace(
-      tmgr_trace_t trace,
-      double start_time,
-      void *model);
+  double next_date() const;
+  tmgr_trace_iterator_t pop_leq(double date, double *value, simgrid::surf::Resource** resource);
+  tmgr_trace_iterator_t add_trace(tmgr_trace_t trace, double start_time, simgrid::surf::Resource *resource);
 
 private:
   // TODO: use a boost type for the heap (or a ladder queue)
index 625e4a6..bae9ab2 100644 (file)
@@ -18,7 +18,7 @@ bottom 2
 #bsendalign 2
 #bsendpending 2
 isendself 1
-issendselfcancel 1
+#issendselfcancel 1
 #needs MPI_Buffer_attach, MPI_Bsend, MPI_Buffer_detach
 #bsendfrag 2
 #needs MPI_Intercomm_create
index 658f51a..f26ebcc 100644 (file)
@@ -61,9 +61,9 @@ char **argv;
    
     for(j=0; j<2;j++ )
       for(i=0; i<3;i++ )
-      printf("%d ", tab[j][i]);
+        printf("%d ", tab[j][i]);
 
-      printf("\n");
+    printf("\n");
 
 
     /* Clean up the type */
index 3cb5899..c9fb7e4 100644 (file)
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include "src/surf/network_cm02.hpp"
 #include "src/surf/trace_mgr.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,
                              "Messages specific for surf example");
 
+class DummyTestResource
+    : public simgrid::surf::Resource {
+public:
+  DummyTestResource(const char *name) : Resource(nullptr,name) {}
+  bool isUsed() override {return false;}
+  void updateState(tmgr_trace_iterator_t it, double date, double value) override {}
+};
+
 static void test(void)
 {
   simgrid::trace_mgr::future_evt_set *fes = new simgrid::trace_mgr::future_evt_set();
@@ -25,25 +34,25 @@ static void test(void)
   tmgr_trace_t trace_B = tmgr_trace_new_from_file("trace_B.txt");
   double next_event_date = -1.0;
   double value = -1.0;
-  char *resource = NULL;
-  char *host_A = strdup("Host A");
-  char *host_B = strdup("Host B");
+  simgrid::surf::Resource *resource = NULL;
+  simgrid::surf::Resource *hostA = new DummyTestResource("Host A");
+  simgrid::surf::Resource *hostB = new DummyTestResource("Host B");
 
-  fes->add_trace(trace_A, 1.0, host_A);
-  fes->add_trace(trace_B, 0.0, host_B);
+  fes->add_trace(trace_A, 1.0, hostA);
+  fes->add_trace(trace_B, 0.0, hostB);
 
   while ((next_event_date = fes->next_date()) != -1.0) {
     XBT_DEBUG("%g" " : \n", next_event_date);
-    while (fes->pop_leq(next_event_date, &value, (void **) &resource)) {
-      XBT_DEBUG("\t %s : " "%g" "\n", resource, value);
+    while (fes->pop_leq(next_event_date, &value, &resource)) {
+      XBT_DEBUG("\t %s : " "%g" "\n", resource->getName(), value);
     }
     if (next_event_date > 1000)
       break;
   }
 
   delete fes;
-  free(host_B);
-  free(host_A);
+  delete hostA;
+  delete hostB;
 }
 
 int main(int argc, char **argv)
index 7a85fdf..4a08a38 100644 (file)
@@ -341,7 +341,7 @@ set(SURF_SRC
   src/surf/surf_routing_none.cpp
   src/surf/surf_routing_vivaldi.cpp
   src/surf/surfxml_parse.c
-  src/surf/surfxml_parseplatf.c
+  src/surf/surfxml_parseplatf.cpp
   src/surf/trace_mgr.hpp
   src/surf/trace_mgr.cpp
   src/surf/vm_hl13.cpp
index 669c428..7f09188 100644 (file)
@@ -145,14 +145,17 @@ if(enable_lib_in_jar)
     #COMMAND ${STRIP_COMMAND} ${JAVA_NATIVE_PATH}/${LIBSIMGRID_JAVA_SO} || true
 
     COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_SO}      ${JAVA_NATIVE_PATH}
-    COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_JAVA_SO} ${JAVA_NATIVE_PATH} 
+    COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_JAVA_SO} ${JAVA_NATIVE_PATH}
+    # There is no way to disable the dependency of mingw-64 on that lib, unfortunately
+    # nor to script cmake -E properly, so let's be brutal
+    COMMAND ${CMAKE_COMMAND} -E copy C:/mingw64/bin/libwinpthread-1.dll  ${JAVA_NATIVE_PATH} || true
     
     COMMAND ${JAVA_ARCHIVE} -uvf ${SIMGRID_JAR}  ${JAVA_NATIVE_PATH}
     COMMAND ${CMAKE_COMMAND} -E remove_directory ${JAVA_NATIVE_PATH}
     
     COMMAND ${CMAKE_COMMAND} -E echo "-- Cmake put the native code in ${JAVA_NATIVE_PATH}"
     COMMAND "${Java_JAVA_EXECUTABLE}" -classpath "${SIMGRID_JAR}" org.simgrid.NativeLib
-    )
+  )
     
 endif(enable_lib_in_jar)