Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 21 Nov 2017 23:15:16 +0000 (00:15 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 21 Nov 2017 23:15:16 +0000 (00:15 +0100)
182 files changed:
.gitignore
ChangeLog
doc/doxygen/getting_started.doc
doc/doxygen/module-xbt.doc
doc/doxygen/outcomes_vizu.doc
doc/doxygen/uhood_arch.doc
examples/java/async/dsend/async-dsend.tesh
examples/java/async/waitall/async-waitall.tesh
examples/java/dht/chord/dht-chord.tesh
examples/java/energy/vm/energy-vm.tesh
examples/msg/README.doc
examples/msg/async-waitany/async-waitany.tesh
examples/msg/dht-kademlia/dht-kademlia.tesh
examples/msg/energy-vm/energy-vm.tesh
examples/msg/process-startkilltime/process-startkilltime.tesh
examples/msg/trace-categories/trace-categories.tesh
examples/msg/trace-masterworker/trace-masterworker.tesh
examples/platforms/config_tracing.xml
examples/s4u/README.doc
examples/s4u/app-bittorrent/s4u-peer.cpp
examples/s4u/app-bittorrent/s4u-tracker.cpp
examples/simdag/test/sd_test.cpp
examples/smpi/replay/replay.tesh
examples/smpi/replay_multiple/replay_multiple.tesh
examples/smpi/trace_simple/trace_simple.tesh
include/simgrid/forward.h
include/simgrid/s4u/File.hpp
include/simgrid/s4u/Host.hpp
include/simgrid/s4u/NetZone.hpp
include/simgrid/s4u/Storage.hpp
include/simgrid/simix.h
include/smpi/smpi.h
include/xbt.h
include/xbt/algorithm.hpp
include/xbt/heap.h [deleted file]
include/xbt/string.hpp
include/xbt/utility.hpp
src/bindings/java/org/simgrid/msg/Msg.java
src/bindings/java/org/simgrid/msg/Process.java
src/bindings/lua/lua_platf.cpp
src/include/surf/maxmin.hpp
src/instr/instr_config.cpp
src/instr/instr_interface.cpp
src/instr/instr_paje_events.cpp
src/instr/instr_paje_events.hpp
src/instr/instr_paje_types.cpp
src/instr/instr_paje_types.hpp
src/instr/instr_private.hpp
src/instr/instr_resource_utilization.cpp
src/instr/instr_smpi.hpp
src/kernel/activity/SynchroIo.cpp
src/kernel/routing/ClusterZone.cpp
src/kernel/routing/ClusterZone.hpp
src/kernel/routing/DijkstraZone.cpp
src/kernel/routing/DragonflyZone.cpp
src/kernel/routing/DragonflyZone.hpp
src/kernel/routing/FatTreeZone.cpp
src/kernel/routing/FloydZone.cpp
src/kernel/routing/FullZone.cpp
src/kernel/routing/NetZoneImpl.cpp
src/kernel/routing/NetZoneImpl.hpp
src/kernel/routing/RoutedZone.cpp
src/kernel/routing/TorusZone.cpp
src/kernel/routing/TorusZone.hpp
src/kernel/routing/VivaldiZone.cpp
src/mc/mc_global.cpp
src/mc/mc_record.cpp
src/mc/mc_request.cpp
src/mc/remote/RemotePtr.hpp
src/msg/msg_io.cpp
src/msg/msg_vm.cpp
src/s4u/s4u_file.cpp
src/s4u/s4u_host.cpp
src/s4u/s4u_netzone.cpp
src/s4u/s4u_storage.cpp
src/simdag/sd_task.cpp
src/simgrid/host.cpp
src/simix/libsmx.cpp
src/simix/popping_accessors.hpp
src/simix/popping_bodies.cpp
src/simix/popping_enum.h
src/simix/popping_generated.cpp
src/simix/popping_private.hpp
src/simix/simcalls.in
src/simix/smx_deployment.cpp
src/simix/smx_global.cpp
src/simix/smx_io.cpp
src/simix/smx_io_private.hpp
src/simix/smx_network.cpp
src/simix/smx_synchro.cpp
src/smpi/bindings/smpi_pmpi.cpp
src/smpi/bindings/smpi_pmpi_coll.cpp
src/smpi/bindings/smpi_pmpi_request.cpp
src/smpi/bindings/smpi_pmpi_type.cpp
src/smpi/bindings/smpi_pmpi_win.cpp
src/smpi/colls/allgatherv/allgatherv-mpich-rdb.cpp
src/smpi/colls/allreduce/allreduce-mvapich-rs.cpp
src/smpi/colls/gather/gather-mvapich.cpp
src/smpi/colls/reduce/reduce-binomial.cpp
src/smpi/colls/reduce/reduce-mvapich-knomial.cpp
src/smpi/colls/reduce/reduce-mvapich-two-level.cpp
src/smpi/colls/reduce_scatter/reduce_scatter-mpich.cpp
src/smpi/include/SmpiHost.hpp
src/smpi/include/smpi_comm.hpp
src/smpi/include/smpi_datatype.hpp
src/smpi/include/smpi_datatype_derived.hpp
src/smpi/include/smpi_f2c.hpp
src/smpi/include/smpi_request.hpp
src/smpi/include/smpi_utils.hpp [moved from src/include/smpi/smpi_utils.hpp with 96% similarity]
src/smpi/internals/SmpiHost.cpp
src/smpi/internals/instr_smpi.cpp
src/smpi/internals/smpi_bench.cpp
src/smpi/internals/smpi_global.cpp
src/smpi/internals/smpi_replay.cpp
src/smpi/internals/smpi_shared.cpp
src/smpi/internals/smpi_utils.cpp
src/smpi/mpi/smpi_comm.cpp
src/smpi/mpi/smpi_datatype.cpp
src/smpi/mpi/smpi_datatype_derived.cpp
src/smpi/mpi/smpi_group.cpp
src/smpi/smpirun.in
src/surf/FileImpl.cpp
src/surf/FileImpl.hpp
src/surf/StorageImpl.cpp
src/surf/StorageImpl.hpp
src/surf/cpu_cas01.cpp
src/surf/cpu_interface.cpp
src/surf/cpu_ti.cpp
src/surf/cpu_ti.hpp
src/surf/fair_bottleneck.cpp
src/surf/lagrange.cpp
src/surf/maxmin.cpp
src/surf/maxmin_private.hpp
src/surf/network_cm02.cpp
src/surf/network_ib.cpp
src/surf/network_ib.hpp
src/surf/network_interface.cpp
src/surf/network_ns3.cpp
src/surf/network_smpi.cpp
src/surf/ptask_L07.cpp
src/surf/sg_platf.cpp
src/surf/storage_n11.cpp
src/surf/surf_c_bindings.cpp
src/surf/surf_interface.cpp
src/surf/surf_interface.hpp
src/surf/trace_mgr.cpp
src/surf/trace_mgr.hpp
src/surf/xml/platf_private.hpp
src/surf/xml/surfxml_sax_cb.cpp
src/xbt/dynar.cpp
src/xbt/ex.cpp
src/xbt/graph.c
src/xbt/heap.c [deleted file]
src/xbt/heap_private.h [deleted file]
src/xbt/log.c
src/xbt/xbt_main.cpp
src/xbt/xbt_str.cpp
teshsuite/mc/dwarf/dwarf.cpp
teshsuite/msg/cloud-sharing/cloud-sharing.tesh
teshsuite/msg/trace_integration/test-hbp1.0-hbp3.0-hbp4.0.xml
teshsuite/msg/trace_integration/test-hbp2.5-hbp1.5.xml
teshsuite/msg/trace_integration/trace_integration.tesh
teshsuite/s4u/concurrent_rw/concurrent_rw.tesh
teshsuite/s4u/storage_client_server/storage_client_server.cpp
teshsuite/simdag/flatifier/flatifier.cpp
teshsuite/simix/generic_simcalls/generic_simcalls.cpp
teshsuite/smpi/isp/umpire/CMakeLists.txt
teshsuite/smpi/isp/umpire/change-send-buffer.c
teshsuite/smpi/isp/umpire/comm-translate-ranks.c
teshsuite/smpi/isp/umpire/irecv-deadlock.c
teshsuite/smpi/isp/umpire/lost-request-waitall.c
teshsuite/smpi/isp/umpire/no-error-testany.c
teshsuite/smpi/isp/umpire/wait-deadlock.c
teshsuite/smpi/mpich3-test/perf/CMakeLists.txt
teshsuite/smpi/mpich3-test/runtests
teshsuite/surf/lmm_usage/lmm_usage.cpp
teshsuite/surf/surf_usage/surf_usage.cpp
teshsuite/xbt/CMakeLists.txt
teshsuite/xbt/heap_bench/heap_bench.c [deleted file]
teshsuite/xbt/heap_bench/heap_bench.tesh [deleted file]
tools/cmake/DefinePackages.cmake
tools/cmake/GCCFlags.cmake

index d342dc4..e0eb0b8 100644 (file)
@@ -1078,7 +1078,6 @@ teshsuite/surf/lmm_usage/lmm_usage
 teshsuite/surf/maxmin_bench/maxmin_bench
 teshsuite/surf/surf_usage/surf_usage
 teshsuite/surf/surf_usage2/surf_usage2
-teshsuite/xbt/heap_bench/heap_bench
 teshsuite/xbt/log_large/log_large
 teshsuite/xbt/log_usage/log_usage
 teshsuite/xbt/mallocator/mallocator
index 4930ddf..4129926 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,10 +13,14 @@ SimGrid (3.18) NOT RELEASED YET (target: December 24 2017)
  - Removed unused functions:
    - xbt/file.h: xbt_basename(), xbt_dirname(), xbt_getline()
    - xbt/str.h: xbt_str_join()
-   
+   - xbt/heap.h: use std::priority_queue or boost::heap instead
+
  XML
  - Remove the undocumented/untested tag <include>
 
+ TRACE
+ - Remove viva specific tracing as the tool is no longer maintained
+
 SimGrid (3.17) Released October 8 2017
 
  The Drained Leaks release: (almost) no known leaks despite the tests.
index 0852c34..f7a049a 100644 (file)
@@ -26,7 +26,7 @@ your version (as long as your version is as free as ours). It also
 means that SimGrid is developed by a vivid community of users and
 developers. We hope that you will come and join us!
 
-SimGrid is the result of over 15 years of research from several
+SimGrid is the result of almost 20 years of research from several
 groups, both in France and in the USA. It benefited of many funding
 from various research instances, including the ANR, Inria, CNRS,
 University of Lorraine, University of Hawai'i at Manoa, ENS Rennes and
index 395f744..d2ce9de 100644 (file)
@@ -17,7 +17,6 @@
       - \ref XBT_dynar
       - \ref XBT_dict
       - \ref XBT_swag
-      - \ref XBT_heap
     - \ref XBT_misc
       - \ref XBT_graph
 
@@ -66,7 +65,6 @@
      /** @defgroup XBT_dynar  Dynar: generic dynamic array */
      /** @defgroup XBT_dict   Dict: generic dictionnary */
      /** @defgroup XBT_swag   Swag: O(1) set datatype */
-     /** @defgroup XBT_heap Heap: generic heap data structure */
 /** @} */
 
 
index d8a7ad3..59f5958 100644 (file)
@@ -121,9 +121,8 @@ tracing/uncategorized
 tracing/filename
 </b>:
   A file with this name will be created to register the simulation. The file
-  is in the Paje format and can be analyzed using Viva or Paje visualization
+  is in the Paje format and can be analyzed using Paje visualization
   tools. More information can be found in these webpages:
-     <a href="http://github.com/schnorr/viva/">http://github.com/schnorr/viva/</a>
      <a href="http://github.com/schnorr/pajeng/">http://github.com/schnorr/pajeng/</a>
 \verbatim
 --cfg=tracing/filename:mytracefile.trace
@@ -326,24 +325,6 @@ TODO
 TODO
 \endverbatim
 
-\li <b>\c
-viva/categorized
-</b>:
-  This option generates a graph configuration file for Viva considering
-  categorized resource utilization.
-\verbatim
---cfg=viva/categorized:graph_categorized.plist
-\endverbatim
-
-\li <b>\c
-viva/uncategorized
-</b>:
-  This option generates a graph configuration file for Viva considering
-  uncategorized resource utilization.
-\verbatim
---cfg=viva/uncategorized:graph_uncategorized.plist
-\endverbatim
-
 Please pass \verbatim --help-tracing \endverbatim to your simulator
 for the updated list of tracing options.
 
@@ -362,7 +343,6 @@ simulator):
           --cfg=tracing:yes \
           --cfg=tracing/uncategorized:yes \
           --cfg=tracing/filename:mytracefile.trace \
-          --cfg=viva/uncategorized:uncat.plist
 \endverbatim
 
 \li I want to trace only a subset of my MSG (or SimDAG) tasks.
@@ -377,7 +357,6 @@ recompiling, run your simulator with the following parameters:
           --cfg=tracing:yes \
           --cfg=tracing/categorized:yes \
           --cfg=tracing/filename:mytracefile.trace \
-          --cfg=viva/categorized:cat.plist
 \endverbatim
 
 
@@ -453,23 +432,6 @@ several options to analyze this trace file:
   file format</a>. Consider this option if you need to understand the
   causality of your distributed simulation.
 
-- Visualize the behavior of your simulation with treemaps (specially
-  if your simulation has a platform with several thousand resources),
-  provided by the <a href="http://github.com/schnorr/viva/">Viva</a>
-  visualization tool. See <a
-  href="https://github.com/schnorr/viva/wiki">Viva's wiki</a> for
-  further details on what is a treemap and how to use it.
-
-- Correlate the behavior of your simulator with the platform topology
-  with an interactive, force-directed, and hierarchical graph
-  visualization, provided by <a
-  href="http://github.com/schnorr/viva/">Viva</a>.  Check <a
-  href="https://github.com/schnorr/viva/wiki">Viva's wiki</a> for
-  further details. This <a
-  href="http://hal.inria.fr/hal-00738321/">research report</a>,
-  published at ISPASS 2013, has a detailed description of this
-  visualization technique.
-
 - You can also check our online <a
   href="http://simgrid.gforge.inria.fr/tutorials.html"> tutorial
   section</a> that contains a dedicated tutorial with several
@@ -484,123 +446,4 @@ several options to analyze this trace file:
   href="http://lists.gforge.inria.fr/pipermail/simgrid-user/">mailing
   list archive</a> for old messages regarding tracing and analysis.
 
-\subsection tracing_viva_analysis Viva Visualization Tool
-
-This subsection describe some of the concepts regarding the <a
-href="http://github.com/schnorr/viva/">Viva Visualization Tool</a> and
-its relation with SimGrid traces. You should refer to Viva's website
-for further details on all its visualization techniques.
-
-\subsubsection tracing_viva_time_slice Time Slice
-
-The analysis of a trace file using the tool always takes into account
-the concept of the <em>time-slice</em>.  This concept means that what
-is being visualized in the screen is always calculated considering a
-specific time frame, with its beggining and end timestamp. The
-time-slice is configured by the user and can be changed dynamically
-through the window called <em>Time Interval</em> that is opened
-whenever a trace file is being analyzed. Users are capable to select
-the beggining and size of the time slice.
-
-\subsubsection tracing_viva_graph Hierarchical Graph View
-
-As stated above (see section \ref tracing_tracing_analyzing), one
-possibility to analyze SimGrid traces is to use Viva's graph view with
-a graph configuration to customize the graph according to the
-traces. A valid graph configuration (we are using the non-XML <a
-href="http://en.wikipedia.org/wiki/Property_list">Property List
-Format</a> to describe the configuration) can be created for any
-SimGrid-based simulator using the
-<em>--cfg=viva/uncategorized:graph_uncategorized.plist</em> or
-<em>--cfg=viva/categorized:graph_categorized.plist</em> (if the
-simulator defines resource utilization categories) when executing the
-simulation.
-
-\subsubsection basic_conf Basic Graph Configuration
-
-The basic description of the configuration is as follows:
-\verbatim
-{
-  node = (LINK, HOST, );
-  edge = (HOST-LINK, LINK-HOST, LINK-LINK, );
-\endverbatim
-
-The nodes of the graph will be created based on the <i>node</i>
-parameter, which in this case is the different <em>"HOST"</em>s and
-<em>"LINK"</em>s of the platform used to simulate. The <i>edge</i>
-parameter indicates that the edges of the graph will be created based
-on the <em>"HOST-LINK"</em>s, <em>"LINK-HOST"</em>s, and
-<em>"LINK-LINK"</em>s of the platform.  After the definition of these
-two parameters, the configuration must detail how the nodes
-(<em>HOST</em>s and <em>LINK</em>s) should be drawn.
-
-For that, the configuration must have an entry for each of
-the types used. For <em>HOST</em>, as basic configuration, we have:
-
-\verbatim
-  HOST = {
-    type = square;
-    size = power;
-    values = (power_used);
-  };
-\endverbatim
-
-The parameter <em>size</em> indicates which variable from the trace
-file will be used to define the size of the node HOST in the
-visualization. If the simulation was executed with availability
-traces, the size of the nodes will be changed according to these
-traces. The parameter <em>type</em> indicates which geometrical shape
-will be used to represent HOST, and the <em>values</em> parameter
-indicates which values from the trace will be used to fill the shape.
-
-For <em>LINK</em> we have:
-
-\verbatim
-  LINK = {
-    type = rhombus;
-    size = bandwidth;
-    values = (bandwidth_used);
-  };
-}
-\endverbatim
-
-The same configuration parameters are used here: <em>type</em> (with a
-rhombus), the <em>size</em> (whose value is from trace's bandwidth
-variable) and the <em>values</em>.
-
-\subsubsection custom_graph Customizing the Graph Representation
-
-Viva is capable to handle a customized graph representation based on
-the variables present in the trace file. In the case of SimGrid, every
-time a category is created for tasks, two variables in the trace file
-are defined: one to indicate node utilization (how much power was used
-by that task category), and another to indicate link utilization (how
-much bandwidth was used by that category). For instance, if the user
-declares a category named <i>request</i>, there will be variables
-named <b>p</b><i>request</i> and a <b>b</b><i>request</i> (<b>p</b>
-for power and <b>b</b> for bandwidth). It is important to notice that
-the variable <i>prequest</i> in this case is only available for HOST,
-and <i>brequest</i> is only available for LINK. <b>Example</b>:
-suppose there are two categories for tasks: request and compute. To
-create a customized graph representation with a proportional
-separation of host and link utilization, use as configuration for HOST
-and LINK this:
-
-\verbatim
-  HOST = {
-    type = square;
-    size = power;
-    values = (prequest, pcomputation);
-  };
-  LINK = {
-    type = rhombus;
-    size = bandwidth;
-    values = (brequest, bcomputation);
-  };
-\endverbatim
-
-This configuration enables the analysis of resource utilization by MSG
-tasks through the identification of load-balancing issues and network
-bottlenecks, for instance.
-
 */
index 9c0e265..e75eb78 100644 (file)
@@ -75,7 +75,7 @@ It is a portable library providing some grounding features such as \ref
 XBT_log, \ref XBT_ex and \ref XBT_config.
 
 XBT also encompass the following convenient C data structures:
-\ref XBT_dynar, \ref XBT_dict, \ref XBT_heap, and
+\ref XBT_dynar, \ref XBT_dict, and
 \ref XBT_swag. The code is being migrated in C++ so you should probably want
 to use standard C++ containers instead of them if possible.
 
index c886a64..94b0015 100644 (file)
@@ -17,9 +17,9 @@ $ java -classpath ${classpath:=.} async/dsend/Main ${srcdir:=.}/../platforms/sma
 > [  0.000000] (1:Sender@Boivin) Sending "Task_5" to "Jupiter"
 > [  0.000000] (1:Sender@Boivin) Sending "Task_6" to "Tremblay"
 > [  0.000000] (1:Sender@Boivin) All tasks have been (asynchronously) dispatched. Let's sleep for 20s so that nobody gets a message from a terminated process.
-> [  1.933362] (2:Receiver@Bourassa) Received a task. I'm done. See you!
-> [  1.933362] (4:Receiver@Ginette) Received a task. I'm done. See you!
 > [  1.933362] (6:Receiver@Jupiter) Received a task. I'm done. See you!
+> [  1.933362] (4:Receiver@Ginette) Received a task. I'm done. See you!
+> [  1.933362] (2:Receiver@Bourassa) Received a task. I'm done. See you!
 > [  2.449247] (7:Receiver@Tremblay) Received a task. I'm done. See you!
 > [  2.964768] (3:Receiver@Fafard) Received a task. I'm done. See you!
 > [  4.162002] (5:Receiver@Jacquelin) Received a task. I'm done. See you!
index d518e7d..9f7ccea 100644 (file)
@@ -16,9 +16,9 @@ $ java -classpath ${classpath:=.} async/waitall/Main ${srcdir:=.}/../platforms/s
 > [  0.000000] (1:Sender@Boivin) Start the Sending 'Task_5' to 'Jupiter'
 > [  0.000000] (1:Sender@Boivin) Start the Sending 'Task_6' to 'Tremblay'
 > [  0.000000] (1:Sender@Boivin) All tasks have been (asynchronously) dispatched. Let's wait for their completion.
-> [  1.933362] (2:Receiver@Bourassa) I got my task, good bye.
-> [  1.933362] (4:Receiver@Ginette) I got my task, good bye.
 > [  1.933362] (6:Receiver@Jupiter) I got my task, good bye.
+> [  1.933362] (4:Receiver@Ginette) I got my task, good bye.
+> [  1.933362] (2:Receiver@Bourassa) I got my task, good bye.
 > [  2.449247] (7:Receiver@Tremblay) I got my task, good bye.
 > [  2.964768] (3:Receiver@Fafard) I got my task, good bye.
 > [  4.162002] (5:Receiver@Jacquelin) I got my task, good bye.
index 85328dc..4ab498e 100644 (file)
@@ -4,7 +4,7 @@
 
 $ java -classpath ${classpath:=.} dht/chord/Main ${srcdir:=.}/../platforms/cluster.xml ${srcdir:=.}/dht/chord/chord.xml
 > [0.000000] [java/INFO] Using regular java threads.
-> [1046.787586] [java/INFO] MSG_main finished; Cleaning up the simulation...
+> [1046.732943] [java/INFO] MSG_main finished; Cleaning up the simulation...
 > [node-1.acme.org:dht.chord.Node:(2) 0.000000] [java/INFO] Joining the ring with id 366680 knowing node 42
 > [node-2.acme.org:dht.chord.Node:(3) 0.000000] [java/INFO] Joining the ring with id 533744 knowing node 366680
 > [node-3.acme.org:dht.chord.Node:(4) 0.000000] [java/INFO] Joining the ring with id 1319738 knowing node 42
index 3afdf2d..7bae428 100644 (file)
@@ -8,12 +8,12 @@ $ java -classpath ${classpath:=.} energy/vm/Main ${srcdir:=.}/../platforms/energ
 > [MyHost1:energy VM runner:(1) 0.000000] [java/INFO] Create two tasks on Host3: both inside a VM
 > [MyHost1:energy VM runner:(1) 0.000000] [java/INFO] Wait 5 seconds. The tasks are still running (they run for 3 seconds, but 2 tasks are co-located, so they run for 6 seconds)
 > [MyHost1:energy VM runner:(1) 5.000000] [java/INFO] Wait another 5 seconds. The tasks stop at some point in between
-> [MyHost3:p31:(6) 6.000000] [java/INFO] This worker is done.
-> [MyHost3:p312:(7) 6.000000] [java/INFO] This worker is done.
 > [MyHost2:p22:(5) 6.000000] [java/INFO] This worker is done.
+> [MyHost3:p312:(7) 6.000000] [java/INFO] This worker is done.
+> [MyHost3:p31:(6) 6.000000] [java/INFO] This worker is done.
 > [vmHost1:p12:(3) 6.000000] [java/INFO] This worker is done.
-> [vmHost3:p21:(4) 6.000000] [java/INFO] This worker is done.
 > [vmHost1:p11:(2) 6.000000] [java/INFO] This worker is done.
+> [vmHost3:p21:(4) 6.000000] [java/INFO] This worker is done.
 > [10.000000] [surf_energy/INFO] Total energy consumption: 4320.000000 Joules (used hosts: 4320.000000 Joules; unused/idle hosts: 0.000000)
 > [10.000000] [java/INFO] MSG_main finished; Cleaning up the simulation...
 > [10.000000] [surf_energy/INFO] Energy consumption of host MyHost1: 1120.000000 Joules
index 0e5654a..63afa51 100644 (file)
@@ -117,7 +117,7 @@ options to see the task executions:
     to that are used to classify its tasks. When the program is executed,
     the tracing mechanism registers the resource utilization of hosts
     and links according to these categories. Recommanded options:
-    @verbatim --cfg=tracing:yes --cfg=tracing/categorized:yes --cfg=tracing/uncategorized:yes --cfg=viva/categorized:viva_cat.plist --cfg=viva/uncategorized:viva_uncat.plist
+    @verbatim --cfg=tracing:yes --cfg=tracing/categorized:yes --cfg=tracing/uncategorized:yes
     @endverbatim
     
   - <b>Master Workers tracing</b>.
@@ -126,7 +126,7 @@ options to see the task executions:
     using several tracing features. It traces resource usage, sorted
     out in several categories; Trace marks and user variables are also
     used. Recommanded options:
-    @verbatim --cfg=tracing/categorized:yes --cfg=tracing/uncategorized:yes --cfg=viva/categorized:viva_cat.plist --cfg=viva/uncategorized:viva_uncat.plist
+    @verbatim --cfg=tracing/categorized:yes --cfg=tracing/uncategorized:yes
     @endverbatim
     
   - <b>Process migration tracing</b>.
@@ -139,7 +139,7 @@ options to see the task executions:
 
 TODO: These tracing examples should be integrated in the examples to
 not duplicate the C files. A full command line to see the result in
-the right tool (viva/vite/FrameSoc) should be given along with some
+the right tool (vite/FrameSoc) should be given along with some
 screenshots.
 
 @subsection msg_ex_tracing_user_variables Tracing user variables
index 6637734..97c19dd 100644 (file)
@@ -17,18 +17,18 @@ $ $SG_TEST_EXENV ${bindir:=.}/async-waitany ${srcdir:=.}/small_platform.xml ${sr
 > [ 10.000000] (3:receiver@Jupiter) Wait to receive task 1
 > [ 10.000000] (3:receiver@Jupiter) Wait to receive task 2
 > [ 10.423774] (2:receiver@Fafard) Processing "Task_4"
-> [ 10.469435] (3:receiver@Jupiter) Processing "Task_3"
+> [ 10.469435] (3:receiver@Jupiter) Processing "Task_5"
 > [ 11.079116] (2:receiver@Fafard) "Task_4" done
 > [ 11.079116] (2:receiver@Fafard) Processing "Task_0"
-> [ 11.124778] (3:receiver@Jupiter) "Task_3" done
+> [ 11.124778] (3:receiver@Jupiter) "Task_5" done
 > [ 11.124778] (3:receiver@Jupiter) Processing "Task_1"
 > [ 11.734459] (2:receiver@Fafard) "Task_0" done
 > [ 11.734459] (2:receiver@Fafard) Processing "Task_2"
 > [ 11.780120] (3:receiver@Jupiter) "Task_1" done
-> [ 11.780120] (3:receiver@Jupiter) Processing "Task_5"
+> [ 11.780120] (3:receiver@Jupiter) Processing "Task_3"
 > [ 12.389801] (2:receiver@Fafard) "Task_2" done
 > [ 12.415509] (2:receiver@Fafard) I'm done. See you!
-> [ 12.435462] (3:receiver@Jupiter) "Task_5" done
+> [ 12.435462] (3:receiver@Jupiter) "Task_3" done
 > [ 12.454477] (0:maestro@) Simulation time 12.4545
 > [ 12.454477] (1:sender@Tremblay) Goodbye now!
 > [ 12.454477] (3:receiver@Jupiter) I'm done. See you!
index 17c786b..cecf9b6 100644 (file)
@@ -18,10 +18,10 @@ $ $SG_TEST_EXENV ${bindir:=.}/dht-kademlia ${srcdir:=.}/cluster.xml ${srcdir:=.}
 > [  0.000000] (12:node@node-11.acme.org) Hi, I'm going to join the network with id 2047
 > [  0.000000] (13:node@node-12.acme.org) Hi, I'm going to join the network with id 4095
 > [780.000000] ( 7:node@node-6.acme.org) 5/5 FIND_NODE have succeeded
-> [780.000000] ( 9:node@node-8.acme.org) 5/5 FIND_NODE have succeeded
-> [780.000000] ( 3:node@node-2.acme.org) 6/6 FIND_NODE have succeeded
+> [780.000000] ( 9:node@node-8.acme.org) 6/6 FIND_NODE have succeeded
+> [780.000000] ( 3:node@node-2.acme.org) 5/5 FIND_NODE have succeeded
 > [780.000000] ( 2:node@node-1.acme.org) 6/6 FIND_NODE have succeeded
-> [780.000000] (11:node@node-10.acme.org) 5/5 FIND_NODE have succeeded
+> [780.000000] (11:node@node-10.acme.org) 6/6 FIND_NODE have succeeded
 > [780.000000] ( 1:node@node-0.acme.org) 7/7 FIND_NODE have succeeded
 > [780.000000] ( 5:node@node-4.acme.org) 6/6 FIND_NODE have succeeded
 > [780.000000] (13:node@node-12.acme.org) 6/6 FIND_NODE have succeeded
index 965e8ac..2735dac 100644 (file)
@@ -9,12 +9,12 @@ $ ${bindir:=.}/energy-vm/energy-vm$EXEEXT ${srcdir:=.}/../platforms/energy_platf
 > [  0.000000] (1:dvfs@MyHost1) Create two tasks on Host3: both inside a VM
 > [  0.000000] (1:dvfs@MyHost1) Wait 5 seconds. The tasks are still running (they run for 3 seconds, but 2 tasks are co-located, so they run for 6 seconds)
 > [  5.000000] (1:dvfs@MyHost1) Wait another 5 seconds. The tasks stop at some point in between
-> [  6.000000] (6:p31@MyHost3) This worker is done.
-> [  6.000000] (7:p32@MyHost3) This worker is done.
 > [  6.000000] (5:p22@MyHost2) This worker is done.
+> [  6.000000] (7:p32@MyHost3) This worker is done.
+> [  6.000000] (6:p31@MyHost3) This worker is done.
 > [  6.000000] (3:p12@vm_host1) This worker is done.
-> [  6.000000] (4:p21@vm_host3) This worker is done.
 > [  6.000000] (2:p11@vm_host1) This worker is done.
+> [  6.000000] (4:p21@vm_host3) This worker is done.
 > [ 10.000000] (0:maestro@) Total energy consumption: 4320.000000 Joules (used hosts: 4320.000000 Joules; unused/idle hosts: 0.000000)
 > [ 10.000000] (0:maestro@) Total simulation time: 10.00; Host2 and Host3 must have the exact same energy consumption; Host1 is multi-core and will differ.
 > [ 10.000000] (0:maestro@) Energy consumption of host MyHost1: 1120.000000 Joules
index b7c58ae..220fffc 100644 (file)
@@ -33,6 +33,7 @@ $ $SG_TEST_EXENV ${bindir:=.}/process-startkilltime ${srcdir:=.}/cluster.xml ${s
 
 p Test1 Process with kill time
 
+! output sort
 $ $SG_TEST_EXENV ${bindir:=.}/process-startkilltime ${srcdir:=.}/cluster.xml ${srcdir:=.}/../msg/process-startkilltime/kill_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
 > [  0.000000] (1:sleeper@node-1.acme.org) Hello! I go to sleep.
 > [  0.000000] (2:sleeper@node-2.acme.org) Hello! I go to sleep.
@@ -45,6 +46,7 @@ $ $SG_TEST_EXENV ${bindir:=.}/process-startkilltime ${srcdir:=.}/cluster.xml ${s
 
 p Test2 Process with start and kill times
 
+! output sort
 $ $SG_TEST_EXENV ${bindir:=.}/process-startkilltime ${srcdir:=.}/cluster.xml ${srcdir:=.}/../msg/process-startkilltime/start_kill_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
 > [  0.000000] (1:sleeper@node-0.acme.org) Hello! I go to sleep.
 > [  1.000000] (2:sleeper@node-1.acme.org) Hello! I go to sleep.
index f2836b6..ebe181c 100644 (file)
@@ -2,43 +2,9 @@
 
 p Tracing multiple categories master/worker application
 
-$ $SG_TEST_EXENV ${bindir:=.}/trace-categories$EXEEXT --cfg=tracing:yes --cfg=tracing/buffer:yes --cfg=tracing/filename:categories.trace --cfg=tracing/categorized:yes --cfg=tracing/uncategorized:yes --cfg=viva/categorized:categories.cat.plist --cfg=viva/uncategorized:categories.uncat.plist ${srcdir:=.}/small_platform.xml ${srcdir:=.}/../msg/app-masterworker/app-masterworker_d.xml
+$ $SG_TEST_EXENV ${bindir:=.}/trace-categories$EXEEXT --cfg=tracing:yes --cfg=tracing/buffer:yes --cfg=tracing/filename:categories.trace --cfg=tracing/categorized:yes --cfg=tracing/uncategorized:yes ${srcdir:=.}/small_platform.xml ${srcdir:=.}/../msg/app-masterworker/app-masterworker_d.xml
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/buffer' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/filename' to 'categories.trace'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/categorized' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/uncategorized' to 'yes'
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'viva/categorized' to 'categories.cat.plist'
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'viva/uncategorized' to 'categories.uncat.plist'
-
-$ $SG_TEST_EXENV cat categories.cat.plist
->   node = ("LINK","HOST");
->   edge = ("0-LINK4-LINK4","0-LINK4-HOST1","0-HOST1-LINK4");
->
->   host = {
->     type = "square";
->     size = "power";
->     values = ("pcompute","pdata","pfinalize","prequest");
->   };
->   link = {
->     type = "rhombus";
->     size = "bandwidth";
->     values = ("bcompute","bdata","bfinalize","brequest");
->   };
-
-$ $SG_TEST_EXENV cat categories.uncat.plist
->   node = ("LINK","HOST");
->   edge = ("0-LINK4-LINK4","0-LINK4-HOST1","0-HOST1-LINK4");
->
->   host = {
->     type = "square";
->     size = "power";
->     values = ("power_used");
->   };
->   link = {
->     type = "rhombus";
->     size = "bandwidth";
->     values = ("bandwidth_used");
->   };
-
-$ rm -rf categories.trace categories.cat.plist categories.uncat.plist
index d17cce3..0ce739d 100644 (file)
@@ -1,14 +1,12 @@
 #! ./tesh
 
 p Tracing master/worker application
-$ $SG_TEST_EXENV ${bindir:=.}/trace-masterworker$EXEEXT --cfg=tracing:yes --cfg=tracing/buffer:yes --cfg=tracing/filename:trace-masterworker.trace --cfg=tracing/categorized:yes --cfg=tracing/uncategorized:yes --cfg=viva/categorized:trace-masterworker.cat.plist --cfg=viva/uncategorized:trace-masterworker.uncat.plist ${srcdir:=.}/small_platform.xml ${srcdir:=.}/../msg/app-masterworker/app-masterworker_d.xml
+$ $SG_TEST_EXENV ${bindir:=.}/trace-masterworker$EXEEXT --cfg=tracing:yes --cfg=tracing/buffer:yes --cfg=tracing/filename:trace-masterworker.trace --cfg=tracing/categorized:yes --cfg=tracing/uncategorized:yes ${srcdir:=.}/small_platform.xml ${srcdir:=.}/../msg/app-masterworker/app-masterworker_d.xml
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/buffer' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/filename' to 'trace-masterworker.trace'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/categorized' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/uncategorized' to 'yes'
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'viva/categorized' to 'trace-masterworker.cat.plist'
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'viva/uncategorized' to 'trace-masterworker.uncat.plist'
 > [4.214821] [msg_trace_masterworker/INFO] Declared tracing categories:
 > [4.214821] [msg_trace_masterworker/INFO] compute
 > [4.214821] [msg_trace_masterworker/INFO] finalize
@@ -24,8 +22,6 @@ $ $SG_TEST_EXENV ${bindir:=.}/trace-masterworker$EXEEXT ${srcdir:=.}/config_trac
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/categorized' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/filename' to 'trace-masterworker.trace'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/uncategorized' to 'yes'
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'viva/categorized' to 'trace-masterworker.cat.plist'
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'viva/uncategorized' to 'trace-masterworker.uncat.plist'
 > [4.214821] [msg_trace_masterworker/INFO] Declared tracing categories:
 > [4.214821] [msg_trace_masterworker/INFO] compute
 > [4.214821] [msg_trace_masterworker/INFO] finalize
@@ -38,15 +34,13 @@ p Not tracing master/worker application
 $ $SG_TEST_EXENV ${bindir:=.}/trace-masterworker$EXEEXT ${srcdir:=.}/small_platform.xml ${srcdir:=.}/../msg/app-masterworker/app-masterworker_d.xml
 
 p Testing tracing by process
-$ $SG_TEST_EXENV ${bindir:=.}/trace-masterworker$EXEEXT --cfg=tracing:yes --cfg=tracing/msg/process:yes --cfg=tracing/buffer:yes --cfg=tracing/filename:trace-masterworker.trace --cfg=tracing/categorized:yes --cfg=tracing/uncategorized:yes --cfg=viva/categorized:trace-masterworker.cat.plist --cfg=viva/uncategorized:trace-masterworker.uncat.plist ${srcdir:=.}/small_platform.xml ${srcdir:=.}/../msg/app-masterworker/app-masterworker_d.xml
+$ $SG_TEST_EXENV ${bindir:=.}/trace-masterworker$EXEEXT --cfg=tracing:yes --cfg=tracing/msg/process:yes --cfg=tracing/buffer:yes --cfg=tracing/filename:trace-masterworker.trace --cfg=tracing/categorized:yes --cfg=tracing/uncategorized:yes  ${srcdir:=.}/small_platform.xml ${srcdir:=.}/../msg/app-masterworker/app-masterworker_d.xml
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/msg/process' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/buffer' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/filename' to 'trace-masterworker.trace'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/categorized' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/uncategorized' to 'yes'
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'viva/categorized' to 'trace-masterworker.cat.plist'
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'viva/uncategorized' to 'trace-masterworker.uncat.plist'
 > [4.214821] [msg_trace_masterworker/INFO] Declared tracing categories:
 > [4.214821] [msg_trace_masterworker/INFO] compute
 > [4.214821] [msg_trace_masterworker/INFO] finalize
@@ -55,34 +49,5 @@ $ $SG_TEST_EXENV ${bindir:=.}/trace-masterworker$EXEEXT --cfg=tracing:yes --cfg=
 > [4.214821] [msg_trace_masterworker/INFO] Declared marks:
 > [4.214821] [msg_trace_masterworker/INFO] msmark
 
-$ $SG_TEST_EXENV cat trace-masterworker.uncat.plist
->   node = ("LINK","HOST");
->   edge = ("0-LINK13-LINK13","0-LINK13-HOST1","0-HOST1-LINK13");
->
->   host = {
->     type = "square";
->     size = "power";
->     values = ("power_used");
->   };
->   link = {
->     type = "rhombus";
->     size = "bandwidth";
->     values = ("bandwidth_used");
->   };
 
-$ $SG_TEST_EXENV cat trace-masterworker.cat.plist
->   node = ("LINK","HOST");
->   edge = ("0-LINK13-LINK13","0-LINK13-HOST1","0-HOST1-LINK13");
->
->   host = {
->     type = "square";
->     size = "power";
->     values = ("pcompute","pfinalize","preport","prequest");
->   };
->   link = {
->     type = "rhombus";
->     size = "bandwidth";
->     values = ("bcompute","bfinalize","breport","brequest");
->   };
-
-$ rm -rf trace-masterworker.trace trace-masterworker.cat.plist trace-masterworker.uncat.plist
+$ rm -rf trace-masterworker.trace
index 38b306b..9f3fbdc 100644 (file)
@@ -5,9 +5,7 @@
     <prop id="tracing/uncategorized" value="yes"/>
     <prop id="tracing/buffer" value="yes"/>
     <prop id="tracing" value="yes"/>
-    <prop id="viva/categorized" value="trace-masterworker.cat.plist"/>
     <prop id="tracing/filename" value="trace-masterworker.trace"/>
-    <prop id="viva/uncategorized" value="trace-masterworker.uncat.plist"/>
     <prop id="tracing/categorized" value="yes"/>
   </config>
 
index 96691c5..78254fb 100644 (file)
@@ -25,7 +25,7 @@ documentation, but it should remain readable directly.
     @ref examples/s4u/actor-create/s4u-actor-create_d.xml \n
     Shows how to start your actors to populate your simulation.
 
-  - <b>Ping Pong</b>: @ref examples/s4u/app-pingpong/s4u-app-pingpong.c\n
+  - <b>Ping Pong</b>: @ref examples/s4u/app-pingpong/s4u-app-pingpong.cpp\n
     This simple example just sends one message back and forth.
     The tesh file laying in the directory show how to start the simulator binary, highlighting how to pass options to 
     the simulators (as detailed in Section \ref options). 
index 3225496..8f9bc79 100644 (file)
@@ -3,6 +3,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include <algorithm>
 #include <climits>
 #include <xbt/ex.hpp>
 
@@ -20,7 +21,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_bt_peer, "Messages specific for the peers");
 #define BLOCK_SIZE 16384
 
 /** Number of blocks asked by each request */
-#define BLOCKS_REQUESTED 2
+#define BLOCKS_REQUESTED 2UL
 
 #define ENABLE_END_GAME_MODE 1
 #define SLEEP_DURATION 1
@@ -163,7 +164,7 @@ void Peer::sendRequestTo(Connection* remote_peer, unsigned int piece)
   xbt_assert(remote_peer->hasPiece(piece));
   int block_index = getFirstMissingBlockFrom(piece);
   if (block_index != -1) {
-    int block_length = MIN(BLOCKS_REQUESTED, PIECES_BLOCKS - block_index);
+    int block_length = std::min(BLOCKS_REQUESTED, PIECES_BLOCKS - block_index);
     XBT_DEBUG("Sending a REQUEST to %s for piece %u (%d,%d)", remote_peer->mailbox_->getCname(), piece, block_index,
               block_length);
     remote_peer->mailbox_
index d450951..1296679 100644 (file)
@@ -5,6 +5,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "s4u-tracker.hpp"
+#include <algorithm>
 #include <xbt/RngStream.h>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_bt_tracker, "Messages specific for the tracker");
@@ -48,7 +49,7 @@ void Tracker::operator()()
       TrackerAnswer* ta = new TrackerAnswer(TRACKER_QUERY_INTERVAL);
       std::set<int>::iterator next_peer;
       int nb_known_peers = known_peers.size();
-      int max_tries      = MIN(MAXIMUM_PEERS, nb_known_peers);
+      int max_tries      = std::min(MAXIMUM_PEERS, nb_known_peers);
       int tried          = 0;
       while (tried < max_tries) {
         do {
index f5fad58..affd7b6 100644 (file)
@@ -40,7 +40,7 @@ int main(int argc, char **argv)
   XBT_INFO("Route between %s and %s:", h1->getCname(), h2->getCname());
   std::vector<sg_link_t> route;
   double latency = 0;
-  h1->routeTo(h2, &route, &latency);
+  h1->routeTo(h2, route, &latency);
 
   for (auto const& link : route)
     XBT_INFO("   Link %s: latency = %f, bandwidth = %f", sg_link_name(link), sg_link_latency(link),
index 1f2c89f..5c702a0 100644 (file)
@@ -155,19 +155,16 @@ $ tail -n +3 ./simgrid.trace
 > 5 5 2 smpi_replay_run_init "0 1 0"
 > 6 0 2 1 0 "rank-1"
 > 6 0 3 1 0 "rank-2"
-> 12 0 2 1 4
 > 12 0 2 1 5
 > 13 0 2 1
-> 12 0 2 2 4
 > 12 0 2 2 5
 > 13 0 2 2
-> 12 0 2 3 4
 > 12 0 2 3 5
 > 13 0 2 3
 > 5 6 2 action_bcast "0 0.78 0.39"
 > 12 0 2 1 6
-> 12 0 2 3 6
 > 12 0 2 2 6
+> 12 0 2 3 6
 > 13 0 2 1
 > 12 0 2 1 4
 > 13 0.015036 2 2
index 3e2ab0a..d4ba9d2 100644 (file)
@@ -10,5 +10,5 @@ $ ./replay_multiple description_file ${srcdir:=.}/../../platforms/small_platform
 > [0.000000] [msg_test/INFO] Initializing instance 1 of size 32
 > [0.000000] [msg_test/INFO] Initializing instance 2 of size 32
 > [0.000000] [smpi_kernel/INFO] You did not set the power of the host running the simulation.  The timings will certainly not be accurate.  Use the option "--cfg=smpi/host-speed:<flops>" to set its value.Check http://simgrid.org/simgrid/latest/doc/options.html#options_smpi_bench for more information.
-> [Jupiter:2:(52) 1140688.493796] [smpi_replay/INFO] Simulation time 1124371.141124
-> [1140688.493796] [msg_test/INFO] Simulation time 1.14069e+06
+> [Jupiter:2:(62) 1140698.106357] [smpi_replay/INFO] Simulation time 1124380.753685
+> [1140698.106357] [msg_test/INFO] Simulation time 1.1407e+06
index c3c3773..c6ce7bb 100644 (file)
@@ -14,11 +14,8 @@ $ ../../../smpi_script/bin/smpirun -hostfile ${srcdir:=.}/hostfile -platform ${s
 p Testing grouped tracing
 $ ../../../smpi_script/bin/smpirun -trace -trace-grouped -trace-file smpi_trace.trace -hostfile ${srcdir:=.}/hostfile -platform ${srcdir:=.}/../platforms/small_platform.xml --cfg=path:${srcdir:=.}/../msg -np 3 ./smpi_trace_simple --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
 
-p Testing generation of viva configuration files
-$ ../../../smpi_script/bin/smpirun -trace -trace-resource -trace-viva -trace-file smpi_trace.trace -hostfile ${srcdir:=.}/hostfile -platform ${srcdir:=.}/../platforms/small_platform.xml --cfg=path:${srcdir:=.}/../msg --cfg=smpi/simulate-computation:no -np 3 ./smpi_trace_simple --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
-> [0.003952] [instr_config/INFO] No categories declared, ignoring generation of viva graph configuration
 
 p Testing with parameters but without activating them with the safe switch (-trace)
-$ ../../../smpi_script/bin/smpirun -trace-resource -trace-viva -trace-file smpi_trace.trace -hostfile ${srcdir:=.}/hostfile -platform ${srcdir:=.}/../platforms/small_platform.xml --cfg=path:${srcdir:=.}/../msg -np 3 ./smpi_trace_simple --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ../../../smpi_script/bin/smpirun -trace-resource -trace-file smpi_trace.trace -hostfile ${srcdir:=.}/hostfile -platform ${srcdir:=.}/../platforms/small_platform.xml --cfg=path:${srcdir:=.}/../msg -np 3 ./smpi_trace_simple --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
 
-$ rm -f smpi_trace.trace smpi_uncat.plist smpi_cat.plist
+$ rm -f smpi_trace.trace
\ No newline at end of file
index e2cdeab..c59cd23 100644 (file)
@@ -80,7 +80,7 @@ typedef simgrid::kernel::context::Context* smx_context_t;
 typedef simgrid::simix::ActorImpl* smx_actor_t;
 typedef simgrid::simix::MutexImpl* smx_mutex_t;
 typedef simgrid::kernel::activity::MailboxImpl* smx_mailbox_t;
-typedef simgrid::surf::FileImpl* surf_file_t;
+typedef simgrid::surf::StorageImpl* surf_storage_t;
 
 #else
 
@@ -100,7 +100,7 @@ typedef struct s_smx_context* smx_context_t;
 typedef struct s_smx_actor* smx_actor_t;
 typedef struct s_smx_mutex* smx_mutex_t;
 typedef struct s_smx_mailbox* smx_mailbox_t;
-typedef struct s_surf_file* surf_file_t;
+typedef struct s_surf_storage* surf_storage_t;
 
 #endif
 
index cdc9b97..1429d2c 100644 (file)
@@ -59,13 +59,12 @@ public:
   /** Remove a file from disk */
   int unlink();
 
-  std::string storage_type;
-  std::string storageId;
   std::string mount_point;
+  Storage* onStorage;
   int desc_id = 0;
 
 private:
-  surf_file_t pimpl_ = nullptr;
+  simgrid::surf::FileImpl* pimpl_ = nullptr;
   std::string path_;
   void* userdata_ = nullptr;
 };
index 6495cf5..6913403 100644 (file)
@@ -104,8 +104,8 @@ public:
    */
   std::unordered_map<std::string, Storage*> const& getMountedStorages();
 
-  void routeTo(Host * dest, std::vector<Link*> * links, double* latency);
-  void routeTo(Host * dest, std::vector<surf::LinkImpl*> * links, double* latency);
+  void routeTo(Host* dest, std::vector<Link*>& links, double* latency);
+  void routeTo(Host* dest, std::vector<surf::LinkImpl*>& links, double* latency);
 
   /** Block the calling actor on an execution located on the called host
    *
index fc8c8fa..8e7429c 100644 (file)
@@ -68,7 +68,7 @@ public:
   /*** Called on each newly created regular route (not on bypass routes) */
   static simgrid::xbt::signal<void(bool symmetrical, kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
                                    kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
-                                   std::vector<surf::LinkImpl*>* link_list)>
+                                   std::vector<surf::LinkImpl*>& link_list)>
       onRouteCreation;
   static simgrid::xbt::signal<void(NetZone&)> onCreation;
   static simgrid::xbt::signal<void(NetZone&)> onSeal;
index b8d328e..c009740 100644 (file)
@@ -38,6 +38,7 @@ public:
   sg_size_t getSize(); /** Retrieve the total amount of space of this storage element */
   sg_size_t getSizeFree();
   sg_size_t getSizeUsed();
+  void decrUsedSize(sg_size_t size);
 
   std::map<std::string, std::string>* getProperties();
   const char* getProperty(std::string key);
@@ -47,6 +48,8 @@ public:
   void setUserdata(void* data) { userdata_ = data; }
   void* getUserdata() { return userdata_; }
 
+  sg_size_t read(sg_size_t size);
+  sg_size_t write(sg_size_t size);
   surf::StorageImpl* getImpl() { return pimpl_; }
 
   /* The signals */
index 8d27291..7d9245d 100644 (file)
@@ -284,9 +284,9 @@ XBT_PUBLIC(void) SIMIX_sem_destroy(smx_sem_t sem);
 XBT_PUBLIC(void) simcall_sem_acquire(smx_sem_t sem);
 XBT_PUBLIC(void) simcall_sem_acquire_timeout(smx_sem_t sem, double max_duration);
 
-/*****************************   File   **********************************/
-XBT_PUBLIC(sg_size_t) simcall_file_read(surf_file_t fd, sg_size_t size);
-XBT_PUBLIC(sg_size_t) simcall_file_write(surf_file_t fd, sg_size_t size);
+/*****************************   Storage   **********************************/
+XBT_PUBLIC(sg_size_t) simcall_storage_read(surf_storage_t st, sg_size_t size);
+XBT_PUBLIC(sg_size_t) simcall_storage_write(surf_storage_t fd, sg_size_t size);
 /************************** MC simcalls   **********************************/
 XBT_PUBLIC(int) simcall_mc_random(int min, int max);
 
index 5005406..eef491c 100644 (file)
@@ -203,30 +203,6 @@ SG_BEGIN_DECL()
 #define MPI_WIN_SIZE -2
 #define MPI_WIN_DISP_UNIT -3
 
-// FIXME : used nowhere...
-typedef enum MPIR_Combiner_enum{
-  MPI_COMBINER_NAMED,
-  MPI_COMBINER_DUP,
-  MPI_COMBINER_CONTIGUOUS,
-  MPI_COMBINER_VECTOR,
-  MPI_COMBINER_HVECTOR_INTEGER,
-  MPI_COMBINER_HVECTOR,
-  MPI_COMBINER_INDEXED,
-  MPI_COMBINER_HINDEXED_INTEGER,
-  MPI_COMBINER_HINDEXED,
-  MPI_COMBINER_INDEXED_BLOCK,
-  MPI_COMBINER_STRUCT_INTEGER,
-  MPI_COMBINER_STRUCT,
-  MPI_COMBINER_SUBARRAY,
-  MPI_COMBINER_DARRAY,
-  MPI_COMBINER_F90_REAL,
-  MPI_COMBINER_F90_COMPLEX,
-  MPI_COMBINER_F90_INTEGER,
-  MPI_COMBINER_RESIZED,
-  MPI_COMBINER_HINDEXED_BLOCK
-}MPIR_Combiner_enum;
-
-
 typedef ptrdiff_t MPI_Aint;
 typedef long long MPI_Offset;
 
@@ -406,13 +382,29 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Init, (int *argc, char ***argv));
 MPI_CALL(XBT_PUBLIC(int), MPI_Finalize, (void));
 MPI_CALL(XBT_PUBLIC(int), MPI_Finalized, (int* flag));
 MPI_CALL(XBT_PUBLIC(int), MPI_Init_thread, (int *argc, char ***argv, int required, int *provided));
+MPI_CALL(XBT_PUBLIC(int), MPI_Initialized, (int* flag));
 MPI_CALL(XBT_PUBLIC(int), MPI_Query_thread, (int *provided));
 MPI_CALL(XBT_PUBLIC(int), MPI_Is_thread_main, (int *flag));
+MPI_CALL(XBT_PUBLIC(int), MPI_Get_version, (int *version,int *subversion));
+MPI_CALL(XBT_PUBLIC(int), MPI_Get_library_version, (char *version,int *len));
+MPI_CALL(XBT_PUBLIC(int), MPI_Get_processor_name, (char *name, int *resultlen));
 MPI_CALL(XBT_PUBLIC(int), MPI_Abort, (MPI_Comm comm, int errorcode));
+MPI_CALL(XBT_PUBLIC(int), MPI_Alloc_mem, (MPI_Aint size, MPI_Info info, void *baseptr));
+MPI_CALL(XBT_PUBLIC(int), MPI_Free_mem, (void *base));
 MPI_CALL(XBT_PUBLIC(double), MPI_Wtime, (void));
 MPI_CALL(XBT_PUBLIC(double), MPI_Wtick,(void));
+
 MPI_CALL(XBT_PUBLIC(int), MPI_Address, (void *location, MPI_Aint * address));
 MPI_CALL(XBT_PUBLIC(int), MPI_Get_address, (void *location, MPI_Aint * address));
+MPI_CALL(XBT_PUBLIC(int), MPI_Error_class, (int errorcode, int* errorclass));
+
+MPI_CALL(XBT_PUBLIC(int), MPI_Attr_delete, (MPI_Comm comm, int keyval));
+MPI_CALL(XBT_PUBLIC(int), MPI_Attr_get, (MPI_Comm comm, int keyval, void* attr_value, int* flag));
+MPI_CALL(XBT_PUBLIC(int), MPI_Attr_put, (MPI_Comm comm, int keyval, void* attr_value));
+MPI_CALL(XBT_PUBLIC(int), MPI_Keyval_create, (MPI_Copy_function* copy_fn, MPI_Delete_function* delete_fn, int* keyval,
+                              void* extra_state));
+MPI_CALL(XBT_PUBLIC(int), MPI_Keyval_free, (int* keyval));
+
 MPI_CALL(XBT_PUBLIC(int), MPI_Type_free, (MPI_Datatype * datatype));
 MPI_CALL(XBT_PUBLIC(int), MPI_Type_size, (MPI_Datatype datatype, int *size));
 MPI_CALL(XBT_PUBLIC(int), MPI_Type_size_x, (MPI_Datatype datatype, MPI_Count *size));
@@ -445,10 +437,33 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Type_create_struct, (int count, int* blocklens, MP
 MPI_CALL(XBT_PUBLIC(int), MPI_Type_vector, (int count, int blocklen, int stride,
                              MPI_Datatype old_type, MPI_Datatype* newtype));
 MPI_CALL(XBT_PUBLIC(int), MPI_Type_contiguous, (int count, MPI_Datatype old_type, MPI_Datatype* newtype));
-MPI_CALL(XBT_PUBLIC(int), MPI_Testall, (int count, MPI_Request* requests, int* flag, MPI_Status* statuses));
+MPI_CALL(XBT_PUBLIC(int), MPI_Type_create_resized ,(MPI_Datatype oldtype,MPI_Aint lb, MPI_Aint extent,
+                                                    MPI_Datatype *newtype));
+MPI_CALL(XBT_PUBLIC(MPI_Datatype), MPI_Type_f2c,(MPI_Fint datatype));
+MPI_CALL(XBT_PUBLIC(MPI_Fint), MPI_Type_c2f,(MPI_Datatype datatype));
+MPI_CALL(XBT_PUBLIC(int), MPI_Get_count, (MPI_Status * status, MPI_Datatype datatype, int *count));
+MPI_CALL(XBT_PUBLIC(int), MPI_Type_get_attr, (MPI_Datatype type, int type_keyval, void *attribute_val, int* flag));
+MPI_CALL(XBT_PUBLIC(int), MPI_Type_set_attr, (MPI_Datatype type, int type_keyval, void *att));
+MPI_CALL(XBT_PUBLIC(int), MPI_Type_delete_attr, (MPI_Datatype type, int comm_keyval));
+MPI_CALL(XBT_PUBLIC(int), MPI_Type_create_keyval,(MPI_Type_copy_attr_function* copy_fn,
+                              MPI_Type_delete_attr_function* delete_fn, int* keyval, void* extra_state));
+MPI_CALL(XBT_PUBLIC(int), MPI_Type_free_keyval,(int* keyval));
+MPI_CALL(XBT_PUBLIC(int), MPI_Type_dup,(MPI_Datatype datatype,MPI_Datatype *newtype));
+MPI_CALL(XBT_PUBLIC(int), MPI_Type_set_name,(MPI_Datatype  datatype, char * name));
+MPI_CALL(XBT_PUBLIC(int), MPI_Type_get_name,(MPI_Datatype  datatype, char * name, int* len));
+
+
+MPI_CALL(XBT_PUBLIC(int), MPI_Pack, (void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount,
+                              int* position, MPI_Comm comm));
+MPI_CALL(XBT_PUBLIC(int), MPI_Pack_size, (int incount, MPI_Datatype datatype, MPI_Comm comm, int* size));
+MPI_CALL(XBT_PUBLIC(int), MPI_Unpack, (void* inbuf, int insize, int* position, void* outbuf, int outcount,
+                              MPI_Datatype type, MPI_Comm comm));
+
 MPI_CALL(XBT_PUBLIC(int), MPI_Op_create, (MPI_User_function * function, int commute, MPI_Op * op));
 MPI_CALL(XBT_PUBLIC(int), MPI_Op_free, (MPI_Op * op));
 MPI_CALL(XBT_PUBLIC(int), MPI_Op_commutative, (MPI_Op op, int *commute));
+MPI_CALL(XBT_PUBLIC(MPI_Op), MPI_Op_f2c,(MPI_Fint op));
+MPI_CALL(XBT_PUBLIC(MPI_Fint), MPI_Op_c2f,(MPI_Op op));
 
 MPI_CALL(XBT_PUBLIC(int), MPI_Group_free, (MPI_Group * group));
 MPI_CALL(XBT_PUBLIC(int), MPI_Group_size, (MPI_Group group, int *size));
@@ -463,21 +478,29 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Group_incl, (MPI_Group group, int n, int *ranks, M
 MPI_CALL(XBT_PUBLIC(int), MPI_Group_excl, (MPI_Group group, int n, int *ranks, MPI_Group * newgroup));
 MPI_CALL(XBT_PUBLIC(int), MPI_Group_range_incl, (MPI_Group group, int n, int ranges[][3], MPI_Group * newgroup));
 MPI_CALL(XBT_PUBLIC(int), MPI_Group_range_excl, (MPI_Group group, int n, int ranges[][3], MPI_Group * newgroup));
+MPI_CALL(XBT_PUBLIC(MPI_Group), MPI_Group_f2c,(MPI_Fint group));
+MPI_CALL(XBT_PUBLIC(MPI_Fint), MPI_Group_c2f,(MPI_Group group));
 
 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_rank, (MPI_Comm comm, int *rank));
 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_size, (MPI_Comm comm, int *size));
 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_get_name, (MPI_Comm comm, char* name, int* len));
-MPI_CALL(XBT_PUBLIC(int), MPI_Get_processor_name, (char *name, int *resultlen));
-MPI_CALL(XBT_PUBLIC(int), MPI_Get_count, (MPI_Status * status, MPI_Datatype datatype, int *count));
-
+MPI_CALL(XBT_PUBLIC(int), MPI_Comm_set_name, (MPI_Comm comm, char* name));
+MPI_CALL(XBT_PUBLIC(int), MPI_Comm_dup, (MPI_Comm comm, MPI_Comm * newcomm));
+MPI_CALL(XBT_PUBLIC(int), MPI_Comm_get_attr, (MPI_Comm comm, int comm_keyval, void *attribute_val, int *flag));
+MPI_CALL(XBT_PUBLIC(int), MPI_Comm_set_attr, (MPI_Comm comm, int comm_keyval, void *attribute_val));
+MPI_CALL(XBT_PUBLIC(int), MPI_Comm_delete_attr, (MPI_Comm comm, int comm_keyval));
+MPI_CALL(XBT_PUBLIC(int), MPI_Comm_create_keyval,(MPI_Comm_copy_attr_function* copy_fn,
+                              MPI_Comm_delete_attr_function* delete_fn, int* keyval, void* extra_state));
+MPI_CALL(XBT_PUBLIC(int), MPI_Comm_free_keyval,(int* keyval));
 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_group, (MPI_Comm comm, MPI_Group * group));
 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_compare, (MPI_Comm comm1, MPI_Comm comm2, int *result));
-
 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_create, (MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm));
 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_create_group, (MPI_Comm comm, MPI_Group group, int tag, MPI_Comm * newcomm));
 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_free, (MPI_Comm * comm));
 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_disconnect, (MPI_Comm * comm));
 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_split, (MPI_Comm comm, int color, int key, MPI_Comm* comm_out));
+MPI_CALL(XBT_PUBLIC(MPI_Comm), MPI_Comm_f2c,(MPI_Fint comm));
+MPI_CALL(XBT_PUBLIC(MPI_Fint), MPI_Comm_c2f,(MPI_Comm comm));
 
 MPI_CALL(XBT_PUBLIC(int), MPI_Send_init, (void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm,
                              MPI_Request * request));
@@ -493,6 +516,11 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Isend, (void *buf, int count, MPI_Datatype datatyp
 MPI_CALL(XBT_PUBLIC(int), MPI_Recv, (void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm,
                              MPI_Status * status));
 MPI_CALL(XBT_PUBLIC(int), MPI_Send, (void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm));
+MPI_CALL(XBT_PUBLIC(int), MPI_Ssend, (void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm));
+MPI_CALL(XBT_PUBLIC(int), MPI_Ssend_init, (void* buf, int count, MPI_Datatype datatype, int dest, int tag,
+                              MPI_Comm comm, MPI_Request* request));
+MPI_CALL(XBT_PUBLIC(int), MPI_Issend, (void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm,
+                              MPI_Request* request));
 MPI_CALL(XBT_PUBLIC(int), MPI_Sendrecv, (void *sendbuf, int sendcount, MPI_Datatype sendtype, int dst, int sendtag,
                              void *recvbuf, int recvcount, MPI_Datatype recvtype, int src, int recvtag,
                              MPI_Comm comm, MPI_Status * status));
@@ -501,13 +529,19 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Sendrecv_replace, (void *buf, int count, MPI_Datat
 
 MPI_CALL(XBT_PUBLIC(int), MPI_Test, (MPI_Request * request, int *flag, MPI_Status* status));
 MPI_CALL(XBT_PUBLIC(int), MPI_Testany, (int count, MPI_Request requests[], int *index, int *flag, MPI_Status * status));
+MPI_CALL(XBT_PUBLIC(int), MPI_Testall, (int count, MPI_Request* requests, int* flag, MPI_Status* statuses));
+MPI_CALL(XBT_PUBLIC(int), MPI_Testsome, (int incount, MPI_Request requests[], int *outcount, int *indices,
+                             MPI_Status status[]));
 MPI_CALL(XBT_PUBLIC(int), MPI_Wait, (MPI_Request * request, MPI_Status * status));
 MPI_CALL(XBT_PUBLIC(int), MPI_Waitany, (int count, MPI_Request requests[], int *index, MPI_Status * status));
 MPI_CALL(XBT_PUBLIC(int), MPI_Waitall, (int count, MPI_Request requests[], MPI_Status status[]));
 MPI_CALL(XBT_PUBLIC(int), MPI_Waitsome, (int incount, MPI_Request requests[], int *outcount, int *indices,
                              MPI_Status status[]));
-MPI_CALL(XBT_PUBLIC(int), MPI_Testsome, (int incount, MPI_Request requests[], int *outcount, int *indices,
-                             MPI_Status status[]));
+MPI_CALL(XBT_PUBLIC(int), MPI_Iprobe, (int source, int tag, MPI_Comm comm, int* flag, MPI_Status* status));
+MPI_CALL(XBT_PUBLIC(int), MPI_Probe, (int source, int tag, MPI_Comm comm, MPI_Status* status));
+MPI_CALL(XBT_PUBLIC(MPI_Request), MPI_Request_f2c,(MPI_Fint request));
+MPI_CALL(XBT_PUBLIC(MPI_Fint), MPI_Request_c2f,(MPI_Request request));
+
 MPI_CALL(XBT_PUBLIC(int), MPI_Bcast, (void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm));
 MPI_CALL(XBT_PUBLIC(int), MPI_Barrier, (MPI_Comm comm));
 MPI_CALL(XBT_PUBLIC(int), MPI_Gather, (void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf,
@@ -528,6 +562,8 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Allreduce, (void *sendbuf, void *recvbuf, int coun
                              MPI_Comm comm));
 MPI_CALL(XBT_PUBLIC(int), MPI_Scan, (void *sendbuf, void *recvbuf, int count,MPI_Datatype datatype, MPI_Op op,
                              MPI_Comm comm));
+MPI_CALL(XBT_PUBLIC(int), MPI_Exscan,(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op,
+                                      MPI_Comm comm));
 MPI_CALL(XBT_PUBLIC(int), MPI_Reduce_scatter, (void *sendbuf, void *recvbuf, int *recvcounts, MPI_Datatype datatype,
                              MPI_Op op, MPI_Comm comm));
 MPI_CALL(XBT_PUBLIC(int), MPI_Reduce_scatter_block, (void *sendbuf, void *recvbuf, int recvcount, MPI_Datatype datatype,
@@ -536,12 +572,20 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Alltoall, (void *sendbuf, int sendcount, MPI_Datat
                              int recvcount, MPI_Datatype recvtype, MPI_Comm comm));
 MPI_CALL(XBT_PUBLIC(int), MPI_Alltoallv, (void *sendbuf, int *sendcounts, int *senddisps, MPI_Datatype sendtype,
                              void *recvbuf, int *recvcounts, int *recvdisps, MPI_Datatype recvtype, MPI_Comm comm));
-MPI_CALL(XBT_PUBLIC(int), MPI_Iprobe, (int source, int tag, MPI_Comm comm, int* flag, MPI_Status* status));
-MPI_CALL(XBT_PUBLIC(int), MPI_Probe, (int source, int tag, MPI_Comm comm, MPI_Status* status));
-MPI_CALL(XBT_PUBLIC(int), MPI_Get_version, (int *version,int *subversion));
-MPI_CALL(XBT_PUBLIC(int), MPI_Get_library_version, (char *version,int *len));
 MPI_CALL(XBT_PUBLIC(int), MPI_Reduce_local,(void *inbuf, void *inoutbuf, int count, MPI_Datatype datatype, MPI_Op op));
 
+MPI_CALL(XBT_PUBLIC(int), MPI_Info_create,( MPI_Info *info));
+MPI_CALL(XBT_PUBLIC(int), MPI_Info_set,( MPI_Info info, char *key, char *value));
+MPI_CALL(XBT_PUBLIC(int), MPI_Info_get,(MPI_Info info,char *key,int valuelen, char *value, int *flag));
+MPI_CALL(XBT_PUBLIC(int), MPI_Info_free,( MPI_Info *info));
+MPI_CALL(XBT_PUBLIC(int), MPI_Info_delete,( MPI_Info info,  char *key));
+MPI_CALL(XBT_PUBLIC(int), MPI_Info_dup,(MPI_Info info, MPI_Info *newinfo));
+MPI_CALL(XBT_PUBLIC(int), MPI_Info_get_nkeys,( MPI_Info info, int *nkeys));
+MPI_CALL(XBT_PUBLIC(int), MPI_Info_get_nthkey,( MPI_Info info, int n, char *key));
+MPI_CALL(XBT_PUBLIC(int), MPI_Info_get_valuelen,( MPI_Info info, char *key, int *valuelen, int *flag));
+MPI_CALL(XBT_PUBLIC(MPI_Info), MPI_Info_f2c,(MPI_Fint info));
+MPI_CALL(XBT_PUBLIC(MPI_Fint), MPI_Info_c2f,(MPI_Info info));
+
 MPI_CALL(XBT_PUBLIC(int), MPI_Win_free,( MPI_Win* win));
 MPI_CALL(XBT_PUBLIC(int), MPI_Win_create,( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm,
                               MPI_Win *win));
@@ -563,7 +607,20 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Win_delete_attr, (MPI_Win type, int comm_keyval));
 MPI_CALL(XBT_PUBLIC(int), MPI_Win_create_keyval,(MPI_Win_copy_attr_function* copy_fn,
                               MPI_Win_delete_attr_function* delete_fn, int* keyval, void* extra_state));
 MPI_CALL(XBT_PUBLIC(int), MPI_Win_free_keyval,(int* keyval));
-
+MPI_CALL(XBT_PUBLIC(int),  MPI_Win_complete,(MPI_Win win));
+MPI_CALL(XBT_PUBLIC(int),  MPI_Win_post,(MPI_Group group, int assert, MPI_Win win));
+MPI_CALL(XBT_PUBLIC(int),  MPI_Win_start,(MPI_Group group, int assert, MPI_Win win));
+MPI_CALL(XBT_PUBLIC(int),  MPI_Win_wait,(MPI_Win win));
+MPI_CALL(XBT_PUBLIC(int),  MPI_Win_lock,(int lock_type, int rank, int assert, MPI_Win win));
+MPI_CALL(XBT_PUBLIC(int),  MPI_Win_lock_all,(int assert, MPI_Win win));
+MPI_CALL(XBT_PUBLIC(int),  MPI_Win_unlock,(int rank, MPI_Win win));
+MPI_CALL(XBT_PUBLIC(int),  MPI_Win_unlock_all,(MPI_Win win));
+MPI_CALL(XBT_PUBLIC(int),  MPI_Win_flush,(int rank, MPI_Win win));
+MPI_CALL(XBT_PUBLIC(int),  MPI_Win_flush_local,(int rank, MPI_Win win));
+MPI_CALL(XBT_PUBLIC(int),  MPI_Win_flush_all,(MPI_Win win));
+MPI_CALL(XBT_PUBLIC(int),  MPI_Win_flush_local_all,(MPI_Win win));
+MPI_CALL(XBT_PUBLIC(MPI_Win), MPI_Win_f2c,(MPI_Fint win));
+MPI_CALL(XBT_PUBLIC(MPI_Fint), MPI_Win_c2f,(MPI_Win win));
 
 MPI_CALL(XBT_PUBLIC(int), MPI_Get,( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
     MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win));
@@ -574,7 +631,6 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Accumulate,( void *origin_addr, int origin_count,
 MPI_CALL(XBT_PUBLIC(int), MPI_Get_accumulate,( void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
     void* result_addr, int result_count, MPI_Datatype result_datatype, int target_rank, MPI_Aint target_disp,
     int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win));
-
 MPI_CALL(XBT_PUBLIC(int), MPI_Rget,( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
     MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win, MPI_Request* request));
 MPI_CALL(XBT_PUBLIC(int), MPI_Rput,( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
@@ -584,30 +640,46 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Raccumulate,( void *origin_addr, int origin_count,
 MPI_CALL(XBT_PUBLIC(int), MPI_Rget_accumulate,( void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
     void* result_addr, int result_count, MPI_Datatype result_datatype, int target_rank, MPI_Aint target_disp,
     int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win, MPI_Request* request));
-
 MPI_CALL(XBT_PUBLIC(int), MPI_Fetch_and_op,( void *origin_addr, void* result_addr, MPI_Datatype datatype,
     int target_rank, MPI_Aint target_disp, MPI_Op op, MPI_Win win));
 MPI_CALL(XBT_PUBLIC(int), MPI_Compare_and_swap, (void *origin_addr, void *compare_addr,
         void *result_addr, MPI_Datatype datatype, int target_rank, MPI_Aint target_disp, MPI_Win win));
 
-MPI_CALL(XBT_PUBLIC(int), MPI_Alloc_mem, (MPI_Aint size, MPI_Info info, void *baseptr));
-MPI_CALL(XBT_PUBLIC(int), MPI_Free_mem, (void *base));
+MPI_CALL(XBT_PUBLIC(int), MPI_Cart_coords, (MPI_Comm comm, int rank, int maxdims, int* coords));
+MPI_CALL(XBT_PUBLIC(int), MPI_Cart_create, (MPI_Comm comm_old, int ndims, int* dims, int* periods, int reorder,
+                                            MPI_Comm* comm_cart));
+MPI_CALL(XBT_PUBLIC(int), MPI_Cart_get, (MPI_Comm comm, int maxdims, int* dims, int* periods, int* coords));
+MPI_CALL(XBT_PUBLIC(int), MPI_Cart_rank, (MPI_Comm comm, int* coords, int* rank));
+MPI_CALL(XBT_PUBLIC(int), MPI_Cart_shift, (MPI_Comm comm, int direction, int displ, int* source, int* dest));
+MPI_CALL(XBT_PUBLIC(int), MPI_Cart_sub, (MPI_Comm comm, int* remain_dims, MPI_Comm* comm_new));
+MPI_CALL(XBT_PUBLIC(int), MPI_Cartdim_get, (MPI_Comm comm, int* ndims));
+MPI_CALL(XBT_PUBLIC(int), MPI_Dims_create, (int nnodes, int ndims, int* dims));
 
-MPI_CALL(XBT_PUBLIC(MPI_Datatype), MPI_Type_f2c,(MPI_Fint datatype));
-MPI_CALL(XBT_PUBLIC(MPI_Fint), MPI_Type_c2f,(MPI_Datatype datatype));
-MPI_CALL(XBT_PUBLIC(MPI_Group), MPI_Group_f2c,(MPI_Fint group));
-MPI_CALL(XBT_PUBLIC(MPI_Fint), MPI_Group_c2f,(MPI_Group group));
-MPI_CALL(XBT_PUBLIC(MPI_Request), MPI_Request_f2c,(MPI_Fint request));
-MPI_CALL(XBT_PUBLIC(MPI_Fint), MPI_Request_c2f,(MPI_Request request));
-MPI_CALL(XBT_PUBLIC(MPI_Win), MPI_Win_f2c,(MPI_Fint win));
-MPI_CALL(XBT_PUBLIC(MPI_Fint), MPI_Win_c2f,(MPI_Win win));
-MPI_CALL(XBT_PUBLIC(MPI_Op), MPI_Op_f2c,(MPI_Fint op));
-MPI_CALL(XBT_PUBLIC(MPI_Fint), MPI_Op_c2f,(MPI_Op op));
-MPI_CALL(XBT_PUBLIC(MPI_Comm), MPI_Comm_f2c,(MPI_Fint comm));
-MPI_CALL(XBT_PUBLIC(MPI_Fint), MPI_Comm_c2f,(MPI_Comm comm));
 
 //FIXME: these are not yet implemented
 
+typedef enum MPIR_Combiner_enum{
+  MPI_COMBINER_NAMED,
+  MPI_COMBINER_DUP,
+  MPI_COMBINER_CONTIGUOUS,
+  MPI_COMBINER_VECTOR,
+  MPI_COMBINER_HVECTOR_INTEGER,
+  MPI_COMBINER_HVECTOR,
+  MPI_COMBINER_INDEXED,
+  MPI_COMBINER_HINDEXED_INTEGER,
+  MPI_COMBINER_HINDEXED,
+  MPI_COMBINER_INDEXED_BLOCK,
+  MPI_COMBINER_STRUCT_INTEGER,
+  MPI_COMBINER_STRUCT,
+  MPI_COMBINER_SUBARRAY,
+  MPI_COMBINER_DARRAY,
+  MPI_COMBINER_F90_REAL,
+  MPI_COMBINER_F90_COMPLEX,
+  MPI_COMBINER_F90_INTEGER,
+  MPI_COMBINER_RESIZED,
+  MPI_COMBINER_HINDEXED_BLOCK
+}MPIR_Combiner_enum;
+
 typedef void MPI_Handler_function(MPI_Comm*, int*, ...);
 
 typedef void* MPI_Errhandler;
@@ -632,20 +704,9 @@ XBT_PUBLIC_DATA(MPI_Errhandler*)  MPI_ERRORS_RETURN;
 XBT_PUBLIC_DATA(MPI_Errhandler*)  MPI_ERRORS_ARE_FATAL;
 XBT_PUBLIC_DATA(MPI_Errhandler*)  MPI_ERRHANDLER_NULL;
 
-MPI_CALL(XBT_PUBLIC(MPI_Info), MPI_Info_f2c,(MPI_Fint info));
-MPI_CALL(XBT_PUBLIC(MPI_Fint), MPI_Info_c2f,(MPI_Info info));
 MPI_CALL(XBT_PUBLIC(MPI_Errhandler), MPI_Errhandler_f2c,(MPI_Fint errhandler));
 MPI_CALL(XBT_PUBLIC(MPI_Fint), MPI_Errhandler_c2f,(MPI_Errhandler errhandler));
-MPI_CALL(XBT_PUBLIC(int), MPI_Pack_size, (int incount, MPI_Datatype datatype, MPI_Comm comm, int* size));
-MPI_CALL(XBT_PUBLIC(int), MPI_Cart_coords, (MPI_Comm comm, int rank, int maxdims, int* coords));
-MPI_CALL(XBT_PUBLIC(int), MPI_Cart_create, (MPI_Comm comm_old, int ndims, int* dims, int* periods, int reorder,
-                                            MPI_Comm* comm_cart));
-MPI_CALL(XBT_PUBLIC(int), MPI_Cart_get, (MPI_Comm comm, int maxdims, int* dims, int* periods, int* coords));
 MPI_CALL(XBT_PUBLIC(int), MPI_Cart_map, (MPI_Comm comm_old, int ndims, int* dims, int* periods, int* newrank));
-MPI_CALL(XBT_PUBLIC(int), MPI_Cart_rank, (MPI_Comm comm, int* coords, int* rank));
-MPI_CALL(XBT_PUBLIC(int), MPI_Cart_shift, (MPI_Comm comm, int direction, int displ, int* source, int* dest));
-MPI_CALL(XBT_PUBLIC(int), MPI_Cart_sub, (MPI_Comm comm, int* remain_dims, MPI_Comm* comm_new));
-MPI_CALL(XBT_PUBLIC(int), MPI_Cartdim_get, (MPI_Comm comm, int* ndims));
 MPI_CALL(XBT_PUBLIC(int), MPI_Graph_create, (MPI_Comm comm_old, int nnodes, int* index, int* edges, int reorder,
                                              MPI_Comm* comm_graph));
 MPI_CALL(XBT_PUBLIC(int), MPI_Graph_get, (MPI_Comm comm, int maxindex, int maxedges, int* index, int* edges));
@@ -654,7 +715,6 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Graph_neighbors, (MPI_Comm comm, int rank, int max
 MPI_CALL(XBT_PUBLIC(int), MPI_Graph_neighbors_count, (MPI_Comm comm, int rank, int* nneighbors));
 MPI_CALL(XBT_PUBLIC(int), MPI_Graphdims_get, (MPI_Comm comm, int* nnodes, int* nedges));
 MPI_CALL(XBT_PUBLIC(int), MPI_Topo_test, (MPI_Comm comm, int* top_type));
-MPI_CALL(XBT_PUBLIC(int), MPI_Error_class, (int errorcode, int* errorclass));
 MPI_CALL(XBT_PUBLIC(int), MPI_Errhandler_create, (MPI_Handler_function* function, MPI_Errhandler* errhandler));
 MPI_CALL(XBT_PUBLIC(int), MPI_Errhandler_free, (MPI_Errhandler* errhandler));
 MPI_CALL(XBT_PUBLIC(int), MPI_Errhandler_get, (MPI_Comm comm, MPI_Errhandler* errhandler));
@@ -671,26 +731,6 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Cancel, (MPI_Request* request));
 MPI_CALL(XBT_PUBLIC(int), MPI_Buffer_attach, (void* buffer, int size));
 MPI_CALL(XBT_PUBLIC(int), MPI_Buffer_detach, (void* buffer, int* size));
 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_test_inter, (MPI_Comm comm, int* flag));
-MPI_CALL(XBT_PUBLIC(int), MPI_Comm_get_attr, (MPI_Comm comm, int comm_keyval, void *attribute_val, int *flag));
-MPI_CALL(XBT_PUBLIC(int), MPI_Comm_set_attr, (MPI_Comm comm, int comm_keyval, void *attribute_val));
-MPI_CALL(XBT_PUBLIC(int), MPI_Comm_delete_attr, (MPI_Comm comm, int comm_keyval));
-MPI_CALL(XBT_PUBLIC(int), MPI_Comm_create_keyval,(MPI_Comm_copy_attr_function* copy_fn,
-                              MPI_Comm_delete_attr_function* delete_fn, int* keyval, void* extra_state));
-MPI_CALL(XBT_PUBLIC(int), MPI_Comm_free_keyval,(int* keyval));
-MPI_CALL(XBT_PUBLIC(int), MPI_Type_get_attr, (MPI_Datatype type, int type_keyval, void *attribute_val, int* flag));
-MPI_CALL(XBT_PUBLIC(int), MPI_Type_set_attr, (MPI_Datatype type, int type_keyval, void *att));
-MPI_CALL(XBT_PUBLIC(int), MPI_Type_delete_attr, (MPI_Datatype type, int comm_keyval));
-MPI_CALL(XBT_PUBLIC(int), MPI_Type_create_keyval,(MPI_Type_copy_attr_function* copy_fn,
-                              MPI_Type_delete_attr_function* delete_fn, int* keyval, void* extra_state));
-MPI_CALL(XBT_PUBLIC(int), MPI_Type_free_keyval,(int* keyval));
-MPI_CALL(XBT_PUBLIC(int), MPI_Type_dup,(MPI_Datatype datatype,MPI_Datatype *newtype));
-MPI_CALL(XBT_PUBLIC(int), MPI_Type_set_name,(MPI_Datatype  datatype, char * name));
-MPI_CALL(XBT_PUBLIC(int), MPI_Type_get_name,(MPI_Datatype  datatype, char * name, int* len));
-MPI_CALL(XBT_PUBLIC(int), MPI_Unpack, (void* inbuf, int insize, int* position, void* outbuf, int outcount,
-                              MPI_Datatype type, MPI_Comm comm));
-MPI_CALL(XBT_PUBLIC(int), MPI_Ssend, (void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm));
-MPI_CALL(XBT_PUBLIC(int), MPI_Ssend_init, (void* buf, int count, MPI_Datatype datatype, int dest, int tag,
-                              MPI_Comm comm, MPI_Request* request));
 MPI_CALL(XBT_PUBLIC(int), MPI_Intercomm_create, (MPI_Comm local_comm, int local_leader, MPI_Comm peer_comm,
                               int remote_leader, int tag, MPI_Comm* comm_out));
 MPI_CALL(XBT_PUBLIC(int), MPI_Intercomm_merge, (MPI_Comm comm, int high, MPI_Comm* comm_out));
@@ -701,38 +741,15 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Ibsend, (void* buf, int count, MPI_Datatype dataty
                               MPI_Request* request));
 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_remote_group, (MPI_Comm comm, MPI_Group* group));
 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_remote_size, (MPI_Comm comm, int* size));
-MPI_CALL(XBT_PUBLIC(int), MPI_Issend, (void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm,
-                              MPI_Request* request));
-MPI_CALL(XBT_PUBLIC(int), MPI_Attr_delete, (MPI_Comm comm, int keyval));
-MPI_CALL(XBT_PUBLIC(int), MPI_Attr_get, (MPI_Comm comm, int keyval, void* attr_value, int* flag));
-MPI_CALL(XBT_PUBLIC(int), MPI_Attr_put, (MPI_Comm comm, int keyval, void* attr_value));
 MPI_CALL(XBT_PUBLIC(int), MPI_Rsend, (void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm));
 MPI_CALL(XBT_PUBLIC(int), MPI_Rsend_init, (void* buf, int count, MPI_Datatype datatype, int dest, int tag,
                               MPI_Comm comm, MPI_Request* request));
 MPI_CALL(XBT_PUBLIC(int), MPI_Irsend, (void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm,
                               MPI_Request* request));
-MPI_CALL(XBT_PUBLIC(int), MPI_Keyval_create, (MPI_Copy_function* copy_fn, MPI_Delete_function* delete_fn, int* keyval,
-                              void* extra_state));
-MPI_CALL(XBT_PUBLIC(int), MPI_Keyval_free, (int* keyval));
 MPI_CALL(XBT_PUBLIC(int), MPI_Test_cancelled, (MPI_Status* status, int* flag));
-MPI_CALL(XBT_PUBLIC(int), MPI_Pack, (void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount,
-                              int* position, MPI_Comm comm));
 MPI_CALL(XBT_PUBLIC(int), MPI_Get_elements, (MPI_Status* status, MPI_Datatype datatype, int* elements));
-MPI_CALL(XBT_PUBLIC(int), MPI_Dims_create, (int nnodes, int ndims, int* dims));
-MPI_CALL(XBT_PUBLIC(int), MPI_Initialized, (int* flag));
 MPI_CALL(XBT_PUBLIC(int), MPI_Pcontrol, (const int level, ... ));
 
-MPI_CALL(XBT_PUBLIC(int), MPI_Info_create,( MPI_Info *info));
-MPI_CALL(XBT_PUBLIC(int), MPI_Info_set,( MPI_Info info, char *key, char *value));
-MPI_CALL(XBT_PUBLIC(int), MPI_Info_get,(MPI_Info info,char *key,int valuelen, char *value, int *flag));
-MPI_CALL(XBT_PUBLIC(int), MPI_Info_free,( MPI_Info *info));
-MPI_CALL(XBT_PUBLIC(int), MPI_Info_delete,( MPI_Info info,  char *key));
-MPI_CALL(XBT_PUBLIC(int), MPI_Info_dup,(MPI_Info info, MPI_Info *newinfo));
-MPI_CALL(XBT_PUBLIC(int), MPI_Info_get_nkeys,( MPI_Info info, int *nkeys));
-MPI_CALL(XBT_PUBLIC(int), MPI_Info_get_nthkey,( MPI_Info info, int n, char *key));
-MPI_CALL(XBT_PUBLIC(int), MPI_Info_get_valuelen,( MPI_Info info, char *key, int *valuelen, int *flag));
-
-
 MPI_CALL(XBT_PUBLIC(int), MPI_Win_set_errhandler, (MPI_Win win, MPI_Errhandler errhandler));
 MPI_CALL(XBT_PUBLIC(int), MPI_Type_get_envelope,(MPI_Datatype datatype,int *num_integers,int *num_addresses,
                             int *num_datatypes, int *combiner));
@@ -747,19 +764,13 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Pack_external, (char *datarep, void *inbuf, int in
                                               void *outbuf, MPI_Aint outcount, MPI_Aint *position));
 MPI_CALL(XBT_PUBLIC(int), MPI_Unpack_external, (char *datarep, void *inbuf, MPI_Aint insize, MPI_Aint *position,
                                                 void *outbuf, int outcount, MPI_Datatype datatype));
-MPI_CALL(XBT_PUBLIC(int), MPI_Type_create_resized ,(MPI_Datatype oldtype,MPI_Aint lb, MPI_Aint extent,
-                                                    MPI_Datatype *newtype));
 MPI_CALL(XBT_PUBLIC(int), MPI_Type_create_subarray,(int ndims,int *array_of_sizes, int *array_of_subsizes,
                               int *array_of_starts, int order, MPI_Datatype oldtype, MPI_Datatype *newtype));
 MPI_CALL(XBT_PUBLIC(int), MPI_Type_match_size,(int typeclass,int size,MPI_Datatype *datatype));
 MPI_CALL(XBT_PUBLIC(int), MPI_Alltoallw, ( void *sendbuf, int *sendcnts, int *sdispls, MPI_Datatype *sendtypes,
                               void *recvbuf, int *recvcnts, int *rdispls, MPI_Datatype *recvtypes, MPI_Comm comm));
-MPI_CALL(XBT_PUBLIC(int), MPI_Exscan,(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op,
-                                      MPI_Comm comm));
-MPI_CALL(XBT_PUBLIC(int), MPI_Comm_set_name, (MPI_Comm comm, char* name));
 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_set_info, (MPI_Comm comm, MPI_Info info));
 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_get_info, (MPI_Comm comm, MPI_Info* info));
-MPI_CALL(XBT_PUBLIC(int), MPI_Comm_dup, (MPI_Comm comm, MPI_Comm * newcomm));
 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_dup_with_info,(MPI_Comm comm, MPI_Info info, MPI_Comm * newcomm));
 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_split_type,(MPI_Comm comm, int split_type, int key, MPI_Info info,
                                                MPI_Comm *newcomm));
@@ -786,22 +797,7 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Comm_spawn_multiple,(int count, char **array_of_co
                                                    int* array_of_maxprocs, MPI_Info* array_of_info, int root,
                                                    MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes));
 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_get_parent,( MPI_Comm *parent));
-MPI_CALL(XBT_PUBLIC(int),  MPI_Win_complete,(MPI_Win win));
-
-MPI_CALL(XBT_PUBLIC(int),  MPI_Win_post,(MPI_Group group, int assert, MPI_Win win));
-MPI_CALL(XBT_PUBLIC(int),  MPI_Win_start,(MPI_Group group, int assert, MPI_Win win));
 MPI_CALL(XBT_PUBLIC(int),  MPI_Win_test,(MPI_Win win, int *flag));
-MPI_CALL(XBT_PUBLIC(int),  MPI_Win_wait,(MPI_Win win));
-
-MPI_CALL(XBT_PUBLIC(int),  MPI_Win_lock,(int lock_type, int rank, int assert, MPI_Win win));
-MPI_CALL(XBT_PUBLIC(int),  MPI_Win_lock_all,(int assert, MPI_Win win));
-MPI_CALL(XBT_PUBLIC(int),  MPI_Win_unlock,(int rank, MPI_Win win));
-MPI_CALL(XBT_PUBLIC(int),  MPI_Win_unlock_all,(MPI_Win win));
-
-MPI_CALL(XBT_PUBLIC(int),  MPI_Win_flush,(int rank, MPI_Win win));
-MPI_CALL(XBT_PUBLIC(int),  MPI_Win_flush_local,(int rank, MPI_Win win));
-MPI_CALL(XBT_PUBLIC(int),  MPI_Win_flush_all,(MPI_Win win));
-MPI_CALL(XBT_PUBLIC(int),  MPI_Win_flush_local_all,(MPI_Win win));
 
 MPI_CALL(XBT_PUBLIC(MPI_Fint), MPI_File_c2f,(MPI_File file));
 MPI_CALL(XBT_PUBLIC(MPI_File), MPI_File_f2c,(MPI_Fint file));
@@ -918,13 +914,11 @@ XBT_PUBLIC(void) smpi_trace_set_call_location_(const char *file, int* line);
 /** Fortran binding + -fsecond-underscore **/
 XBT_PUBLIC(void) smpi_trace_set_call_location__(const char *file, int* line);
 
-#define SMPI_SAMPLE_LOCAL(iters,thres) for(smpi_sample_1(0, __FILE__, __LINE__, iters, thres); \
-                                           smpi_sample_2(0, __FILE__, __LINE__);      \
-                                           smpi_sample_3(0, __FILE__, __LINE__))
-
-#define SMPI_SAMPLE_GLOBAL(iters,thres) for(smpi_sample_1(1, __FILE__, __LINE__, iters, thres); \
-                                            smpi_sample_2(1, __FILE__, __LINE__);      \
-                                            smpi_sample_3(1, __FILE__, __LINE__))
+#define SMPI_SAMPLE_LOOP(global, iters, thres)                                                                         \
+  for (smpi_sample_1(global, __FILE__, __LINE__, iters, thres); smpi_sample_2(global, __FILE__, __LINE__);             \
+       smpi_sample_3(global, __FILE__, __LINE__))
+#define SMPI_SAMPLE_LOCAL(iters, thres) SMPI_SAMPLE_LOOP(0, iters, thres)
+#define SMPI_SAMPLE_GLOBAL(iters, thres) SMPI_SAMPLE_LOOP(1, iters, thres)
 
 #define SMPI_SAMPLE_DELAY(duration) for(smpi_execute(duration); 0; )
 #define SMPI_SAMPLE_FLOPS(flops) for(smpi_execute_flops(flops); 0; )
index 9dd4caf..5890af3 100644 (file)
@@ -22,7 +22,6 @@
 #include <xbt/dynar.h>
 #include <xbt/dict.h>
 #include <xbt/swag.h>
-#include <xbt/heap.h>
 #include <xbt/parmap.h>
 
 #include <xbt/config.h>
index 1a91452..20e148e 100644 (file)
@@ -6,6 +6,8 @@
 #ifndef XBT_ALGORITHM_HPP
 #define XBT_ALGORITHM_HPP
 
+#include <utility>
+
 namespace simgrid {
 namespace xbt {
 
diff --git a/include/xbt/heap.h b/include/xbt/heap.h
deleted file mode 100644 (file)
index 27c2a81..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Copyright (c) 2004-2007, 2009-2011, 2013-2017. The SimGrid Team.
- * All rights reserved.                                                     */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#ifndef XBT_HEAP_H
-#define XBT_HEAP_H
-
-#include "xbt/misc.h"
-#include "xbt/dynar.h"          /* void_f_pvoid_t */
-
-SG_BEGIN_DECL()
-
-/** @addtogroup XBT_heap
- *  @brief This section describes the API to generic heap with O(log(n)) access.
- *
- *  @deprecated If you are using C++ you might want to use `std::priority_queue`
- *  instead.
- *
- *  @{
- */
-/* @brief heap datatype */
-typedef struct xbt_heap *xbt_heap_t;
-
-XBT_PUBLIC(xbt_heap_t) xbt_heap_new(int init_size, void_f_pvoid_t const free_func);
-XBT_PUBLIC(void) xbt_heap_free(xbt_heap_t H);
-XBT_PUBLIC(int) xbt_heap_size(xbt_heap_t H);
-
-XBT_PUBLIC(void) xbt_heap_push(xbt_heap_t H, void *content, double key);
-XBT_PUBLIC(void *) xbt_heap_pop(xbt_heap_t H);
-XBT_PUBLIC(void *) xbt_heap_rm_elm(xbt_heap_t H, void *content, double key);
-
-XBT_PUBLIC(double) xbt_heap_maxkey(xbt_heap_t H);
-XBT_PUBLIC(void *) xbt_heap_maxcontent(xbt_heap_t H);
-XBT_PUBLIC(void) xbt_heap_set_update_callback(xbt_heap_t H, void (*update_callback) (void*, int));
-XBT_PUBLIC(void *) xbt_heap_remove(xbt_heap_t H, int i);
-XBT_PUBLIC(void ) xbt_heap_update(xbt_heap_t H, int i, double key);
-
-/* @} */
-SG_END_DECL()
-
-#endif                          /* _XBT_HEAP_H */
index e610b81..1916178 100644 (file)
@@ -300,14 +300,13 @@ typedef std::string string;
  *
  * @ingroup XBT_str
 */
-std::string string_printf(const char *fmt, ...);
+XBT_PUBLIC(std::string) string_printf(const char* fmt, ...);
 
 /** Create a C++ string from a C-style format
  *
  * @ingroup XBT_str
 */
-std::string string_vprintf(const char *fmt, va_list ap);
-
+XBT_PUBLIC(std::string) string_vprintf(const char* fmt, va_list ap);
 }
 }
 
index 095130f..e577631 100644 (file)
@@ -1,14 +1,27 @@
-/* Copyright (c) 2016. The SimGrid Team.
+/* Copyright (c) 2016-2017. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#ifndef XBT_UTILITY_HPP
+#define XBT_UTILITY_HPP
+
 #include <tuple>
 
 namespace simgrid {
 namespace xbt {
 
+/** @brief Comparator class for using with std::priority_queue or boost::heap.
+ *
+ * Compare two std::pair by their first element (of type double), and return true when the first is greater than the
+ * second.  Useful to have priority queues with the smallest element on top.
+ */
+template <class Pair> class HeapComparator {
+public:
+  bool operator()(const Pair& a, const Pair& b) const { return a.first > b.first; }
+};
+
 // integer_sequence and friends from C++14
 // We need them to implement `apply` from C++17.
 
@@ -78,3 +91,4 @@ static_assert(std::is_same< index_sequence_for<int,double,float>, make_index_seq
 
 }
 }
+#endif
index 0cc18d0..c58b213 100644 (file)
@@ -58,7 +58,6 @@ public final class Msg {
 
        /** Example launcher. You can use it or provide your own launcher, as you wish
         * @param args
-        * @throws MsgException
         */
        public static void main(String[]args) {
                /* initialize the MSG simulation. Must be done before anything else (even logging). */
index 055939e..e4c7900 100644 (file)
@@ -280,7 +280,6 @@ public abstract class Process implements Runnable {
        /**
         * This method actually creates and run the process.
         * It is a noop if the process is already launched.
-        * @throws HostNotFoundException
         */
        public final void start() {
           if (bind == 0)
index 6f45328..e7c3370 100644 (file)
@@ -141,7 +141,6 @@ int console_add_host___link(lua_State *L) {
 
 int console_add_host(lua_State *L) {
   s_sg_platf_host_cbarg_t host;
-  memset(&host,0,sizeof(host));
   int type;
 
   // we get values from the table passed as argument
@@ -304,7 +303,6 @@ int console_add_router(lua_State* L) {
 int console_add_route(lua_State *L) {
   XBT_DEBUG("Adding route");
   s_sg_platf_route_cbarg_t route;
-  memset(&route,0,sizeof(route));
   int type;
 
   lua_ensure(lua_istable(L, -1), "Bad Arguments to add a route. Should be a table with named arguments");
@@ -329,19 +327,18 @@ int console_add_route(lua_State *L) {
   type = lua_gettable(L,-2);
   lua_ensure(type == LUA_TSTRING,
       "Attribute 'links' must be specified for any route and must be a string (different links separated by commas or single spaces.");
-  route.link_list   = new std::vector<simgrid::surf::LinkImpl*>();
   std::vector<std::string> names;
   const char* str = lua_tostring(L, -1);
   boost::split(names, str, boost::is_any_of(", \t\r\n"));
   if (names.empty()) {
     /* unique name */
-    route.link_list->push_back(simgrid::surf::LinkImpl::byName(lua_tostring(L, -1)));
+    route.link_list.push_back(simgrid::surf::LinkImpl::byName(lua_tostring(L, -1)));
   } else {
     // Several names separated by , \t\r\n
     for (auto const& name : names) {
       if (name.length() > 0) {
         simgrid::surf::LinkImpl* link = simgrid::surf::LinkImpl::byName(name);
-        route.link_list->push_back(link);
+        route.link_list.push_back(link);
       }
     }
   }
@@ -371,14 +368,12 @@ int console_add_route(lua_State *L) {
   route.gw_dst = nullptr;
 
   sg_platf_new_route(&route);
-  delete route.link_list;
 
   return 0;
 }
 
 int console_add_ASroute(lua_State *L) {
   s_sg_platf_route_cbarg_t ASroute;
-  memset(&ASroute,0,sizeof(ASroute));
 
   lua_pushstring(L, "src");
   lua_gettable(L, -2);
@@ -410,19 +405,18 @@ int console_add_ASroute(lua_State *L) {
 
   lua_pushstring(L,"links");
   lua_gettable(L,-2);
-  ASroute.link_list = new std::vector<simgrid::surf::LinkImpl*>();
   std::vector<std::string> names;
   const char* str = lua_tostring(L, -1);
   boost::split(names, str, boost::is_any_of(", \t\r\n"));
   if (names.empty()) {
     /* unique name with no comma */
-    ASroute.link_list->push_back(simgrid::surf::LinkImpl::byName(lua_tostring(L, -1)));
+    ASroute.link_list.push_back(simgrid::surf::LinkImpl::byName(lua_tostring(L, -1)));
   } else {
     // Several names separated by , \t\r\n
     for (auto const& name : names) {
       if (name.length() > 0) {
         simgrid::surf::LinkImpl* link = simgrid::surf::LinkImpl::byName(name);
-        ASroute.link_list->push_back(link);
+        ASroute.link_list.push_back(link);
       }
     }
   }
@@ -443,7 +437,6 @@ int console_add_ASroute(lua_State *L) {
   lua_pop(L,1);
 
   sg_platf_new_route(&ASroute);
-  delete ASroute.link_list;
 
   return 0;
 }
index bdf2977..6325d07 100644 (file)
@@ -183,13 +183,6 @@ XBT_PUBLIC(void) lmm_constraint_shared(lmm_constraint_t cnst);
  */
 XBT_PUBLIC(int) lmm_constraint_sharing_policy(lmm_constraint_t cnst);
 
-/**
- * @brief Free a constraint
- * @param sys The system associated to the constraint
- * @param cnst The constraint to free
- */
-XBT_PUBLIC(void) lmm_constraint_free(lmm_system_t sys, lmm_constraint_t cnst);
-
 /**
  * @brief Get the usage of the constraint after the last lmm solve
  * @param cnst A constraint
@@ -266,14 +259,6 @@ XBT_PUBLIC(double) lmm_variable_getbound(lmm_variable_t var);
  */
 XBT_PUBLIC(void) lmm_variable_concurrency_share_set(lmm_variable_t var, short int concurrency_share);
 
-/**
- * @brief Remove a variable from a constraint
- * @param sys A system
- * @param cnst A constraint
- * @param var The variable to remove
- */
-XBT_PUBLIC(void) lmm_shrink(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var);
-
 /**
  * @brief Associate a variable to a constraint with a coefficient
  * @param sys A system
@@ -299,7 +284,7 @@ XBT_PUBLIC(void) lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst, lmm_var
  * @param num The rank of constraint we want to get
  * @return The numth constraint
  */
-XBT_PUBLIC(lmm_constraint_t) lmm_get_cnst_from_var(lmm_system_t sys, lmm_variable_t var, int num);
+XBT_PUBLIC(lmm_constraint_t) lmm_get_cnst_from_var(lmm_system_t sys, lmm_variable_t var, unsigned num);
 
 /**
  * @brief Get the weigth of the numth constraint associated to the variable
@@ -308,7 +293,7 @@ XBT_PUBLIC(lmm_constraint_t) lmm_get_cnst_from_var(lmm_system_t sys, lmm_variabl
  * @param num The rank of constraint we want to get
  * @return The numth constraint
  */
-XBT_PUBLIC(double) lmm_get_cnst_weight_from_var(lmm_system_t sys, lmm_variable_t var, int num);
+XBT_PUBLIC(double) lmm_get_cnst_weight_from_var(lmm_system_t sys, lmm_variable_t var, unsigned num);
 
 /**
  * @brief Get the number of constraint associated to a variable
index 486b564..b2623ae 100644 (file)
@@ -37,8 +37,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_config, instr, "Configuration");
 #define OPT_TRACING_TOPOLOGY             "tracing/platform/topology"
 #define OPT_TRACING                      "tracing"
 #define OPT_TRACING_UNCATEGORIZED        "tracing/uncategorized"
-#define OPT_VIVA_CAT_CONF                "viva/categorized"
-#define OPT_VIVA_UNCAT_CONF              "viva/uncategorized"
 
 static bool trace_enabled = false;
 static bool trace_platform;
@@ -133,9 +131,6 @@ int TRACE_end()
   } else {
     retval = 0;
 
-    TRACE_generate_viva_uncat_conf();
-    TRACE_generate_viva_cat_conf();
-
     /* dump trace buffer */
     TRACE_last_timestamp_to_dump = surf_get_clock();
     TRACE_paje_dump_buffer(true);
@@ -290,16 +285,6 @@ std::string TRACE_get_filename()
   return xbt_cfg_get_string(OPT_TRACING_FILENAME);
 }
 
-std::string TRACE_get_viva_uncat_conf()
-{
-  return xbt_cfg_get_string(OPT_VIVA_UNCAT_CONF);
-}
-
-std::string TRACE_get_viva_cat_conf()
-{
-  return xbt_cfg_get_string(OPT_VIVA_CAT_CONF);
-}
-
 void TRACE_global_init()
 {
   static bool is_initialised = false;
@@ -337,9 +322,6 @@ void TRACE_global_init()
       "The contents of the file are added to the top of the trace file as comment.");
   xbt_cfg_register_int(OPT_TRACING_PRECISION, 6, nullptr, "Numerical precision used when timestamping events "
       "(expressed in number of digits after decimal point)");
-  /* Viva graph configuration for uncategorized tracing */
-  xbt_cfg_register_string(OPT_VIVA_UNCAT_CONF, "", nullptr, "Viva Graph configuration file for uncategorized resource utilization traces.");
-  xbt_cfg_register_string(OPT_VIVA_CAT_CONF, "", nullptr, "Viva Graph configuration file for categorized resource utilization traces.");
 
   xbt_cfg_register_alias(OPT_TRACING_COMMENT_FILE,"tracing/comment_file");
   xbt_cfg_register_alias(OPT_TRACING_DISABLE_DESTROY, "tracing/disable_destroy");
@@ -377,13 +359,13 @@ void TRACE_help (int detailed)
       "  It activates the uncategorized resource utilization tracing. Use it if\n"
       "  this simulator do not use tracing categories and resource use have to be\n"
       "  traced.", detailed);
-  print_line (OPT_TRACING_FILENAME, "Filename to register traces",
-      "  A file with this name will be created to register the simulation. The file\n"
-      "  is in the Paje format and can be analyzed using Viva, Paje, and PajeNG visualization\n"
-      "  tools. More information can be found in these webpages:\n"
-      "     http://github.com/schnorr/viva/\n"
-      "     http://github.com/schnorr/pajeng/\n"
-      "     http://paje.sourceforge.net/", detailed);
+  print_line(OPT_TRACING_FILENAME, "Filename to register traces",
+             "  A file with this name will be created to register the simulation. The file\n"
+             "  is in the Paje format and can be analyzed using Paje, and PajeNG visualization\n"
+             "  tools. More information can be found in these webpages:\n"
+             "     http://github.com/schnorr/pajeng/\n"
+             "     http://paje.sourceforge.net/",
+             detailed);
   print_line (OPT_TRACING_SMPI, "Trace the MPI Interface (SMPI)",
       "  This option only has effect if this simulator is SMPI-based. Traces the MPI\n"
       "  interface and generates a trace that can be analyzed using Gantt-like\n"
@@ -440,18 +422,6 @@ void TRACE_help (int detailed)
       "  Use this to add a comment line to the top of the trace file.", detailed);
   print_line (OPT_TRACING_COMMENT_FILE, "File contents added to trace file as comment.",
       "  Use this to add the contents of a file to the top of the trace file as comment.", detailed);
-  print_line (OPT_VIVA_UNCAT_CONF, "Generate a graph configuration for Viva",
-      "  This option can be used in all types of simulators build with SimGrid\n"
-      "  to generate a uncategorized resource utilization graph to be used as\n"
-      "  configuration for the Viva visualization tool. This option\n"
-      "  can be used with tracing/categorized:1 and tracing:1 options to\n"
-      "  analyze an unmodified simulator before changing it to contain\n"
-      "  categories.", detailed);
-  print_line (OPT_VIVA_CAT_CONF, "Generate an uncategorized graph configuration for Viva",
-      "  This option can be used if this simulator uses tracing categories\n"
-      "  in its code. The file specified by this option holds a graph configuration\n"
-      "  file for the Viva visualization tool that can be used to analyze a categorized\n"
-      "  resource utilization.", detailed);
   print_line (OPT_TRACING_TOPOLOGY, "Register the platform topology as a graph",
         "  This option (enabled by default) can be used to disable the tracing of\n"
         "  the platform topology in the trace file. Sometimes, such task is really\n"
@@ -475,116 +445,6 @@ static void output_types (const char *name, xbt_dynar_t types, FILE *file)
   xbt_dynar_free (&types);
 }
 
-static void output_categories(const char* name, FILE* file)
-{
-  unsigned int i = created_categories.size();
-  fprintf (file, "    values = (");
-  for (auto const& cat : created_categories) {
-    --i;
-    fprintf(file, "\"%s%s\"", name, cat.c_str());
-    if (i > 0) {
-      fprintf (file, ",");
-    }else{
-      fprintf (file, ");\n");
-    }
-  }
-}
-
-static void uncat_configuration (FILE *file)
-{
-  //register NODE and EDGE types
-  output_types ("node", TRACE_get_node_types(), file);
-  output_types ("edge", TRACE_get_edge_types(), file);
-  fprintf (file, "\n");
-
-  //configuration for all nodes
-  fprintf (file,
-      "  host = {\n"
-      "    type = \"square\";\n"
-      "    size = \"power\";\n"
-      "    values = (\"power_used\");\n"
-      "  };\n"
-      "  link = {\n"
-      "    type = \"rhombus\";\n"
-      "    size = \"bandwidth\";\n"
-      "    values = (\"bandwidth_used\");\n"
-      "  };\n");
-  //close
-}
-
-static void cat_configuration (FILE *file)
-{
-  //register NODE and EDGE types
-  output_types ("node", TRACE_get_node_types(), file);
-  output_types ("edge", TRACE_get_edge_types(), file);
-  fprintf (file, "\n");
-
-  //configuration for all nodes
-  fprintf (file,
-           "  host = {\n"
-           "    type = \"square\";\n"
-           "    size = \"power\";\n");
-  output_categories("p", file);
-  fprintf (file,
-           "  };\n"
-           "  link = {\n"
-           "    type = \"rhombus\";\n"
-           "    size = \"bandwidth\";\n");
-  output_categories("b", file);
-  fprintf (file, "  };\n");
-  //close
-}
-
-static void generate_uncat_configuration (const char *output, const char *name, int brackets)
-{
-  if (output && strlen(output) > 0){
-    FILE *file = fopen (output, "w");
-    if (file == nullptr){
-      THROWF (system_error, 1, "Unable to open file (%s) for writing %s graph configuration (uncategorized).",
-              output, name);
-    }
-
-    if (brackets)
-      fprintf (file, "{\n");
-    uncat_configuration (file);
-    if (brackets)
-      fprintf (file, "}\n");
-    fclose (file);
-  }
-}
-
-static void generate_cat_configuration (const char *output, const char *name, int brackets)
-{
-  if (output && strlen(output) > 0){
-    //check if we do have categories declared
-    if (created_categories.empty()) {
-      XBT_INFO("No categories declared, ignoring generation of %s graph configuration", name);
-      return;
-    }
-
-    FILE *file = fopen (output, "w");
-    if (file == nullptr){
-      THROWF (system_error, 1, "Unable to open file (%s) for writing %s graph "
-          "configuration (categorized).", output, name);
-    }
-
-    if (brackets) fprintf (file, "{\n");
-    cat_configuration (file);
-    if (brackets) fprintf (file, "}\n");
-    fclose (file);
-  }
-}
-
-void TRACE_generate_viva_uncat_conf ()
-{
-  generate_uncat_configuration(TRACE_get_viva_uncat_conf().c_str(), "viva", 0);
-}
-
-void TRACE_generate_viva_cat_conf ()
-{
-  generate_cat_configuration(TRACE_get_viva_cat_conf().c_str(), "viva", 0);
-}
-
 static int previous_trace_state = -1;
 
 void instr_pause_tracing ()
index 8053955..455dffe 100644 (file)
@@ -307,7 +307,7 @@ static void instr_user_srcdst_variable(double time, const char *src, const char
     xbt_die("Element '%s' not found!",dst);
 
   std::vector<simgrid::surf::LinkImpl*> route;
-  simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(src_elm, dst_elm, &route, nullptr);
+  simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(src_elm, dst_elm, route, nullptr);
   for (auto const& link : route)
     instr_user_variable(time, link->getCname(), variable, father_type, value, what, nullptr, &user_link_variables);
 }
index d04a1f9..29b7e34 100644 (file)
@@ -52,7 +52,7 @@ StateEvent::StateEvent(Container* container, Type* type, e_event_type event_type
 {
 }
 
-StateEvent::StateEvent(Container* container, Type* type, e_event_type event_type, EntityValue* value, void* extra)
+StateEvent::StateEvent(Container* container, Type* type, e_event_type event_type, EntityValue* value, TIData* extra)
     : PajeEvent::PajeEvent(container, type, SIMIX_get_clock(), event_type), value(value), extra_(extra)
 {
 #if HAVE_SMPI
@@ -136,14 +136,9 @@ void StateEvent::print()
     if (value != nullptr) // PAJE_PopState Event does not need to have a value
       stream << " " << value->getId();
 
-    if (TRACE_display_sizes()) {
-      stream << " ";
-      if (extra_ != nullptr) {
-        stream << static_cast<instr_extra_data>(extra_)->send_size;
-      } else {
-        stream << 0;
-      }
-    }
+    if (TRACE_display_sizes())
+      stream << " " << ((extra_ != nullptr) ? extra_->display_size() : 0);
+
 #if HAVE_SMPI
     if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
       stream << " \"" << filename << "\" " << linenumber;
@@ -151,134 +146,24 @@ void StateEvent::print()
 #endif
     XBT_DEBUG("Dump %s", stream.str().c_str());
     fprintf(tracing_file, "%s\n", stream.str().c_str());
-
-    if (extra_ != nullptr) {
-      if (static_cast<instr_extra_data>(extra_)->sendcounts != nullptr)
-        xbt_free(static_cast<instr_extra_data>(extra_)->sendcounts);
-      if (static_cast<instr_extra_data>(extra_)->recvcounts != nullptr)
-        xbt_free(static_cast<instr_extra_data>(extra_)->recvcounts);
-      xbt_free(extra_);
-    }
   } else if (instr_fmt_type == instr_fmt_TI) {
     if (extra_ == nullptr)
       return;
-    instr_extra_data extra = (instr_extra_data)extra_;
+
+    /* Unimplemented calls are: WAITANY, SENDRECV, SCAN, EXSCAN, SSEND, and ISSEND. */
 
     // FIXME: dirty extract "rank-" from the name, as we want the bare process id here
     if (getContainer()->getName().find("rank-") != 0)
-      stream << getContainer()->getName() << " ";
+      stream << getContainer()->getName() << " " << extra_->print();
     else
-      stream << getContainer()->getName().erase(0, 5) << " ";
-
-    FILE* trace_file = tracing_files.at(getContainer());
-
-    switch (extra->type) {
-      case TRACING_INIT:
-        stream << "init";
-        break;
-      case TRACING_FINALIZE:
-        stream << "finalize";
-        break;
-      case TRACING_SEND:
-        stream << "send " << extra->dst << " " << extra->send_size << " " << extra->datatype1;
-        break;
-      case TRACING_ISEND:
-        stream << "Isend " << extra->dst << " " << extra->send_size << " " << extra->datatype1;
-        break;
-      case TRACING_RECV:
-        stream << "recv " << extra->src << " " << extra->send_size << " " << extra->datatype1;
-        break;
-      case TRACING_IRECV:
-        stream << "Irecv " << extra->src << " " << extra->send_size << " " << extra->datatype1;
-        break;
-      case TRACING_TEST:
-        stream << "test";
-        break;
-      case TRACING_WAIT:
-        stream << "wait";
-        break;
-      case TRACING_WAITALL:
-        stream << "waitAll";
-        break;
-      case TRACING_BARRIER:
-        stream << "barrier";
-        break;
-      case TRACING_BCAST: // rank bcast size (root) (datatype)
-        stream << "bcast " << extra->send_size;
-        if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, "")))
-          stream << " " << extra->root << " " << extra->datatype1;
-        break;
-      case TRACING_REDUCE: // rank reduce comm_size comp_size (root) (datatype)
-        stream << "reduce " << extra->send_size << " " << extra->comp_size;
-        if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, "")))
-          stream << " " << extra->root << " " << extra->datatype1;
-        break;
-      case TRACING_ALLREDUCE: // rank allreduce comm_size comp_size (datatype)
-        stream << "allReduce " << extra->send_size << " " << extra->comp_size << " " << extra->datatype1;
-        break;
-      case TRACING_ALLTOALL: // rank alltoall send_size recv_size (sendtype) (recvtype)
-        stream << "allToAll " << extra->send_size << " " << extra->recv_size << " " << extra->datatype1 << " ";
-        stream << extra->datatype2;
-        break;
-      case TRACING_ALLTOALLV: // rank alltoallv send_size [sendcounts] recv_size [recvcounts] (sendtype) (recvtype)
-        stream << "allToAllV " << extra->send_size << " ";
-        for (int i = 0; i < extra->num_processes; i++)
-          stream << extra->sendcounts[i] << " ";
-        stream << extra->recv_size << " ";
-        for (int i = 0; i < extra->num_processes; i++)
-          stream << extra->recvcounts[i] << " ";
-        stream << extra->datatype1 << " " << extra->datatype2;
-        break;
-      case TRACING_GATHER: // rank gather send_size recv_size root (sendtype) (recvtype)
-        stream << "gather " << extra->send_size << " " << extra->recv_size << " " << extra->datatype1 << " ";
-        stream << extra->datatype2;
-        break;
-      case TRACING_ALLGATHERV: // rank allgatherv send_size [recvcounts] (sendtype) (recvtype)
-        stream << "allGatherV " << extra->send_size;
-        for (int i = 0; i < extra->num_processes; i++)
-          stream << extra->recvcounts[i] << " ";
-        stream << extra->datatype1 << " " << extra->datatype2;
-        break;
-      case TRACING_REDUCE_SCATTER: // rank reducescatter [recvcounts] comp_size (sendtype)
-        stream << "reduceScatter ";
-        for (int i = 0; i < extra->num_processes; i++)
-          stream << extra->recvcounts[i] << " ";
-        stream << extra->comp_size << " " << extra->datatype1;
-        break;
-      case TRACING_COMPUTING:
-        stream << "compute " << extra->comp_size;
-        break;
-      case TRACING_SLEEPING:
-        stream << "sleep " << extra->sleep_duration;
-        break;
-      case TRACING_GATHERV: // rank gatherv send_size [recvcounts] root (sendtype) (recvtype)
-        stream << "gatherV " << extra->send_size;
-        for (int i = 0; i < extra->num_processes; i++)
-          stream << extra->recvcounts[i] << " ";
-        stream << extra->root << " " << extra->datatype1 << " " << extra->datatype2;
-        break;
-      case TRACING_ALLGATHER: // rank allgather sendcount recvcounts (sendtype) (recvtype)
-        stream << "allGather " << extra->send_size << " " << extra->recv_size << " " << extra->datatype1 << " ";
-        stream << extra->datatype2;
-        break;
-      default:
-        /* Unimplemented calls are: WAITANY, SENDRECV, SCATTER, SCATTERV, SCAN, EXSCAN, COMM_SIZE, COMM_SPLIT, COMM_DUP,
-         * SSEND, and ISSEND.
-         */
-        XBT_WARN("Call from %s impossible to translate into replay command : Not implemented (yet)", value->getCname());
-        break;
-    }
-    fprintf(trace_file, "%s\n", stream.str().c_str());
-
-    if (extra->recvcounts != nullptr)
-      xbt_free(extra->recvcounts);
-    if (extra->sendcounts != nullptr)
-      xbt_free(extra->sendcounts);
-    xbt_free(extra);
+      stream << getContainer()->getName().erase(0, 5) << " " << extra_->print();
 
+    fprintf(tracing_files.at(getContainer()), "%s\n", stream.str().c_str());
   } else {
     THROW_IMPOSSIBLE;
   }
+
+  delete extra_;
 }
 }
 }
index 3c2fc02..c8fa8b2 100644 (file)
@@ -12,6 +12,7 @@
 namespace simgrid {
 namespace instr {
 class EntityValue;
+class TIData;
 
 enum e_event_type : unsigned int {
   PAJE_DefineContainerType,
@@ -62,12 +63,12 @@ public:
 class StateEvent : public PajeEvent {
   EntityValue* value;
   std::string filename;
-  int linenumber;
-  void* extra_ = nullptr;
+  int linenumber = 0;
+  TIData* extra_ = nullptr;
 
 public:
   StateEvent(Container* container, Type* type, e_event_type event_type, EntityValue* value);
-  StateEvent(Container* container, Type* type, e_event_type event_type, EntityValue* value, void* extra);
+  StateEvent(Container* container, Type* type, e_event_type event_type, EntityValue* value, TIData* extra);
   void print() override;
 };
 
index 314bc86..3f87707 100644 (file)
@@ -65,7 +65,7 @@ void StateType::setEvent(std::string value_name)
   events_.push_back(new StateEvent(issuer_, this, PAJE_SetState, getEntityValue(value_name)));
 }
 
-void StateType::pushEvent(std::string value_name, void* extra)
+void StateType::pushEvent(std::string value_name, TIData* extra)
 {
   events_.push_back(new StateEvent(issuer_, this, PAJE_PushState, getEntityValue(value_name), extra));
 }
index ab5b97a..b07bc65 100644 (file)
@@ -93,7 +93,7 @@ public:
   ~StateType();
   void setEvent(std::string value_name);
   void pushEvent(std::string value_name);
-  void pushEvent(std::string value_name, void* extra);
+  void pushEvent(std::string value_name, TIData* extra);
   void popEvent();
 };
 }
index fdfd350..263d4f4 100644 (file)
 
 typedef simgrid::instr::Container* container_t;
 
+namespace simgrid {
+namespace instr {
+
+class TIData {
+  std::string name_;
+  double amount_ = 0;
+
+public:
+  int endpoint                 = 0;
+  int send_size                = 0;
+  std::vector<int>* sendcounts = nullptr;
+  int recv_size                = 0;
+  std::vector<int>* recvcounts = nullptr;
+  std::string send_type        = "";
+  std::string recv_type        = "";
+
+  // NoOpTI: init, finalize, test, wait, barrier
+  explicit TIData(std::string name) : name_(name){};
+  // CPuTI: compute, sleep (+ waitAny and waitAll out of laziness)
+  explicit TIData(std::string name, double amount) : name_(name), amount_(amount){};
+  // Pt2PtTI: send, isend, sssend, issend, recv, irecv
+  explicit TIData(std::string name, int endpoint, int size, std::string datatype)
+      : name_(name), endpoint(endpoint), send_size(size), send_type(datatype){};
+  // CollTI: bcast, reduce, allReduce, gather, scatter, allGather, allToAll
+  explicit TIData(std::string name, int root, double amount, int send_size, int recv_size, std::string send_type,
+                  std::string recv_type)
+      : name_(name)
+      , amount_(amount)
+      , endpoint(root)
+      , send_size(send_size)
+      , recv_size(recv_size)
+      , send_type(send_type)
+      , recv_type(recv_type){};
+  // VarCollTI: gatherV, scatterV, allGatherV, allToAllV (+ reduceScatter out of laziness)
+  explicit TIData(std::string name, int root, int send_size, std::vector<int>* sendcounts, int recv_size,
+                  std::vector<int>* recvcounts, std::string send_type, std::string recv_type)
+      : name_(name)
+      , endpoint(root)
+      , send_size(send_size)
+      , sendcounts(sendcounts)
+      , recv_size(recv_size)
+      , recvcounts(recvcounts)
+      , send_type(send_type)
+      , recv_type(recv_type){};
+
+  virtual ~TIData()
+  {
+    delete sendcounts;
+    delete recvcounts;
+  }
+
+  std::string getName() { return name_; }
+  double getAmount() { return amount_; }
+  virtual std::string print()        = 0;
+  virtual std::string display_size() = 0;
+};
+
+class NoOpTIData : public TIData {
+public:
+  explicit NoOpTIData(std::string name) : TIData(name){};
+  std::string print() override { return getName(); }
+  std::string display_size() override { return ""; }
+};
+
+class CpuTIData : public TIData {
+public:
+  explicit CpuTIData(std::string name, double amount) : TIData(name, amount){};
+  std::string print() override
+  {
+    std::stringstream stream;
+    stream << getName() << " " << getAmount();
+    return stream.str();
+  }
+  std::string display_size() override { return std::to_string(getAmount()); }
+};
+
+class Pt2PtTIData : public TIData {
+public:
+  explicit Pt2PtTIData(std::string name, int endpoint, int size, std::string datatype)
+      : TIData(name, endpoint, size, datatype){};
+  std::string print() override
+  {
+    std::stringstream stream;
+    stream << getName() << " ";
+    if (endpoint >= 0)
+      stream << endpoint << " ";
+    stream << send_size << " " << send_type;
+    return stream.str();
+  }
+  std::string display_size() override { return std::to_string(send_size); }
+};
+
+class CollTIData : public TIData {
+public:
+  explicit CollTIData(std::string name, int root, double amount, int send_size, int recv_size, std::string send_type,
+                      std::string recv_type)
+      : TIData(name, root, amount, send_size, recv_size, send_type, recv_type){};
+  std::string print() override
+  {
+    std::stringstream stream;
+    stream << getName() << " " << send_size << " ";
+    if (recv_size >= 0)
+      stream << recv_size << " ";
+    if (getAmount() >= 0.0)
+      stream << getAmount() << " ";
+    if (endpoint > 0 || (endpoint == 0 && not send_type.empty()))
+      stream << endpoint << " ";
+    stream << send_type << " " << recv_type;
+
+    return stream.str();
+  }
+  std::string display_size() override { return std::to_string(send_size); }
+};
+
+class VarCollTIData : public TIData {
+public:
+  explicit VarCollTIData(std::string name, int root, int send_size, std::vector<int>* sendcounts, int recv_size,
+                         std::vector<int>* recvcounts, std::string send_type, std::string recv_type)
+      : TIData(name, root, send_size, sendcounts, recv_size, recvcounts, send_type, recv_type){};
+  std::string print() override
+  {
+    std::stringstream stream;
+    stream << getName() << " ";
+    if (send_size >= 0)
+      stream << send_size << " ";
+    if (sendcounts != nullptr)
+      for (auto count : *sendcounts)
+        stream << count << " ";
+    if (recv_size >= 0)
+      stream << recv_size << " ";
+    if (recvcounts != nullptr)
+      for (auto count : *recvcounts)
+        stream << count << " ";
+    if (endpoint > 0 || (endpoint == 0 && not send_type.empty()))
+      stream << endpoint << " ";
+    stream << send_type << " " << recv_type;
+
+    return stream.str();
+  }
+  std::string display_size() override { return std::to_string(send_size > 0 ? send_size : recv_size); }
+};
+}
+}
+
 extern "C" {
 
 extern XBT_PRIVATE std::set<std::string> created_categories;
@@ -66,8 +210,6 @@ XBT_PRIVATE bool TRACE_disable_destroy();
 XBT_PRIVATE bool TRACE_basic();
 XBT_PRIVATE bool TRACE_display_sizes();
 XBT_PRIVATE int TRACE_precision();
-XBT_PRIVATE void TRACE_generate_viva_uncat_conf();
-XBT_PRIVATE void TRACE_generate_viva_cat_conf();
 XBT_PRIVATE void instr_pause_tracing();
 XBT_PRIVATE void instr_resume_tracing();
 
@@ -102,59 +244,6 @@ XBT_PRIVATE void TRACE_paje_dump_buffer(bool force);
 XBT_PRIVATE void dump_comment_file(std::string filename);
 XBT_PRIVATE void dump_comment(std::string comment);
 
-enum e_caller_type {
-  TRACING_INIT,
-  TRACING_FINALIZE,
-  TRACING_COMM_SIZE,
-  TRACING_COMM_SPLIT,
-  TRACING_COMM_DUP,
-  TRACING_SEND,
-  TRACING_ISEND,
-  TRACING_SSEND,
-  TRACING_ISSEND,
-  TRACING_RECV,
-  TRACING_IRECV,
-  TRACING_SENDRECV,
-  TRACING_TEST,
-  TRACING_WAIT,
-  TRACING_WAITALL,
-  TRACING_WAITANY,
-  TRACING_BARRIER,
-  TRACING_BCAST,
-  TRACING_REDUCE,
-  TRACING_ALLREDUCE,
-  TRACING_ALLTOALL,
-  TRACING_ALLTOALLV,
-  TRACING_GATHER,
-  TRACING_GATHERV,
-  TRACING_SCATTER,
-  TRACING_SCATTERV,
-  TRACING_ALLGATHER,
-  TRACING_ALLGATHERV,
-  TRACING_REDUCE_SCATTER,
-  TRACING_COMPUTING,
-  TRACING_SLEEPING,
-  TRACING_SCAN,
-  TRACING_EXSCAN
-};
-
-struct s_instr_extra_data_t {
-  e_caller_type type;
-  int send_size;
-  int recv_size;
-  double comp_size;
-  double sleep_duration;
-  int src;
-  int dst;
-  int root;
-  const char* datatype1;
-  const char* datatype2;
-  int* sendcounts;
-  int* recvcounts;
-  int num_processes;
-};
-typedef s_instr_extra_data_t* instr_extra_data;
-
 /* Format of TRACING output.
  *   - paje is the regular format, that we all know
  *   - TI is a trick to reuse the tracing functions to generate a time independent trace during the execution. Such
@@ -167,7 +256,5 @@ extern instr_fmt_type_t instr_fmt_type;
 XBT_PRIVATE std::string TRACE_get_comment();
 XBT_PRIVATE std::string TRACE_get_comment_file();
 XBT_PRIVATE std::string TRACE_get_filename();
-XBT_PRIVATE std::string TRACE_get_viva_uncat_conf();
-XBT_PRIVATE std::string TRACE_get_viva_cat_conf();
 
 #endif
index 77dc1e9..19468d2 100644 (file)
@@ -34,56 +34,40 @@ static void instr_event(double now, double delta, simgrid::instr::VariableType*
   variable->subEvent(now + delta, value);
 }
 
-/* TRACE_surf_link_set_utilization: entry point from SimGrid */
-void TRACE_surf_link_set_utilization(const char *resource, const char *category, double value, double now, double delta)
+static void TRACE_surf_resource_set_utilization(const char* type, const char* name, const char* resource,
+                                                const char* category, double value, double now, double delta)
 {
-  //only trace link utilization if link is known by tracing mechanism
+  // only trace resource utilization if resource is known by tracing mechanism
   container_t container = simgrid::instr::Container::byNameOrNull(resource);
   if (not container || not value)
     return;
 
-  //trace uncategorized link utilization
+  // trace uncategorized resource utilization
   if (TRACE_uncategorized()){
-    XBT_DEBUG("UNCAT LINK [%f - %f] %s bandwidth_used %f", now, now + delta, resource, value);
-    simgrid::instr::VariableType* variable = container->getVariable("bandwidth_used");
+    XBT_DEBUG("UNCAT %s [%f - %f] %s %s %f", type, now, now + delta, resource, name, value);
+    simgrid::instr::VariableType* variable = container->getVariable(name);
     instr_event(now, delta, variable, container, value);
   }
 
-  //trace categorized utilization
+  // trace categorized resource utilization
   if (TRACE_categorized()){
     if (not category)
       return;
-    //variable of this category starts by 'b', because we have a link here
-    std::string category_type = std::string("b") + category;
-    XBT_DEBUG("CAT LINK [%f - %f] %s %s %f", now, now + delta, resource, category_type.c_str(), value);
+    std::string category_type = name[0] + std::string(category);
+    XBT_DEBUG("CAT %s [%f - %f] %s %s %f", type, now, now + delta, resource, category_type.c_str(), value);
     simgrid::instr::VariableType* variable = container->getVariable(category_type);
     instr_event(now, delta, variable, container, value);
   }
 }
 
-/* TRACE_surf_host_set_utilization: entry point from SimGrid */
-void TRACE_surf_host_set_utilization(const char *resource, const char *category, double value, double now, double delta)
+/* TRACE_surf_link_set_utilization: entry point from SimGrid */
+void TRACE_surf_link_set_utilization(const char* resource, const char* category, double value, double now, double delta)
 {
-  //only trace host utilization if host is known by tracing mechanism
-  container_t container = simgrid::instr::Container::byNameOrNull(resource);
-  if (not container || not value)
-    return;
-
-  //trace uncategorized host utilization
-  if (TRACE_uncategorized()){
-    XBT_DEBUG("UNCAT HOST [%f - %f] %s power_used %f", now, now+delta, resource, value);
-    simgrid::instr::VariableType* variable = container->getVariable("power_used");
-    instr_event(now, delta, variable, container, value);
-  }
+  TRACE_surf_resource_set_utilization("LINK", "bandwidth_used", resource, category, value, now, delta);
+}
 
-  //trace categorized utilization
-  if (TRACE_categorized()){
-    if (not category)
-      return;
-    //variable of this category starts by 'p', because we have a host here
-    std::string category_type = std::string("p") + category;
-    XBT_DEBUG("CAT HOST [%f - %f] %s %s %f", now, now + delta, resource, category_type.c_str(), value);
-    simgrid::instr::VariableType* variable = container->getVariable(category_type);
-    instr_event(now, delta, variable, container, value);
-  }
+/* TRACE_surf_host_set_utilization: entry point from SimGrid */
+void TRACE_surf_host_set_utilization(const char* resource, const char* category, double value, double now, double delta)
+{
+  TRACE_surf_resource_set_utilization("HOST", "power_used", resource, category, value, now, delta);
 }
index 146d6b7..def907b 100644 (file)
 #include "src/instr/instr_private.hpp"
 #include <string>
 
-XBT_PRIVATE std::string smpi_container(int rank);
+XBT_PRIVATE container_t smpi_container(int rank);
 
 extern "C" {
 
 XBT_PRIVATE void TRACE_internal_smpi_set_category(const char* category);
 XBT_PRIVATE const char* TRACE_internal_smpi_get_category();
-XBT_PRIVATE void TRACE_smpi_collective_in(int rank, const char* operation, instr_extra_data extra);
-XBT_PRIVATE void TRACE_smpi_collective_out(int rank, const char* operation);
 XBT_PRIVATE void TRACE_smpi_computing_init(int rank);
 XBT_PRIVATE void TRACE_smpi_computing_out(int rank);
-XBT_PRIVATE void TRACE_smpi_computing_in(int rank, instr_extra_data extra);
+XBT_PRIVATE void TRACE_smpi_computing_in(int rank, double amount);
 XBT_PRIVATE void TRACE_smpi_sleeping_init(int rank);
 XBT_PRIVATE void TRACE_smpi_sleeping_out(int rank);
-XBT_PRIVATE void TRACE_smpi_sleeping_in(int rank, instr_extra_data extra);
+XBT_PRIVATE void TRACE_smpi_sleeping_in(int rank, double duration);
 XBT_PRIVATE void TRACE_smpi_testing_out(int rank);
-XBT_PRIVATE void TRACE_smpi_testing_in(int rank, instr_extra_data extra);
+XBT_PRIVATE void TRACE_smpi_testing_in(int rank);
 XBT_PRIVATE void TRACE_smpi_alloc();
 XBT_PRIVATE void TRACE_smpi_release();
-XBT_PRIVATE void TRACE_smpi_ptp_in(int rank, const char* operation, instr_extra_data extra);
-XBT_PRIVATE void TRACE_smpi_ptp_out(int rank, int dst, const char* operation);
+XBT_PRIVATE void TRACE_smpi_comm_in(int rank, const char* operation, simgrid::instr::TIData* extra);
+XBT_PRIVATE void TRACE_smpi_comm_out(int rank);
 XBT_PRIVATE void TRACE_smpi_send(int rank, int src, int dst, int tag, int size);
 XBT_PRIVATE void TRACE_smpi_recv(int src, int dst, int tag);
 XBT_PRIVATE void TRACE_smpi_init(int rank);
 XBT_PRIVATE void TRACE_smpi_finalize(int rank);
 
-XBT_PRIVATE const char* encode_datatype(MPI_Datatype datatype, int* known);
+XBT_PRIVATE const char* encode_datatype(MPI_Datatype datatype);
 
 class smpi_trace_call_location_t {
 public:
index 65ac052..9001cf9 100644 (file)
@@ -23,14 +23,14 @@ void simgrid::kernel::activity::IoImpl::post()
 {
   for (smx_simcall_t const& simcall : simcalls) {
     switch (simcall->call) {
-    case SIMCALL_FILE_WRITE:
-      simcall_file_write__set__result(simcall, surf_io->getCost());
-      break;
-    case SIMCALL_FILE_READ:
-      simcall_file_read__set__result(simcall, surf_io->getCost());
-      break;
-    default:
-      break;
+      case SIMCALL_STORAGE_WRITE:
+        simcall_storage_write__set__result(simcall, surf_io->getCost());
+        break;
+      case SIMCALL_STORAGE_READ:
+        simcall_storage_read__set__result(simcall, surf_io->getCost());
+        break;
+      default:
+        break;
     }
   }
 
index 08da44b..ad30187 100644 (file)
@@ -30,7 +30,7 @@ void ClusterZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cba
     xbt_assert(not src->isRouter(), "Routing from a cluster private router to itself is meaningless");
 
     std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePosition(src->id()));
-    route->link_list->push_back(info.first);
+    route->link_list.push_back(info.first);
     if (lat)
       *lat += info.first->latency();
     return;
@@ -39,19 +39,19 @@ void ClusterZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cba
   if (not src->isRouter()) { // No private link for the private router
     if (hasLimiter_) { // limiter for sender
       std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePositionWithLoopback(src->id()));
-      route->link_list->push_back(info.first);
+      route->link_list.push_back(info.first);
     }
 
     std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePositionWithLimiter(src->id()));
     if (info.first) { // link up
-      route->link_list->push_back(info.first);
+      route->link_list.push_back(info.first);
       if (lat)
         *lat += info.first->latency();
     }
   }
 
   if (backbone_) {
-    route->link_list->push_back(backbone_);
+    route->link_list.push_back(backbone_);
     if (lat)
       *lat += backbone_->latency();
   }
@@ -60,13 +60,13 @@ void ClusterZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cba
 
     std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePositionWithLimiter(dst->id()));
     if (info.second) { // link down
-      route->link_list->push_back(info.second);
+      route->link_list.push_back(info.second);
       if (lat)
         *lat += info.second->latency();
     }
     if (hasLimiter_) { // limiter for receiver
       info = privateLinks_.at(nodePositionWithLoopback(dst->id()));
-      route->link_list->push_back(info.first);
+      route->link_list.push_back(info.first);
     }
   }
 }
@@ -117,7 +117,7 @@ void ClusterZone::getGraph(xbt_graph_t graph, std::map<std::string, xbt_node_t>*
   }
 }
 
-void ClusterZone::create_links_for_node(ClusterCreationArgs* cluster, int id, int /*rank*/, int position)
+void ClusterZone::create_links_for_node(ClusterCreationArgs* cluster, int id, int /*rank*/, unsigned int position)
 {
   std::string link_id = cluster->id + "_link_" + std::to_string(id);
 
index 9fe5cba..376747e 100644 (file)
@@ -73,7 +73,7 @@ public:
   void getGraph(xbt_graph_t graph, std::map<std::string, xbt_node_t>* nodes,
                 std::map<std::string, xbt_edge_t>* edges) override;
 
-  virtual void create_links_for_node(ClusterCreationArgs* cluster, int id, int rank, int position);
+  virtual void create_links_for_node(ClusterCreationArgs* cluster, int id, int rank, unsigned int position);
   virtual void parse_specific_arguments(ClusterCreationArgs* cluster)
   {
     /* this routing method does not require any specific argument */
@@ -83,9 +83,9 @@ public:
   /* The pair is {linkUp, linkDown} */
   std::unordered_map<unsigned int, std::pair<surf::LinkImpl*, surf::LinkImpl*>> privateLinks_;
 
-  int nodePosition(int id) { return id * linkCountPerNode_; }
-  int nodePositionWithLoopback(int id) { return nodePosition(id) + (hasLoopback_ ? 1 : 0); }
-  int nodePositionWithLimiter(int id) { return nodePositionWithLoopback(id) + (hasLimiter_ ? 1 : 0); }
+  unsigned int nodePosition(int id) { return id * linkCountPerNode_; }
+  unsigned int nodePositionWithLoopback(int id) { return nodePosition(id) + (hasLoopback_ ? 1 : 0); }
+  unsigned int nodePositionWithLimiter(int id) { return nodePositionWithLoopback(id) + (hasLimiter_ ? 1 : 0); }
 
   surf::LinkImpl* backbone_      = nullptr;
   void* loopback_                = nullptr;
index 0c5123d..85dfd1a 100644 (file)
@@ -8,6 +8,8 @@
 #include "src/surf/network_interface.hpp"
 
 #include <cfloat>
+#include <queue>
+#include <vector>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_dijkstra, surf, "Routing part of surf -- dijkstra routing logic");
 
@@ -19,13 +21,10 @@ static void graph_node_data_free(void* n)
   delete data;
 }
 
-static void graph_edge_data_free(void* e) // FIXME: useless code duplication
+static void graph_edge_data_free(void* e)
 {
   sg_platf_route_cbarg_t e_route = static_cast<sg_platf_route_cbarg_t>(e);
-  if (e_route) {
-    delete e_route->link_list;
-    delete e_route;
-  }
+  delete e_route;
 }
 
 /* Utility functions */
@@ -58,8 +57,7 @@ void DijkstraZone::seal()
 
       if (not found) {
         sg_platf_route_cbarg_t e_route = new s_sg_platf_route_cbarg_t;
-        e_route->link_list             = new std::vector<surf::LinkImpl*>();
-        e_route->link_list->push_back(surf_network_model->loopback_);
+        e_route->link_list.push_back(surf_network_model->loopback_);
         xbt_graph_new_edge(routeGraph_, node, node, e_route);
       }
     }
@@ -153,8 +151,8 @@ void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb
 
     sg_platf_route_cbarg_t e_route = static_cast<sg_platf_route_cbarg_t>(xbt_graph_edge_get_data(edge));
 
-    for (auto const& link : *e_route->link_list) {
-      route->link_list->insert(route->link_list->begin(), link);
+    for (auto const& link : e_route->link_list) {
+      route->link_list.insert(route->link_list.begin(), link);
       if (lat)
         *lat += static_cast<surf::LinkImpl*>(link)->latency();
     }
@@ -167,7 +165,8 @@ void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb
     int nr_nodes      = xbt_dynar_length(nodes);
     std::vector<double> cost_arr(nr_nodes); /* link cost from src to other hosts */
     pred_arr.resize(nr_nodes);              /* predecessors in path from src */
-    xbt_heap_t pqueue = xbt_heap_new(nr_nodes, nullptr);
+    typedef std::pair<double, int> Qelt;
+    std::priority_queue<Qelt, std::vector<Qelt>, std::greater<Qelt>> pqueue;
 
     /* initialize */
     cost_arr[src_node_id] = 0.0;
@@ -180,14 +179,14 @@ void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb
       pred_arr[i] = 0;
 
       /* initialize priority queue */
-      int* nodeid = new int(i);
-      xbt_heap_push(pqueue, nodeid, cost_arr[i]);
+      pqueue.emplace(cost_arr[i], i);
     }
 
     /* apply dijkstra using the indexes from the graph's node array */
-    while (xbt_heap_size(pqueue) > 0) {
-      int* v_id         = static_cast<int*>(xbt_heap_pop(pqueue));
-      xbt_node_t v_node = xbt_dynar_get_as(nodes, *v_id, xbt_node_t);
+    while (not pqueue.empty()) {
+      int v_id = pqueue.top().second;
+      pqueue.pop();
+      xbt_node_t v_node = xbt_dynar_get_as(nodes, v_id, xbt_node_t);
       xbt_edge_t edge   = nullptr;
       unsigned int cursor;
 
@@ -196,20 +195,15 @@ void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb
         graph_node_data_t data             = static_cast<graph_node_data_t>(xbt_graph_node_get_data(u_node));
         int u_id                           = data->graph_id;
         sg_platf_route_cbarg_t tmp_e_route = static_cast<sg_platf_route_cbarg_t>(xbt_graph_edge_get_data(edge));
-        int cost_v_u                       = tmp_e_route->link_list->size(); /* count of links, old model assume 1 */
+        int cost_v_u                       = tmp_e_route->link_list.size(); /* count of links, old model assume 1 */
 
-        if (cost_v_u + cost_arr[*v_id] < cost_arr[u_id]) {
-          pred_arr[u_id] = *v_id;
-          cost_arr[u_id] = cost_v_u + cost_arr[*v_id];
-          int* nodeid    = new int(u_id);
-          xbt_heap_push(pqueue, nodeid, cost_arr[u_id]);
+        if (cost_v_u + cost_arr[v_id] < cost_arr[u_id]) {
+          pred_arr[u_id] = v_id;
+          cost_arr[u_id] = cost_v_u + cost_arr[v_id];
+          pqueue.emplace(cost_arr[u_id], u_id);
         }
       }
-
-      /* free item popped from pqueue */
-      delete v_id;
     }
-    xbt_heap_free(pqueue);
   }
 
   /* compose route path with links */
@@ -239,18 +233,18 @@ void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb
 
       NetPoint* gw_dst_net_elm      = nullptr;
       NetPoint* prev_gw_src_net_elm = nullptr;
-      getGlobalRoute(gw_dst_net_elm, prev_gw_src_net_elm, &e_route_as_to_as, nullptr);
-      auto pos = route->link_list->begin();
+      getGlobalRoute(gw_dst_net_elm, prev_gw_src_net_elm, e_route_as_to_as, nullptr);
+      auto pos = route->link_list.begin();
       for (auto const& link : e_route_as_to_as) {
-        route->link_list->insert(pos, link);
+        route->link_list.insert(pos, link);
         if (lat)
           *lat += link->latency();
         pos++;
       }
     }
 
-    for (auto const& link : *e_route->link_list) {
-      route->link_list->insert(route->link_list->begin(), link);
+    for (auto const& link : e_route->link_list) {
+      route->link_list.insert(route->link_list.begin(), link);
       if (lat)
         *lat += static_cast<surf::LinkImpl*>(link)->latency();
     }
index fd60b9d..d6eecc5 100644 (file)
@@ -112,12 +112,13 @@ void DragonflyZone::parse_specific_arguments(ClusterCreationArgs* cluster)
     throw std::invalid_argument(std::string("Last parameter is not the amount of nodes per blade:") + parameters[3]);
   }
 
+  if (cluster->sharing_policy == SURF_LINK_FULLDUPLEX)
+    this->numLinksperLink_ = 2;
+
   this->cluster_ = cluster;
 }
 
-/*
-* Generate the cluster once every node is created
-*/
+/* Generate the cluster once every node is created */
 void DragonflyZone::seal()
 {
   if (this->numNodesPerBlade_ == 0) {
@@ -167,14 +168,9 @@ void DragonflyZone::createLink(const std::string& id, int numlinks, surf::LinkIm
   sg_platf_new_link(&linkTemplate);
   XBT_DEBUG("Generating link %s", id.c_str());
   surf::LinkImpl* link;
-  std::string tmpID;
   if (this->cluster_->sharing_policy == SURF_LINK_FULLDUPLEX) {
-    tmpID     = linkTemplate.id + "_UP";
-    link      = surf::LinkImpl::byName(tmpID);
-    *linkup   = link; // check link?
-    tmpID     = linkTemplate.id + "_DOWN";
-    link      = surf::LinkImpl::byName(tmpID);
-    *linkdown = link; // check link ?
+    *linkup   = surf::LinkImpl::byName(linkTemplate.id + "_UP");   // check link?
+    *linkdown = surf::LinkImpl::byName(linkTemplate.id + "_DOWN"); // check link ?
   } else {
     link      = surf::LinkImpl::byName(linkTemplate.id);
     *linkup   = link;
@@ -190,9 +186,6 @@ void DragonflyZone::generateLinks()
 
   unsigned int numRouters = this->numGroups_ * this->numChassisPerGroup_ * this->numBladesPerChassis_;
 
-  if (this->cluster_->sharing_policy == SURF_LINK_FULLDUPLEX)
-    numLinksperLink_ = 2;
-
   // Links from routers to their local nodes.
   for (unsigned int i = 0; i < numRouters; i++) {
     // allocate structures
@@ -205,12 +198,10 @@ void DragonflyZone::generateLinks()
           std::to_string(j / numLinksperLink_) + "_" + std::to_string(uniqueId);
       this->createLink(id, 1, &linkup, &linkdown);
 
-      if (this->cluster_->sharing_policy == SURF_LINK_FULLDUPLEX) {
-        this->routers_[i]->myNodes_[j]     = linkup;
+      this->routers_[i]->myNodes_[j] = linkup;
+      if (this->cluster_->sharing_policy == SURF_LINK_FULLDUPLEX)
         this->routers_[i]->myNodes_[j + 1] = linkdown;
-      } else {
-        this->routers_[i]->myNodes_[j] = linkup;
-      }
+
       uniqueId++;
     }
   }
@@ -282,7 +273,7 @@ void DragonflyZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_c
   if ((src->id() == dst->id()) && hasLoopback_) {
     std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePosition(src->id()));
 
-    route->link_list->push_back(info.first);
+    route->link_list.push_back(info.first);
     if (latency)
       *latency += info.first->latency();
     return;
@@ -303,13 +294,13 @@ void DragonflyZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_c
   DragonflyRouter* currentRouter = myRouter;
 
   // node->router local link
-  route->link_list->push_back(myRouter->myNodes_[myCoords[3] * numLinksperLink_]);
+  route->link_list.push_back(myRouter->myNodes_[myCoords[3] * numLinksperLink_]);
   if (latency)
     *latency += myRouter->myNodes_[myCoords[3] * numLinksperLink_]->latency();
 
   if (hasLimiter_) { // limiter for sender
     std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePositionWithLoopback(src->id()));
-    route->link_list->push_back(info.first);
+    route->link_list.push_back(info.first);
   }
 
   if (targetRouter != myRouter) {
@@ -319,7 +310,7 @@ void DragonflyZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_c
       // go to the router of our group connected to this one.
       if (currentRouter->blade_ != targetCoords[0]) {
         // go to the nth router in our chassis
-        route->link_list->push_back(currentRouter->greenLinks_[targetCoords[0]]);
+        route->link_list.push_back(currentRouter->greenLinks_[targetCoords[0]]);
         if (latency)
           *latency += currentRouter->greenLinks_[targetCoords[0]]->latency();
         currentRouter = routers_[myCoords[0] * (numChassisPerGroup_ * numBladesPerChassis_) +
@@ -328,14 +319,14 @@ void DragonflyZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_c
 
       if (currentRouter->chassis_ != 0) {
         // go to the first chassis of our group
-        route->link_list->push_back(currentRouter->blackLinks_[0]);
+        route->link_list.push_back(currentRouter->blackLinks_[0]);
         if (latency)
           *latency += currentRouter->blackLinks_[0]->latency();
         currentRouter = routers_[myCoords[0] * (numChassisPerGroup_ * numBladesPerChassis_) + targetCoords[0]];
       }
 
       // go to destination group - the only optical hop
-      route->link_list->push_back(currentRouter->blueLinks_[0]);
+      route->link_list.push_back(currentRouter->blueLinks_[0]);
       if (latency)
         *latency += currentRouter->blueLinks_[0]->latency();
       currentRouter = routers_[targetCoords[0] * (numChassisPerGroup_ * numBladesPerChassis_) + myCoords[0]];
@@ -343,7 +334,7 @@ void DragonflyZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_c
 
     // same group, but same blade ?
     if (targetRouter->blade_ != currentRouter->blade_) {
-      route->link_list->push_back(currentRouter->greenLinks_[targetCoords[2]]);
+      route->link_list.push_back(currentRouter->greenLinks_[targetCoords[2]]);
       if (latency)
         *latency += currentRouter->greenLinks_[targetCoords[2]]->latency();
       currentRouter = routers_[targetCoords[0] * (numChassisPerGroup_ * numBladesPerChassis_) + targetCoords[2]];
@@ -351,7 +342,7 @@ void DragonflyZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_c
 
     // same blade, but same chassis ?
     if (targetRouter->chassis_ != currentRouter->chassis_) {
-      route->link_list->push_back(currentRouter->blackLinks_[targetCoords[1]]);
+      route->link_list.push_back(currentRouter->blackLinks_[targetCoords[1]]);
       if (latency)
         *latency += currentRouter->blackLinks_[targetCoords[1]]->latency();
     }
@@ -359,11 +350,11 @@ void DragonflyZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_c
 
   if (hasLimiter_) { // limiter for receiver
     std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(nodePositionWithLoopback(dst->id()));
-    route->link_list->push_back(info.first);
+    route->link_list.push_back(info.first);
   }
 
   // router->node local link
-  route->link_list->push_back(targetRouter->myNodes_[targetCoords[3] * numLinksperLink_ + numLinksperLink_ - 1]);
+  route->link_list.push_back(targetRouter->myNodes_[targetCoords[3] * numLinksperLink_ + numLinksperLink_ - 1]);
   if (latency)
     *latency += targetRouter->myNodes_[targetCoords[3] * numLinksperLink_ + numLinksperLink_ - 1]->latency();
 }
index 6feea64..fd63be5 100644 (file)
@@ -72,7 +72,7 @@ public:
 
 private:
   void rankId_to_coords(int rankId, unsigned int (*coords)[4]);
-  ClusterCreationArgs* cluster_;
+  ClusterCreationArgs* cluster_     = nullptr;
   unsigned int numNodesPerBlade_    = 0;
   unsigned int numBladesPerChassis_ = 0;
   unsigned int numChassisPerGroup_  = 0;
index 92301b4..16e2798 100644 (file)
@@ -78,7 +78,7 @@ void FatTreeZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cba
 
   /* In case destination is the source, and there is a loopback, let's use it instead of going up to a switch */
   if (source->id == destination->id && this->hasLoopback_) {
-    into->link_list->push_back(source->loopback);
+    into->link_list.push_back(source->loopback);
     if (latency)
       *latency += source->loopback->latency();
     return;
@@ -95,13 +95,13 @@ void FatTreeZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cba
 
     int k = this->upperLevelNodesNumber_[currentNode->level];
     d     = d % k;
-    into->link_list->push_back(currentNode->parents[d]->upLink);
+    into->link_list.push_back(currentNode->parents[d]->upLink);
 
     if (latency)
       *latency += currentNode->parents[d]->upLink->latency();
 
     if (this->hasLimiter_)
-      into->link_list->push_back(currentNode->limiterLink);
+      into->link_list.push_back(currentNode->limiterLink);
     currentNode = currentNode->parents[d]->upNode;
   }
 
@@ -112,12 +112,12 @@ void FatTreeZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cba
   while (currentNode != destination) {
     for (unsigned int i = 0; i < currentNode->children.size(); i++) {
       if (i % this->lowerLevelNodesNumber_[currentNode->level - 1] == destination->label[currentNode->level - 1]) {
-        into->link_list->push_back(currentNode->children[i]->downLink);
+        into->link_list.push_back(currentNode->children[i]->downLink);
         if (latency)
           *latency += currentNode->children[i]->downLink->latency();
         currentNode = currentNode->children[i]->downNode;
         if (this->hasLimiter_)
-          into->link_list->push_back(currentNode->limiterLink);
+          into->link_list.push_back(currentNode->limiterLink);
         XBT_DEBUG("%d(%u,%u) is accessible through %d(%u,%u)", destination->id, destination->level,
                   destination->position, currentNode->id, currentNode->level, currentNode->position);
       }
index 4162fa4..354f13d 100644 (file)
@@ -36,7 +36,7 @@ FloydZone::~FloydZone()
   /* Delete link_table */
   for (unsigned int i = 0; i < table_size; i++)
     for (unsigned int j = 0; j < table_size; j++)
-      routing_route_free(TO_FLOYD_LINK(i, j));
+      delete TO_FLOYD_LINK(i, j);
   delete[] linkTable_;
 
   delete[] predecessorTable_;
@@ -74,8 +74,8 @@ void FloydZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg
       getGlobalRoute(prev_dst_gw, e_route->gw_src, route->link_list, lat);
     }
 
-    for (auto const& link : *e_route->link_list) {
-      route->link_list->push_back(link);
+    for (auto const& link : e_route->link_list) {
+      route->link_list.push_back(link);
       if (lat)
         *lat += link->latency();
     }
@@ -119,7 +119,7 @@ void FloydZone::addRoute(sg_platf_route_cbarg_t route)
   TO_FLOYD_LINK(route->src->id(), route->dst->id()) = newExtendedRoute(hierarchy_, route, 1);
   TO_FLOYD_PRED(route->src->id(), route->dst->id()) = route->src->id();
   TO_FLOYD_COST(route->src->id(), route->dst->id()) =
-      (TO_FLOYD_LINK(route->src->id(), route->dst->id()))->link_list->size();
+      (TO_FLOYD_LINK(route->src->id(), route->dst->id()))->link_list.size();
 
   if (route->symmetrical == true) {
     if (route->gw_dst) // netzone route (to adapt the error message, if any)
@@ -147,7 +147,7 @@ void FloydZone::addRoute(sg_platf_route_cbarg_t route)
     TO_FLOYD_LINK(route->dst->id(), route->src->id()) = newExtendedRoute(hierarchy_, route, 0);
     TO_FLOYD_PRED(route->dst->id(), route->src->id()) = route->dst->id();
     TO_FLOYD_COST(route->dst->id(), route->src->id()) =
-        (TO_FLOYD_LINK(route->dst->id(), route->src->id()))->link_list->size(); /* count of links, old model assume 1 */
+        (TO_FLOYD_LINK(route->dst->id(), route->src->id()))->link_list.size(); /* count of links, old model assume 1 */
   }
 }
 
@@ -179,8 +179,7 @@ void FloydZone::seal()
         e_route            = new s_sg_platf_route_cbarg_t;
         e_route->gw_src    = nullptr;
         e_route->gw_dst    = nullptr;
-        e_route->link_list = new std::vector<surf::LinkImpl*>();
-        e_route->link_list->push_back(surf_network_model->loopback_);
+        e_route->link_list.push_back(surf_network_model->loopback_);
         TO_FLOYD_LINK(i, i) = e_route;
         TO_FLOYD_PRED(i, i) = i;
         TO_FLOYD_COST(i, i) = 1;
index d6e4660..a05458a 100644 (file)
@@ -34,8 +34,7 @@ void FullZone::seal()
         e_route            = new s_sg_platf_route_cbarg_t;
         e_route->gw_src    = nullptr;
         e_route->gw_dst    = nullptr;
-        e_route->link_list = new std::vector<surf::LinkImpl*>();
-        e_route->link_list->push_back(surf_network_model->loopback_);
+        e_route->link_list.push_back(surf_network_model->loopback_);
         TO_ROUTE_FULL(i, i) = e_route;
       }
     }
@@ -48,12 +47,8 @@ FullZone::~FullZone()
     unsigned int table_size = getTableSize();
     /* Delete routing table */
     for (unsigned int i = 0; i < table_size; i++)
-      for (unsigned int j = 0; j < table_size; j++) {
-        if (TO_ROUTE_FULL(i, j)) {
-          delete TO_ROUTE_FULL(i, j)->link_list;
-          delete TO_ROUTE_FULL(i, j);
-        }
-      }
+      for (unsigned int j = 0; j < table_size; j++)
+        delete TO_ROUTE_FULL(i, j);
     delete[] routingTable_;
   }
 }
@@ -68,8 +63,8 @@ void FullZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_
   if (e_route != nullptr) {
     res->gw_src = e_route->gw_src;
     res->gw_dst = e_route->gw_dst;
-    for (auto const& link : *e_route->link_list) {
-      res->link_list->push_back(link);
+    for (auto const& link : e_route->link_list) {
+      res->link_list.push_back(link);
       if (lat)
         *lat += link->latency();
     }
index a9e952e..08b74df 100644 (file)
@@ -70,7 +70,7 @@ void NetZoneImpl::addBypassRoute(sg_platf_route_cbarg_t e_route)
   if (e_route->gw_dst) {
     XBT_DEBUG("Load bypassNetzoneRoute from %s@%s to %s@%s", e_route->src->getCname(), e_route->gw_src->getCname(),
               e_route->dst->getCname(), e_route->gw_dst->getCname());
-    xbt_assert(not e_route->link_list->empty(), "Bypass route between %s@%s and %s@%s cannot be empty.",
+    xbt_assert(not e_route->link_list.empty(), "Bypass route between %s@%s and %s@%s cannot be empty.",
                e_route->src->getCname(), e_route->gw_src->getCname(), e_route->dst->getCname(),
                e_route->gw_dst->getCname());
     xbt_assert(bypassRoutes_.find({e_route->src, e_route->dst}) == bypassRoutes_.end(),
@@ -78,7 +78,7 @@ void NetZoneImpl::addBypassRoute(sg_platf_route_cbarg_t e_route)
                e_route->gw_src->getCname(), e_route->dst->getCname(), e_route->gw_dst->getCname());
   } else {
     XBT_DEBUG("Load bypassRoute from %s to %s", e_route->src->getCname(), e_route->dst->getCname());
-    xbt_assert(not e_route->link_list->empty(), "Bypass route between %s and %s cannot be empty.",
+    xbt_assert(not e_route->link_list.empty(), "Bypass route between %s and %s cannot be empty.",
                e_route->src->getCname(), e_route->dst->getCname());
     xbt_assert(bypassRoutes_.find({e_route->src, e_route->dst}) == bypassRoutes_.end(),
                "The bypass route between %s and %s already exists.", e_route->src->getCname(),
@@ -87,7 +87,7 @@ void NetZoneImpl::addBypassRoute(sg_platf_route_cbarg_t e_route)
 
   /* Build a copy that will be stored in the dict */
   kernel::routing::BypassRoute* newRoute = new kernel::routing::BypassRoute(e_route->gw_src, e_route->gw_dst);
-  for (auto const& link : *e_route->link_list)
+  for (auto const& link : e_route->link_list)
     newRoute->links.push_back(link);
 
   /* Store it */
@@ -205,7 +205,7 @@ static void find_common_ancestors(NetPoint* src, NetPoint* dst,
 
 /* PRECONDITION: this is the common ancestor of src and dst */
 bool NetZoneImpl::getBypassRoute(routing::NetPoint* src, routing::NetPoint* dst,
-                                 /* OUT */ std::vector<surf::LinkImpl*>* links, double* latency)
+                                 /* OUT */ std::vector<surf::LinkImpl*>& links, double* latency)
 {
   // If never set a bypass route return nullptr without any further computations
   if (bypassRoutes_.empty())
@@ -216,7 +216,7 @@ bool NetZoneImpl::getBypassRoute(routing::NetPoint* src, routing::NetPoint* dst,
     if (bypassRoutes_.find({src, dst}) != bypassRoutes_.end()) {
       BypassRoute* bypassedRoute = bypassRoutes_.at({src, dst});
       for (surf::LinkImpl* const& link : bypassedRoute->links) {
-        links->push_back(link);
+        links.push_back(link);
         if (latency)
           *latency += link->latency();
       }
@@ -300,7 +300,7 @@ bool NetZoneImpl::getBypassRoute(routing::NetPoint* src, routing::NetPoint* dst,
     if (src != key.first)
       getGlobalRoute(src, bypassedRoute->gw_src, links, latency);
     for (surf::LinkImpl* const& link : bypassedRoute->links) {
-      links->push_back(link);
+      links.push_back(link);
       if (latency)
         *latency += link->latency();
     }
@@ -313,10 +313,9 @@ bool NetZoneImpl::getBypassRoute(routing::NetPoint* src, routing::NetPoint* dst,
 }
 
 void NetZoneImpl::getGlobalRoute(routing::NetPoint* src, routing::NetPoint* dst,
-                                 /* OUT */ std::vector<surf::LinkImpl*>* links, double* latency)
+                                 /* OUT */ std::vector<surf::LinkImpl*>& links, double* latency)
 {
   s_sg_platf_route_cbarg_t route;
-  memset(&route, 0, sizeof(route));
 
   XBT_DEBUG("Resolve route from '%s' to '%s'", src->getCname(), dst->getCname());
 
@@ -334,15 +333,14 @@ void NetZoneImpl::getGlobalRoute(routing::NetPoint* src, routing::NetPoint* dst,
 
   /* If src and dst are in the same netzone, life is good */
   if (src_ancestor == dst_ancestor) { /* SURF_ROUTING_BASE */
-    route.link_list = links;
+    route.link_list = std::move(links);
     common_ancestor->getLocalRoute(src, dst, &route, latency);
+    links = std::move(route.link_list);
     return;
   }
 
   /* Not in the same netzone, no bypass. We'll have to find our path between the netzones recursively */
 
-  route.link_list = new std::vector<surf::LinkImpl*>();
-
   common_ancestor->getLocalRoute(src_ancestor->netpoint_, dst_ancestor->netpoint_, &route, latency);
   xbt_assert((route.gw_src != nullptr) && (route.gw_dst != nullptr), "bad gateways for route from \"%s\" to \"%s\"",
              src->getCname(), dst->getCname());
@@ -350,9 +348,8 @@ void NetZoneImpl::getGlobalRoute(routing::NetPoint* src, routing::NetPoint* dst,
   /* If source gateway is not our source, we have to recursively find our way up to this point */
   if (src != route.gw_src)
     getGlobalRoute(src, route.gw_src, links, latency);
-  for (auto const& link : *route.link_list)
-    links->push_back(link);
-  delete route.link_list;
+  for (auto const& link : route.link_list)
+    links.push_back(link);
 
   /* If dest gateway is not our destination, we have to recursively find our way from this point */
   if (route.gw_dst != dst)
index 95f5ae3..c2d7738 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016. The SimGrid Team. All rights reserved.               */
+/* Copyright (c) 2016-2017. The SimGrid Team. All rights reserved.               */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -76,7 +76,7 @@ protected:
   /** @brief retrieves the list of all routes of size 1 (of type src x dst x Link) */
   /* returns whether we found a bypass path */
   bool getBypassRoute(routing::NetPoint * src, routing::NetPoint * dst,
-                      /* OUT */ std::vector<surf::LinkImpl*> * links, double* latency);
+                      /* OUT */ std::vector<surf::LinkImpl*>& links, double* latency);
 
 public:
   /* @brief get the route between two nodes in the full platform
@@ -87,7 +87,7 @@ public:
    * @param latency Accumulator in which the latencies should be added (caller must set it to 0)
    */
   static void getGlobalRoute(routing::NetPoint * src, routing::NetPoint * dst,
-                             /* OUT */ std::vector<surf::LinkImpl*> * links, double* latency);
+                             /* OUT */ std::vector<surf::LinkImpl*>& links, double* latency);
 
   virtual void getGraph(xbt_graph_t graph, std::map<std::string, xbt_node_t> * nodes,
                         std::map<std::string, xbt_edge_t> * edges) = 0;
index 0263235..dab2e4e 100644 (file)
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_routing_generic, surf_route, "Generic implementation of the surf routing");
 
-void routing_route_free(sg_platf_route_cbarg_t route)
-{
-  if (route) {
-    delete route->link_list;
-    delete route;
-  }
-}
-
 /* ***************************************************************** */
 /* *********************** GENERIC METHODS ************************* */
 
@@ -82,7 +74,6 @@ void RoutedZone::getGraph(xbt_graph_t graph, std::map<std::string, xbt_node_t>*
         continue;
 
       sg_platf_route_cbarg_t route = new s_sg_platf_route_cbarg_t;
-      route->link_list             = new std::vector<surf::LinkImpl*>();
 
       getLocalRoute(my_src, my_dst, route, nullptr);
 
@@ -101,7 +92,7 @@ void RoutedZone::getGraph(xbt_graph_t graph, std::map<std::string, xbt_node_t>*
         previous_name = my_src->getCname();
       }
 
-      for (auto const& link : *route->link_list) {
+      for (auto const& link : route->link_list) {
         const char* link_name = link->getCname();
         current               = new_xbt_graph_node(graph, link_name, nodes);
         current_name          = link_name;
@@ -121,7 +112,6 @@ void RoutedZone::getGraph(xbt_graph_t graph, std::map<std::string, xbt_node_t>*
       new_xbt_graph_edge(graph, previous, current, edges);
       XBT_DEBUG("  %s -> %s", previous_name, current_name);
 
-      delete route->link_list;
       delete route;
     }
   }
@@ -136,7 +126,6 @@ sg_platf_route_cbarg_t RoutedZone::newExtendedRoute(RoutingMode hierarchy, sg_pl
   sg_platf_route_cbarg_t result;
 
   result            = new s_sg_platf_route_cbarg_t;
-  result->link_list = new std::vector<surf::LinkImpl*>();
 
   xbt_assert(hierarchy == RoutingMode::base || hierarchy == RoutingMode::recursive,
              "The hierarchy of this netzone is neither BASIC nor RECURSIVE, I'm lost here.");
@@ -148,13 +137,13 @@ sg_platf_route_cbarg_t RoutedZone::newExtendedRoute(RoutingMode hierarchy, sg_pl
     result->gw_dst = routearg->gw_dst;
   }
 
-  for (auto const& link : *routearg->link_list) {
+  for (auto const& link : routearg->link_list) {
     if (change_order)
-      result->link_list->push_back(link);
+      result->link_list.push_back(link);
     else
-      result->link_list->insert(result->link_list->begin(), link);
+      result->link_list.insert(result->link_list.begin(), link);
   }
-  result->link_list->shrink_to_fit();
+  result->link_list.shrink_to_fit();
 
   return result;
 }
@@ -186,7 +175,7 @@ void RoutedZone::addRouteCheckParams(sg_platf_route_cbarg_t route)
     XBT_DEBUG("Load Route from \"%s\" to \"%s\"", srcName, dstName);
     xbt_assert(src, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, srcName);
     xbt_assert(dst, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, dstName);
-    xbt_assert(not route->link_list->empty(), "Empty route (between %s and %s) forbidden.", srcName, dstName);
+    xbt_assert(not route->link_list.empty(), "Empty route (between %s and %s) forbidden.", srcName, dstName);
     xbt_assert(not src->isNetZone(),
                "When defining a route, src cannot be a netzone such as '%s'. Did you meant to have an NetzoneRoute?",
                srcName);
@@ -211,7 +200,7 @@ void RoutedZone::addRouteCheckParams(sg_platf_route_cbarg_t route)
                dstName, route->gw_dst->getCname(), srcName);
     xbt_assert(dst, "Cannot add a route from %s@%s to %s@%s: %s does not exist.", srcName, route->gw_src->getCname(),
                dstName, route->gw_dst->getCname(), dstName);
-    xbt_assert(not route->link_list->empty(), "Empty route (between %s@%s and %s@%s) forbidden.", srcName,
+    xbt_assert(not route->link_list.empty(), "Empty route (between %s@%s and %s@%s) forbidden.", srcName,
                route->gw_src->getCname(), dstName, route->gw_dst->getCname());
   }
 
index 4992637..c9d1636 100644 (file)
@@ -31,7 +31,7 @@ TorusZone::TorusZone(NetZone* father, std::string name) : ClusterZone(father, na
 {
 }
 
-void TorusZone::create_links_for_node(ClusterCreationArgs* cluster, int id, int rank, int position)
+void TorusZone::create_links_for_node(ClusterCreationArgs* cluster, int id, int rank, unsigned int position)
 {
   /* Create all links that exist in the torus. Each rank creates @a dimensions-1 links */
   int dim_product = 1; // Needed to calculate the next neighbor_id
@@ -102,7 +102,7 @@ void TorusZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg
   if (src->id() == dst->id() && hasLoopback_) {
     std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(src->id() * linkCountPerNode_);
 
-    route->link_list->push_back(info.first);
+    route->link_list.push_back(info.first);
     if (lat)
       *lat += info.first->latency();
     return;
@@ -179,17 +179,17 @@ void TorusZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg
 
     if (hasLimiter_) { // limiter for sender
       info = privateLinks_.at(nodeOffset + (hasLoopback_ ? 1 : 0));
-      route->link_list->push_back(info.first);
+      route->link_list.push_back(info.first);
     }
 
     info = privateLinks_.at(linkOffset);
 
     if (use_lnk_up == false) {
-      route->link_list->push_back(info.second);
+      route->link_list.push_back(info.second);
       if (lat)
         *lat += info.second->latency();
     } else {
-      route->link_list->push_back(info.first);
+      route->link_list.push_back(info.first);
       if (lat)
         *lat += info.first->latency();
     }
index 56d4c70..0cdad3d 100644 (file)
@@ -21,7 +21,7 @@ namespace routing {
 class XBT_PRIVATE TorusZone : public ClusterZone {
 public:
   explicit TorusZone(NetZone* father, std::string name);
-  void create_links_for_node(ClusterCreationArgs* cluster, int id, int rank, int position) override;
+  void create_links_for_node(ClusterCreationArgs* cluster, int id, int rank, unsigned int position) override;
   void getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_t into, double* latency) override;
   void parse_specific_arguments(ClusterCreationArgs* cluster) override;
 
index a6b4fc3..3d78b3a 100644 (file)
@@ -91,7 +91,7 @@ void VivaldiZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cba
   if (src_link != privateLinks_.end()) {
     std::pair<surf::LinkImpl*, surf::LinkImpl*> info = src_link->second;
     if (info.first) {
-      route->link_list->push_back(info.first);
+      route->link_list.push_back(info.first);
       if (lat)
         *lat += info.first->latency();
     }
@@ -103,7 +103,7 @@ void VivaldiZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cba
   if (dst_link != privateLinks_.end()) {
     std::pair<surf::LinkImpl*, surf::LinkImpl*> info = dst_link->second;
     if (info.second) {
-      route->link_list->push_back(info.second);
+      route->link_list.push_back(info.second);
       if (lat)
         *lat += info.second->latency();
     }
index cd9f830..b143298 100644 (file)
@@ -13,6 +13,7 @@
 #include <vector>
 
 #include "xbt/automaton.h"
+#include "xbt/backtrace.hpp"
 #include "xbt/dynar.h"
 #include "xbt/swag.h"
 
@@ -136,24 +137,20 @@ void dumpStack(FILE* file, unw_cursor_t cursor)
   unw_word_t off;
   do {
     const char* name = not unw_get_proc_name(&cursor, buffer, 100, &off) ? buffer : "?";
-
-    int status;
-
     // Unmangle C++ names:
-    char* realname = abi::__cxa_demangle(name, 0, 0, &status);
+    auto realname = simgrid::xbt::demangle(name);
 
 #if defined(__x86_64__)
     unw_word_t rip = 0;
     unw_word_t rsp = 0;
     unw_get_reg(&cursor, UNW_X86_64_RIP, &rip);
     unw_get_reg(&cursor, UNW_X86_64_RSP, &rsp);
-    fprintf(file, "  %i: %s (RIP=0x%" PRIx64 " RSP=0x%" PRIx64 ")\n",
-      nframe, realname ? realname : name, (std::uint64_t) rip, (std::uint64_t) rsp);
+    fprintf(file, "  %i: %s (RIP=0x%" PRIx64 " RSP=0x%" PRIx64 ")\n", nframe, realname.get(), (std::uint64_t)rip,
+            (std::uint64_t)rsp);
 #else
-    fprintf(file, "  %i: %s\n", nframe, realname ? realname : name);
+    fprintf(file, "  %i: %s\n", nframe, realname.get());
 #endif
 
-    free(realname);
     ++nframe;
   } while(unw_step(&cursor));
 }
index 5018b25..4af7633 100644 (file)
@@ -77,7 +77,7 @@ RecordTrace parseRecordTrace(const char* data)
   RecordTrace res;
   XBT_INFO("path=%s", data);
   if (data == nullptr || data[0] == '\0')
-    throw std::runtime_error("Could not parse record path");
+    throw std::invalid_argument("Could not parse record path");
 
   const char* current = data;
   while (*current) {
@@ -85,7 +85,7 @@ RecordTrace parseRecordTrace(const char* data)
     simgrid::mc::Transition item;
     int count = sscanf(current, "%d/%d", &item.pid, &item.argument);
     if(count != 2 && count != 1)
-      throw std::runtime_error("Could not parse record path");
+      throw std::invalid_argument("Could not parse record path");
     res.push_back(item);
 
     // Find next chunk:
index 6a800b7..c07f4ff 100644 (file)
@@ -324,7 +324,7 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
       read_element(mc_model_checker->process(),
         &remote_sync, remote(simcall_comm_waitany__get__comms(req)), value,
         sizeof(remote_sync));
-      char* p = pointer_to_string(&*remote_sync);
+      char* p = pointer_to_string(remote_sync.get());
       args = bprintf("comm=%s (%d of %lu)",
         p, value + 1, xbt_dynar_length(&comms));
       xbt_free(p);
index 62c317c..d92eb7a 100644 (file)
@@ -40,11 +40,14 @@ private:
 public:
   Remote() { /* Nothing to do */}
   ~Remote() { /* Nothing to do */}
-  Remote(T& p) { std::memcpy(&buffer, &p, sizeof(buffer)); }
-  Remote(Remote const& that) { std::memcpy(&buffer, &that.buffer, sizeof(buffer)); }
+  Remote(T const& p) { std::memcpy(static_cast<void*>(&buffer), static_cast<const void*>(&p), sizeof(buffer)); }
+  Remote(Remote const& that)
+  {
+    std::memcpy(static_cast<void*>(&buffer), static_cast<const void*>(&that.buffer), sizeof(buffer));
+  }
   Remote& operator=(Remote const& that)
   {
-    std::memcpy(&buffer, &that.buffer, sizeof(buffer));
+    std::memcpy(static_cast<void*>(&buffer), static_cast<const void*>(&that.buffer), sizeof(buffer));
     return *this;
   }
   T* getBuffer() { return &buffer; }
index 11de4c7..fffbd34 100644 (file)
@@ -73,7 +73,7 @@ void MSG_file_dump (msg_file_t fd){
            "\t\tStorage Id: '%s'\n"
            "\t\tStorage Type: '%s'\n"
            "\t\tFile Descriptor Id: %d",
-           fd->getPath(), fd->size(), fd->mount_point.c_str(), fd->storageId.c_str(), fd->storage_type.c_str(),
+           fd->getPath(), fd->size(), fd->mount_point.c_str(), fd->onStorage->getCname(), fd->onStorage->getType(),
            fd->desc_id);
 }
 
@@ -92,7 +92,7 @@ sg_size_t MSG_file_read(msg_file_t fd, sg_size_t size)
     return 0;
 
   /* Find the host where the file is physically located and read it */
-  msg_storage_t storage_src           = simgrid::s4u::Storage::byName(fd->storageId);
+  msg_storage_t storage_src           = fd->onStorage;
   msg_host_t attached_host            = storage_src->getHost();
   read_size                           = fd->read(size);
 
@@ -133,7 +133,7 @@ sg_size_t MSG_file_write(msg_file_t fd, sg_size_t size)
     return 0;
 
   /* Find the host where the file is physically located (remote or local)*/
-  msg_storage_t storage_src = simgrid::s4u::Storage::byName(fd->storageId);
+  msg_storage_t storage_src = fd->onStorage;
   msg_host_t attached_host  = storage_src->getHost();
 
   if (strcmp(attached_host->getCname(), MSG_host_self()->getCname())) {
@@ -275,7 +275,7 @@ msg_error_t MSG_file_move (msg_file_t fd, const char* fullpath)
 msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpath)
 {
   /* Find the host where the file is physically located and read it */
-  msg_storage_t storage_src = simgrid::s4u::Storage::byName(file->storageId);
+  msg_storage_t storage_src = file->onStorage;
   msg_host_t src_host       = storage_src->getHost();
   MSG_file_seek(file, 0, SEEK_SET);
   sg_size_t read_size = file->read(file->size());
index ba6cbec..4938bfc 100644 (file)
 
 #include "simgrid/host.h"
 #include "simgrid/simix.hpp"
+#include "xbt/string.hpp"
 
 extern "C" {
 
 struct s_dirty_page {
-  double prev_clock;
-  double prev_remaining;
-  msg_task_t task;
+  double prev_clock     = 0.0;
+  double prev_remaining = 0.0;
+  msg_task_t task       = nullptr;
 };
 typedef s_dirty_page* dirty_page_t;
 
@@ -114,12 +115,14 @@ msg_vm_t MSG_vm_create(msg_host_t pm, const char* name, int coreAmount, int rams
 
   msg_vm_t vm = new simgrid::s4u::VirtualMachine(name, pm, coreAmount);
   s_vm_params_t params;
-  memset(&params, 0, sizeof(params));
-  params.ramsize = static_cast<sg_size_t>(ramsize) * 1024 * 1024;
-  params.devsize = 0;
-  params.skip_stage2 = 0;
+  params.ncpus        = 0;
+  params.ramsize      = static_cast<sg_size_t>(ramsize) * 1024 * 1024;
+  params.overcommit   = 0;
+  params.devsize      = 0;
+  params.skip_stage1  = 0;
+  params.skip_stage2  = 0;
   params.max_downtime = 0.03;
-  params.mig_speed = static_cast<double>(mig_netspeed) * 1024 * 1024; // mig_speed
+  params.mig_speed    = static_cast<double>(mig_netspeed) * 1024 * 1024; // mig_speed
   params.dp_intensity = static_cast<double>(dp_intensity) / 100;
   params.dp_cap       = params.ramsize * 0.9; // assume working set memory is 90% of ramsize
 
@@ -230,9 +233,9 @@ struct migration_session {
 
   /* The miration_rx process uses mbox_ctl to let the caller of do_migration()
    * know the completion of the migration. */
-  char *mbox_ctl;
+  std::string mbox_ctl;
   /* The migration_rx and migration_tx processes use mbox to transfer migration data. */
-  char *mbox;
+  std::string mbox;
 };
 
 static int migration_rx_fun(int argc, char *argv[])
@@ -247,7 +250,7 @@ static int migration_rx_fun(int argc, char *argv[])
   std::string finalize_task_name = get_mig_task_name(ms->vm, ms->src_pm, ms->dst_pm, 3);
   while (not received_finalize) {
     msg_task_t task = nullptr;
-    int ret         = MSG_task_recv(&task, ms->mbox);
+    int ret         = MSG_task_recv(&task, ms->mbox.c_str());
 
     if (ret != MSG_OK) {
       // An error occurred, clean the code and return
@@ -311,7 +314,7 @@ static int migration_rx_fun(int argc, char *argv[])
   // Inform the SRC that the migration has been correctly performed
   std::string task_name = get_mig_task_name(ms->vm, ms->src_pm, ms->dst_pm, 4);
   msg_task_t task       = MSG_task_create(task_name.c_str(), 0, 0, nullptr);
-  msg_error_t ret = MSG_task_send(task, ms->mbox_ctl);
+  msg_error_t ret       = MSG_task_send(task, ms->mbox_ctl.c_str());
   if(ret == MSG_HOST_FAILURE){
     // The DST has crashed, this is a problem has the VM since we are not sure whether SRC is considering that the VM
     // has been correctly migrated on the DST node
@@ -346,12 +349,12 @@ static void stop_dirty_page_tracking(msg_vm_t vm)
   vm->pimpl_vm_->dp_enabled = 0;
 }
 
-static double get_computed(const char* key, msg_vm_t vm, dirty_page_t dp, double remaining, double clock)
+static double get_computed(const std::string& key, msg_vm_t vm, dirty_page_t dp, double remaining, double clock)
 {
   double computed = dp->prev_remaining - remaining;
   double duration = clock - dp->prev_clock;
 
-  XBT_DEBUG("%s@%s: computed %f ops (remaining %f -> %f) in %f secs (%f -> %f)", key, vm->getCname(), computed,
+  XBT_DEBUG("%s@%s: computed %f ops (remaining %f -> %f) in %f secs (%f -> %f)", key.c_str(), vm->getCname(), computed,
             dp->prev_remaining, remaining, duration, dp->prev_clock, clock);
 
   return computed;
@@ -362,7 +365,7 @@ static double lookup_computed_flop_counts(msg_vm_t vm, int stage_for_fancy_debug
   double total = 0;
 
   for (auto const& elm : vm->pimpl_vm_->dp_objs) {
-    const char* key  = elm.first.c_str();
+    const std::string& key = elm.first;
     dirty_page_t dp  = elm.second;
     double remaining = MSG_task_get_flops_amount(dp->task);
 
@@ -394,18 +397,17 @@ void MSG_host_add_task(msg_host_t host, msg_task_t task)
     return;
 
   double remaining = MSG_task_get_flops_amount(task);
-  char *key = bprintf("%s-%p", task->name, task);
+  std::string key  = simgrid::xbt::string_printf("%s-%p", task->name, task);
 
-  dirty_page_t dp = xbt_new0(s_dirty_page, 1);
+  dirty_page_t dp = new s_dirty_page;
   dp->task = task;
   if (vm->pimpl_vm_->dp_enabled) {
     dp->prev_clock = MSG_get_clock();
     dp->prev_remaining = remaining;
   }
   vm->pimpl_vm_->dp_objs.insert({key, dp});
-  XBT_DEBUG("add %s on %s (remaining %f, dp_enabled %d)", key, host->getCname(), remaining, vm->pimpl_vm_->dp_enabled);
-
-  xbt_free(key);
+  XBT_DEBUG("add %s on %s (remaining %f, dp_enabled %d)", key.c_str(), host->getCname(), remaining,
+            vm->pimpl_vm_->dp_enabled);
 }
 
 void MSG_host_del_task(msg_host_t host, msg_task_t task)
@@ -414,10 +416,11 @@ void MSG_host_del_task(msg_host_t host, msg_task_t task)
   if (vm == nullptr)
     return;
 
-  char *key = bprintf("%s-%p", task->name, task);
+  std::string key = simgrid::xbt::string_printf("%s-%p", task->name, task);
   dirty_page_t dp = nullptr;
-  if (vm->pimpl_vm_->dp_objs.find(key) != vm->pimpl_vm_->dp_objs.end())
-    dp = vm->pimpl_vm_->dp_objs.at(key);
+  auto dp_obj     = vm->pimpl_vm_->dp_objs.find(key);
+  if (dp_obj != vm->pimpl_vm_->dp_objs.end())
+    dp = dp_obj->second;
   xbt_assert(dp && dp->task == task);
 
   /* If we are in the middle of dirty page tracking, we record how much computation has been done until now, and keep
@@ -431,14 +434,14 @@ void MSG_host_del_task(msg_host_t host, msg_task_t task)
   }
 
   vm->pimpl_vm_->dp_objs.erase(key);
-  xbt_free(dp);
+  delete dp;
 
-  XBT_DEBUG("del %s on %s", key, host->getCname());
-  xbt_free(key);
+  XBT_DEBUG("del %s on %s", key.c_str(), host->getCname());
 }
 
-static sg_size_t send_migration_data(msg_vm_t vm, msg_host_t src_pm, msg_host_t dst_pm, sg_size_t size, char* mbox,
-                                     int stage, int stage2_round, double mig_speed, double timeout)
+static sg_size_t send_migration_data(msg_vm_t vm, msg_host_t src_pm, msg_host_t dst_pm, sg_size_t size,
+                                     const std::string& mbox, int stage, int stage2_round, double mig_speed,
+                                     double timeout)
 {
   sg_size_t sent = 0;
   std::string task_name = get_mig_task_name(vm, src_pm, dst_pm, stage);
@@ -448,9 +451,9 @@ static sg_size_t send_migration_data(msg_vm_t vm, msg_host_t src_pm, msg_host_t
 
   msg_error_t ret;
   if (mig_speed > 0)
-    ret = MSG_task_send_with_timeout_bounded(task, mbox, timeout, mig_speed);
+    ret = MSG_task_send_with_timeout_bounded(task, mbox.c_str(), timeout, mig_speed);
   else
-    ret = MSG_task_send(task, mbox);
+    ret = MSG_task_send(task, mbox.c_str());
 
   if (ret == MSG_OK) {
     sent = size;
@@ -700,34 +703,32 @@ void MSG_vm_migrate(msg_vm_t vm, msg_host_t dst_pm)
 
   vm->pimpl_vm_->isMigrating = true;
 
-  migration_session* ms = xbt_new(migration_session, 1);
-  ms->vm = vm;
-  ms->src_pm = src_pm;
-  ms->dst_pm = dst_pm;
+  migration_session ms;
+  ms.vm     = vm;
+  ms.src_pm = src_pm;
+  ms.dst_pm = dst_pm;
 
   /* We have two mailboxes. mbox is used to transfer migration data between source and destination PMs. mbox_ctl is used
    * to detect the completion of a migration. The names of these mailboxes must not conflict with others. */
-  ms->mbox_ctl = bprintf("__mbox_mig_ctl:%s(%s-%s)", vm->getCname(), src_pm->getCname(), dst_pm->getCname());
-  ms->mbox     = bprintf("__mbox_mig_src_dst:%s(%s-%s)", vm->getCname(), src_pm->getCname(), dst_pm->getCname());
+  ms.mbox_ctl =
+      simgrid::xbt::string_printf("__mbox_mig_ctl:%s(%s-%s)", vm->getCname(), src_pm->getCname(), dst_pm->getCname());
+  ms.mbox = simgrid::xbt::string_printf("__mbox_mig_src_dst:%s(%s-%s)", vm->getCname(), src_pm->getCname(),
+                                        dst_pm->getCname());
 
   std::string pr_rx_name = get_mig_process_rx_name(vm, src_pm, dst_pm);
   std::string pr_tx_name = get_mig_process_tx_name(vm, src_pm, dst_pm);
 
-  MSG_process_create(pr_rx_name.c_str(), migration_rx_fun, ms, dst_pm);
+  MSG_process_create(pr_rx_name.c_str(), migration_rx_fun, &ms, dst_pm);
 
-  MSG_process_create(pr_tx_name.c_str(), migration_tx_fun, ms, src_pm);
+  MSG_process_create(pr_tx_name.c_str(), migration_tx_fun, &ms, src_pm);
 
   /* wait until the migration have finished or on error has occurred */
   XBT_DEBUG("wait for reception of the final ACK (i.e. migration has been correctly performed");
   msg_task_t task = nullptr;
-  msg_error_t ret = MSG_task_receive(&task, ms->mbox_ctl);
+  msg_error_t ret = MSG_task_receive(&task, ms.mbox_ctl.c_str());
 
   vm->pimpl_vm_->isMigrating = false;
 
-  xbt_free(ms->mbox_ctl);
-  xbt_free(ms->mbox);
-  xbt_free(ms);
-
   if (ret == MSG_HOST_FAILURE) {
     // Note that since the communication failed, the owner did not change and the task should be destroyed on the
     // other side. Hence, just throw the execption
index 14c73e0..8c90137 100644 (file)
@@ -45,8 +45,7 @@ File::File(std::string fullpath, sg_host_t host, void* userdata) : path_(fullpat
 
   pimpl_ =
       simgrid::simix::kernelImmediate([this, st, path] { return new simgrid::surf::FileImpl(st, path, mount_point); });
-  storage_type = st->getType();
-  storageId    = st->getName();
+  onStorage = st;
 }
 
 File::~File()
@@ -56,12 +55,30 @@ File::~File()
 
 sg_size_t File::read(sg_size_t size)
 {
-  return simcall_file_read(pimpl_, size);
+  XBT_DEBUG("READ %s on disk '%s'", getPath(), onStorage->getCname());
+  // if the current position is close to the end of the file, we may not be able to read the requested size
+  sg_size_t read_size = onStorage->read(std::min(size, this->size() - this->tell()));
+  pimpl_->incrPosition(read_size);
+  return read_size;
 }
 
 sg_size_t File::write(sg_size_t size)
 {
-  return simcall_file_write(pimpl_, size);
+  XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu'", getPath(), onStorage->getCname(), size, this->size());
+  // If the storage is full before even starting to write
+  if (onStorage->getSizeUsed() >= onStorage->getSize())
+    return 0;
+  /* Substract the part of the file that might disappear from the used sized on the storage element */
+  onStorage->decrUsedSize(this->size() - this->tell());
+
+  sg_size_t write_size = onStorage->write(size);
+  pimpl_->incrPosition(write_size);
+  pimpl_->setSize(this->tell());
+
+  onStorage->getContent()->erase(pimpl_->getName());
+  onStorage->getContent()->insert({pimpl_->getName(), this->size()});
+
+  return write_size;
 }
 
 sg_size_t File::size()
index b4245ed..f173821 100644 (file)
@@ -153,22 +153,22 @@ void Host::actorList(std::vector<ActorPtr>* whereto)
  * walk through the routing components tree and find a route between hosts
  * by calling each "get_route" function in each routing component.
  */
-void Host::routeTo(Host* dest, std::vector<Link*>* links, double* latency)
+void Host::routeTo(Host* dest, std::vector<Link*>& links, double* latency)
 {
   std::vector<surf::LinkImpl*> linkImpls;
-  this->routeTo(dest, &linkImpls, latency);
+  this->routeTo(dest, linkImpls, latency);
   for (surf::LinkImpl* const& l : linkImpls)
-    links->push_back(&l->piface_);
+    links.push_back(&l->piface_);
 }
 
 /** @brief Just like Host::routeTo, but filling an array of link implementations */
-void Host::routeTo(Host* dest, std::vector<surf::LinkImpl*>* links, double* latency)
+void Host::routeTo(Host* dest, std::vector<surf::LinkImpl*>& links, double* latency)
 {
   simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(pimpl_netpoint, dest->pimpl_netpoint, links, latency);
   if (XBT_LOG_ISENABLED(surf_route, xbt_log_priority_debug)) {
     XBT_CDEBUG(surf_route, "Route from '%s' to '%s' (latency: %f):", getCname(), dest->getCname(),
                (latency == nullptr ? -1 : *latency));
-    for (auto const& link : *links)
+    for (auto const& link : links)
       XBT_CDEBUG(surf_route, "Link %s", link->getCname());
   }
 }
index 2675596..52e4014 100644 (file)
@@ -18,7 +18,7 @@ namespace s4u {
 
 simgrid::xbt::signal<void(bool symmetrical, kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
                           kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
-                          std::vector<surf::LinkImpl*>* link_list)>
+                          std::vector<surf::LinkImpl*>& link_list)>
     NetZone::onRouteCreation;
 simgrid::xbt::signal<void(NetZone&)> NetZone::onCreation;
 simgrid::xbt::signal<void(NetZone&)> NetZone::onSeal;
index 6dd8fe9..5cb09af 100644 (file)
@@ -3,10 +3,10 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "../surf/StorageImpl.hpp"
 #include "simgrid/s4u/Host.hpp"
 #include "simgrid/s4u/Storage.hpp"
 #include "simgrid/simix.hpp"
+#include "src/surf/StorageImpl.hpp"
 #include <unordered_map>
 
 namespace simgrid {
@@ -60,6 +60,11 @@ sg_size_t Storage::getSizeUsed()
   return simgrid::simix::kernelImmediate([this] { return pimpl_->getUsedSize(); });
 }
 
+void Storage::decrUsedSize(sg_size_t size)
+{
+  simgrid::simix::kernelImmediate([this, size] { pimpl_->usedSize_ -= size; });
+}
+
 sg_size_t Storage::getSize()
 {
   return pimpl_->getSize();
@@ -85,6 +90,16 @@ std::map<std::string, sg_size_t>* Storage::getContent()
   return simgrid::simix::kernelImmediate([this] { return pimpl_->getContent(); });
 }
 
+sg_size_t Storage::read(sg_size_t size)
+{
+  return simcall_storage_read(pimpl_, size);
+}
+
+sg_size_t Storage::write(sg_size_t size)
+{
+  return simcall_storage_write(pimpl_, size);
+}
+
 /*************
  * Callbacks *
  *************/
index 84b9b74..42b7142 100644 (file)
@@ -882,7 +882,8 @@ void SD_task_build_MxN_1D_block_matrix(SD_task_t task, int src_nb, int dst_nb){
       XBT_VERB("(%d->%d): (%.2f, %.2f)-> (%.2f, %.2f)", i, j, src_start, src_end, dst_start, dst_end);
       task->bytes_amount[i*(src_nb+dst_nb)+src_nb+j]=0.0;
       if ((src_end > dst_start) && (dst_end > src_start)) { /* There is something to send */
-        task->bytes_amount[i*(src_nb+dst_nb)+src_nb+j] = MIN(src_end, dst_end)- MAX(src_start, dst_start);
+        task->bytes_amount[i * (src_nb + dst_nb) + src_nb + j] =
+            std::min(src_end, dst_end) - std::max(src_start, dst_start);
         XBT_VERB("==> %.2f", task->bytes_amount[i*(src_nb+dst_nb)+src_nb+j]);
       }
     }
index 5b709b4..51da4ba 100644 (file)
@@ -217,7 +217,7 @@ void sg_host_set_property_value(sg_host_t host, const char* name, const char* va
 void sg_host_route(sg_host_t from, sg_host_t to, xbt_dynar_t links)
 {
   std::vector<simgrid::s4u::Link*> vlinks;
-  from->routeTo(to, &vlinks, nullptr);
+  from->routeTo(to, vlinks, nullptr);
   for (auto const& link : vlinks)
     xbt_dynar_push(links, &link);
 }
@@ -231,7 +231,7 @@ double sg_host_route_latency(sg_host_t from, sg_host_t to)
 {
   std::vector<simgrid::s4u::Link*> vlinks;
   double res = 0;
-  from->routeTo(to, &vlinks, &res);
+  from->routeTo(to, vlinks, &res);
   return res;
 }
 /**
@@ -245,7 +245,7 @@ double sg_host_route_bandwidth(sg_host_t from, sg_host_t to)
   double min_bandwidth = -1.0;
 
   std::vector<simgrid::s4u::Link*> vlinks;
-  from->routeTo(to, &vlinks, nullptr);
+  from->routeTo(to, vlinks, nullptr);
   for (auto const& link : vlinks) {
     double bandwidth = link->bandwidth();
     if (bandwidth < min_bandwidth || min_bandwidth < 0.0)
index 568bce1..6af4880 100644 (file)
@@ -505,9 +505,7 @@ void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
  * \ingroup simix_synchro_management
  *
  */
-void simcall_cond_wait_timeout(smx_cond_t cond,
-                                 smx_mutex_t mutex,
-                                 double timeout)
+void simcall_cond_wait_timeout(smx_cond_t cond, smx_mutex_t mutex, double timeout)
 {
   xbt_assert(std::isfinite(timeout), "timeout is not finite!");
   simcall_BODY_cond_wait_timeout(cond, mutex, timeout);
@@ -541,22 +539,14 @@ void simcall_sem_acquire_timeout(smx_sem_t sem, double timeout)
   simcall_BODY_sem_acquire_timeout(sem, timeout);
 }
 
-/**
- * \ingroup simix_file_management
- *
- */
-sg_size_t simcall_file_read(surf_file_t fd, sg_size_t size)
+sg_size_t simcall_storage_read(surf_storage_t st, sg_size_t size)
 {
-  return simcall_BODY_file_read(fd, size);
+  return simcall_BODY_storage_read(st, size);
 }
 
-/**
- * \ingroup simix_file_management
- *
- */
-sg_size_t simcall_file_write(surf_file_t fd, sg_size_t size)
+sg_size_t simcall_storage_write(surf_storage_t st, sg_size_t size)
 {
-  return simcall_BODY_file_write(fd, size);
+  return simcall_BODY_storage_write(st, size);
 }
 
 void simcall_run_kernel(std::function<void()> const& code)
index 3201a9e..020056e 100644 (file)
@@ -1195,76 +1195,76 @@ static inline void simcall_sem_acquire_timeout__set__timeout(smx_simcall_t simca
   simgrid::simix::marshal<double>(simcall->args[1], arg);
 }
 
-static inline surf_file_t simcall_file_read__get__fd(smx_simcall_t simcall)
+static inline surf_storage_t simcall_storage_read__get__st(smx_simcall_t simcall)
 {
-  return simgrid::simix::unmarshal<surf_file_t>(simcall->args[0]);
+  return simgrid::simix::unmarshal<surf_storage_t>(simcall->args[0]);
 }
-static inline surf_file_t simcall_file_read__getraw__fd(smx_simcall_t simcall)
+static inline surf_storage_t simcall_storage_read__getraw__st(smx_simcall_t simcall)
 {
-  return simgrid::simix::unmarshal_raw<surf_file_t>(simcall->args[0]);
+  return simgrid::simix::unmarshal_raw<surf_storage_t>(simcall->args[0]);
 }
-static inline void simcall_file_read__set__fd(smx_simcall_t simcall, surf_file_t arg)
+static inline void simcall_storage_read__set__st(smx_simcall_t simcall, surf_storage_t arg)
 {
-  simgrid::simix::marshal<surf_file_t>(simcall->args[0], arg);
+  simgrid::simix::marshal<surf_storage_t>(simcall->args[0], arg);
 }
-static inline sg_size_t simcall_file_read__get__size(smx_simcall_t simcall)
+static inline sg_size_t simcall_storage_read__get__size(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<sg_size_t>(simcall->args[1]);
 }
-static inline sg_size_t simcall_file_read__getraw__size(smx_simcall_t simcall)
+static inline sg_size_t simcall_storage_read__getraw__size(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal_raw<sg_size_t>(simcall->args[1]);
 }
-static inline void simcall_file_read__set__size(smx_simcall_t simcall, sg_size_t arg)
+static inline void simcall_storage_read__set__size(smx_simcall_t simcall, sg_size_t arg)
 {
   simgrid::simix::marshal<sg_size_t>(simcall->args[1], arg);
 }
-static inline sg_size_t simcall_file_read__get__result(smx_simcall_t simcall)
+static inline sg_size_t simcall_storage_read__get__result(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<sg_size_t>(simcall->result);
 }
-static inline sg_size_t simcall_file_read__getraw__result(smx_simcall_t simcall)
+static inline sg_size_t simcall_storage_read__getraw__result(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal_raw<sg_size_t>(simcall->result);
 }
-static inline void simcall_file_read__set__result(smx_simcall_t simcall, sg_size_t result)
+static inline void simcall_storage_read__set__result(smx_simcall_t simcall, sg_size_t result)
 {
   simgrid::simix::marshal<sg_size_t>(simcall->result, result);
 }
 
-static inline surf_file_t simcall_file_write__get__fd(smx_simcall_t simcall)
+static inline surf_storage_t simcall_storage_write__get__st(smx_simcall_t simcall)
 {
-  return simgrid::simix::unmarshal<surf_file_t>(simcall->args[0]);
+  return simgrid::simix::unmarshal<surf_storage_t>(simcall->args[0]);
 }
-static inline surf_file_t simcall_file_write__getraw__fd(smx_simcall_t simcall)
+static inline surf_storage_t simcall_storage_write__getraw__st(smx_simcall_t simcall)
 {
-  return simgrid::simix::unmarshal_raw<surf_file_t>(simcall->args[0]);
+  return simgrid::simix::unmarshal_raw<surf_storage_t>(simcall->args[0]);
 }
-static inline void simcall_file_write__set__fd(smx_simcall_t simcall, surf_file_t arg)
+static inline void simcall_storage_write__set__st(smx_simcall_t simcall, surf_storage_t arg)
 {
-  simgrid::simix::marshal<surf_file_t>(simcall->args[0], arg);
+  simgrid::simix::marshal<surf_storage_t>(simcall->args[0], arg);
 }
-static inline sg_size_t simcall_file_write__get__size(smx_simcall_t simcall)
+static inline sg_size_t simcall_storage_write__get__size(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<sg_size_t>(simcall->args[1]);
 }
-static inline sg_size_t simcall_file_write__getraw__size(smx_simcall_t simcall)
+static inline sg_size_t simcall_storage_write__getraw__size(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal_raw<sg_size_t>(simcall->args[1]);
 }
-static inline void simcall_file_write__set__size(smx_simcall_t simcall, sg_size_t arg)
+static inline void simcall_storage_write__set__size(smx_simcall_t simcall, sg_size_t arg)
 {
   simgrid::simix::marshal<sg_size_t>(simcall->args[1], arg);
 }
-static inline sg_size_t simcall_file_write__get__result(smx_simcall_t simcall)
+static inline sg_size_t simcall_storage_write__get__result(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<sg_size_t>(simcall->result);
 }
-static inline sg_size_t simcall_file_write__getraw__result(smx_simcall_t simcall)
+static inline sg_size_t simcall_storage_write__getraw__result(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal_raw<sg_size_t>(simcall->result);
 }
-static inline void simcall_file_write__set__result(smx_simcall_t simcall, sg_size_t result)
+static inline void simcall_storage_write__set__result(smx_simcall_t simcall, sg_size_t result)
 {
   simgrid::simix::marshal<sg_size_t>(simcall->result, result);
 }
@@ -1381,6 +1381,6 @@ XBT_PRIVATE void simcall_HANDLER_cond_wait(smx_simcall_t simcall, smx_cond_t con
 XBT_PRIVATE void simcall_HANDLER_cond_wait_timeout(smx_simcall_t simcall, smx_cond_t cond, smx_mutex_t mutex, double timeout);
 XBT_PRIVATE void simcall_HANDLER_sem_acquire(smx_simcall_t simcall, smx_sem_t sem);
 XBT_PRIVATE void simcall_HANDLER_sem_acquire_timeout(smx_simcall_t simcall, smx_sem_t sem, double timeout);
-XBT_PRIVATE void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd, sg_size_t size);
-XBT_PRIVATE void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size);
+XBT_PRIVATE void simcall_HANDLER_storage_read(smx_simcall_t simcall, surf_storage_t st, sg_size_t size);
+XBT_PRIVATE void simcall_HANDLER_storage_write(smx_simcall_t simcall, surf_storage_t st, sg_size_t size);
 XBT_PRIVATE int simcall_HANDLER_mc_random(smx_simcall_t simcall, int min, int max);
\ No newline at end of file
index f942251..dd9b622 100644 (file)
@@ -232,18 +232,18 @@ inline static void simcall_BODY_sem_acquire_timeout(smx_sem_t sem, double timeou
   return simcall<void, smx_sem_t, double>(SIMCALL_SEM_ACQUIRE_TIMEOUT, sem, timeout);
 }
 
-inline static sg_size_t simcall_BODY_file_read(surf_file_t fd, sg_size_t size)
+inline static sg_size_t simcall_BODY_storage_read(surf_storage_t st, sg_size_t size)
 {
   if (0) /* Go to that function to follow the code flow through the simcall barrier */
-    simcall_HANDLER_file_read(&SIMIX_process_self()->simcall, fd, size);
-  return simcall<sg_size_t, surf_file_t, sg_size_t>(SIMCALL_FILE_READ, fd, size);
+    simcall_HANDLER_storage_read(&SIMIX_process_self()->simcall, st, size);
+  return simcall<sg_size_t, surf_storage_t, sg_size_t>(SIMCALL_STORAGE_READ, st, size);
 }
 
-inline static sg_size_t simcall_BODY_file_write(surf_file_t fd, sg_size_t size)
+inline static sg_size_t simcall_BODY_storage_write(surf_storage_t st, sg_size_t size)
 {
   if (0) /* Go to that function to follow the code flow through the simcall barrier */
-    simcall_HANDLER_file_write(&SIMIX_process_self()->simcall, fd, size);
-  return simcall<sg_size_t, surf_file_t, sg_size_t>(SIMCALL_FILE_WRITE, fd, size);
+    simcall_HANDLER_storage_write(&SIMIX_process_self()->simcall, st, size);
+  return simcall<sg_size_t, surf_storage_t, sg_size_t>(SIMCALL_STORAGE_WRITE, st, size);
 }
 
 inline static int simcall_BODY_mc_random(int min, int max)
index 8e44e97..e2a7c49 100644 (file)
@@ -47,10 +47,11 @@ typedef enum {
   SIMCALL_COND_BROADCAST,
   SIMCALL_SEM_ACQUIRE,
   SIMCALL_SEM_ACQUIRE_TIMEOUT,
-  SIMCALL_FILE_READ,
-  SIMCALL_FILE_WRITE,
+  SIMCALL_STORAGE_READ,
+  SIMCALL_STORAGE_WRITE,
   SIMCALL_MC_RANDOM,
   SIMCALL_SET_CATEGORY,
   SIMCALL_RUN_KERNEL,
-  SIMCALL_RUN_BLOCKING,  NUM_SIMCALLS
+  SIMCALL_RUN_BLOCKING,
+  NUM_SIMCALLS
 } e_smx_simcall_t;
index 13531f7..1d6a4a6 100644 (file)
@@ -53,8 +53,8 @@ const char* simcall_names[] = {
     "SIMCALL_COND_BROADCAST",
     "SIMCALL_SEM_ACQUIRE",
     "SIMCALL_SEM_ACQUIRE_TIMEOUT",
-    "SIMCALL_FILE_READ",
-    "SIMCALL_FILE_WRITE",
+    "SIMCALL_STORAGE_READ",
+    "SIMCALL_STORAGE_WRITE",
     "SIMCALL_MC_RANDOM",
     "SIMCALL_SET_CATEGORY",
     "SIMCALL_RUN_KERNEL",
@@ -197,12 +197,14 @@ case SIMCALL_SEM_ACQUIRE_TIMEOUT:
   simcall_HANDLER_sem_acquire_timeout(simcall, simgrid::simix::unmarshal<smx_sem_t>(simcall->args[0]), simgrid::simix::unmarshal<double>(simcall->args[1]));
   break;
 
-case SIMCALL_FILE_READ:
-  simcall_HANDLER_file_read(simcall, simgrid::simix::unmarshal<surf_file_t>(simcall->args[0]), simgrid::simix::unmarshal<sg_size_t>(simcall->args[1]));
+case SIMCALL_STORAGE_READ:
+  simcall_HANDLER_storage_read(simcall, simgrid::simix::unmarshal<surf_storage_t>(simcall->args[0]),
+                               simgrid::simix::unmarshal<sg_size_t>(simcall->args[1]));
   break;
 
-case SIMCALL_FILE_WRITE:
-  simcall_HANDLER_file_write(simcall, simgrid::simix::unmarshal<surf_file_t>(simcall->args[0]), simgrid::simix::unmarshal<sg_size_t>(simcall->args[1]));
+case SIMCALL_STORAGE_WRITE:
+  simcall_HANDLER_storage_write(simcall, simgrid::simix::unmarshal<surf_storage_t>(simcall->args[0]),
+                                simgrid::simix::unmarshal<sg_size_t>(simcall->args[1]));
   break;
 
 case SIMCALL_MC_RANDOM:
index e0c200a..b7d4b5f 100644 (file)
@@ -143,8 +143,8 @@ inline void marshal(type<boost::intrusive_ptr<T>>, u_smx_scalar& simcall, boost:
   if (value.get() == nullptr) { // Sometimes we return nullptr in an intrusive_ptr...
     simcall.dp = nullptr;
   } else {
-    intrusive_ptr_add_ref(&*value);
-    simcall.dp = static_cast<void*>(&*value);
+    intrusive_ptr_add_ref(value.get());
+    simcall.dp = static_cast<void*>(value.get());
   }
 }
 template <class T> inline boost::intrusive_ptr<T> unmarshal(type<boost::intrusive_ptr<T>>, u_smx_scalar const& simcall)
index 8397063..99e748f 100644 (file)
@@ -70,8 +70,8 @@ void       cond_broadcast(smx_cond_t cond) [[nohandler]];
 void      sem_acquire(smx_sem_t sem) [[block]];
 void      sem_acquire_timeout(smx_sem_t sem, double timeout) [[block]];
 
-sg_size_t   file_read(surf_file_t fd, sg_size_t size) [[block]];
-sg_size_t   file_write(surf_file_t fd, sg_size_t size) [[block]];
+sg_size_t   storage_read(surf_storage_t st, sg_size_t size) [[block]];
+sg_size_t   storage_write(surf_storage_t st, sg_size_t size) [[block]];
 
 int        mc_random(int min, int max);
 void       set_category(boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> synchro, const char* category) [[nohandler]];
index 3093fc5..18bf778 100644 (file)
@@ -118,23 +118,18 @@ void SIMIX_process_set_function(const char* process_host, const char* process_fu
                                 double process_start_time, double process_kill_time)
 {
   s_sg_platf_process_cbarg_t process;
-  memset(&process,0,sizeof(process));
 
   sg_host_t host = sg_host_by_name(process_host);
   if (not host)
     THROWF(arg_error, 0, "Host '%s' unknown", process_host);
   process.host = process_host;
-
-  process.argc = 1 + xbt_dynar_length(arguments);
-  process.argv    = static_cast<const char**>(xbt_new(const char*, process.argc + 1));
-  process.argv[0] = xbt_strdup(process_function);
+  process.args.push_back(process_function);
   /* add arguments */
   unsigned int i;
   char *arg;
   xbt_dynar_foreach(arguments, i, arg) {
-    process.argv[i + 1] = xbt_strdup(arg);
+    process.args.push_back(arg);
   }
-  process.argv[process.argc] = nullptr;
 
   // Check we know how to handle this function name:
   simgrid::simix::ActorCodeFactory& parse_code = SIMIX_get_actor_code_factory(process_function);
index 6e770e8..ad2d351 100644 (file)
@@ -3,6 +3,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include <boost/heap/fibonacci_heap.hpp>
 #include <functional>
 #include <memory>
 
@@ -12,6 +13,7 @@
 
 #include <xbt/algorithm.hpp>
 #include <xbt/functional.hpp>
+#include <xbt/utility.hpp>
 
 #include "simgrid/s4u/Engine.hpp"
 #include "simgrid/s4u/Host.hpp"
@@ -50,14 +52,18 @@ XBT_LOG_NEW_CATEGORY(simix, "All SIMIX categories");
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_kernel, simix, "Logging specific to SIMIX (kernel)");
 
 std::unique_ptr<simgrid::simix::Global> simix_global;
-static xbt_heap_t simix_timers = nullptr;
+
+namespace {
+typedef std::pair<double, smx_timer_t> TimerQelt;
+boost::heap::fibonacci_heap<TimerQelt, boost::heap::compare<simgrid::xbt::HeapComparator<TimerQelt>>> simix_timers;
+}
 
 /** @brief Timer datatype */
 class s_smx_timer_t {
   double date = 0.0;
-  s_smx_timer_t() = default;
 
 public:
+  decltype(simix_timers)::handle_type handle_;
   simgrid::xbt::Task<void()> callback;
   double getDate() { return date; }
   s_smx_timer_t(double date, simgrid::xbt::Task<void()> callback) : date(date), callback(std::move(callback)) {}
@@ -156,7 +162,7 @@ static void install_segvhandler()
 /********************************* SIMIX **************************************/
 double SIMIX_timer_next()
 {
-  return xbt_heap_size(simix_timers) > 0 ? xbt_heap_maxkey(simix_timers) : -1.0;
+  return simix_timers.empty() ? -1.0 : simix_timers.top().first;
 }
 
 static void kill_process(smx_actor_t process)
@@ -240,11 +246,6 @@ void SIMIX_global_init(int *argc, char **argv)
     });
   }
 
-  if (not simix_timers)
-    simix_timers = xbt_heap_new(8, [](void* p) {
-      delete static_cast<smx_timer_t>(p);
-    });
-
   if (xbt_cfg_get_boolean("clean-atexit"))
     atexit(SIMIX_clean);
 
@@ -292,8 +293,10 @@ void SIMIX_clean()
   /* Exit the SIMIX network module */
   SIMIX_mailbox_exit();
 
-  xbt_heap_free(simix_timers);
-  simix_timers = nullptr;
+  while (not simix_timers.empty()) {
+    delete simix_timers.top().second;
+    simix_timers.pop();
+  }
   /* Free the remaining data structures */
   simix_global->process_to_run.clear();
   simix_global->process_that_ran.clear();
@@ -363,18 +366,18 @@ static void SIMIX_wake_processes()
 static bool SIMIX_execute_timers()
 {
   bool result = false;
-  while (xbt_heap_size(simix_timers) > 0 && SIMIX_get_clock() >= SIMIX_timer_next()) {
+  while (not simix_timers.empty() && SIMIX_get_clock() >= simix_timers.top().first) {
     result = true;
-     //FIXME: make the timers being real callbacks
-     // (i.e. provide dispatchers that read and expand the args)
-     smx_timer_t timer = (smx_timer_t) xbt_heap_pop(simix_timers);
-     try {
-       timer->callback();
-     }
-     catch(...) {
-       xbt_die("Exception throwed ouf of timer callback");
-     }
-     delete timer;
+    // FIXME: make the timers being real callbacks
+    // (i.e. provide dispatchers that read and expand the args)
+    smx_timer_t timer = simix_timers.top().second;
+    simix_timers.pop();
+    try {
+      timer->callback();
+    } catch (...) {
+      xbt_die("Exception thrown ouf of timer callback");
+    }
+    delete timer;
   }
   return result;
 }
@@ -564,20 +567,21 @@ void SIMIX_run()
 smx_timer_t SIMIX_timer_set(double date, void (*callback)(void*), void *arg)
 {
   smx_timer_t timer = new s_smx_timer_t(date, [callback, arg]() { callback(arg); });
-  xbt_heap_push(simix_timers, timer, date);
+  timer->handle_    = simix_timers.emplace(std::make_pair(date, timer));
   return timer;
 }
 
 smx_timer_t SIMIX_timer_set(double date, simgrid::xbt::Task<void()> callback)
 {
   smx_timer_t timer = new s_smx_timer_t(date, std::move(callback));
-  xbt_heap_push(simix_timers, timer, date);
+  timer->handle_    = simix_timers.emplace(std::make_pair(date, timer));
   return timer;
 }
 
 /** @brief cancels a timer that was added earlier */
 void SIMIX_timer_remove(smx_timer_t timer) {
-  delete static_cast<smx_timer_t>(xbt_heap_rm_elm(simix_timers, timer, timer->getDate()));
+  simix_timers.erase(timer->handle_);
+  delete timer;
 }
 
 /** @brief Returns the date at which the timer will trigger (or 0 if nullptr timer) */
index dc04477..1f35bf2 100644 (file)
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_io, simix, "Logging specific to SIMIX (io)");
 
-//SIMIX FILE READ
-void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd, sg_size_t size)
+void simcall_HANDLER_storage_read(smx_simcall_t simcall, surf_storage_t st, sg_size_t size)
 {
-  smx_activity_t synchro = SIMIX_file_read(fd, size);
+  smx_activity_t synchro = SIMIX_storage_read(st, size);
   synchro->simcalls.push_back(simcall);
   simcall->issuer->waiting_synchro = synchro;
 }
 
-smx_activity_t SIMIX_file_read(surf_file_t file, sg_size_t size)
+smx_activity_t SIMIX_storage_read(surf_storage_t st, sg_size_t size)
 {
   simgrid::kernel::activity::IoImpl* synchro = new simgrid::kernel::activity::IoImpl();
-  synchro->surf_io                           = file->read(size);
+  synchro->surf_io                           = st->read(size);
 
   synchro->surf_io->setData(synchro);
   XBT_DEBUG("Create io synchro %p", synchro);
@@ -40,18 +39,17 @@ smx_activity_t SIMIX_file_read(surf_file_t file, sg_size_t size)
   return synchro;
 }
 
-//SIMIX FILE WRITE
-void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size)
+void simcall_HANDLER_storage_write(smx_simcall_t simcall, surf_storage_t st, sg_size_t size)
 {
-  smx_activity_t synchro = SIMIX_file_write(fd, size);
+  smx_activity_t synchro = SIMIX_storage_write(st, size);
   synchro->simcalls.push_back(simcall);
   simcall->issuer->waiting_synchro = synchro;
 }
 
-smx_activity_t SIMIX_file_write(surf_file_t file, sg_size_t size)
+smx_activity_t SIMIX_storage_write(surf_storage_t st, sg_size_t size)
 {
   simgrid::kernel::activity::IoImpl* synchro = new simgrid::kernel::activity::IoImpl();
-  synchro->surf_io                           = file->write(size);
+  synchro->surf_io                           = st->write(size);
   synchro->surf_io->setData(synchro);
   XBT_DEBUG("Create io synchro %p", synchro);
 
index 05846b7..79581a8 100644 (file)
@@ -11,8 +11,8 @@
 #include "popping_private.hpp"
 #include "simgrid/simix.h"
 
-XBT_PRIVATE smx_activity_t SIMIX_file_read(surf_file_t fd, sg_size_t size);
-XBT_PRIVATE smx_activity_t SIMIX_file_write(surf_file_t fd, sg_size_t size);
+XBT_PRIVATE smx_activity_t SIMIX_storage_read(surf_storage_t fd, sg_size_t size);
+XBT_PRIVATE smx_activity_t SIMIX_storage_write(surf_storage_t fd, sg_size_t size);
 
 XBT_PRIVATE void SIMIX_io_destroy(smx_activity_t synchro);
 XBT_PRIVATE void SIMIX_io_finish(smx_activity_t synchro);
index 30bd46e..173e0af 100644 (file)
@@ -318,7 +318,7 @@ void simcall_HANDLER_comm_wait(smx_simcall_t simcall, smx_activity_t synchro, do
   } else { /* we need a surf sleep action even when there is no timeout, otherwise surf won't tell us when the host
               fails */
     surf_action_t sleep = simcall->issuer->host->pimpl_cpu->sleep(timeout);
-    sleep->setData(&*synchro);
+    sleep->setData(synchro.get());
 
     simgrid::kernel::activity::CommImplPtr comm =
         boost::static_pointer_cast<simgrid::kernel::activity::CommImpl>(synchro);
@@ -690,7 +690,7 @@ void SIMIX_comm_copy_data(smx_activity_t synchro)
 
   /* Copy at most dst_buff_size bytes of the message to receiver's buffer */
   if (comm->dst_buff_size)
-    buff_size = MIN(buff_size, *(comm->dst_buff_size));
+    buff_size = std::min(buff_size, *(comm->dst_buff_size));
 
   /* Update the receiver's buffer size to the copied amount */
   if (comm->dst_buff_size)
index 6194069..e25a227 100644 (file)
@@ -29,7 +29,7 @@ static smx_activity_t SIMIX_synchro_wait(sg_host_t smx_host, double timeout)
   simgrid::kernel::activity::RawImplPtr sync =
       simgrid::kernel::activity::RawImplPtr(new simgrid::kernel::activity::RawImpl());
   sync->sleep                          = smx_host->pimpl_cpu->sleep(timeout);
-  sync->sleep->setData(&*sync);
+  sync->sleep->setData(sync.get());
   XBT_OUT();
   return sync;
 }
index da15d37..52dcf73 100644 (file)
@@ -39,11 +39,9 @@ int PMPI_Init(int *argc, char ***argv)
     smpi_process()->mark_as_initialized();
     int rank = smpi_process()->index();
     TRACE_smpi_init(rank);
+    TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::NoOpTIData("init"));
+    TRACE_smpi_comm_out(rank);
     TRACE_smpi_computing_init(rank);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_INIT;
-    TRACE_smpi_collective_in(rank, __FUNCTION__, extra);
-    TRACE_smpi_collective_out(rank, __FUNCTION__);
     smpi_bench_begin();
   }
 
@@ -56,14 +54,12 @@ int PMPI_Finalize()
 {
   smpi_bench_end();
   int rank = smpi_process()->index();
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type = TRACING_FINALIZE;
-  TRACE_smpi_collective_in(rank, __FUNCTION__, extra);
+  TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::NoOpTIData("finalize"));
 
   smpi_process()->finalize();
 
-  TRACE_smpi_collective_out(rank, __FUNCTION__);
-  TRACE_smpi_finalize(smpi_process()->index());
+  TRACE_smpi_comm_out(rank);
+  TRACE_smpi_finalize(rank);
   return MPI_SUCCESS;
 }
 
@@ -88,7 +84,7 @@ int PMPI_Get_library_version (char *version,int *len){
   return MPI_SUCCESS;
 }
 
-int PMPI_Init_thread(int *argc, char ***argv, int required, int *provided)
+int PMPI_Init_thread(int* argc, char*** argv, int /*required*/, int* provided)
 {
   if (provided != nullptr) {
     *provided = MPI_THREAD_SINGLE;
@@ -116,7 +112,7 @@ int PMPI_Is_thread_main(int *flag)
   }
 }
 
-int PMPI_Abort(MPI_Comm comm, int errorcode)
+int PMPI_Abort(MPI_Comm /*comm*/, int /*errorcode*/)
 {
   smpi_bench_end();
   // FIXME: should kill all processes in comm instead
@@ -186,7 +182,8 @@ int PMPI_Initialized(int* flag) {
    return MPI_SUCCESS;
 }
 
-int PMPI_Alloc_mem(MPI_Aint size, MPI_Info info, void *baseptr){
+int PMPI_Alloc_mem(MPI_Aint size, MPI_Info /*info*/, void* baseptr)
+{
   void *ptr = xbt_malloc(size);
   if(ptr==nullptr)
     return MPI_ERR_NO_MEM;
index b642343..aaf32c3 100644 (file)
@@ -12,7 +12,6 @@
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi);
 
-
 /* PMPI User level calls */
 extern "C" { // Obviously, the C MPI interface should use the C linkage
 
@@ -28,23 +27,15 @@ int PMPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm c
     retval = MPI_ERR_ARG;
   } else {
     int rank        = smpi_process()->index();
-    int root_traced = comm->group()->index(root);
-
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
-    extra->type            = TRACING_BCAST;
-    extra->root            = root_traced;
-    int known              = 0;
-    extra->datatype1       = encode_datatype(datatype, &known);
-    int dt_size_send       = 1;
-    if (known == 0)
-      dt_size_send   = datatype->size();
-    extra->send_size = count * dt_size_send;
-    TRACE_smpi_collective_in(rank, __FUNCTION__, extra);
+    TRACE_smpi_comm_in(rank, __FUNCTION__,
+                       new simgrid::instr::CollTIData("bcast", comm->group()->index(root), -1.0,
+                                                      datatype->is_basic() ? count : count * datatype->size(), -1,
+                                                      encode_datatype(datatype), ""));
     if (comm->size() > 1)
       simgrid::smpi::Colls::bcast(buf, count, datatype, root, comm);
     retval = MPI_SUCCESS;
 
-    TRACE_smpi_collective_out(rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
   smpi_bench_begin();
   return retval;
@@ -59,10 +50,8 @@ int PMPI_Barrier(MPI_Comm comm)
   if (comm == MPI_COMM_NULL) {
     retval = MPI_ERR_COMM;
   } else {
-    int rank               = smpi_process()->index();
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
-    extra->type            = TRACING_BARRIER;
-    TRACE_smpi_collective_in(rank, __FUNCTION__, extra);
+    int rank = smpi_process()->index();
+    TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::NoOpTIData("barrier"));
 
     simgrid::smpi::Colls::barrier(comm);
 
@@ -71,7 +60,7 @@ int PMPI_Barrier(MPI_Comm comm)
 
     retval = MPI_SUCCESS;
 
-    TRACE_smpi_collective_out(rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
 
   smpi_bench_begin();
@@ -102,28 +91,18 @@ int PMPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,void *recvbu
       sendtmptype=recvtype;
     }
     int rank               = smpi_process()->index();
-    int root_traced        = comm->group()->index(root);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
-    extra->type            = TRACING_GATHER;
-    extra->root            = root_traced;
-    int known              = 0;
-    extra->datatype1       = encode_datatype(sendtmptype, &known);
-    int dt_size_send       = 1;
-    if (known == 0)
-      dt_size_send   = sendtmptype->size();
-    extra->send_size = sendtmpcount * dt_size_send;
-    extra->datatype2 = encode_datatype(recvtype, &known);
-    int dt_size_recv = 1;
-    if ((comm->rank() == root) && known == 0)
-      dt_size_recv   = recvtype->size();
-    extra->recv_size = recvcount * dt_size_recv;
-
-    TRACE_smpi_collective_in(rank, __FUNCTION__, extra);
+
+    TRACE_smpi_comm_in(rank, __FUNCTION__,
+                       new simgrid::instr::CollTIData(
+                           "gather", comm->group()->index(root), -1.0,
+                           sendtmptype->is_basic() ? sendtmpcount : sendtmpcount * sendtmptype->size(),
+                           (comm->rank() != root || recvtype->is_basic()) ? recvcount : recvcount * recvtype->size(),
+                           encode_datatype(sendtmptype), encode_datatype(recvtype)));
 
     simgrid::smpi::Colls::gather(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcount, recvtype, root, comm);
 
     retval = MPI_SUCCESS;
-    TRACE_smpi_collective_out(rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
 
   smpi_bench_begin();
@@ -155,32 +134,23 @@ int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recv
       sendtmptype=recvtype;
     }
 
-    int rank               = smpi_process()->index();
-    int root_traced        = comm->group()->index(root);
-    int size               = comm->size();
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
-    extra->type            = TRACING_GATHERV;
-    extra->num_processes   = size;
-    extra->root            = root_traced;
-    int known              = 0;
-    extra->datatype1       = encode_datatype(sendtmptype, &known);
-    int dt_size_send       = 1;
-    if (known == 0)
-      dt_size_send   = sendtype->size();
-    extra->send_size = sendtmpcount * dt_size_send;
-    extra->datatype2 = encode_datatype(recvtype, &known);
-    int dt_size_recv = 1;
-    if (known == 0)
-      dt_size_recv = recvtype->size();
+    int rank         = smpi_process()->index();
+    int dt_size_recv = recvtype->is_basic() ? 1 : recvtype->size();
+
+    std::vector<int>* trace_recvcounts = new std::vector<int>;
     if (comm->rank() == root) {
-      extra->recvcounts = xbt_new(int, size);
-      for (int i = 0; i < size; i++) // copy data to avoid bad free
-        extra->recvcounts[i] = recvcounts[i] * dt_size_recv;
+      for (int i = 0; i < comm->size(); i++) // copy data to avoid bad free
+        trace_recvcounts->push_back(recvcounts[i] * dt_size_recv);
     }
-    TRACE_smpi_collective_in(rank, __FUNCTION__, extra);
+
+    TRACE_smpi_comm_in(rank, __FUNCTION__,
+                       new simgrid::instr::VarCollTIData(
+                           "gatherV", comm->group()->index(root),
+                           sendtmptype->is_basic() ? sendtmpcount : sendtmpcount * sendtmptype->size(), nullptr,
+                           dt_size_recv, trace_recvcounts, encode_datatype(sendtmptype), encode_datatype(recvtype)));
 
     retval = simgrid::smpi::Colls::gatherv(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcounts, displs, recvtype, root, comm);
-    TRACE_smpi_collective_out(rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
 
   smpi_bench_begin();
@@ -190,7 +160,7 @@ int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recv
 int PMPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
                    void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm)
 {
-  int retval = 0;
+  int retval = MPI_SUCCESS;
 
   smpi_bench_end();
 
@@ -209,25 +179,15 @@ int PMPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
       sendtype=recvtype;
     }
     int rank               = smpi_process()->index();
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
-    extra->type            = TRACING_ALLGATHER;
-    int known              = 0;
-    extra->datatype1       = encode_datatype(sendtype, &known);
-    int dt_size_send       = 1;
-    if (known == 0)
-      dt_size_send   = sendtype->size();
-    extra->send_size = sendcount * dt_size_send;
-    extra->datatype2 = encode_datatype(recvtype, &known);
-    int dt_size_recv = 1;
-    if (known == 0)
-      dt_size_recv   = recvtype->size();
-    extra->recv_size = recvcount * dt_size_recv;
-
-    TRACE_smpi_collective_in(rank, __FUNCTION__, extra);
+
+    TRACE_smpi_comm_in(rank, __FUNCTION__,
+                       new simgrid::instr::CollTIData("allGather", -1, -1.0,
+                                                      sendtype->is_basic() ? sendcount : sendcount * sendtype->size(),
+                                                      recvtype->is_basic() ? recvcount : recvcount * recvtype->size(),
+                                                      encode_datatype(sendtype), encode_datatype(recvtype)));
 
     simgrid::smpi::Colls::allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
-    retval = MPI_SUCCESS;
-    TRACE_smpi_collective_out(rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
   smpi_bench_begin();
   return retval;
@@ -256,30 +216,20 @@ int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
       sendtype=recvtype;
     }
     int rank               = smpi_process()->index();
-    int i                  = 0;
-    int size               = comm->size();
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
-    extra->type            = TRACING_ALLGATHERV;
-    extra->num_processes   = size;
-    int known              = 0;
-    extra->datatype1       = encode_datatype(sendtype, &known);
-    int dt_size_send       = 1;
-    if (known == 0)
-      dt_size_send   = sendtype->size();
-    extra->send_size = sendcount * dt_size_send;
-    extra->datatype2 = encode_datatype(recvtype, &known);
-    int dt_size_recv = 1;
-    if (known == 0)
-      dt_size_recv    = recvtype->size();
-    extra->recvcounts = xbt_new(int, size);
-    for (i                 = 0; i < size; i++) // copy data to avoid bad free
-      extra->recvcounts[i] = recvcounts[i] * dt_size_recv;
-
-    TRACE_smpi_collective_in(rank, __FUNCTION__, extra);
+    int dt_size_recv       = recvtype->is_basic() ? 1 : recvtype->size();
+
+    std::vector<int>* trace_recvcounts = new std::vector<int>;
+    for (int i = 0; i < comm->size(); i++) // copy data to avoid bad free
+      trace_recvcounts->push_back(recvcounts[i] * dt_size_recv);
+
+    TRACE_smpi_comm_in(rank, __FUNCTION__,
+                       new simgrid::instr::VarCollTIData(
+                           "allGatherV", -1, sendtype->is_basic() ? sendcount : sendcount * sendtype->size(), nullptr,
+                           dt_size_recv, trace_recvcounts, encode_datatype(sendtype), encode_datatype(recvtype)));
 
     simgrid::smpi::Colls::allgatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, comm);
     retval = MPI_SUCCESS;
-    TRACE_smpi_collective_out(rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
 
   smpi_bench_begin();
@@ -308,26 +258,17 @@ int PMPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
       recvcount = sendcount;
     }
     int rank               = smpi_process()->index();
-    int root_traced        = comm->group()->index(root);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
-    extra->type            = TRACING_SCATTER;
-    extra->root            = root_traced;
-    int known              = 0;
-    extra->datatype1       = encode_datatype(sendtype, &known);
-    int dt_size_send       = 1;
-    if ((comm->rank() == root) && known == 0)
-      dt_size_send   = sendtype->size();
-    extra->send_size = sendcount * dt_size_send;
-    extra->datatype2 = encode_datatype(recvtype, &known);
-    int dt_size_recv = 1;
-    if (known == 0)
-      dt_size_recv   = recvtype->size();
-    extra->recv_size = recvcount * dt_size_recv;
-    TRACE_smpi_collective_in(rank, __FUNCTION__, extra);
+
+    TRACE_smpi_comm_in(rank, __FUNCTION__,
+                       new simgrid::instr::CollTIData(
+                           "scatter", comm->group()->index(root), -1.0,
+                           (comm->rank() != root || sendtype->is_basic()) ? sendcount : sendcount * sendtype->size(),
+                           recvtype->is_basic() ? recvcount : recvcount * recvtype->size(), encode_datatype(sendtype),
+                           encode_datatype(recvtype)));
 
     simgrid::smpi::Colls::scatter(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm);
     retval = MPI_SUCCESS;
-    TRACE_smpi_collective_out(rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
 
   smpi_bench_begin();
@@ -354,32 +295,22 @@ int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
       recvcount = sendcounts[comm->rank()];
     }
     int rank               = smpi_process()->index();
-    int root_traced        = comm->group()->index(root);
-    int size               = comm->size();
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
-    extra->type            = TRACING_SCATTERV;
-    extra->num_processes   = size;
-    extra->root            = root_traced;
-    int known              = 0;
-    extra->datatype1       = encode_datatype(sendtype, &known);
-    int dt_size_send       = 1;
-    if (known == 0)
-      dt_size_send = sendtype->size();
+    int dt_size_send       = sendtype->is_basic() ? 1 : sendtype->size();
+
+    std::vector<int>* trace_sendcounts = new std::vector<int>;
     if (comm->rank() == root) {
-      extra->sendcounts = xbt_new(int, size);
-      for (int i = 0; i < size; i++) // copy data to avoid bad free
-        extra->sendcounts[i] = sendcounts[i] * dt_size_send;
+      for (int i = 0; i < comm->size(); i++) // copy data to avoid bad free
+        trace_sendcounts->push_back(sendcounts[i] * dt_size_send);
     }
-    extra->datatype2 = encode_datatype(recvtype, &known);
-    int dt_size_recv = 1;
-    if (known == 0)
-      dt_size_recv   = recvtype->size();
-    extra->recv_size = recvcount * dt_size_recv;
-    TRACE_smpi_collective_in(rank, __FUNCTION__, extra);
+
+    TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::VarCollTIData(
+                                               "scatterV", comm->group()->index(root), dt_size_send, trace_sendcounts,
+                                               recvtype->is_basic() ? recvcount : recvcount * recvtype->size(), nullptr,
+                                               encode_datatype(sendtype), encode_datatype(recvtype)));
 
     retval = simgrid::smpi::Colls::scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf, recvcount, recvtype, root, comm);
 
-    TRACE_smpi_collective_out(rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
 
   smpi_bench_begin();
@@ -398,23 +329,16 @@ int PMPI_Reduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
     retval = MPI_ERR_ARG;
   } else {
     int rank               = smpi_process()->index();
-    int root_traced        = comm->group()->index(root);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
-    extra->type            = TRACING_REDUCE;
-    int known              = 0;
-    extra->datatype1       = encode_datatype(datatype, &known);
-    int dt_size_send       = 1;
-    if (known == 0)
-      dt_size_send   = datatype->size();
-    extra->send_size = count * dt_size_send;
-    extra->root      = root_traced;
-
-    TRACE_smpi_collective_in(rank, __FUNCTION__, extra);
+
+    TRACE_smpi_comm_in(rank, __FUNCTION__,
+                       new simgrid::instr::CollTIData("reduce", comm->group()->index(root), 0,
+                                                      datatype->is_basic() ? count : count * datatype->size(), -1,
+                                                      encode_datatype(datatype), ""));
 
     simgrid::smpi::Colls::reduce(sendbuf, recvbuf, count, datatype, op, root, comm);
 
     retval = MPI_SUCCESS;
-    TRACE_smpi_collective_out(rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
 
   smpi_bench_begin();
@@ -455,16 +379,11 @@ int PMPI_Allreduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatyp
       simgrid::smpi::Datatype::copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
     }
     int rank               = smpi_process()->index();
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
-    extra->type            = TRACING_ALLREDUCE;
-    int known              = 0;
-    extra->datatype1       = encode_datatype(datatype, &known);
-    int dt_size_send       = 1;
-    if (known == 0)
-      dt_size_send   = datatype->size();
-    extra->send_size = count * dt_size_send;
 
-    TRACE_smpi_collective_in(rank, __FUNCTION__, extra);
+    TRACE_smpi_comm_in(rank, __FUNCTION__,
+                       new simgrid::instr::CollTIData("allReduce", -1, 0,
+                                                      datatype->is_basic() ? count : count * datatype->size(), -1,
+                                                      encode_datatype(datatype), ""));
 
     simgrid::smpi::Colls::allreduce(sendtmpbuf, recvbuf, count, datatype, op, comm);
 
@@ -472,7 +391,7 @@ int PMPI_Allreduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatyp
       xbt_free(sendtmpbuf);
 
     retval = MPI_SUCCESS;
-    TRACE_smpi_collective_out(rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
 
   smpi_bench_begin();
@@ -493,20 +412,14 @@ int PMPI_Scan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MP
     retval = MPI_ERR_OP;
   } else {
     int rank               = smpi_process()->index();
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
-    extra->type            = TRACING_SCAN;
-    int known              = 0;
-    extra->datatype1       = encode_datatype(datatype, &known);
-    int dt_size_send       = 1;
-    if (known == 0)
-      dt_size_send   = datatype->size();
-    extra->send_size = count * dt_size_send;
 
-    TRACE_smpi_collective_in(rank, __FUNCTION__, extra);
+    TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData(
+                                               "scan", -1, datatype->is_basic() ? count : count * datatype->size(),
+                                               encode_datatype(datatype)));
 
     retval = simgrid::smpi::Colls::scan(sendbuf, recvbuf, count, datatype, op, comm);
 
-    TRACE_smpi_collective_out(rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
 
   smpi_bench_begin();
@@ -526,24 +439,19 @@ int PMPI_Exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
     retval = MPI_ERR_OP;
   } else {
     int rank               = smpi_process()->index();
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
-    extra->type            = TRACING_EXSCAN;
-    int known              = 0;
-    extra->datatype1       = encode_datatype(datatype, &known);
-    int dt_size_send       = 1;
-    if (known == 0)
-      dt_size_send   = datatype->size();
-    extra->send_size = count * dt_size_send;
     void* sendtmpbuf = sendbuf;
     if (sendbuf == MPI_IN_PLACE) {
       sendtmpbuf = static_cast<void*>(xbt_malloc(count * datatype->size()));
       memcpy(sendtmpbuf, recvbuf, count * datatype->size());
     }
-    TRACE_smpi_collective_in(rank, __FUNCTION__, extra);
+
+    TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData(
+                                               "exscan", -1, datatype->is_basic() ? count : count * datatype->size(),
+                                               encode_datatype(datatype)));
 
     retval = simgrid::smpi::Colls::exscan(sendtmpbuf, recvbuf, count, datatype, op, comm);
 
-    TRACE_smpi_collective_out(rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
     if (sendbuf == MPI_IN_PLACE)
       xbt_free(sendtmpbuf);
   }
@@ -567,34 +475,28 @@ int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts, MPI_Datat
     retval = MPI_ERR_ARG;
   } else {
     int rank               = smpi_process()->index();
-    int i                  = 0;
-    int size               = comm->size();
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
-    extra->type            = TRACING_REDUCE_SCATTER;
-    extra->num_processes   = size;
-    int known              = 0;
-    extra->datatype1       = encode_datatype(datatype, &known);
-    int dt_size_send       = 1;
-    if (known == 0)
-      dt_size_send    = datatype->size();
-    extra->send_size  = 0;
-    extra->recvcounts = xbt_new(int, size);
+    std::vector<int>* trace_recvcounts = new std::vector<int>;
+    int dt_send_size                   = datatype->is_basic() ? 1 : datatype->size();
     int totalcount    = 0;
-    for (i = 0; i < size; i++) { // copy data to avoid bad free
-      extra->recvcounts[i] = recvcounts[i] * dt_size_send;
+
+    for (int i = 0; i < comm->size(); i++) { // copy data to avoid bad free
+      trace_recvcounts->push_back(recvcounts[i] * dt_send_size);
       totalcount += recvcounts[i];
     }
+
     void* sendtmpbuf = sendbuf;
     if (sendbuf == MPI_IN_PLACE) {
       sendtmpbuf = static_cast<void*>(xbt_malloc(totalcount * datatype->size()));
       memcpy(sendtmpbuf, recvbuf, totalcount * datatype->size());
     }
 
-    TRACE_smpi_collective_in(rank, __FUNCTION__, extra);
+    TRACE_smpi_comm_in(rank, __FUNCTION__,
+                       new simgrid::instr::VarCollTIData("reduceScatter", -1, dt_send_size, nullptr, -1,
+                                                         trace_recvcounts, encode_datatype(datatype), ""));
 
     simgrid::smpi::Colls::reduce_scatter(sendtmpbuf, recvbuf, recvcounts, datatype, op, comm);
     retval = MPI_SUCCESS;
-    TRACE_smpi_collective_out(rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
 
     if (sendbuf == MPI_IN_PLACE)
       xbt_free(sendtmpbuf);
@@ -622,34 +524,27 @@ int PMPI_Reduce_scatter_block(void *sendbuf, void *recvbuf, int recvcount,
     int count = comm->size();
 
     int rank               = smpi_process()->index();
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
-    extra->type            = TRACING_REDUCE_SCATTER;
-    extra->num_processes   = count;
-    int known              = 0;
-    extra->datatype1       = encode_datatype(datatype, &known);
-    int dt_size_send       = 1;
-    if (known == 0)
-      dt_size_send    = datatype->size();
-    extra->send_size  = 0;
-    extra->recvcounts = xbt_new(int, count);
-    for (int i             = 0; i < count; i++) // copy data to avoid bad free
-      extra->recvcounts[i] = recvcount * dt_size_send;
+    int dt_send_size                   = datatype->is_basic() ? 1 : datatype->size();
+    std::vector<int>* trace_recvcounts = new std::vector<int>(recvcount * dt_send_size); // copy data to avoid bad free
+
     void* sendtmpbuf       = sendbuf;
     if (sendbuf == MPI_IN_PLACE) {
       sendtmpbuf = static_cast<void*>(xbt_malloc(recvcount * count * datatype->size()));
       memcpy(sendtmpbuf, recvbuf, recvcount * count * datatype->size());
     }
 
-    TRACE_smpi_collective_in(rank, __FUNCTION__, extra);
+    TRACE_smpi_comm_in(rank, __FUNCTION__,
+                       new simgrid::instr::VarCollTIData("reduceScatter", -1, 0, nullptr, -1, trace_recvcounts,
+                                                         encode_datatype(datatype), ""));
 
-    int* recvcounts = static_cast<int*>(xbt_malloc(count * sizeof(int)));
+    int* recvcounts = new int[count];
     for (int i      = 0; i < count; i++)
       recvcounts[i] = recvcount;
     simgrid::smpi::Colls::reduce_scatter(sendtmpbuf, recvbuf, recvcounts, datatype, op, comm);
-    xbt_free(recvcounts);
+    delete[] recvcounts;
     retval = MPI_SUCCESS;
 
-    TRACE_smpi_collective_out(rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
 
     if (sendbuf == MPI_IN_PLACE)
       xbt_free(sendtmpbuf);
@@ -671,9 +566,6 @@ int PMPI_Alltoall(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* rec
     retval = MPI_ERR_TYPE;
   } else {
     int rank               = smpi_process()->index();
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
-    extra->type            = TRACING_ALLTOALL;
-
     void* sendtmpbuf         = static_cast<char*>(sendbuf);
     int sendtmpcount         = sendcount;
     MPI_Datatype sendtmptype = sendtype;
@@ -684,23 +576,16 @@ int PMPI_Alltoall(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* rec
       sendtmptype  = recvtype;
     }
 
-    int known        = 0;
-    extra->datatype1 = encode_datatype(sendtmptype, &known);
-    if (known == 0)
-      extra->send_size = sendtmpcount * sendtmptype->size();
-    else
-      extra->send_size = sendtmpcount;
-    extra->datatype2   = encode_datatype(recvtype, &known);
-    if (known == 0)
-      extra->recv_size = recvcount * recvtype->size();
-    else
-      extra->recv_size = recvcount;
-
-    TRACE_smpi_collective_in(rank, __FUNCTION__, extra);
+    TRACE_smpi_comm_in(
+        rank, __FUNCTION__,
+        new simgrid::instr::CollTIData("allToAll", -1, -1.0,
+                                       sendtmptype->is_basic() ? sendtmpcount : sendtmpcount * sendtmptype->size(),
+                                       recvtype->is_basic() ? recvcount : recvcount * recvtype->size(),
+                                       encode_datatype(sendtmptype), encode_datatype(recvtype)));
 
     retval = simgrid::smpi::Colls::alltoall(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcount, recvtype, comm);
 
-    TRACE_smpi_collective_out(rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
 
     if (sendbuf == MPI_IN_PLACE)
       xbt_free(sendtmpbuf);
@@ -726,16 +611,11 @@ int PMPI_Alltoallv(void* sendbuf, int* sendcounts, int* senddisps, MPI_Datatype
     retval = MPI_ERR_ARG;
   } else {
     int rank               = smpi_process()->index();
-    int i                  = 0;
     int size               = comm->size();
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
-    extra->type            = TRACING_ALLTOALLV;
-    extra->send_size       = 0;
-    extra->recv_size       = 0;
-    extra->recvcounts      = xbt_new(int, size);
-    extra->sendcounts      = xbt_new(int, size);
-    int known              = 0;
-    extra->datatype2       = encode_datatype(recvtype, &known);
+    int send_size                      = 0;
+    int recv_size                      = 0;
+    std::vector<int>* trace_sendcounts = new std::vector<int>;
+    std::vector<int>* trace_recvcounts = new std::vector<int>;
     int dt_size_recv       = recvtype->size();
 
     void* sendtmpbuf         = static_cast<char*>(sendbuf);
@@ -743,9 +623,9 @@ int PMPI_Alltoallv(void* sendbuf, int* sendcounts, int* senddisps, MPI_Datatype
     int* sendtmpdisps        = senddisps;
     MPI_Datatype sendtmptype = sendtype;
     int maxsize              = 0;
-    for (i = 0; i < size; i++) { // copy data to avoid bad free
-      extra->recv_size += recvcounts[i] * dt_size_recv;
-      extra->recvcounts[i] = recvcounts[i] * dt_size_recv;
+    for (int i = 0; i < size; i++) { // copy data to avoid bad free
+      recv_size += recvcounts[i] * dt_size_recv;
+      trace_recvcounts->push_back(recvcounts[i] * dt_size_recv);
       if (((recvdisps[i] + recvcounts[i]) * dt_size_recv) > maxsize)
         maxsize = (recvdisps[i] + recvcounts[i]) * dt_size_recv;
     }
@@ -760,18 +640,20 @@ int PMPI_Alltoallv(void* sendbuf, int* sendcounts, int* senddisps, MPI_Datatype
       sendtmptype = recvtype;
     }
 
-    extra->datatype1 = encode_datatype(sendtmptype, &known);
     int dt_size_send = sendtmptype->size();
 
-    for (i = 0; i < size; i++) { // copy data to avoid bad free
-      extra->send_size += sendtmpcounts[i] * dt_size_send;
-      extra->sendcounts[i] = sendtmpcounts[i] * dt_size_send;
+    for (int i = 0; i < size; i++) { // copy data to avoid bad free
+      send_size += sendtmpcounts[i] * dt_size_send;
+      trace_sendcounts->push_back(sendtmpcounts[i] * dt_size_send);
     }
-    extra->num_processes = size;
-    TRACE_smpi_collective_in(rank, __FUNCTION__, extra);
+
+    TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::VarCollTIData(
+                                               "allToAllV", -1, send_size, trace_sendcounts, recv_size,
+                                               trace_recvcounts, encode_datatype(sendtype), encode_datatype(recvtype)));
+
     retval = simgrid::smpi::Colls::alltoallv(sendtmpbuf, sendtmpcounts, sendtmpdisps, sendtmptype, recvbuf, recvcounts,
                                     recvdisps, recvtype, comm);
-    TRACE_smpi_collective_out(rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
 
     if (sendbuf == MPI_IN_PLACE) {
       xbt_free(sendtmpbuf);
index 81dbe1b..fd9d4a6 100644 (file)
@@ -158,24 +158,16 @@ int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MP
   } else {
 
     int rank       = smpi_process()->index();
-    int src_traced = comm->group()->index(src);
-
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_IRECV;
-    extra->src = src_traced;
-    extra->dst = rank;
-    int known=0;
-    extra->datatype1 = encode_datatype(datatype, &known);
-    int dt_size_send = 1;
-    if(known==0)
-      dt_size_send = datatype->size();
-    extra->send_size = count*dt_size_send;
-    TRACE_smpi_ptp_in(rank, __FUNCTION__, extra);
+
+    TRACE_smpi_comm_in(rank, __FUNCTION__,
+                       new simgrid::instr::Pt2PtTIData("Irecv", comm->group()->index(src),
+                                                       datatype->is_basic() ? count : count * datatype->size(),
+                                                       encode_datatype(datatype)));
 
     *request = simgrid::smpi::Request::irecv(buf, count, datatype, src, tag, comm);
     retval = MPI_SUCCESS;
 
-    TRACE_smpi_ptp_out(rank, rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
 
   smpi_bench_begin();
@@ -206,25 +198,19 @@ int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MP
   } else if(tag<0 && tag !=  MPI_ANY_TAG){
     retval = MPI_ERR_TAG;
   } else {
-    int rank               = smpi_process()->index();
-    int dst_traced = comm->group()->index(dst);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_ISEND;
-    extra->src = rank;
-    extra->dst = dst_traced;
-    int known=0;
-    extra->datatype1 = encode_datatype(datatype, &known);
-    int dt_size_send = 1;
-    if(known==0)
-      dt_size_send = datatype->size();
-    extra->send_size = count*dt_size_send;
-    TRACE_smpi_ptp_in(rank, __FUNCTION__, extra);
-    TRACE_smpi_send(rank, rank, dst_traced, tag, count*datatype->size());
+    int rank      = smpi_process()->index();
+    int trace_dst = comm->group()->index(dst);
+    TRACE_smpi_comm_in(rank, __FUNCTION__,
+                       new simgrid::instr::Pt2PtTIData("Isend", trace_dst,
+                                                       datatype->is_basic() ? count : count * datatype->size(),
+                                                       encode_datatype(datatype)));
+
+    TRACE_smpi_send(rank, rank, trace_dst, tag, count * datatype->size());
 
     *request = simgrid::smpi::Request::isend(buf, count, datatype, dst, tag, comm);
     retval = MPI_SUCCESS;
 
-    TRACE_smpi_ptp_out(rank, dst_traced, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
 
   smpi_bench_begin();
@@ -254,25 +240,18 @@ int PMPI_Issend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, M
   } else if(tag<0 && tag !=  MPI_ANY_TAG){
     retval = MPI_ERR_TAG;
   } else {
-    int rank               = smpi_process()->index();
-    int dst_traced = comm->group()->index(dst);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_ISSEND;
-    extra->src = rank;
-    extra->dst = dst_traced;
-    int known=0;
-    extra->datatype1 = encode_datatype(datatype, &known);
-    int dt_size_send = 1;
-    if(known==0)
-      dt_size_send = datatype->size();
-    extra->send_size = count*dt_size_send;
-    TRACE_smpi_ptp_in(rank, __FUNCTION__, extra);
-    TRACE_smpi_send(rank, rank, dst_traced, tag, count*datatype->size());
+    int rank      = smpi_process()->index();
+    int trace_dst = comm->group()->index(dst);
+    TRACE_smpi_comm_in(rank, __FUNCTION__,
+                       new simgrid::instr::Pt2PtTIData("ISsend", trace_dst,
+                                                       datatype->is_basic() ? count : count * datatype->size(),
+                                                       encode_datatype(datatype)));
+    TRACE_smpi_send(rank, rank, trace_dst, tag, count * datatype->size());
 
     *request = simgrid::smpi::Request::issend(buf, count, datatype, dst, tag, comm);
     retval = MPI_SUCCESS;
 
-    TRACE_smpi_ptp_out(rank, dst_traced, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
 
   smpi_bench_begin();
@@ -303,17 +282,10 @@ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI
   } else {
     int rank               = smpi_process()->index();
     int src_traced         = comm->group()->index(src);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
-    extra->type            = TRACING_RECV;
-    extra->src             = src_traced;
-    extra->dst             = rank;
-    int known              = 0;
-    extra->datatype1       = encode_datatype(datatype, &known);
-    int dt_size_send       = 1;
-    if (known == 0)
-      dt_size_send   = datatype->size();
-    extra->send_size = count * dt_size_send;
-    TRACE_smpi_ptp_in(rank, __FUNCTION__, extra);
+    TRACE_smpi_comm_in(rank, __FUNCTION__,
+                       new simgrid::instr::Pt2PtTIData("recv", src_traced,
+                                                       datatype->is_basic() ? count : count * datatype->size(),
+                                                       encode_datatype(datatype)));
 
     simgrid::smpi::Request::recv(buf, count, datatype, src, tag, comm, status);
     retval = MPI_SUCCESS;
@@ -325,7 +297,7 @@ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI
         TRACE_smpi_recv(src_traced, rank, tag);
       }
     }
-    TRACE_smpi_ptp_out(rank, rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
 
   smpi_bench_begin();
@@ -353,18 +325,10 @@ int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI
   } else {
     int rank               = smpi_process()->index();
     int dst_traced         = comm->group()->index(dst);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type            = TRACING_SEND;
-    extra->src             = rank;
-    extra->dst             = dst_traced;
-    int known              = 0;
-    extra->datatype1       = encode_datatype(datatype, &known);
-    int dt_size_send       = 1;
-    if (known == 0) {
-      dt_size_send = datatype->size();
-    }
-    extra->send_size = count*dt_size_send;
-    TRACE_smpi_ptp_in(rank, __FUNCTION__, extra);
+    TRACE_smpi_comm_in(rank, __FUNCTION__,
+                       new simgrid::instr::Pt2PtTIData("send", dst_traced,
+                                                       datatype->is_basic() ? count : count * datatype->size(),
+                                                       encode_datatype(datatype)));
     if (not TRACE_smpi_view_internals()) {
       TRACE_smpi_send(rank, rank, dst_traced, tag,count*datatype->size());
     }
@@ -372,7 +336,7 @@ int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI
     simgrid::smpi::Request::send(buf, count, datatype, dst, tag, comm);
     retval = MPI_SUCCESS;
 
-    TRACE_smpi_ptp_out(rank, dst_traced, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
 
   smpi_bench_begin();
@@ -399,24 +363,16 @@ int PMPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MP
   } else {
     int rank               = smpi_process()->index();
     int dst_traced         = comm->group()->index(dst);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type            = TRACING_SSEND;
-    extra->src             = rank;
-    extra->dst             = dst_traced;
-    int known              = 0;
-    extra->datatype1       = encode_datatype(datatype, &known);
-    int dt_size_send       = 1;
-    if(known == 0) {
-      dt_size_send = datatype->size();
-    }
-    extra->send_size = count*dt_size_send;
-    TRACE_smpi_ptp_in(rank, __FUNCTION__, extra);
-    TRACE_smpi_send(rank, rank, dst_traced, tag,count*datatype->size());
+    TRACE_smpi_comm_in(rank, __FUNCTION__,
+                       new simgrid::instr::Pt2PtTIData("Ssend", dst_traced,
+                                                       datatype->is_basic() ? count : count * datatype->size(),
+                                                       encode_datatype(datatype)));
+    TRACE_smpi_send(rank, rank, dst_traced, tag, count * datatype->size());
 
     simgrid::smpi::Request::ssend(buf, count, datatype, dst, tag, comm);
     retval = MPI_SUCCESS;
 
-    TRACE_smpi_ptp_out(rank, dst_traced, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
 
   smpi_bench_begin();
@@ -447,35 +403,29 @@ int PMPI_Sendrecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, int dst,
   } else if((sendtag<0 && sendtag !=  MPI_ANY_TAG)||(recvtag<0 && recvtag != MPI_ANY_TAG)){
     retval = MPI_ERR_TAG;
   } else {
-
     int rank               = smpi_process()->index();
     int dst_traced         = comm->group()->index(dst);
     int src_traced         = comm->group()->index(src);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1);
-    extra->type            = TRACING_SENDRECV;
-    extra->src             = src_traced;
-    extra->dst             = dst_traced;
-    int known              = 0;
-    extra->datatype1       = encode_datatype(sendtype, &known);
-    int dt_size_send       = 1;
-    if (known == 0)
-      dt_size_send   = sendtype->size();
-    extra->send_size = sendcount * dt_size_send;
-    extra->datatype2 = encode_datatype(recvtype, &known);
-    int dt_size_recv = 1;
-    if (known == 0)
-      dt_size_recv   = recvtype->size();
-    extra->recv_size = recvcount * dt_size_recv;
-
-    TRACE_smpi_ptp_in(rank, __FUNCTION__, extra);
+
+    // FIXME: Hack the way to trace this one
+    std::vector<int>* dst_hack = new std::vector<int>;
+    std::vector<int>* src_hack = new std::vector<int>;
+    dst_hack->push_back(dst_traced);
+    src_hack->push_back(src_traced);
+    TRACE_smpi_comm_in(rank, __FUNCTION__,
+                       new simgrid::instr::VarCollTIData(
+                           "sendRecv", -1, sendtype->is_basic() ? sendcount : sendcount * sendtype->size(), dst_hack,
+                           recvtype->is_basic() ? recvcount : recvcount * recvtype->size(), src_hack,
+                           encode_datatype(sendtype), encode_datatype(recvtype)));
+
     TRACE_smpi_send(rank, rank, dst_traced, sendtag, sendcount * sendtype->size());
 
     simgrid::smpi::Request::sendrecv(sendbuf, sendcount, sendtype, dst, sendtag, recvbuf, recvcount, recvtype, src,
                                      recvtag, comm, status);
     retval = MPI_SUCCESS;
 
-    TRACE_smpi_ptp_out(rank, dst_traced, __FUNCTION__);
     TRACE_smpi_recv(src_traced, rank, recvtag);
+    TRACE_smpi_comm_out(rank);
   }
 
   smpi_bench_begin();
@@ -516,9 +466,7 @@ int PMPI_Test(MPI_Request * request, int *flag, MPI_Status * status)
   } else {
     int rank = ((*request)->comm() != MPI_COMM_NULL) ? smpi_process()->index() : -1;
 
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_TEST;
-    TRACE_smpi_testing_in(rank, extra);
+    TRACE_smpi_testing_in(rank);
 
     *flag = simgrid::smpi::Request::test(request,status);
 
@@ -620,15 +568,13 @@ int PMPI_Wait(MPI_Request * request, MPI_Status * status)
     int tag_traced= (*request)->tag();
     MPI_Comm comm = (*request)->comm();
     int is_wait_for_receive = ((*request)->flags() & RECV);
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type = TRACING_WAIT;
-    TRACE_smpi_ptp_in(rank, __FUNCTION__, extra);
+    TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::NoOpTIData("wait"));
 
     simgrid::smpi::Request::wait(request, status);
     retval = MPI_SUCCESS;
 
     //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
-    TRACE_smpi_ptp_out(rank, dst_traced, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
     if (is_wait_for_receive) {
       if(src_traced==MPI_ANY_SOURCE)
         src_traced = (status != MPI_STATUS_IGNORE) ? comm->group()->rank(status->MPI_SOURCE) : src_traced;
@@ -666,10 +612,7 @@ int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * sta
     }
   }
   int rank_traced = smpi_process()->index();
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type = TRACING_WAITANY;
-  extra->send_size=count;
-  TRACE_smpi_ptp_in(rank_traced, __FUNCTION__,extra);
+  TRACE_smpi_comm_in(rank_traced, __FUNCTION__, new simgrid::instr::CpuTIData("waitAny", static_cast<double>(count)));
 
   *index = simgrid::smpi::Request::waitany(count, requests, status);
 
@@ -684,7 +627,7 @@ int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * sta
                                                      : savedvals[*index].src;
       TRACE_smpi_recv(src_traced, dst_traced, savedvals[*index].tag);
     }
-    TRACE_smpi_ptp_out(rank_traced, dst_traced, __FUNCTION__);
+    TRACE_smpi_comm_out(rank_traced);
   }
   xbt_free(savedvals);
 
@@ -715,10 +658,7 @@ int PMPI_Waitall(int count, MPI_Request requests[], MPI_Status status[])
     }
   }
   int rank_traced = smpi_process()->index();
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type = TRACING_WAITALL;
-  extra->send_size=count;
-  TRACE_smpi_ptp_in(rank_traced, __FUNCTION__,extra);
+  TRACE_smpi_comm_in(rank_traced, __FUNCTION__, new simgrid::instr::CpuTIData("waitAll", static_cast<double>(count)));
 
   int retval = simgrid::smpi::Request::waitall(count, requests, status);
 
@@ -736,7 +676,7 @@ int PMPI_Waitall(int count, MPI_Request requests[], MPI_Status status[])
       }
     }
   }
-  TRACE_smpi_ptp_out(rank_traced, -1, __FUNCTION__);
+  TRACE_smpi_comm_out(rank_traced);
   xbt_free(savedvals);
 
   smpi_bench_begin();
index ec5cc1b..69b7eaa 100644 (file)
@@ -338,7 +338,7 @@ int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int out
     return MPI_ERR_TYPE;
   if(comm==MPI_COMM_NULL)
     return MPI_ERR_COMM;
-  return type->pack(inbuf, incount, outbuf,outcount,position, comm);
+  return type->pack(inbuf == MPI_BOTTOM ? nullptr : inbuf, incount, outbuf, outcount, position, comm);
 }
 
 int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) {
index 6c72e88..71d64a1 100644 (file)
@@ -77,7 +77,8 @@ int PMPI_Win_attach(MPI_Win win, void *base, MPI_Aint size){
   return retval;
 }
 
-int PMPI_Win_detach(MPI_Win win,  void *base){
+int PMPI_Win_detach(MPI_Win win, void* base)
+{
   int retval = 0;
   smpi_bench_end();
   if(win == MPI_WIN_NULL){
@@ -166,9 +167,9 @@ int PMPI_Win_fence( int assert,  MPI_Win win){
     retval = MPI_ERR_WIN;
   } else {
   int rank = smpi_process()->index();
-  TRACE_smpi_collective_in(rank, __FUNCTION__, nullptr);
+  TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_fence"));
   retval = win->fence(assert);
-  TRACE_smpi_collective_out(rank, __FUNCTION__);
+  TRACE_smpi_comm_out(rank);
   }
   smpi_bench_begin();
   return retval;
@@ -197,12 +198,14 @@ int PMPI_Get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
     int rank = smpi_process()->index();
     MPI_Group group;
     win->get_group(&group);
-    TRACE_smpi_ptp_in(rank, __FUNCTION__, nullptr);
+    TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData("Get", target_rank,
+                                                       origin_datatype->is_basic() ? origin_count : origin_count * origin_datatype->size(),
+                                                       encode_datatype(origin_datatype)));
 
     retval = win->get( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
                            target_datatype);
 
-    TRACE_smpi_ptp_out(rank, rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
   smpi_bench_begin();
   return retval;
@@ -234,12 +237,14 @@ int PMPI_Rget( void *origin_addr, int origin_count, MPI_Datatype origin_datatype
     int rank = smpi_process()->index();
     MPI_Group group;
     win->get_group(&group);
-    TRACE_smpi_ptp_in(rank, __FUNCTION__, nullptr);
+    TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData("Rget", target_rank,
+                                                       origin_datatype->is_basic() ? origin_count : origin_count * origin_datatype->size(),
+                                                       encode_datatype(origin_datatype)));
 
     retval = win->get( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
                            target_datatype, request);
 
-    TRACE_smpi_ptp_out(rank, rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
   smpi_bench_begin();
   return retval;
@@ -269,13 +274,15 @@ int PMPI_Put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
     MPI_Group group;
     win->get_group(&group);
     int dst_traced = group->index(target_rank);
-    TRACE_smpi_ptp_in(rank, __FUNCTION__, nullptr);
+    TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData("Put", dst_traced,
+                                                       origin_datatype->is_basic() ? origin_count : origin_count * origin_datatype->size(),
+                                                       encode_datatype(origin_datatype)));
     TRACE_smpi_send(rank, rank, dst_traced, SMPI_RMA_TAG, origin_count*origin_datatype->size());
 
     retval = win->put( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
                            target_datatype);
 
-    TRACE_smpi_ptp_out(rank, dst_traced, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
   smpi_bench_begin();
   return retval;
@@ -308,13 +315,15 @@ int PMPI_Rput( void *origin_addr, int origin_count, MPI_Datatype origin_datatype
     MPI_Group group;
     win->get_group(&group);
     int dst_traced = group->index(target_rank);
-    TRACE_smpi_ptp_in(rank, __FUNCTION__, nullptr);
+    TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData("Rput", dst_traced,
+                                                       origin_datatype->is_basic() ? origin_count : origin_count * origin_datatype->size(),
+                                                       encode_datatype(origin_datatype)));
     TRACE_smpi_send(rank, rank, dst_traced, SMPI_RMA_TAG, origin_count*origin_datatype->size());
 
     retval = win->put( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
                            target_datatype, request);
 
-    TRACE_smpi_ptp_out(rank, dst_traced, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
   smpi_bench_begin();
   return retval;
@@ -345,11 +354,13 @@ int PMPI_Accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_da
     int rank = smpi_process()->index();
     MPI_Group group;
     win->get_group(&group);
-    TRACE_smpi_ptp_in(rank, __FUNCTION__, nullptr);
+    TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData("Accumulate", target_rank,
+                                                       origin_datatype->is_basic() ? origin_count : origin_count * origin_datatype->size(),
+                                                       encode_datatype(origin_datatype)));
     retval = win->accumulate( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
                                   target_datatype, op);
 
-    TRACE_smpi_ptp_out(rank, rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
   smpi_bench_begin();
   return retval;
@@ -383,12 +394,14 @@ int PMPI_Raccumulate( void *origin_addr, int origin_count, MPI_Datatype origin_d
     int rank = smpi_process()->index();
     MPI_Group group;
     win->get_group(&group);
-    TRACE_smpi_ptp_in(rank, __FUNCTION__, nullptr);
+    TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData("Raccumulate", target_rank,
+                                                       origin_datatype->is_basic() ? origin_count : origin_count * origin_datatype->size(),
+                                                       encode_datatype(origin_datatype)));
 
     retval = win->accumulate( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
                                   target_datatype, op, request);
 
-    TRACE_smpi_ptp_out(rank, rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
   smpi_bench_begin();
   return retval;
@@ -421,13 +434,15 @@ MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){
     int rank = smpi_process()->index();
     MPI_Group group;
     win->get_group(&group);
-    TRACE_smpi_ptp_in(rank, __FUNCTION__, nullptr);
+    TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData("Get_accumulate", target_rank,
+                                                       target_datatype->is_basic() ? target_count : target_count * target_datatype->size(),
+                                                       encode_datatype(target_datatype)));
 
     retval = win->get_accumulate( origin_addr, origin_count, origin_datatype, result_addr,
                                   result_count, result_datatype, target_rank, target_disp,
                                   target_count, target_datatype, op);
 
-    TRACE_smpi_ptp_out(rank, rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
   smpi_bench_begin();
   return retval;
@@ -464,13 +479,15 @@ MPI_Datatype target_datatype, MPI_Op op, MPI_Win win, MPI_Request* request){
     int rank = smpi_process()->index();
     MPI_Group group;
     win->get_group(&group);
-    TRACE_smpi_ptp_in(rank, __FUNCTION__, nullptr);
+    TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData("Rget_accumulate", target_rank,
+                                                       target_datatype->is_basic() ? target_count : target_count * target_datatype->size(),
+                                                       encode_datatype(target_datatype)));
 
     retval = win->get_accumulate( origin_addr, origin_count, origin_datatype, result_addr,
                                   result_count, result_datatype, target_rank, target_disp,
                                   target_count, target_datatype, op, request);
 
-    TRACE_smpi_ptp_out(rank, rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
   smpi_bench_begin();
   return retval;
@@ -480,9 +497,9 @@ int PMPI_Fetch_and_op(void *origin_addr, void *result_addr, MPI_Datatype dtype,
   return PMPI_Get_accumulate(origin_addr, origin_addr==nullptr?0:1, dtype, result_addr, 1, dtype, target_rank, target_disp, 1, dtype, op, win);
 }
 
-int PMPI_Compare_and_swap(void *origin_addr, void *compare_addr,
-        void *result_addr, MPI_Datatype datatype, int target_rank,
-        MPI_Aint target_disp, MPI_Win win){
+int PMPI_Compare_and_swap(void* origin_addr, void* compare_addr, void* result_addr, MPI_Datatype datatype,
+                          int target_rank, MPI_Aint target_disp, MPI_Win win)
+{
   int retval = 0;
   smpi_bench_end();
   if (win == MPI_WIN_NULL) {
@@ -502,12 +519,13 @@ int PMPI_Compare_and_swap(void *origin_addr, void *compare_addr,
     int rank = smpi_process()->index();
     MPI_Group group;
     win->get_group(&group);
-    TRACE_smpi_ptp_in(rank, __FUNCTION__, nullptr);
+    TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::Pt2PtTIData("Compare_and_swap", target_rank,
+                                                       datatype->is_basic() ? 1 : datatype->size(),
+                                                       encode_datatype(datatype)));
 
-    retval = win->compare_and_swap( origin_addr, compare_addr, result_addr, datatype,
-                                  target_rank, target_disp);
+    retval = win->compare_and_swap(origin_addr, compare_addr, result_addr, datatype, target_rank, target_disp);
 
-    TRACE_smpi_ptp_out(rank, rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
   smpi_bench_begin();
   return retval;
@@ -522,9 +540,9 @@ int PMPI_Win_post(MPI_Group group, int assert, MPI_Win win){
     retval = MPI_ERR_GROUP;
   } else {
     int rank = smpi_process()->index();
-    TRACE_smpi_collective_in(rank, __FUNCTION__, nullptr);
+    TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_post"));
     retval = win->post(group,assert);
-    TRACE_smpi_collective_out(rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
   smpi_bench_begin();
   return retval;
@@ -539,9 +557,9 @@ int PMPI_Win_start(MPI_Group group, int assert, MPI_Win win){
     retval = MPI_ERR_GROUP;
   } else {
     int rank = smpi_process()->index();
-    TRACE_smpi_collective_in(rank, __FUNCTION__, nullptr);
+    TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_start"));
     retval = win->start(group,assert);
-    TRACE_smpi_collective_out(rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
   smpi_bench_begin();
   return retval;
@@ -554,11 +572,11 @@ int PMPI_Win_complete(MPI_Win win){
     retval = MPI_ERR_WIN;
   } else {
     int rank = smpi_process()->index();
-    TRACE_smpi_collective_in(rank, __FUNCTION__, nullptr);
+    TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_complete"));
 
     retval = win->complete();
 
-    TRACE_smpi_collective_out(rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
   smpi_bench_begin();
   return retval;
@@ -571,11 +589,11 @@ int PMPI_Win_wait(MPI_Win win){
     retval = MPI_ERR_WIN;
   } else {
     int rank = smpi_process()->index();
-    TRACE_smpi_collective_in(rank, __FUNCTION__, nullptr);
+    TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_wait"));
 
     retval = win->wait();
 
-    TRACE_smpi_collective_out(rank, __FUNCTION__);
+    TRACE_smpi_comm_out(rank);
   }
   smpi_bench_begin();
   return retval;
@@ -593,9 +611,9 @@ int PMPI_Win_lock(int lock_type, int rank, int assert, MPI_Win win){
     retval = MPI_SUCCESS;
   } else {
     int myrank = smpi_process()->index();
-    TRACE_smpi_collective_in(myrank, __FUNCTION__, nullptr);
+    TRACE_smpi_comm_in(myrank, __func__, new simgrid::instr::NoOpTIData("Win_lock"));
     retval = win->lock(lock_type,rank,assert);
-    TRACE_smpi_collective_out(myrank, __FUNCTION__);
+    TRACE_smpi_comm_out(myrank);
   }
   smpi_bench_begin();
   return retval;
@@ -610,9 +628,9 @@ int PMPI_Win_unlock(int rank, MPI_Win win){
     retval = MPI_SUCCESS;
   } else {
     int myrank = smpi_process()->index();
-    TRACE_smpi_collective_in(myrank, __FUNCTION__, nullptr);
+    TRACE_smpi_comm_in(myrank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_unlock"));
     retval = win->unlock(rank);
-    TRACE_smpi_collective_out(myrank, __FUNCTION__);
+    TRACE_smpi_comm_out(myrank);
   }
   smpi_bench_begin();
   return retval;
@@ -625,9 +643,9 @@ int PMPI_Win_lock_all(int assert, MPI_Win win){
     retval = MPI_ERR_WIN;
   } else {
     int myrank = smpi_process()->index();
-    TRACE_smpi_collective_in(myrank, __FUNCTION__, nullptr);
+    TRACE_smpi_comm_in(myrank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_lock_all"));
     retval = win->lock_all(assert);
-    TRACE_smpi_collective_out(myrank, __FUNCTION__);
+    TRACE_smpi_comm_out(myrank);
   }
   smpi_bench_begin();
   return retval;
@@ -640,9 +658,9 @@ int PMPI_Win_unlock_all(MPI_Win win){
     retval = MPI_ERR_WIN;
   } else {
     int myrank = smpi_process()->index();
-    TRACE_smpi_collective_in(myrank, __FUNCTION__, nullptr);
+    TRACE_smpi_comm_in(myrank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_unlock_all"));
     retval = win->unlock_all();
-    TRACE_smpi_collective_out(myrank, __FUNCTION__);
+    TRACE_smpi_comm_out(myrank);
   }
   smpi_bench_begin();
   return retval;
@@ -657,9 +675,9 @@ int PMPI_Win_flush(int rank, MPI_Win win){
     retval = MPI_SUCCESS;
   } else {
     int myrank = smpi_process()->index();
-    TRACE_smpi_collective_in(myrank, __FUNCTION__, nullptr);
+    TRACE_smpi_comm_in(myrank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_flush"));
     retval = win->flush(rank);
-    TRACE_smpi_collective_out(myrank, __FUNCTION__);
+    TRACE_smpi_comm_out(myrank);
   }
   smpi_bench_begin();
   return retval;
@@ -674,9 +692,9 @@ int PMPI_Win_flush_local(int rank, MPI_Win win){
     retval = MPI_SUCCESS;
   } else {
     int myrank = smpi_process()->index();
-    TRACE_smpi_collective_in(myrank, __FUNCTION__, nullptr);
+    TRACE_smpi_comm_in(myrank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_flush_local"));
     retval = win->flush_local(rank);
-    TRACE_smpi_collective_out(myrank, __FUNCTION__);
+    TRACE_smpi_comm_out(myrank);
   }
   smpi_bench_begin();
   return retval;
@@ -689,9 +707,9 @@ int PMPI_Win_flush_all(MPI_Win win){
     retval = MPI_ERR_WIN;
   } else {
     int myrank = smpi_process()->index();
-    TRACE_smpi_collective_in(myrank, __FUNCTION__, nullptr);
+    TRACE_smpi_comm_in(myrank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_flush_all"));
     retval = win->flush_all();
-    TRACE_smpi_collective_out(myrank, __FUNCTION__);
+    TRACE_smpi_comm_out(myrank);
   }
   smpi_bench_begin();
   return retval;
@@ -704,9 +722,9 @@ int PMPI_Win_flush_local_all(MPI_Win win){
     retval = MPI_ERR_WIN;
   } else {
     int myrank = smpi_process()->index();
-    TRACE_smpi_collective_in(myrank, __FUNCTION__, nullptr);
+    TRACE_smpi_comm_in(myrank, __FUNCTION__, new simgrid::instr::NoOpTIData("Win_flush_local_all"));
     retval = win->flush_local_all();
-    TRACE_smpi_collective_out(myrank, __FUNCTION__);
+    TRACE_smpi_comm_out(myrank);
   }
   smpi_bench_begin();
   return retval;
index c094c7d..9174ad8 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "../colls_private.hpp"
 #include "smpi_status.hpp"
+#include <algorithm>
 
 namespace simgrid{
 namespace smpi{
@@ -48,7 +49,7 @@ int Coll_allgatherv_mpich_rdb::allgatherv (
 
   recvtype->extent(&recvtype_true_lb, &recvtype_true_extent);
 
-  tmp_buf_rl= (void*)smpi_get_tmp_sendbuffer(total_count*(MAX(recvtype_true_extent,recvtype_extent)));
+  tmp_buf_rl = (void*)smpi_get_tmp_sendbuffer(total_count * std::max(recvtype_true_extent, recvtype_extent));
 
   /* adjust for potential negative lower bound in datatype */
   tmp_buf = (void *)((char*)tmp_buf_rl - recvtype_true_lb);
index 1711f3b..32b2548 100644 (file)
@@ -22,6 +22,8 @@
  */
 
 #include "../colls_private.hpp"
+#include <algorithm>
+
 namespace simgrid{
 namespace smpi{
 int Coll_allreduce_mvapich2_rs::allreduce(void *sendbuf,
@@ -53,7 +55,7 @@ int Coll_allreduce_mvapich2_rs::allreduce(void *sendbuf,
     datatype->extent(&true_lb, &true_extent);
     extent = datatype->get_extent();
 
-    tmp_buf_free= smpi_get_tmp_recvbuffer(count * (MAX(extent, true_extent)));
+    tmp_buf_free = smpi_get_tmp_recvbuffer(count * std::max(extent, true_extent));
 
     /* adjust for potential negative lower bound in datatype */
     tmp_buf = (void *) ((char *) tmp_buf_free - true_lb);
index 79b7035..2ebd387 100644 (file)
@@ -36,6 +36,7 @@
  */
 
 #include "../colls_private.hpp"
+#include <algorithm>
 
 #define MPIR_Gather_MV2_Direct Coll_gather_ompi_basic_linear::gather
 #define MPIR_Gather_MV2_two_level_Direct Coll_gather_ompi_basic_linear::gather
@@ -223,12 +224,9 @@ int Coll_gather_mvapich2_two_level::gather(void *sendbuf,
         if (local_rank == 0) {
             /* Node leader, allocate tmp_buffer */
             if (rank == root) {
-                tmp_buf = smpi_get_tmp_recvbuffer(recvcnt * MAX(recvtype_extent,
-                            recvtype_true_extent) * local_size);
+              tmp_buf = smpi_get_tmp_recvbuffer(recvcnt * std::max(recvtype_extent, recvtype_true_extent) * local_size);
             } else {
-                tmp_buf = smpi_get_tmp_sendbuffer(sendcnt * MAX(sendtype_extent,
-                            sendtype_true_extent) *
-                        local_size);
+              tmp_buf = smpi_get_tmp_sendbuffer(sendcnt * std::max(sendtype_extent, sendtype_true_extent) * local_size);
             }
             if (tmp_buf == NULL) {
                 mpi_errno = MPI_ERR_OTHER;
@@ -291,10 +289,10 @@ int Coll_gather_mvapich2_two_level::gather(void *sendbuf,
            * is the same as leader_root */
           if (rank == root) {
             leader_gather_buf =
-                smpi_get_tmp_recvbuffer(recvcnt * MAX(recvtype_extent, recvtype_true_extent) * comm_size);
+                smpi_get_tmp_recvbuffer(recvcnt * std::max(recvtype_extent, recvtype_true_extent) * comm_size);
           } else {
             leader_gather_buf =
-                smpi_get_tmp_sendbuffer(sendcnt * MAX(sendtype_extent, sendtype_true_extent) * comm_size);
+                smpi_get_tmp_sendbuffer(sendcnt * std::max(sendtype_extent, sendtype_true_extent) * comm_size);
           }
           if (leader_gather_buf == NULL) {
             mpi_errno = MPI_ERR_OTHER;
index d36c30f..07abde4 100644 (file)
@@ -5,6 +5,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "../colls_private.hpp"
+#include <algorithm>
 
 //#include <star-reduction.c>
 namespace simgrid{
@@ -47,7 +48,7 @@ int Coll_reduce_binomial::reduce(void *sendbuf, void *recvbuf, int count,
   /* If I'm not the root, then my recvbuf may not be valid, therefore
      I have to allocate a temporary one */
   if (rank != root) {
-      recvbuf = (void *) smpi_get_tmp_recvbuffer(count*(MAX(extent,true_extent)));
+      recvbuf = (void*)smpi_get_tmp_recvbuffer(count * std::max(extent, true_extent));
       recvbuf = (void *)((char*)recvbuf - true_lb);
   }
    if ((rank != root) || (sendbuf != MPI_IN_PLACE)) {
index d5788fb..90619c2 100644 (file)
@@ -39,6 +39,8 @@
  */
 
 #include "../colls_private.hpp"
+#include <algorithm>
+
 extern int mv2_reduce_intra_knomial_factor;
 extern int mv2_reduce_inter_knomial_factor;
 
@@ -150,7 +152,7 @@ int Coll_reduce_mvapich2_knomial::reduce (
     is_commutative =  (op==MPI_OP_NULL || op->is_commutative());
 
     if (rank != root) {
-        recvbuf=(void *)smpi_get_tmp_recvbuffer(count*(MAX(extent,true_extent)));
+        recvbuf = (void*)smpi_get_tmp_recvbuffer(count * std::max(extent, true_extent));
         recvbuf = (void *)((char*)recvbuf - true_lb);
     }
 
@@ -177,7 +179,7 @@ int Coll_reduce_mvapich2_knomial::reduce (
         tmp_buf  = static_cast<void**>(xbt_malloc(sizeof(void *)*expected_recv_count));
         requests = static_cast<MPI_Request*>(xbt_malloc(sizeof(MPI_Request)*expected_recv_count));
         for(k=0; k < expected_recv_count; k++ ) {
-            tmp_buf[k] = smpi_get_tmp_sendbuffer(count*(MAX(extent,true_extent)));
+            tmp_buf[k] = smpi_get_tmp_sendbuffer(count * std::max(extent, true_extent));
             tmp_buf[k] = (void *)((char*)tmp_buf[k] - true_lb);
         }
 
index 3c3adc1..7a14eb4 100644 (file)
@@ -36,6 +36,8 @@
  */
 
 #include "../colls_private.hpp"
+#include <algorithm>
+
 #define MV2_INTRA_SHMEM_REDUCE_MSG 2048
 
 #define mv2_g_shmem_coll_max_msg_size (1 << 17)
@@ -117,15 +119,14 @@ int Coll_reduce_mvapich2_two_level::reduce( void *sendbuf,
     datatype->extent(&true_lb,
                                        &true_extent);
     extent =datatype->get_extent();
-    stride = count * MAX(extent, true_extent);
+    stride = count * std::max(extent, true_extent);
 
     if (local_size == total_size) {
         /* First handle the case where there is only one node */
         if (stride <= MV2_INTRA_SHMEM_REDUCE_MSG &&
             is_commutative == 1) {
             if (local_rank == 0 ) {
-                tmp_buf=(void *)smpi_get_tmp_sendbuffer( count *
-                                    (MAX(extent, true_extent)));
+                tmp_buf = (void*)smpi_get_tmp_sendbuffer(count * std::max(extent, true_extent));
                 tmp_buf = (void *) ((char *) tmp_buf - true_lb);
             }
 
@@ -150,7 +151,7 @@ int Coll_reduce_mvapich2_two_level::reduce( void *sendbuf,
                 out_buf = NULL;
             }
 
-            if (count * (MAX(extent, true_extent)) < SHMEM_COLL_BLOCK_SIZE) {
+            if (count * (std::max(extent, true_extent)) < SHMEM_COLL_BLOCK_SIZE) {
               mpi_errno = MPIR_Reduce_shmem_MV2(in_buf, out_buf, count, datatype, op, 0, shmem_comm);
             } else {
               mpi_errno = MPIR_Reduce_intra_knomial_wrapper_MV2(in_buf, out_buf, count, datatype, op, 0, shmem_comm);
@@ -189,8 +190,7 @@ int Coll_reduce_mvapich2_two_level::reduce( void *sendbuf,
         }
         leader_comm_size = leader_comm->size();
         leader_comm_rank = leader_comm->rank();
-        tmp_buf=(void *)smpi_get_tmp_sendbuffer(count *
-                            (MAX(extent, true_extent)));
+        tmp_buf          = (void*)smpi_get_tmp_sendbuffer(count * std::max(extent, true_extent));
         tmp_buf = (void *) ((char *) tmp_buf - true_lb);
     }
     if (sendbuf != MPI_IN_PLACE) {
@@ -214,7 +214,7 @@ int Coll_reduce_mvapich2_two_level::reduce( void *sendbuf,
          *this step*/
         if (MV2_Reduce_intra_function == & MPIR_Reduce_shmem_MV2)
         {
-          if (is_commutative == 1 && (count * (MAX(extent, true_extent)) < SHMEM_COLL_BLOCK_SIZE)) {
+          if (is_commutative == 1 && (count * (std::max(extent, true_extent)) < SHMEM_COLL_BLOCK_SIZE)) {
             mpi_errno = MV2_Reduce_intra_function(in_buf, out_buf, count, datatype, op, intra_node_root, shmem_comm);
             } else {
                     mpi_errno = MPIR_Reduce_intra_knomial_wrapper_MV2(in_buf, out_buf, count,
index 995f078..8061733 100644 (file)
@@ -5,6 +5,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "../colls_private.hpp"
+#include <algorithm>
 
 static inline int MPIU_Mirror_permutation(unsigned int x, int bits)
 {
@@ -64,7 +65,7 @@ int Coll_reduce_scatter_mpich_pair::reduce_scatter(void *sendbuf, void *recvbuf,
         }
 
         /* allocate temporary buffer to store incoming data */
-        tmp_recvbuf = (void*)smpi_get_tmp_recvbuffer(recvcounts[rank]*(MAX(true_extent,extent))+1);
+        tmp_recvbuf = (void*)smpi_get_tmp_recvbuffer(recvcounts[rank] * std::max(true_extent, extent) + 1);
         /* adjust for potential negative lower bound in datatype */
         tmp_recvbuf = (void *)((char*)tmp_recvbuf - true_lb);
 
@@ -295,13 +296,13 @@ int Coll_reduce_scatter_mpich_rdb::reduce_scatter(void *sendbuf, void *recvbuf,
             /* noncommutative and (non-pof2 or block irregular), use recursive doubling. */
 
             /* need to allocate temporary buffer to receive incoming data*/
-            tmp_recvbuf= (void *) smpi_get_tmp_recvbuffer( total_count*(MAX(true_extent,extent)));
+            tmp_recvbuf= (void*)smpi_get_tmp_recvbuffer(total_count * std::max(true_extent, extent));
             /* adjust for potential negative lower bound in datatype */
             tmp_recvbuf = (void *)((char*)tmp_recvbuf - true_lb);
 
             /* need to allocate another temporary buffer to accumulate
                results */
-            tmp_results = (void *)smpi_get_tmp_sendbuffer( total_count*(MAX(true_extent,extent)));
+            tmp_results = (void*)smpi_get_tmp_sendbuffer(total_count * std::max(true_extent, extent));
             /* adjust for potential negative lower bound in datatype */
             tmp_results = (void *)((char*)tmp_results - true_lb);
 
index d1bca75..024bb92 100644 (file)
@@ -6,7 +6,7 @@
 #ifndef SMPI_HOST_HPP_
 #define SMPI_HOST_HPP_
 
-#include "src/include/smpi/smpi_utils.hpp"
+#include "smpi_utils.hpp"
 
 #include "simgrid/s4u/Host.hpp"
 #include <string>
index ed621f1..86f00b2 100644 (file)
@@ -58,7 +58,7 @@ class Comm : public F2C, public Keyval{
     static void destroy(MPI_Comm comm);
     void init_smp();
 
-    int add_f();
+    int add_f() override;
     static void free_f(int id);
     static Comm* f2c(int);
 
index 97beb46..2453f10 100644 (file)
@@ -102,6 +102,7 @@ public:
   static void unref(MPI_Datatype datatype);
   void commit();
   bool is_valid();
+  bool is_basic();
   void addflag(int flag);
   int extent(MPI_Aint* lb, MPI_Aint* extent);
   MPI_Aint get_extent();
index 5c46639..9e1f4c8 100644 (file)
@@ -23,20 +23,6 @@ public:
   void unserialize(void* contiguous_vector, void* noncontiguous_vector, int count, MPI_Op op);
 };
 
-class Type_Vector: public Datatype{
-  int block_count_;
-  int block_length_;
-  int block_stride_;
-  MPI_Datatype old_type_;
-
-public:
-  Type_Vector(int size, MPI_Aint lb, MPI_Aint ub, int flags, int count, int blocklen, int stride,
-              MPI_Datatype old_type);
-  ~Type_Vector();
-  void serialize(void* noncontiguous, void* contiguous, int count);
-  void unserialize(void* contiguous_vector, void* noncontiguous_vector, int count, MPI_Op op);
-};
-
 class Type_Hvector: public Datatype{
   int block_count_;
   int block_length_;
@@ -51,18 +37,10 @@ public:
   void unserialize(void* contiguous_vector, void* noncontiguous_vector, int count, MPI_Op op);
 };
 
-class Type_Indexed: public Datatype{
-  int block_count_;
-  int* block_lengths_;
-  int* block_indices_;
-  MPI_Datatype old_type_;
-
+class Type_Vector : public Type_Hvector {
 public:
-  Type_Indexed(int size, MPI_Aint lb, MPI_Aint ub, int flags, int block_count, int* block_lengths, int* block_indices,
-               MPI_Datatype old_type);
-  ~Type_Indexed();
-  void serialize(void* noncontiguous, void* contiguous, int count);
-  void unserialize(void* contiguous_vector, void* noncontiguous_vector, int count, MPI_Op op);
+  Type_Vector(int size, MPI_Aint lb, MPI_Aint ub, int flags, int count, int blocklen, int stride,
+              MPI_Datatype old_type);
 };
 
 class Type_Hindexed: public Datatype{
@@ -74,11 +52,19 @@ class Type_Hindexed: public Datatype{
 public:
   Type_Hindexed(int size, MPI_Aint lb, MPI_Aint ub, int flags, int block_count, int* block_lengths,
                 MPI_Aint* block_indices, MPI_Datatype old_type);
+  Type_Hindexed(int size, MPI_Aint lb, MPI_Aint ub, int flags, int block_count, int* block_lengths, int* block_indices,
+                MPI_Datatype old_type, MPI_Aint factor);
   ~Type_Hindexed();
   void serialize(void* noncontiguous, void* contiguous, int count);
   void unserialize(void* contiguous_vector, void* noncontiguous_vector, int count, MPI_Op op);
 };
 
+class Type_Indexed : public Type_Hindexed {
+public:
+  Type_Indexed(int size, MPI_Aint lb, MPI_Aint ub, int flags, int block_count, int* block_lengths, int* block_indices,
+               MPI_Datatype old_type);
+};
+
 class Type_Struct: public Datatype{
   int block_count_;
   int* block_lengths_;
index 207c699..03d8908 100644 (file)
@@ -33,10 +33,12 @@ class F2C {
     static void delete_lookup();
     static std::unordered_map<std::string, F2C*>* lookup();
 
+    virtual ~F2C() = default;
+
     //Override these to handle specific values.
-    int add_f();
+    virtual int add_f();
     static void free_f(int id);
-    int c2f();
+    virtual int c2f();
 
     // This method should be overridden in all subclasses to avoid casting the result when calling it.
     // For the default one, the MPI_*_NULL returned is assumed to be NULL.
index 5a11b2d..f6c69ac 100644 (file)
@@ -91,7 +91,7 @@ class Request : public F2C {
     static int match_send(void* a, void* b, simgrid::kernel::activity::CommImpl* ignored);
     static int match_recv(void* a, void* b, simgrid::kernel::activity::CommImpl* ignored);
 
-    int add_f();
+    int add_f() override;
     static void free_f(int id);
     static Request* f2c(int);
 
similarity index 96%
rename from src/include/smpi/smpi_utils.hpp
rename to src/smpi/include/smpi_utils.hpp
index 52289c4..972e285 100644 (file)
@@ -14,7 +14,7 @@ extern "C" {
 
 // Methods used to parse and store the values for timing injections in smpi
 struct s_smpi_factor_t {
-  size_t factor=0;
+  size_t factor = 0;
   std::vector<double> values;
 };
 typedef s_smpi_factor_t* smpi_os_factor_t;
index 95e4217..380c72d 100644 (file)
@@ -5,7 +5,7 @@
 
 #include "SmpiHost.hpp"
 #include "simgrid/s4u/VirtualMachine.hpp"
-#include "smpi/smpi_utils.hpp"
+#include "smpi_utils.hpp"
 
 #include <string>
 #include <vector>
index f0b8b40..6d219aa 100644 (file)
@@ -33,8 +33,13 @@ static const char* smpi_colors[] = {
     "init",      "0 1 0",       "finalize",      "0 1 0",
 
     "put",       "0.3 1 0",     "get",           "0 1 0.3",        "accumulate", "1 0.3 0",
+    "rput",       "0.3 1 0",     "rget",           "0 1 0.3",        "raccumulate", "1 0.3 0",
+    "compare_and_swap",       "0.3 1 0",     "get_accumulate",           "0 1 0.3",        "rget_accumulate", "1 0.3 0",
     "win_fence", "1 0 0.3",     "win_post",      "1 0 0.8",        "win_wait",   "1 0.8 0",
-    "win_start", "0.8 0 1",     "win_complete",  "0.8 1 0",        nullptr,      nullptr,
+    "win_start", "0.8 0 1",     "win_complete",  "0.8 1 0",        "win_lock", "1 0 0.3",     
+    "win_unlock", "1 0 0.3",     "win_lock_all",      "1 0 0.8",        "win_unlock_all",   "1 0.8 0",
+    "win_flush", "1 0 0.3",     "win_flush_local",      "1 0 0.8",        "win_flush_all",   "1 0.8 0",
+    "win_flush_local_all", "1 0 0.3", ""  , ""
 };
 
 static const char* instr_find_color(const char* state)
@@ -56,9 +61,9 @@ static const char* instr_find_color(const char* state)
   return ret;
 }
 
-XBT_PRIVATE std::string smpi_container(int rank)
+XBT_PRIVATE container_t smpi_container(int rank)
 {
-  return std::string("rank-") + std::to_string(rank);
+  return simgrid::instr::Container::byName(std::string("rank-") + std::to_string(rank));
 }
 
 static std::string TRACE_smpi_put_key(int src, int dst, int tag, int send)
@@ -105,16 +110,6 @@ static std::string TRACE_smpi_get_key(int src, int dst, int tag, int send)
 
 static std::unordered_map<smx_actor_t, std::string> process_category;
 
-static void cleanup_extra_data (instr_extra_data extra){
-  if(extra!=nullptr){
-    if(extra->sendcounts!=nullptr)
-      xbt_free(extra->sendcounts);
-    if(extra->recvcounts!=nullptr)
-      xbt_free(extra->recvcounts);
-    xbt_free(extra);
-  }
-}
-
 void TRACE_internal_smpi_set_category (const char *category)
 {
   if (not TRACE_smpi_is_enabled())
@@ -152,7 +147,7 @@ void TRACE_smpi_init(int rank)
   if (not TRACE_smpi_is_enabled())
     return;
 
-  std::string str = smpi_container(rank);
+  std::string str = std::string("rank-") + std::to_string(rank);
 
   container_t father;
   if (TRACE_smpi_is_grouped()){
@@ -185,129 +180,86 @@ void TRACE_smpi_finalize(int rank)
   if (not TRACE_smpi_is_enabled())
     return;
 
-  container_t container = simgrid::instr::Container::byName(smpi_container(rank));
+  container_t container = smpi_container(rank);
   container->removeFromParent();
   delete container;
 }
 
-void TRACE_smpi_collective_in(int rank, const char *operation, instr_extra_data extra)
-{
-  if (not TRACE_smpi_is_enabled()) {
-    cleanup_extra_data(extra);
-    return;
-  }
-
-  simgrid::instr::StateType* state = simgrid::instr::Container::byName(smpi_container(rank))->getState("MPI_STATE");
-  const char *color = instr_find_color (operation);
-  state->addEntityValue(operation, color);
-  state->pushEvent(operation, static_cast<void*>(extra));
-}
-
-void TRACE_smpi_collective_out(int rank, const char *operation)
-{
-  if (TRACE_smpi_is_enabled())
-    simgrid::instr::Container::byName(smpi_container(rank))->getState("MPI_STATE")->popEvent();
-}
-
 void TRACE_smpi_computing_init(int rank)
 {
  //first use, initialize the color in the trace
- if (not TRACE_smpi_is_enabled() || not TRACE_smpi_is_computing())
-   return;
-
- simgrid::instr::StateType* state = simgrid::instr::Container::byName(smpi_container(rank))->getState("MPI_STATE");
- state->addEntityValue("computing", instr_find_color("computing"));
- state->pushEvent("computing");
+ if (TRACE_smpi_is_enabled() && TRACE_smpi_is_computing())
+   smpi_container(rank)->getState("MPI_STATE")->addEntityValue("computing", instr_find_color("computing"));
 }
 
-void TRACE_smpi_computing_in(int rank, instr_extra_data extra)
+void TRACE_smpi_computing_in(int rank, double amount)
 {
-  //do not forget to set the color first, otherwise this will explode
-  if (not TRACE_smpi_is_enabled() || not TRACE_smpi_is_computing()) {
-    cleanup_extra_data(extra);
-    return;
-  }
-
-  simgrid::instr::StateType* state = simgrid::instr::Container::byName(smpi_container(rank))->getState("MPI_STATE");
-  state->addEntityValue("computing");
-  state->pushEvent("computing", static_cast<void*>(extra));
+  if (TRACE_smpi_is_enabled() && TRACE_smpi_is_computing())
+    smpi_container(rank)
+        ->getState("MPI_STATE")
+        ->pushEvent("computing", new simgrid::instr::CpuTIData("compute", amount));
 }
 
 void TRACE_smpi_computing_out(int rank)
 {
-  if (not TRACE_smpi_is_enabled() || not TRACE_smpi_is_computing())
-    return;
-
-  simgrid::instr::Container::byName(smpi_container(rank))->getState("MPI_STATE")->popEvent();
+  if (TRACE_smpi_is_enabled() && TRACE_smpi_is_computing())
+    smpi_container(rank)->getState("MPI_STATE")->popEvent();
 }
 
 void TRACE_smpi_sleeping_init(int rank)
 {
   //first use, initialize the color in the trace
-  if (not TRACE_smpi_is_enabled() || not TRACE_smpi_is_sleeping())
-    return;
-
-  simgrid::instr::StateType* state = simgrid::instr::Container::byName(smpi_container(rank))->getState("MPI_STATE");
-  state->addEntityValue("sleeping", instr_find_color("sleeping"));
-  state->pushEvent("sleeping");
+  if (TRACE_smpi_is_enabled() && TRACE_smpi_is_sleeping())
+    smpi_container(rank)->getState("MPI_STATE")->addEntityValue("sleeping", instr_find_color("sleeping"));
 }
 
-void TRACE_smpi_sleeping_in(int rank, instr_extra_data extra)
+void TRACE_smpi_sleeping_in(int rank, double duration)
 {
-  //do not forget to set the color first, otherwise this will explode
-  if (not TRACE_smpi_is_enabled() || not TRACE_smpi_is_sleeping()) {
-    cleanup_extra_data(extra);
-    return;
-  }
-
-  simgrid::instr::StateType* state = simgrid::instr::Container::byName(smpi_container(rank))->getState("MPI_STATE");
-  state->addEntityValue("sleeping");
-  state->pushEvent("sleeping", static_cast<void*>(extra));
+  if (TRACE_smpi_is_enabled() && TRACE_smpi_is_sleeping())
+    smpi_container(rank)
+        ->getState("MPI_STATE")
+        ->pushEvent("sleeping", new simgrid::instr::CpuTIData("sleep", duration));
 }
 
 void TRACE_smpi_sleeping_out(int rank)
 {
-  if (not TRACE_smpi_is_enabled() || not TRACE_smpi_is_sleeping())
-    return;
-
-  simgrid::instr::Container::byName(smpi_container(rank))->getState("MPI_STATE")->popEvent();
+  if (TRACE_smpi_is_enabled() && not TRACE_smpi_is_sleeping())
+    smpi_container(rank)->getState("MPI_STATE")->popEvent();
 }
 
-void TRACE_smpi_testing_in(int rank, instr_extra_data extra)
+void TRACE_smpi_testing_in(int rank)
 {
   //do not forget to set the color first, otherwise this will explode
-  if (not TRACE_smpi_is_enabled()) {
-    cleanup_extra_data(extra);
+  if (not TRACE_smpi_is_enabled())
     return;
-  }
 
-  simgrid::instr::StateType* state = simgrid::instr::Container::byName(smpi_container(rank))->getState("MPI_STATE");
+  simgrid::instr::StateType* state = smpi_container(rank)->getState("MPI_STATE");
   state->addEntityValue("test");
-  state->pushEvent("test", static_cast<void*>(extra));
+  state->pushEvent("test", new simgrid::instr::NoOpTIData("test"));
 }
 
 void TRACE_smpi_testing_out(int rank)
 {
   if (TRACE_smpi_is_enabled())
-    simgrid::instr::Container::byName(smpi_container(rank))->getState("MPI_STATE")->popEvent();
+    smpi_container(rank)->getState("MPI_STATE")->popEvent();
 }
 
-void TRACE_smpi_ptp_in(int rank, const char *operation, instr_extra_data extra)
+void TRACE_smpi_comm_in(int rank, const char* operation, simgrid::instr::TIData* extra)
 {
   if (not TRACE_smpi_is_enabled()) {
-    cleanup_extra_data(extra);
+    delete extra;
     return;
   }
 
-  simgrid::instr::StateType* state = simgrid::instr::Container::byName(smpi_container(rank))->getState("MPI_STATE");
+  simgrid::instr::StateType* state = smpi_container(rank)->getState("MPI_STATE");
   state->addEntityValue(operation, instr_find_color(operation));
-  state->pushEvent(operation, static_cast<void*>(extra));
+  state->pushEvent(operation, extra);
 }
 
-void TRACE_smpi_ptp_out(int rank, int dst, const char *operation)
+void TRACE_smpi_comm_out(int rank)
 {
   if (TRACE_smpi_is_enabled())
-    simgrid::instr::Container::byName(smpi_container(rank))->getState("MPI_STATE")->popEvent();
+    smpi_container(rank)->getState("MPI_STATE")->popEvent();
 }
 
 void TRACE_smpi_send(int rank, int src, int dst, int tag, int size)
@@ -318,8 +270,7 @@ void TRACE_smpi_send(int rank, int src, int dst, int tag, int size)
   std::string key = TRACE_smpi_get_key(src, dst, tag, 1);
 
   XBT_DEBUG("Send tracing from %d to %d, tag %d, with key %s", src, dst, tag, key.c_str());
-  container_t startContainer = simgrid::instr::Container::byName(smpi_container(rank));
-  simgrid::instr::Container::getRoot()->getLink("MPI_LINK")->startEvent(startContainer, "PTP", key, size);
+  simgrid::instr::Container::getRoot()->getLink("MPI_LINK")->startEvent(smpi_container(rank), "PTP", key, size);
 }
 
 void TRACE_smpi_recv(int src, int dst, int tag)
@@ -330,6 +281,5 @@ void TRACE_smpi_recv(int src, int dst, int tag)
   std::string key = TRACE_smpi_get_key(src, dst, tag, 0);
 
   XBT_DEBUG("Recv tracing from %d to %d, tag %d, with key %s", src, dst, tag, key.c_str());
-  container_t endContainer = simgrid::instr::Container::byName(smpi_container(dst));
-  simgrid::instr::Container::getRoot()->getLink("MPI_LINK")->endEvent(endContainer, "PTP", key);
+  simgrid::instr::Container::getRoot()->getLink("MPI_LINK")->endEvent(smpi_container(dst), "PTP", key);
 }
index aefe6b7..795521e 100644 (file)
@@ -54,10 +54,7 @@ void smpi_execute(double duration)
     XBT_DEBUG("Sleep for %g to handle real computation time", duration);
     double flops = duration * smpi_host_speed;
     int rank = smpi_process()->index();
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type=TRACING_COMPUTING;
-    extra->comp_size=flops;
-    TRACE_smpi_computing_in(rank, extra);
+    TRACE_smpi_computing_in(rank, flops);
 
     smpi_execute_flops(flops);
 
@@ -156,7 +153,8 @@ void smpi_bench_end()
 
 #if HAVE_PAPI
   if (xbt_cfg_get_string("smpi/papi-events")[0] != '\0' && TRACE_smpi_is_enabled()) {
-    container_t container        = new simgrid::instr::Container(smpi_container(smpi_process()->index()));
+    container_t container =
+        new simgrid::instr::Container(std::string("rank-") + std::to_string(smpi_process()->index()));
     papi_counter_t& counter_data = smpi_process()->papi_counters();
 
     for (auto const& pair : counter_data) {
@@ -176,10 +174,7 @@ static unsigned int private_sleep(double secs)
 
   XBT_DEBUG("Sleep for: %lf secs", secs);
   int rank = MPI_COMM_WORLD->rank();
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type=TRACING_SLEEPING;
-  extra->sleep_duration=secs;
-  TRACE_smpi_sleeping_in(rank, extra);
+  TRACE_smpi_sleeping_in(rank, secs);
 
   simcall_process_sleep(secs);
 
index 7414846..351269c 100644 (file)
@@ -371,7 +371,8 @@ void smpi_global_destroy()
   smpi_bench_destroy();
   smpi_shared_destroy();
   smpi_deployment_cleanup_instances();
-  for (int i = 0; i < smpi_process_count(); i++) {
+  int count = smpi_process_count();
+  for (int i = 0; i < count; i++) {
     if(process_data[i]->comm_self()!=MPI_COMM_NULL){
       simgrid::smpi::Comm::destroy(process_data[i]->comm_self());
     }
@@ -658,7 +659,8 @@ int smpi_main(const char* executable, int argc, char *argv[])
     }
   }
   int ret   = 0;
-  for (int i = 0, count = smpi_process_count(); i < count; i++) {
+  int count = smpi_process_count();
+  for (int i = 0; i < count; i++) {
     if(process_data[i]->return_value()!=0){
       ret=process_data[i]->return_value();//return first non 0 value
       break;
index 265b3be..8e02386 100644 (file)
@@ -118,12 +118,8 @@ static MPI_Datatype decode_datatype(const char *const action)
    return MPI_CURRENT_TYPE;
 }
 
-const char* encode_datatype(MPI_Datatype datatype, int* known)
+const char* encode_datatype(MPI_Datatype datatype)
 {
-  //default type for output is set to MPI_BYTE
-  // MPI_DEFAULT_TYPE is not set for output, use directly MPI_BYTE
-  if(known!=nullptr)
-    *known=1;
   if (datatype==MPI_BYTE)
       return "";
   if(datatype==MPI_DOUBLE)
@@ -138,9 +134,6 @@ const char* encode_datatype(MPI_Datatype datatype, int* known)
     return "4";
   if(datatype==MPI_FLOAT)
       return "5";
-  //tell that the datatype is not handled by replay, and that its size should be measured and replayed as size*MPI_BYTE
-  if(known!=nullptr)
-    *known=0;
   // default - not implemented.
   // do not warn here as we pass in this function even for other trace formats
   return "-1";
@@ -165,8 +158,9 @@ static void action_init(const char *const *action)
   XBT_DEBUG("Initialize the counters");
   CHECK_ACTION_PARAMS(action, 0, 1)
   if(action[2])
-    MPI_DEFAULT_TYPE=MPI_DOUBLE; // default MPE dataype
-  else MPI_DEFAULT_TYPE= MPI_BYTE; // default TAU datatype
+    MPI_DEFAULT_TYPE = MPI_DOUBLE; // default MPE datatype
+  else
+    MPI_DEFAULT_TYPE = MPI_BYTE; // default TAU datatype
 
   /* start a simulated timer */
   smpi_process()->simulated_start();
@@ -203,14 +197,11 @@ static void action_compute(const char *const *action)
   double clock = smpi_process()->simulated_elapsed();
   double flops= parse_double(action[2]);
   int rank = smpi_process()->index();
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type=TRACING_COMPUTING;
-  extra->comp_size=flops;
-  TRACE_smpi_computing_in(rank, extra);
 
+  TRACE_smpi_computing_in(rank, flops);
   smpi_execute_flops(flops);
-
   TRACE_smpi_computing_out(rank);
+
   log_timed_action (action, clock);
 }
 
@@ -227,23 +218,18 @@ static void action_send(const char *const *action)
     MPI_CURRENT_TYPE= MPI_DEFAULT_TYPE;
 
   int rank = smpi_process()->index();
-
   int dst_traced = MPI_COMM_WORLD->group()->rank(to);
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type = TRACING_SEND;
-  extra->send_size = size;
-  extra->src = rank;
-  extra->dst = dst_traced;
-  extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr);
-  TRACE_smpi_ptp_in(rank, __FUNCTION__, extra);
+
+  TRACE_smpi_comm_in(rank, __FUNCTION__,
+                     new simgrid::instr::Pt2PtTIData("send", dst_traced, size, encode_datatype(MPI_CURRENT_TYPE)));
   if (not TRACE_smpi_view_internals())
     TRACE_smpi_send(rank, rank, dst_traced, 0, size*MPI_CURRENT_TYPE->size());
 
   Request::send(nullptr, size, MPI_CURRENT_TYPE, to , 0, MPI_COMM_WORLD);
 
-  log_timed_action (action, clock);
+  TRACE_smpi_comm_out(rank);
 
-  TRACE_smpi_ptp_out(rank, dst_traced, __FUNCTION__);
+  log_timed_action(action, clock);
 }
 
 static void action_Isend(const char *const *action)
@@ -260,19 +246,14 @@ static void action_Isend(const char *const *action)
 
   int rank = smpi_process()->index();
   int dst_traced = MPI_COMM_WORLD->group()->rank(to);
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type = TRACING_ISEND;
-  extra->send_size = size;
-  extra->src = rank;
-  extra->dst = dst_traced;
-  extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr);
-  TRACE_smpi_ptp_in(rank, __FUNCTION__, extra);
+  TRACE_smpi_comm_in(rank, __FUNCTION__,
+                     new simgrid::instr::Pt2PtTIData("Isend", dst_traced, size, encode_datatype(MPI_CURRENT_TYPE)));
   if (not TRACE_smpi_view_internals())
     TRACE_smpi_send(rank, rank, dst_traced, 0, size*MPI_CURRENT_TYPE->size());
 
-  MPI_Request request = Request::isend(nullptr, size, MPI_CURRENT_TYPE, to, 0,MPI_COMM_WORLD);
+  MPI_Request request = Request::isend(nullptr, size, MPI_CURRENT_TYPE, to, 0, MPI_COMM_WORLD);
 
-  TRACE_smpi_ptp_out(rank, dst_traced, __FUNCTION__);
+  TRACE_smpi_comm_out(rank);
 
   get_reqq_self()->push_back(request);
 
@@ -294,23 +275,18 @@ static void action_recv(const char *const *action) {
   int rank = smpi_process()->index();
   int src_traced = MPI_COMM_WORLD->group()->rank(from);
 
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type = TRACING_RECV;
-  extra->send_size = size;
-  extra->src = src_traced;
-  extra->dst = rank;
-  extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr);
-  TRACE_smpi_ptp_in(rank, __FUNCTION__, extra);
+  TRACE_smpi_comm_in(rank, __FUNCTION__,
+                     new simgrid::instr::Pt2PtTIData("recv", src_traced, size, encode_datatype(MPI_CURRENT_TYPE)));
 
   //unknown size from the receiver point of view
-  if(size<=0.0){
+  if (size <= 0.0) {
     Request::probe(from, 0, MPI_COMM_WORLD, &status);
     size=status.count;
   }
 
   Request::recv(nullptr, size, MPI_CURRENT_TYPE, from, 0, MPI_COMM_WORLD, &status);
 
-  TRACE_smpi_ptp_out(rank, rank, __FUNCTION__);
+  TRACE_smpi_comm_out(rank);
   if (not TRACE_smpi_view_internals()) {
     TRACE_smpi_recv(src_traced, rank, 0);
   }
@@ -332,29 +308,25 @@ static void action_Irecv(const char *const *action)
 
   int rank = smpi_process()->index();
   int src_traced = MPI_COMM_WORLD->group()->rank(from);
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type = TRACING_IRECV;
-  extra->send_size = size;
-  extra->src = src_traced;
-  extra->dst = rank;
-  extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr);
-  TRACE_smpi_ptp_in(rank, __FUNCTION__, extra);
+  TRACE_smpi_comm_in(rank, __FUNCTION__,
+                     new simgrid::instr::Pt2PtTIData("Irecv", src_traced, size, encode_datatype(MPI_CURRENT_TYPE)));
   MPI_Status status;
   //unknow size from the receiver pov
-  if(size<=0.0){
-      Request::probe(from, 0, MPI_COMM_WORLD, &status);
-      size=status.count;
+  if (size <= 0.0) {
+    Request::probe(from, 0, MPI_COMM_WORLD, &status);
+    size = status.count;
   }
 
   MPI_Request request = Request::irecv(nullptr, size, MPI_CURRENT_TYPE, from, 0, MPI_COMM_WORLD);
 
-  TRACE_smpi_ptp_out(rank, rank, __FUNCTION__);
+  TRACE_smpi_comm_out(rank);
   get_reqq_self()->push_back(request);
 
   log_timed_action (action, clock);
 }
 
-static void action_test(const char *const *action){
+static void action_test(const char* const* action)
+{
   CHECK_ACTION_PARAMS(action, 0, 0)
   double clock = smpi_process()->simulated_elapsed();
   MPI_Status status;
@@ -366,9 +338,7 @@ static void action_test(const char *const *action){
   //In this case, ignore the extra calls.
   if(request!=nullptr){
     int rank = smpi_process()->index();
-    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-    extra->type=TRACING_TEST;
-    TRACE_smpi_testing_in(rank, extra);
+    TRACE_smpi_testing_in(rank);
 
     int flag = Request::test(&request, &status);
 
@@ -402,13 +372,11 @@ static void action_wait(const char *const *action){
   int src_traced = group->rank(request->src());
   int dst_traced = group->rank(request->dst());
   int is_wait_for_receive = (request->flags() & RECV);
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type = TRACING_WAIT;
-  TRACE_smpi_ptp_in(rank, __FUNCTION__, extra);
+  TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::NoOpTIData("wait"));
 
   Request::wait(&request, &status);
 
-  TRACE_smpi_ptp_out(rank, dst_traced, __FUNCTION__);
+  TRACE_smpi_comm_out(rank);
   if (is_wait_for_receive)
     TRACE_smpi_recv(src_traced, dst_traced, 0);
   log_timed_action (action, clock);
@@ -423,10 +391,7 @@ static void action_waitall(const char *const *action){
     MPI_Status status[count_requests];
 
    int rank_traced = smpi_process()->index();
-   instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-   extra->type = TRACING_WAITALL;
-   extra->send_size=count_requests;
-   TRACE_smpi_ptp_in(rank_traced, __FUNCTION__,extra);
+   TRACE_smpi_comm_in(rank_traced, __FUNCTION__, new simgrid::instr::Pt2PtTIData("waitAll", -1, count_requests, ""));
    int recvs_snd[count_requests];
    int recvs_rcv[count_requests];
    for (unsigned int i = 0; i < count_requests; i++) {
@@ -443,7 +408,7 @@ static void action_waitall(const char *const *action){
      if (recvs_snd[i]!=-100)
        TRACE_smpi_recv(recvs_snd[i], recvs_rcv[i],0);
    }
-   TRACE_smpi_ptp_out(rank_traced, -1, __FUNCTION__);
+   TRACE_smpi_comm_out(rank_traced);
   }
   log_timed_action (action, clock);
 }
@@ -451,13 +416,11 @@ static void action_waitall(const char *const *action){
 static void action_barrier(const char *const *action){
   double clock = smpi_process()->simulated_elapsed();
   int rank = smpi_process()->index();
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type = TRACING_BARRIER;
-  TRACE_smpi_collective_in(rank, __FUNCTION__, extra);
+  TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::NoOpTIData("barrier"));
 
   Colls::barrier(MPI_COMM_WORLD);
 
-  TRACE_smpi_collective_out(rank, __FUNCTION__);
+  TRACE_smpi_comm_out(rank);
   log_timed_action (action, clock);
 }
 
@@ -477,19 +440,15 @@ static void action_bcast(const char *const *action)
   }
 
   int rank = smpi_process()->index();
-  int root_traced = MPI_COMM_WORLD->group()->index(root);
-
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type = TRACING_BCAST;
-  extra->send_size = size;
-  extra->root = root_traced;
-  extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr);
-  TRACE_smpi_collective_in(rank, __FUNCTION__, extra);
+  TRACE_smpi_comm_in(rank, __FUNCTION__,
+                     new simgrid::instr::CollTIData("bcast", MPI_COMM_WORLD->group()->index(root), -1.0, size, -1,
+                                                    encode_datatype(MPI_CURRENT_TYPE), ""));
+
   void *sendbuf = smpi_get_tmp_sendbuffer(size* MPI_CURRENT_TYPE->size());
 
   Colls::bcast(sendbuf, size, MPI_CURRENT_TYPE, root, MPI_COMM_WORLD);
 
-  TRACE_smpi_collective_out(rank, __FUNCTION__);
+  TRACE_smpi_comm_out(rank);
   log_timed_action (action, clock);
 }
 
@@ -509,22 +468,16 @@ static void action_reduce(const char *const *action)
   }
 
   int rank = smpi_process()->index();
-  int root_traced = MPI_COMM_WORLD->group()->rank(root);
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type = TRACING_REDUCE;
-  extra->send_size = comm_size;
-  extra->comp_size = comp_size;
-  extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr);
-  extra->root = root_traced;
-
-  TRACE_smpi_collective_in(rank, __FUNCTION__,extra);
+  TRACE_smpi_comm_in(rank, __FUNCTION__,
+                     new simgrid::instr::CollTIData("reduce", MPI_COMM_WORLD->group()->index(root), comp_size,
+                                                    comm_size, -1, encode_datatype(MPI_CURRENT_TYPE), ""));
 
   void *recvbuf = smpi_get_tmp_sendbuffer(comm_size* MPI_CURRENT_TYPE->size());
   void *sendbuf = smpi_get_tmp_sendbuffer(comm_size* MPI_CURRENT_TYPE->size());
   Colls::reduce(sendbuf, recvbuf, comm_size, MPI_CURRENT_TYPE, MPI_OP_NULL, root, MPI_COMM_WORLD);
   smpi_execute_flops(comp_size);
 
-  TRACE_smpi_collective_out(rank, __FUNCTION__);
+  TRACE_smpi_comm_out(rank);
   log_timed_action (action, clock);
 }
 
@@ -540,19 +493,15 @@ static void action_allReduce(const char *const *action) {
 
   double clock = smpi_process()->simulated_elapsed();
   int rank = smpi_process()->index();
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type = TRACING_ALLREDUCE;
-  extra->send_size = comm_size;
-  extra->comp_size = comp_size;
-  extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr);
-  TRACE_smpi_collective_in(rank, __FUNCTION__,extra);
+  TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::CollTIData("allReduce", -1, comp_size, comm_size, -1,
+                                                                        encode_datatype(MPI_CURRENT_TYPE), ""));
 
   void *recvbuf = smpi_get_tmp_sendbuffer(comm_size* MPI_CURRENT_TYPE->size());
   void *sendbuf = smpi_get_tmp_sendbuffer(comm_size* MPI_CURRENT_TYPE->size());
   Colls::allreduce(sendbuf, recvbuf, comm_size, MPI_CURRENT_TYPE, MPI_OP_NULL, MPI_COMM_WORLD);
   smpi_execute_flops(comp_size);
 
-  TRACE_smpi_collective_out(rank, __FUNCTION__);
+  TRACE_smpi_comm_out(rank);
   log_timed_action (action, clock);
 }
 
@@ -575,18 +524,13 @@ static void action_allToAll(const char *const *action) {
   void *recv = smpi_get_tmp_recvbuffer(recv_size*comm_size* MPI_CURRENT_TYPE2->size());
 
   int rank = smpi_process()->index();
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type = TRACING_ALLTOALL;
-  extra->send_size = send_size;
-  extra->recv_size = recv_size;
-  extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr);
-  extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, nullptr);
-
-  TRACE_smpi_collective_in(rank, __FUNCTION__,extra);
+  TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::CollTIData("allToAll", -1, -1.0, send_size, recv_size,
+                                                                        encode_datatype(MPI_CURRENT_TYPE),
+                                                                        encode_datatype(MPI_CURRENT_TYPE2)));
 
   Colls::alltoall(send, send_size, MPI_CURRENT_TYPE, recv, recv_size, MPI_CURRENT_TYPE2, MPI_COMM_WORLD);
 
-  TRACE_smpi_collective_out(rank, __FUNCTION__);
+  TRACE_smpi_comm_out(rank);
   log_timed_action (action, clock);
 }
 
@@ -622,22 +566,59 @@ static void action_gather(const char *const *action) {
   if(rank==root)
     recv = smpi_get_tmp_recvbuffer(recv_size*comm_size* MPI_CURRENT_TYPE2->size());
 
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type = TRACING_GATHER;
-  extra->send_size = send_size;
-  extra->recv_size = recv_size;
-  extra->root = root;
-  extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr);
-  extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, nullptr);
-
-  TRACE_smpi_collective_in(smpi_process()->index(), __FUNCTION__, extra);
+  TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::CollTIData("gather", root, -1.0, send_size, recv_size,
+                                                                        encode_datatype(MPI_CURRENT_TYPE),
+                                                                        encode_datatype(MPI_CURRENT_TYPE2)));
 
   Colls::gather(send, send_size, MPI_CURRENT_TYPE, recv, recv_size, MPI_CURRENT_TYPE2, root, MPI_COMM_WORLD);
 
-  TRACE_smpi_collective_out(smpi_process()->index(), __FUNCTION__);
+  TRACE_smpi_comm_out(smpi_process()->index());
   log_timed_action (action, clock);
 }
 
+static void action_scatter(const char* const* action)
+{
+  /* The structure of the scatter action for the rank 0 (total 4 processes) is the following:
+        0 gather 68 68 0 0 0
+      where:
+        1) 68 is the sendcounts
+        2) 68 is the recvcounts
+        3) 0 is the root node
+        4) 0 is the send datatype id, see decode_datatype()
+        5) 0 is the recv datatype id, see decode_datatype()
+  */
+  CHECK_ACTION_PARAMS(action, 2, 3)
+  double clock                   = smpi_process()->simulated_elapsed();
+  int comm_size                  = MPI_COMM_WORLD->size();
+  int send_size                  = parse_double(action[2]);
+  int recv_size                  = parse_double(action[3]);
+  MPI_Datatype MPI_CURRENT_TYPE2 = MPI_DEFAULT_TYPE;
+  if (action[4] && action[5]) {
+    MPI_CURRENT_TYPE  = decode_datatype(action[5]);
+    MPI_CURRENT_TYPE2 = decode_datatype(action[6]);
+  } else {
+    MPI_CURRENT_TYPE = MPI_DEFAULT_TYPE;
+  }
+  void* send = smpi_get_tmp_sendbuffer(send_size * MPI_CURRENT_TYPE->size());
+  void* recv = nullptr;
+  int root   = 0;
+  if (action[4])
+    root   = atoi(action[4]);
+  int rank = MPI_COMM_WORLD->rank();
+
+  if (rank == root)
+    recv = smpi_get_tmp_recvbuffer(recv_size * comm_size * MPI_CURRENT_TYPE2->size());
+
+  TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::CollTIData("gather", root, -1.0, send_size, recv_size,
+                                                                        encode_datatype(MPI_CURRENT_TYPE),
+                                                                        encode_datatype(MPI_CURRENT_TYPE2)));
+
+  Colls::scatter(send, send_size, MPI_CURRENT_TYPE, recv, recv_size, MPI_CURRENT_TYPE2, root, MPI_COMM_WORLD);
+
+  TRACE_smpi_comm_out(smpi_process()->index());
+  log_timed_action(action, clock);
+}
+
 static void action_gatherv(const char *const *action) {
   /* The structure of the gatherv action for the rank 0 (total 4 processes) is the following:
        0 gather 68 68 10 10 10 0 0 0
@@ -677,25 +658,74 @@ static void action_gatherv(const char *const *action) {
   if(rank==root)
     recv = smpi_get_tmp_recvbuffer(recv_sum* MPI_CURRENT_TYPE2->size());
 
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type = TRACING_GATHERV;
-  extra->send_size = send_size;
-  extra->recvcounts= xbt_new(int,comm_size);
-  for(int i=0; i< comm_size; i++)//copy data to avoid bad free
-    extra->recvcounts[i] = recvcounts[i];
-  extra->root = root;
-  extra->num_processes = comm_size;
-  extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr);
-  extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, nullptr);
+  std::vector<int>* trace_recvcounts = new std::vector<int>;
+  for (int i = 0; i < comm_size; i++) // copy data to avoid bad free
+    trace_recvcounts->push_back(recvcounts[i]);
 
-  TRACE_smpi_collective_in(smpi_process()->index(), __FUNCTION__, extra);
+  TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::VarCollTIData(
+                                             "gatherV", root, send_size, nullptr, -1, trace_recvcounts,
+                                             encode_datatype(MPI_CURRENT_TYPE), encode_datatype(MPI_CURRENT_TYPE2)));
 
   Colls::gatherv(send, send_size, MPI_CURRENT_TYPE, recv, recvcounts, disps, MPI_CURRENT_TYPE2, root, MPI_COMM_WORLD);
 
-  TRACE_smpi_collective_out(smpi_process()->index(), __FUNCTION__);
+  TRACE_smpi_comm_out(smpi_process()->index());
   log_timed_action (action, clock);
 }
 
+static void action_scatterv(const char* const* action)
+{
+  /* The structure of the scatterv action for the rank 0 (total 4 processes) is the following:
+       0 gather 68 10 10 10 68 0 0 0
+     where:
+       1) 68 10 10 10 is the sendcounts
+       2) 68 is the recvcount
+       3) 0 is the root node
+       4) 0 is the send datatype id, see decode_datatype()
+       5) 0 is the recv datatype id, see decode_datatype()
+  */
+  double clock  = smpi_process()->simulated_elapsed();
+  int comm_size = MPI_COMM_WORLD->size();
+  CHECK_ACTION_PARAMS(action, comm_size + 1, 2)
+  int recv_size = parse_double(action[2 + comm_size]);
+  int disps[comm_size];
+  int sendcounts[comm_size];
+  int send_sum = 0;
+
+  MPI_Datatype MPI_CURRENT_TYPE2 = MPI_DEFAULT_TYPE;
+  if (action[4 + comm_size] && action[5 + comm_size]) {
+    MPI_CURRENT_TYPE  = decode_datatype(action[4 + comm_size]);
+    MPI_CURRENT_TYPE2 = decode_datatype(action[5 + comm_size]);
+  } else
+    MPI_CURRENT_TYPE = MPI_DEFAULT_TYPE;
+
+  void* send = nullptr;
+  void* recv = smpi_get_tmp_recvbuffer(recv_size * MPI_CURRENT_TYPE->size());
+  for (int i = 0; i < comm_size; i++) {
+    sendcounts[i] = atoi(action[i + 2]);
+    send_sum += sendcounts[i];
+    disps[i] = 0;
+  }
+
+  int root = atoi(action[3 + comm_size]);
+  int rank = MPI_COMM_WORLD->rank();
+
+  if (rank == root)
+    send = smpi_get_tmp_sendbuffer(send_sum * MPI_CURRENT_TYPE2->size());
+
+  std::vector<int>* trace_sendcounts = new std::vector<int>;
+  for (int i = 0; i < comm_size; i++) // copy data to avoid bad free
+    trace_sendcounts->push_back(sendcounts[i]);
+
+  TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::VarCollTIData(
+                                             "gatherV", root, -1, trace_sendcounts, recv_size, nullptr,
+                                             encode_datatype(MPI_CURRENT_TYPE), encode_datatype(MPI_CURRENT_TYPE2)));
+
+  Colls::scatterv(send, sendcounts, disps, MPI_CURRENT_TYPE, recv, recv_size, MPI_CURRENT_TYPE2, root, MPI_COMM_WORLD);
+
+  TRACE_smpi_comm_out(smpi_process()->index());
+  log_timed_action(action, clock);
+}
+
 static void action_reducescatter(const char *const *action) {
  /* The structure of the reducescatter action for the rank 0 (total 4 processes) is the following:
       0 reduceScatter 275427 275427 275427 204020 11346849 0
@@ -711,6 +741,7 @@ static void action_reducescatter(const char *const *action) {
   int recvcounts[comm_size];
   int rank = smpi_process()->index();
   int size = 0;
+  std::vector<int>* trace_recvcounts = new std::vector<int>;
   if(action[3+comm_size])
     MPI_CURRENT_TYPE=decode_datatype(action[3+comm_size]);
   else
@@ -718,20 +749,14 @@ static void action_reducescatter(const char *const *action) {
 
   for(int i=0;i<comm_size;i++) {
     recvcounts[i] = atoi(action[i+2]);
+    trace_recvcounts->push_back(recvcounts[i]);
     size+=recvcounts[i];
   }
 
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type = TRACING_REDUCE_SCATTER;
-  extra->send_size = 0;
-  extra->recvcounts= xbt_new(int, comm_size);
-  for(int i=0; i< comm_size; i++)//copy data to avoid bad free
-    extra->recvcounts[i] = recvcounts[i];
-  extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr);
-  extra->comp_size = comp_size;
-  extra->num_processes = comm_size;
-
-  TRACE_smpi_collective_in(rank, __FUNCTION__,extra);
+  TRACE_smpi_comm_in(rank, __FUNCTION__,
+                     new simgrid::instr::VarCollTIData("reduceScatter", -1, 0, nullptr, -1, trace_recvcounts,
+                                                       std::to_string(comp_size), /* ugly hack to print comp_size */
+                                                       encode_datatype(MPI_CURRENT_TYPE)));
 
   void *sendbuf = smpi_get_tmp_sendbuffer(size* MPI_CURRENT_TYPE->size());
   void *recvbuf = smpi_get_tmp_recvbuffer(size* MPI_CURRENT_TYPE->size());
@@ -739,7 +764,7 @@ static void action_reducescatter(const char *const *action) {
   Colls::reduce_scatter(sendbuf, recvbuf, recvcounts, MPI_CURRENT_TYPE, MPI_OP_NULL, MPI_COMM_WORLD);
   smpi_execute_flops(comp_size);
 
-  TRACE_smpi_collective_out(rank, __FUNCTION__);
+  TRACE_smpi_comm_out(rank);
   log_timed_action (action, clock);
 }
 
@@ -769,19 +794,14 @@ static void action_allgather(const char *const *action) {
   void *recvbuf = smpi_get_tmp_recvbuffer(recvcount* MPI_CURRENT_TYPE2->size());
 
   int rank = smpi_process()->index();
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type = TRACING_ALLGATHER;
-  extra->send_size = sendcount;
-  extra->recv_size= recvcount;
-  extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr);
-  extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, nullptr);
-  extra->num_processes = MPI_COMM_WORLD->size();
 
-  TRACE_smpi_collective_in(rank, __FUNCTION__,extra);
+  TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::CollTIData("allGather", -1, -1.0, sendcount, recvcount,
+                                                                        encode_datatype(MPI_CURRENT_TYPE),
+                                                                        encode_datatype(MPI_CURRENT_TYPE2)));
 
   Colls::allgather(sendbuf, sendcount, MPI_CURRENT_TYPE, recvbuf, recvcount, MPI_CURRENT_TYPE2, MPI_COMM_WORLD);
 
-  TRACE_smpi_collective_out(rank, __FUNCTION__);
+  TRACE_smpi_comm_out(rank);
   log_timed_action (action, clock);
 }
 
@@ -819,22 +839,19 @@ static void action_allgatherv(const char *const *action) {
   void *recvbuf = smpi_get_tmp_recvbuffer(recv_sum* MPI_CURRENT_TYPE2->size());
 
   int rank = smpi_process()->index();
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type = TRACING_ALLGATHERV;
-  extra->send_size = sendcount;
-  extra->recvcounts= xbt_new(int, comm_size);
-  for(int i=0; i< comm_size; i++)//copy data to avoid bad free
-    extra->recvcounts[i] = recvcounts[i];
-  extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr);
-  extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, nullptr);
-  extra->num_processes = comm_size;
-
-  TRACE_smpi_collective_in(rank, __FUNCTION__,extra);
+
+  std::vector<int>* trace_recvcounts = new std::vector<int>;
+  for (int i = 0; i < comm_size; i++) // copy data to avoid bad free
+    trace_recvcounts->push_back(recvcounts[i]);
+
+  TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::VarCollTIData(
+                                             "allGatherV", -1, sendcount, nullptr, -1, trace_recvcounts,
+                                             encode_datatype(MPI_CURRENT_TYPE), encode_datatype(MPI_CURRENT_TYPE2)));
 
   Colls::allgatherv(sendbuf, sendcount, MPI_CURRENT_TYPE, recvbuf, recvcounts, disps, MPI_CURRENT_TYPE2,
                           MPI_COMM_WORLD);
 
-  TRACE_smpi_collective_out(rank, __FUNCTION__);
+  TRACE_smpi_comm_out(rank);
   log_timed_action (action, clock);
 }
 
@@ -851,8 +868,12 @@ static void action_allToAllv(const char *const *action) {
 
   int comm_size = MPI_COMM_WORLD->size();
   CHECK_ACTION_PARAMS(action, 2*comm_size+2, 2)
+  int send_size = 0;
+  int recv_size = 0;
   int sendcounts[comm_size];
+  std::vector<int>* trace_sendcounts = new std::vector<int>;
   int recvcounts[comm_size];
+  std::vector<int>* trace_recvcounts = new std::vector<int>;
   int senddisps[comm_size];
   int recvdisps[comm_size];
 
@@ -867,38 +888,29 @@ static void action_allToAllv(const char *const *action) {
   else
     MPI_CURRENT_TYPE=MPI_DEFAULT_TYPE;
 
+  int rank       = smpi_process()->index();
   void *sendbuf = smpi_get_tmp_sendbuffer(send_buf_size* MPI_CURRENT_TYPE->size());
   void *recvbuf  = smpi_get_tmp_recvbuffer(recv_buf_size* MPI_CURRENT_TYPE2->size());
 
   for(int i=0;i<comm_size;i++) {
     sendcounts[i] = atoi(action[i+3]);
+    trace_sendcounts->push_back(sendcounts[i]);
+    send_size += sendcounts[i];
     recvcounts[i] = atoi(action[i+4+comm_size]);
+    trace_recvcounts->push_back(recvcounts[i]);
+    recv_size += recvcounts[i];
     senddisps[i] = 0;
     recvdisps[i] = 0;
   }
 
-  int rank = smpi_process()->index();
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type = TRACING_ALLTOALLV;
-  extra->recvcounts= xbt_new(int, comm_size);
-  extra->sendcounts= xbt_new(int, comm_size);
-  extra->num_processes = comm_size;
-
-  for(int i=0; i< comm_size; i++){//copy data to avoid bad free
-    extra->send_size += sendcounts[i];
-    extra->sendcounts[i] = sendcounts[i];
-    extra->recv_size += recvcounts[i];
-    extra->recvcounts[i] = recvcounts[i];
-  }
-  extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr);
-  extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, nullptr);
-
-  TRACE_smpi_collective_in(rank, __FUNCTION__,extra);
+  TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::VarCollTIData(
+                                             "allToAllV", -1, send_size, trace_sendcounts, recv_size, trace_recvcounts,
+                                             encode_datatype(MPI_CURRENT_TYPE), encode_datatype(MPI_CURRENT_TYPE2)));
 
   Colls::alltoallv(sendbuf, sendcounts, senddisps, MPI_CURRENT_TYPE,recvbuf, recvcounts, recvdisps,
                          MPI_CURRENT_TYPE, MPI_COMM_WORLD);
 
-  TRACE_smpi_collective_out(rank, __FUNCTION__);
+  TRACE_smpi_comm_out(rank);
   log_timed_action (action, clock);
 }
 
@@ -914,10 +926,8 @@ void smpi_replay_init(int* argc, char*** argv)
   int rank = smpi_process()->index();
   TRACE_smpi_init(rank);
   TRACE_smpi_computing_init(rank);
-  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-  extra->type = TRACING_INIT;
-  TRACE_smpi_collective_in(rank, "smpi_replay_run_init", extra);
-  TRACE_smpi_collective_out(rank, "smpi_replay_run_init");
+  TRACE_smpi_comm_in(rank, "smpi_replay_run_init", new simgrid::instr::NoOpTIData("init"));
+  TRACE_smpi_comm_out(rank);
   xbt_replay_action_register("init",       simgrid::smpi::action_init);
   xbt_replay_action_register("finalize",   simgrid::smpi::action_finalize);
   xbt_replay_action_register("comm_size",  simgrid::smpi::action_comm_size);
@@ -937,7 +947,9 @@ void smpi_replay_init(int* argc, char*** argv)
   xbt_replay_action_register("allToAll",   simgrid::smpi::action_allToAll);
   xbt_replay_action_register("allToAllV",  simgrid::smpi::action_allToAllv);
   xbt_replay_action_register("gather",     simgrid::smpi::action_gather);
+  xbt_replay_action_register("scatter", simgrid::smpi::action_scatter);
   xbt_replay_action_register("gatherV",    simgrid::smpi::action_gatherv);
+  xbt_replay_action_register("scatterV", simgrid::smpi::action_scatterv);
   xbt_replay_action_register("allGather",  simgrid::smpi::action_allgather);
   xbt_replay_action_register("allGatherV", simgrid::smpi::action_allgatherv);
   xbt_replay_action_register("reduceScatter",  simgrid::smpi::action_reducescatter);
@@ -985,13 +997,11 @@ void smpi_replay_main(int* argc, char*** argv)
     xbt_free(recvbuffer);
   }
 
-  instr_extra_data extra_fin = xbt_new0(s_instr_extra_data_t,1);
-  extra_fin->type = TRACING_FINALIZE;
-  TRACE_smpi_collective_in(smpi_process()->index(), "smpi_replay_run_finalize", extra_fin);
+  TRACE_smpi_comm_in(smpi_process()->index(), "smpi_replay_run_finalize", new simgrid::instr::NoOpTIData("finalize"));
 
   smpi_process()->finalize();
 
-  TRACE_smpi_collective_out(smpi_process()->index(), "smpi_replay_run_finalize");
+  TRACE_smpi_comm_out(smpi_process()->index());
   TRACE_smpi_finalize(smpi_process()->index());
 }
 
index 8ed34e8..ce65e1b 100644 (file)
@@ -271,9 +271,9 @@ void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int
               "stop_offset (%zu) should be lower than its successor start offset (%zu)", stop_offset, shared_block_offsets[2*i_block+2]);
     size_t start_block_offset = ALIGN_UP(start_offset, smpi_shared_malloc_blocksize);
     size_t stop_block_offset = ALIGN_DOWN(stop_offset, smpi_shared_malloc_blocksize);
-    for (unsigned block_id=0, i = start_block_offset / smpi_shared_malloc_blocksize; i < stop_block_offset / smpi_shared_malloc_blocksize; block_id++, i++) {
-      XBT_DEBUG("\t\tglobal shared allocation, mmap block offset %u", block_id);
-      void* pos = (void*)((unsigned long)mem + i * smpi_shared_malloc_blocksize);
+    for (size_t offset = start_block_offset; offset < stop_block_offset; offset += smpi_shared_malloc_blocksize) {
+      XBT_DEBUG("\t\tglobal shared allocation, mmap block offset %zx", offset);
+      void* pos = (void*)((unsigned long)mem + offset);
       void* res = mmap(pos, smpi_shared_malloc_blocksize, PROT_READ | PROT_WRITE, mmap_flag,
                        huge_fd, 0);
       xbt_assert(res == pos, "Could not map folded virtual memory (%s). Do you perhaps need to increase the "
index fb514c3..e646ff7 100644 (file)
@@ -4,9 +4,9 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "smpi/smpi_utils.hpp"
-#include "xbt/sysdep.h"
+#include "smpi_utils.hpp"
 #include "xbt/log.h"
+#include "xbt/sysdep.h"
 #include <boost/tokenizer.hpp>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_utils, smpi, "Logging specific to SMPI (utils)");
index 2416e66..4998ea0 100644 (file)
@@ -263,7 +263,7 @@ void Comm::cleanup_smp(){
   if (non_uniform_map_ != nullptr)
     xbt_free(non_uniform_map_);
   if (leaders_map_ != nullptr)
-    xbt_free(leaders_map_);
+    delete[] leaders_map_;
 }
 
 void Comm::unref(Comm* comm){
@@ -332,11 +332,10 @@ void Comm::init_smp(){
   MPI_Comm comm_intra = new  Comm(group_intra, nullptr);
   leader=min_index;
 
-  int * leaders_map= static_cast<int*>(xbt_malloc0(sizeof(int)*comm_size));
-  int * leader_list= static_cast<int*>(xbt_malloc0(sizeof(int)*comm_size));
-  for(i=0; i<comm_size; i++){
-    leader_list[i] = -1;
-  }
+  int* leaders_map = new int[comm_size];
+  int* leader_list = new int[comm_size];
+  std::fill_n(leaders_map, comm_size, 0);
+  std::fill_n(leader_list, comm_size, -1);
 
   Coll_allgather_mpich::allgather(&leader, 1, MPI_INT , leaders_map, 1, MPI_INT, this);
 
@@ -347,7 +346,7 @@ void Comm::init_smp(){
   if(leaders_map_==nullptr){
     leaders_map_= leaders_map;
   }else{
-    xbt_free(leaders_map);
+    delete[] leaders_map;
   }
   int j=0;
   int leader_group_size = 0;
@@ -438,7 +437,7 @@ void Comm::init_smp(){
   }else{
     is_blocked_=global_blocked;
   }
-  xbt_free(leader_list);
+  delete[] leader_list;
 
   if(replaying)
     smpi_process()->set_replaying(true);
index b738b7b..4237217 100644 (file)
@@ -193,6 +193,11 @@ bool Datatype::is_valid(){
   return (flags_ & DT_FLAG_COMMITED);
 }
 
+bool Datatype::is_basic()
+{
+  return (flags_ & DT_FLAG_BASIC);
+}
+
 size_t Datatype::size(){
   return size_;
 }
@@ -278,9 +283,9 @@ int Datatype::copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
       if (not smpi_process()->replaying())
         memcpy(recvbuf, sendbuf, count);
     } else if (not(sendtype->flags() & DT_FLAG_DERIVED)) {
-      recvtype->unserialize( sendbuf, recvbuf, recvcount/recvtype->size(), MPI_REPLACE);
+      recvtype->unserialize(sendbuf, recvbuf, count / recvtype->size(), MPI_REPLACE);
     } else if (not(recvtype->flags() & DT_FLAG_DERIVED)) {
-      sendtype->serialize(sendbuf, recvbuf, sendcount/sendtype->size());
+      sendtype->serialize(sendbuf, recvbuf, count / sendtype->size());
     }else{
 
       void * buf_tmp = xbt_malloc(count);
index 2624ca3..b620511 100644 (file)
@@ -38,56 +38,6 @@ void Type_Contiguous::unserialize(void* contiguous_buf, void* noncontiguous_buf,
     op->apply( contiguous_buf_char, noncontiguous_buf_char, &n, old_type_);
 }
 
-
-Type_Vector::Type_Vector(int size,MPI_Aint lb, MPI_Aint ub, int flags, int count, int block_length, int stride, MPI_Datatype old_type): Datatype(size, lb, ub, flags), block_count_(count), block_length_(block_length),block_stride_(stride),  old_type_(old_type){
-  old_type_->ref();
-}
-
-Type_Vector::~Type_Vector(){
-  Datatype::unref(old_type_);
-}
-
-
-void Type_Vector::serialize( void* noncontiguous_buf, void *contiguous_buf,
-                            int count){
-  char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
-  char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf);
-
-  for (int i = 0; i < block_count_ * count; i++) {
-    if (not(old_type_->flags() & DT_FLAG_DERIVED))
-      memcpy(contiguous_buf_char, noncontiguous_buf_char, block_length_ * old_type_->size());
-    else
-      old_type_->serialize(noncontiguous_buf_char, contiguous_buf_char, block_length_);
-
-    contiguous_buf_char += block_length_*old_type_->size();
-    if((i+1)%block_count_ ==0)
-      noncontiguous_buf_char += block_length_*old_type_->get_extent();
-    else
-      noncontiguous_buf_char += block_stride_*old_type_->get_extent();
-  }
-}
-
-void Type_Vector::unserialize( void* contiguous_buf, void *noncontiguous_buf,
-                              int count, MPI_Op op){
-  char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
-  char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf);
-
-  for (int i = 0; i < block_count_ * count; i++) {
-    if (not(old_type_->flags() & DT_FLAG_DERIVED)) {
-      if(op != MPI_OP_NULL)
-        op->apply(contiguous_buf_char, noncontiguous_buf_char, &block_length_,
-          old_type_);
-    }else
-      old_type_->unserialize(contiguous_buf_char, noncontiguous_buf_char, block_length_, op);
-
-    contiguous_buf_char += block_length_*old_type_->size();
-    if((i+1)%block_count_ ==0)
-      noncontiguous_buf_char += block_length_*old_type_->get_extent();
-    else
-      noncontiguous_buf_char += block_stride_*old_type_->get_extent();
-  }
-}
-
 Type_Hvector::Type_Hvector(int size,MPI_Aint lb, MPI_Aint ub, int flags, int count, int block_length, MPI_Aint stride, MPI_Datatype old_type): Datatype(size, lb, ub, flags), block_count_(count), block_length_(block_length), block_stride_(stride), old_type_(old_type){
   old_type->ref();
 }
@@ -114,7 +64,6 @@ void Type_Hvector::serialize( void* noncontiguous_buf, void *contiguous_buf,
   }
 }
 
-
 void Type_Hvector::unserialize( void* contiguous_buf, void *noncontiguous_buf,
                               int count, MPI_Op op){
   char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
@@ -134,86 +83,40 @@ void Type_Hvector::unserialize( void* contiguous_buf, void *noncontiguous_buf,
   }
 }
 
-Type_Indexed::Type_Indexed(int size,MPI_Aint lb, MPI_Aint ub, int flags, int count, int* block_lengths, int* block_indices, MPI_Datatype old_type): Datatype(size, lb, ub, flags), block_count_(count), old_type_(old_type){
-  old_type->ref();
-  block_lengths_ = new int[count];
-  block_indices_ = new int[count];
-  for (int i = 0; i < count; i++) {
-    block_lengths_[i]=block_lengths[i];
-    block_indices_[i]=block_indices[i];
-  }
-}
-
-Type_Indexed::~Type_Indexed(){
-  Datatype::unref(old_type_);
-  if(refcount()==0){
-    delete[] block_lengths_;
-    delete[] block_indices_;
-  }
-}
-
-
-void Type_Indexed::serialize( void* noncontiguous_buf, void *contiguous_buf,
-                        int count){
-  char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
-  char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf)+block_indices_[0] * old_type_->size();
-  for (int j = 0; j < count; j++) {
-    for (int i = 0; i < block_count_; i++) {
-      if (not(old_type_->flags() & DT_FLAG_DERIVED))
-        memcpy(contiguous_buf_char, noncontiguous_buf_char, block_lengths_[i] * old_type_->size());
-      else
-        old_type_->serialize( noncontiguous_buf_char, contiguous_buf_char, block_lengths_[i]);
-
-      contiguous_buf_char += block_lengths_[i]*old_type_->size();
-      if (i<block_count_-1)
-        noncontiguous_buf_char =
-          static_cast<char*>(noncontiguous_buf) + block_indices_[i+1]*old_type_->get_extent();
-      else
-        noncontiguous_buf_char += block_lengths_[i]*old_type_->get_extent();
-    }
-    noncontiguous_buf=static_cast< void*>(noncontiguous_buf_char);
-  }
+Type_Vector::Type_Vector(int size, MPI_Aint lb, MPI_Aint ub, int flags, int count, int block_length, int stride,
+                         MPI_Datatype old_type)
+    : Type_Hvector(size, lb, ub, flags, count, block_length, stride * old_type->get_extent(), old_type)
+{
 }
 
-
-void Type_Indexed::unserialize( void* contiguous_buf, void *noncontiguous_buf,
-                      int count, MPI_Op op){
-  char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
-  char* noncontiguous_buf_char =
-    static_cast<char*>(noncontiguous_buf)+block_indices_[0]*old_type_->get_extent();
-  for (int j = 0; j < count; j++) {
-    for (int i = 0; i < block_count_; i++) {
-      if (not(old_type_->flags() & DT_FLAG_DERIVED)) {
-        if(op!=MPI_OP_NULL)
-          op->apply( contiguous_buf_char, noncontiguous_buf_char, &block_lengths_[i],
-                    old_type_);
-      }else
-        old_type_->unserialize( contiguous_buf_char,noncontiguous_buf_char,block_lengths_[i], op);
-
-      contiguous_buf_char += block_lengths_[i]*old_type_->size();
-      if (i<block_count_-1)
-        noncontiguous_buf_char =
-          static_cast<char*>(noncontiguous_buf) + block_indices_[i+1]*old_type_->get_extent();
-      else
-        noncontiguous_buf_char += block_lengths_[i]*old_type_->get_extent();
-    }
-    noncontiguous_buf=static_cast<void*>(noncontiguous_buf_char);
+Type_Hindexed::Type_Hindexed(int size, MPI_Aint lb, MPI_Aint ub, int flags, int count, int* block_lengths,
+                             MPI_Aint* block_indices, MPI_Datatype old_type)
+    : Datatype(size, lb, ub, flags), block_count_(count), old_type_(old_type)
+{
+  old_type_->ref();
+  block_lengths_ = new int[count];
+  block_indices_ = new MPI_Aint[count];
+  for (int i = 0; i < count; i++) {
+    block_lengths_[i] = block_lengths[i];
+    block_indices_[i] = block_indices[i];
   }
 }
 
-Type_Hindexed::Type_Hindexed(int size,MPI_Aint lb, MPI_Aint ub, int flags, int count, int* block_lengths, MPI_Aint* block_indices, MPI_Datatype old_type)
-: Datatype(size, lb, ub, flags), block_count_(count), old_type_(old_type)
+Type_Hindexed::Type_Hindexed(int size, MPI_Aint lb, MPI_Aint ub, int flags, int count, int* block_lengths,
+                             int* block_indices, MPI_Datatype old_type, MPI_Aint factor)
+    : Datatype(size, lb, ub, flags), block_count_(count), old_type_(old_type)
 {
   old_type_->ref();
   block_lengths_ = new int[count];
   block_indices_ = new MPI_Aint[count];
   for (int i = 0; i < count; i++) {
-    block_lengths_[i]=block_lengths[i];
-    block_indices_[i]=block_indices[i];
+    block_lengths_[i] = block_lengths[i];
+    block_indices_[i] = block_indices[i] * factor;
   }
 }
 
-    Type_Hindexed::~Type_Hindexed(){
+Type_Hindexed::~Type_Hindexed()
+{
   Datatype::unref(old_type_);
   if(refcount()==0){
     delete[] block_lengths_;
@@ -265,6 +168,12 @@ void Type_Hindexed::unserialize( void* contiguous_buf, void *noncontiguous_buf,
   }
 }
 
+Type_Indexed::Type_Indexed(int size, MPI_Aint lb, MPI_Aint ub, int flags, int count, int* block_lengths,
+                           int* block_indices, MPI_Datatype old_type)
+    : Type_Hindexed(size, lb, ub, flags, count, block_lengths, block_indices, old_type, old_type->get_extent())
+{
+}
+
 Type_Struct::Type_Struct(int size,MPI_Aint lb, MPI_Aint ub, int flags, int count, int* block_lengths, MPI_Aint* block_indices, MPI_Datatype* old_types): Datatype(size, lb, ub, flags), block_count_(count), block_lengths_(block_lengths), block_indices_(block_indices), old_types_(old_types){
   block_lengths_= new int[count];
   block_indices_= new MPI_Aint[count];
index d49c78a..4506de6 100644 (file)
@@ -234,6 +234,14 @@ int Group::excl(int n, int *ranks, MPI_Group * newgroup){
 
 }
 
+static bool is_rank_in_range(int rank, int first, int last)
+{
+  if (first < last)
+    return rank <= last;
+  else
+    return rank >= last;
+}
+
 int Group::range_incl(int n, int ranges[][3], MPI_Group * newgroup){
   int newsize = 0;
   for (int i = 0; i < n; i++) {
@@ -245,13 +253,8 @@ int Group::range_incl(int n, int ranges[][3], MPI_Group * newgroup){
         break;
       }
       rank += ranges[i][2]; /* Stride */
-      if (ranges[i][0] < ranges[i][1]) {
-        if (rank > ranges[i][1])
-          break;
-      } else {
-        if (rank < ranges[i][1])
-          break;
-      }
+      if (not is_rank_in_range(rank, ranges[i][0], ranges[i][1]))
+        break;
     }
   }
   *newgroup = new  Group(newsize);
@@ -267,13 +270,8 @@ int Group::range_incl(int n, int ranges[][3], MPI_Group * newgroup){
         break;
       }
       rank += ranges[i][2]; /* Stride */
-      if (ranges[i][0] < ranges[i][1]) {
-        if (rank > ranges[i][1])
-          break;
-      } else {
-        if (rank < ranges[i][1])
-          break;
-      }
+      if (not is_rank_in_range(rank, ranges[i][0], ranges[i][1]))
+        break;
     }
   }
   return MPI_SUCCESS;
@@ -290,13 +288,8 @@ int Group::range_excl(int n, int ranges[][3], MPI_Group * newgroup){
         break;
       }
       rank += ranges[i][2]; /* Stride */
-      if (ranges[i][0] < ranges[i][1]) {
-        if (rank > ranges[i][1])
-          break;
-      } else {
-        if (rank < ranges[i][1])
-          break;
-      }
+      if (not is_rank_in_range(rank, ranges[i][0], ranges[i][1]))
+        break;
     }
   }
   if (newsize == 0) {
@@ -317,13 +310,8 @@ int Group::range_excl(int n, int ranges[][3], MPI_Group * newgroup){
             break;
           }
           rank += ranges[i][2]; /* Stride */
-          if (ranges[i][0]<ranges[i][1]){
-            if (rank > ranges[i][1])
-              break;
-          }else{
-            if (rank < ranges[i][1])
-              break;
-          }
+          if (not is_rank_in_range(rank, ranges[i][0], ranges[i][1]))
+            break;
         }
       }
       if(add==1){
index 7a33dc2..3016954 100755 (executable)
@@ -44,7 +44,6 @@ Options:
   -trace-comment-file <file> # put file contents on the top of the trace file as comment
   -trace-grouped             # group MPI processes by location
   -trace-resource            # trace resource utilization
-  -trace-viva                # generate configuration for Viva's GraphView
   -trace-file <tracefile>    # name of the tracefile (simgrid_smpi.trace)
   -ext <value>               # additional parameter (reserved)
 
@@ -147,14 +146,7 @@ while true; do
             fi
            shift 2
             ;;
-        "-hostfile")
-           HOSTFILE="$2"
-            if [ ! -f "${HOSTFILE}" ]; then
-                die "the file '${HOSTFILE}' does not exist"
-            fi
-           shift 2
-            ;;
-        "-machinefile")
+        "-hostfile" | "-machinefile")
            HOSTFILE="$2"
             if [ ! -f "${HOSTFILE}" ]; then
                 die "the file '${HOSTFILE}' does not exist"
@@ -202,10 +194,6 @@ while true; do
             TRACE_RESOURCE="true"
             shift 1
             ;;
-        "-trace-viva")
-           TRACE_VIVA="true"
-           shift 1
-            ;;
         "-keep-temps")
            KEEP="true"
            SIMOPTS="$SIMOPTS --cfg=smpi/keep-temps:yes"
@@ -482,10 +470,6 @@ if [ -n "${TRACE_ACTIVE}" ]; then
     if [ -n "${TRACE_RESOURCE}" ]; then
         TRACEOPTIONS="${TRACEOPTIONS} --cfg=tracing/categorized:yes --cfg=tracing/uncategorized:yes"
     fi
-
-    if [ -n "${TRACE_VIVA}" ]; then
-        TRACEOPTIONS="${TRACEOPTIONS} --cfg=viva/categorized:smpi_cat.plist --cfg=viva/uncategorized:smpi_uncat.plist"
-    fi
 fi
 ##---------------------- end SMPI TRACING OPTIONS ---------------------------------
 
index d190065..4a85e3d 100644 (file)
@@ -27,37 +27,6 @@ FileImpl::FileImpl(sg_storage_t st, std::string path, std::string mount) : path_
   }
 }
 
-Action* FileImpl::read(sg_size_t size)
-{
-  XBT_DEBUG("READ %s on disk '%s'", getCname(), location_->getCname());
-  if (current_position_ + size > size_) {
-    if (current_position_ > size_) {
-      size = 0;
-    } else {
-      size = size_ - current_position_;
-    }
-    current_position_ = size_;
-  } else
-    current_position_ += size;
-
-  return location_->read(size);
-}
-
-Action* FileImpl::write(sg_size_t size)
-{
-  XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu'", getCname(), location_->getCname(), size, size_);
-
-  StorageAction* action = location_->write(size);
-  action->file_         = this;
-  /* Substract the part of the file that might disappear from the used sized on the storage element */
-  location_->usedSize_ -= (size_ - current_position_);
-  // If the storage is full before even starting to write
-  if (location_->usedSize_ >= location_->getSize()) {
-    action->setState(Action::State::failed);
-  }
-  return action;
-}
-
 int FileImpl::seek(sg_offset_t offset, int origin)
 {
   switch (origin) {
index acb8f27..b7acf36 100644 (file)
@@ -29,8 +29,6 @@ public:
   int seek(sg_offset_t offset, int origin);
   int unlink();
   void move(std::string fullpath);
-  Action* read(sg_size_t size);
-  Action* write(sg_size_t size);
 
 private:
   StorageImpl* location_;
index a4ddf1b..cc888dd 100644 (file)
@@ -7,6 +7,7 @@
 #include "StorageImpl.hpp"
 
 #include "surf_private.hpp"
+#include <algorithm>
 #include <boost/algorithm/string.hpp>
 #include <boost/algorithm/string/join.hpp>
 #include <boost/algorithm/string/split.hpp>
@@ -60,14 +61,14 @@ StorageModel::~StorageModel()
 
 StorageImpl::StorageImpl(Model* model, std::string name, lmm_system_t maxminSystem, double bread, double bwrite,
                          std::string type_id, std::string content_name, sg_size_t size, std::string attach)
-    : Resource(model, name.c_str(), lmm_constraint_new(maxminSystem, this, MAX(bread, bwrite)))
+    : Resource(model, name.c_str(), lmm_constraint_new(maxminSystem, this, std::max(bread, bwrite)))
     , piface_(this)
     , typeId_(type_id)
     , size_(size)
     , attach_(attach)
 {
   content_ = parseContent(content_name);
-  turnOn();
+  StorageImpl::turnOn();
   XBT_DEBUG("Create resource with Bread '%f' Bwrite '%f' and Size '%llu'", bread, bwrite, size);
   constraintRead_  = lmm_constraint_new(maxminSystem, this, bread);
   constraintWrite_ = lmm_constraint_new(maxminSystem, this, bwrite);
index b5f52e1..2c45054 100644 (file)
@@ -205,7 +205,6 @@ public:
 
   e_surf_action_storage_type_t type_;
   StorageImpl* storage_;
-  FileImpl* file_ = nullptr;
 };
 
 class StorageType {
index 40d145e..99707a2 100644 (file)
@@ -8,6 +8,7 @@
 #include "cpu_ti.hpp"
 #include "maxmin_private.hpp"
 #include "simgrid/sg_config.h"
+#include <algorithm>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu_cas, surf_cpu, "Logging specific to the SURF CPU IMPROVED module");
 
@@ -55,8 +56,6 @@ CpuCas01Model::CpuCas01Model() : simgrid::surf::CpuModel()
   maxminSystem_ = lmm_system_new(selectiveUpdate_);
 
   if (getUpdateMechanism() == UM_LAZY) {
-    actionHeap_ = xbt_heap_new(8, nullptr);
-    xbt_heap_set_update_callback(actionHeap_,  surf_action_lmm_update_index_heap);
     modifiedSet_ = new ActionLmmList();
     maxminSystem_->keep_track = modifiedSet_;
   }
@@ -66,7 +65,6 @@ CpuCas01Model::~CpuCas01Model()
 {
   lmm_system_free(maxminSystem_);
   maxminSystem_ = nullptr;
-  xbt_heap_free(actionHeap_);
   delete modifiedSet_;
 
   surf_cpu_model_pm = nullptr;
@@ -176,7 +174,7 @@ CpuAction* CpuCas01::execution_start(double size, int requestedCores)
 CpuAction *CpuCas01::sleep(double duration)
 {
   if (duration > 0)
-    duration = MAX(duration, sg_surf_precision);
+    duration = std::max(duration, sg_surf_precision);
 
   XBT_IN("(%s,%g)", getCname(), duration);
   CpuCas01Action* action = new CpuCas01Action(model(), 1.0, isOff(), speed_.scale * speed_.peak, constraint());
@@ -213,7 +211,6 @@ CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double sp
     , requestedCore_(requestedCore)
 {
   if (model->getUpdateMechanism() == UM_LAZY) {
-    updateIndexHeap(-1);
     refreshLastUpdate();
     setLastValue(0.0);
   }
index 044d58f..554c871 100644 (file)
@@ -23,10 +23,9 @@ namespace surf {
 
 void CpuModel::updateActionsStateLazy(double now, double /*delta*/)
 {
-  while ((xbt_heap_size(getActionHeap()) > 0)
-         && (double_equals(xbt_heap_maxkey(getActionHeap()), now, sg_surf_precision))) {
+  while (not actionHeapIsEmpty() && double_equals(actionHeapTopDate(), now, sg_surf_precision)) {
 
-    CpuAction *action = static_cast<CpuAction*>(xbt_heap_pop(getActionHeap()));
+    CpuAction* action = static_cast<CpuAction*>(actionHeapPop());
     XBT_CDEBUG(surf_kernel, "Something happened to action %p", action);
     if (TRACE_is_enabled()) {
       Cpu *cpu = static_cast<Cpu*>(lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0)));
index d899ed0..942cfd2 100644 (file)
@@ -5,8 +5,8 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "cpu_ti.hpp"
-#include "xbt/heap.h"
 #include "src/surf/trace_mgr.hpp"
+#include <algorithm>
 
 #ifndef SURF_MODEL_CPUTI_H_
 #define SURF_MODEL_CPUTI_H_
@@ -16,12 +16,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu_ti, surf_cpu, "Logging specific to the
 namespace simgrid {
 namespace surf {
 
-static inline
-void cpu_ti_action_update_index_heap(void *action, int i)
-{
-  (static_cast<simgrid::surf::CpuTiAction*>(action))->updateIndexHeap(i);
-}
-
 /*********
  * Trace *
  *********/
@@ -337,9 +331,6 @@ CpuTiModel::CpuTiModel() : CpuModel()
   runningActionSetThatDoesNotNeedBeingChecked_ = new ActionList();
 
   modifiedCpu_ = new CpuTiList();
-
-  tiActionHeap_ = xbt_heap_new(8, nullptr);
-  xbt_heap_set_update_callback(tiActionHeap_, cpu_ti_action_update_index_heap);
 }
 
 CpuTiModel::~CpuTiModel()
@@ -347,7 +338,6 @@ CpuTiModel::~CpuTiModel()
   surf_cpu_model_pm = nullptr;
   delete runningActionSetThatDoesNotNeedBeingChecked_;
   delete modifiedCpu_;
-  xbt_heap_free(tiActionHeap_);
 }
 
 Cpu *CpuTiModel::createCpu(simgrid::s4u::Host *host, std::vector<double>* speedPerPstate, int core)
@@ -360,15 +350,17 @@ double CpuTiModel::nextOccuringEvent(double now)
   double min_action_duration = -1;
 
 /* iterates over modified cpus to update share resources */
-  for(CpuTiList::iterator it(modifiedCpu_->begin()), itend(modifiedCpu_->end()) ; it != itend ;) {
+  CpuTiList::iterator itend(modifiedCpu_->end());
+  CpuTiList::iterator it(modifiedCpu_->begin());
+  while (it != itend) {
     CpuTi *ti = &*it;
     ++it;
     ti->updateActionsFinishTime(now);
   }
 
 /* get the min next event if heap not empty */
-  if (xbt_heap_size(tiActionHeap_) > 0)
-    min_action_duration = xbt_heap_maxkey(tiActionHeap_) - now;
+  if (not actionHeapIsEmpty())
+    min_action_duration = actionHeapTopDate() - now;
 
   XBT_DEBUG("Share resources, min next event date: %f", min_action_duration);
 
@@ -377,8 +369,8 @@ double CpuTiModel::nextOccuringEvent(double now)
 
 void CpuTiModel::updateActionsState(double now, double /*delta*/)
 {
-  while ((xbt_heap_size(tiActionHeap_) > 0) && (xbt_heap_maxkey(tiActionHeap_) <= now)) {
-    CpuTiAction *action = static_cast<CpuTiAction*>(xbt_heap_pop(tiActionHeap_));
+  while (not actionHeapIsEmpty() && actionHeapTopDate() <= now) {
+    CpuTiAction* action = static_cast<CpuTiAction*>(actionHeapPop());
     XBT_DEBUG("Action %p: finish", action);
     action->finish(Action::State::done);
     /* set the remains to 0 due to precision problems when updating the remaining amount */
@@ -460,20 +452,15 @@ void CpuTi::apply_event(tmgr_trace_event_t event, double value)
       double date = surf_get_clock();
 
       /* put all action running on cpu to failed */
-      for(ActionTiList::iterator it(actionSet_->begin()), itend(actionSet_->end()); it != itend ; ++it) {
-
+      ActionTiList::iterator itend(actionSet_->end());
+      for (ActionTiList::iterator it(actionSet_->begin()); it != itend; ++it) {
         CpuTiAction *action = &*it;
         if (action->getState() == Action::State::running
          || action->getState() == Action::State::ready
          || action->getState() == Action::State::not_in_the_system) {
           action->setFinishTime(date);
           action->setState(Action::State::failed);
-          if (action->getIndexHeap() >= 0) {
-            CpuTiAction* heap_act = static_cast<CpuTiAction*>(
-                xbt_heap_remove(static_cast<CpuTiModel*>(model())->tiActionHeap_, action->getIndexHeap()));
-            if (heap_act != action)
-              DIE_IMPOSSIBLE;
-          }
+          action->heapRemove(model()->getActionHeap());
         }
       }
     }
@@ -493,7 +480,8 @@ void CpuTi::updateActionsFinishTime(double now)
   /* update remaining amount of actions */
   updateRemainingAmount(now);
 
-  for(ActionTiList::iterator it(actionSet_->begin()), itend(actionSet_->end()) ; it != itend ; ++it) {
+  ActionTiList::iterator itend(actionSet_->end());
+  for (ActionTiList::iterator it(actionSet_->begin()); it != itend; ++it) {
     action = &*it;
     /* action not running, skip it */
     if (action->getStateSet() != surf_cpu_model_pm->getRunningActionSet())
@@ -511,7 +499,7 @@ void CpuTi::updateActionsFinishTime(double now)
   }
   sumPriority_ = sum_priority;
 
-  for(ActionTiList::iterator it(actionSet_->begin()), itend(actionSet_->end()) ; it != itend ; ++it) {
+  for (ActionTiList::iterator it(actionSet_->begin()); it != itend; ++it) {
     action = &*it;
     double min_finish = -1;
     /* action not running, skip it */
@@ -538,15 +526,10 @@ void CpuTi::updateActionsFinishTime(double now)
         min_finish = action->getStartTime() + action->getMaxDuration();
     }
     /* add in action heap */
-    XBT_DEBUG("action(%p) index %d", action, action->getIndexHeap());
-    if (action->getIndexHeap() >= 0) {
-      CpuTiAction* heap_act = static_cast<CpuTiAction*>(
-          xbt_heap_remove(static_cast<CpuTiModel*>(model())->tiActionHeap_, action->getIndexHeap()));
-      if (heap_act != action)
-        DIE_IMPOSSIBLE;
-    }
     if (min_finish > NO_MAX_DURATION)
-      xbt_heap_push(static_cast<CpuTiModel*>(model())->tiActionHeap_, action, min_finish);
+      action->heapUpdate(model()->getActionHeap(), min_finish, NOTSET);
+    else
+      action->heapRemove(model()->getActionHeap());
 
     XBT_DEBUG("Update finish time: Cpu(%s) Action: %p, Start Time: %f Finish Time: %f Max duration %f", getCname(),
               action, action->getStartTime(), action->getFinishTime(), action->getMaxDuration());
@@ -577,8 +560,8 @@ void CpuTi::updateRemainingAmount(double now)
   /* compute the integration area */
   double area_total = speedIntegratedTrace_->integrate(lastUpdate_, now) * speed_.peak;
   XBT_DEBUG("Flops total: %f, Last update %f", area_total, lastUpdate_);
-
-  for(ActionTiList::iterator it(actionSet_->begin()), itend(actionSet_->end()) ; it != itend ; ++it) {
+  ActionTiList::iterator itend(actionSet_->end());
+  for (ActionTiList::iterator it(actionSet_->begin()); it != itend; ++it) {
     CpuTiAction *action = &*it;
     /* action not running, skip it */
     if (action->getStateSet() != model()->getRunningActionSet())
@@ -622,7 +605,7 @@ CpuAction *CpuTi::execution_start(double size)
 CpuAction *CpuTi::sleep(double duration)
 {
   if (duration > 0)
-    duration = MAX(duration, sg_surf_precision);
+    duration = std::max(duration, sg_surf_precision);
 
   XBT_IN("(%s,%g)", getCname(), duration);
   CpuTiAction* action = new CpuTiAction(static_cast<CpuTiModel*>(model()), 1.0, isOff(), this);
@@ -664,7 +647,6 @@ CpuTiAction::CpuTiAction(CpuTiModel *model_, double cost, bool failed, CpuTi *cp
  : CpuAction(model_, cost, failed)
  , cpu_(cpu)
 {
-  updateIndexHeap(-1);
   cpu_->modified(true);
 }
 
@@ -684,7 +666,7 @@ int CpuTiAction::unref()
     if (action_ti_hook.is_linked())
       cpu_->actionSet_->erase(cpu_->actionSet_->iterator_to(*this));
     /* remove from heap */
-    xbt_heap_remove(static_cast<CpuTiModel*>(getModel())->tiActionHeap_, getIndexHeap());
+    heapRemove(getModel()->getActionHeap());
     cpu_->modified(true);
     delete this;
     return 1;
@@ -695,7 +677,7 @@ int CpuTiAction::unref()
 void CpuTiAction::cancel()
 {
   this->setState(Action::State::failed);
-  xbt_heap_remove(getModel()->getActionHeap(), getIndexHeap());
+  heapRemove(getModel()->getActionHeap());
   cpu_->modified(true);
 }
 
@@ -704,7 +686,7 @@ void CpuTiAction::suspend()
   XBT_IN("(%p)", this);
   if (suspended_ != 2) {
     suspended_ = 1;
-    xbt_heap_remove(getModel()->getActionHeap(), getIndexHeap());
+    heapRemove(getModel()->getActionHeap());
     cpu_->modified(true);
   }
   XBT_OUT();
@@ -734,13 +716,8 @@ void CpuTiAction::setMaxDuration(double duration)
   else
     min_finish = getFinishTime();
 
-/* add in action heap */
-  if (getIndexHeap() >= 0) {
-    CpuTiAction* heap_act = static_cast<CpuTiAction*>(xbt_heap_remove(getModel()->getActionHeap(), getIndexHeap()));
-    if (heap_act != this)
-      DIE_IMPOSSIBLE;
-  }
-  xbt_heap_push(getModel()->getActionHeap(), this, min_finish);
+  /* add in action heap */
+  heapUpdate(getModel()->getActionHeap(), min_finish, NOTSET);
 
   XBT_OUT();
 }
index ebf4a4a..1789127 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2015. The SimGrid Team.
+/* Copyright (c) 2013-2017. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -149,7 +149,6 @@ public:
 
   ActionList *runningActionSetThatDoesNotNeedBeingChecked_;
   CpuTiList *modifiedCpu_;
-  xbt_heap_t tiActionHeap_;
 };
 
 }
index 2a0fcb7..84be37f 100644 (file)
@@ -7,6 +7,7 @@
 #include "maxmin_private.hpp"
 #include "xbt/log.h"
 #include "xbt/sysdep.h"
+#include <algorithm>
 #include <cfloat>
 #include <cmath>
 #include <cstdlib>
@@ -43,15 +44,12 @@ void bottleneck_solve(lmm_system_t sys)
   XBT_DEBUG("Variable set : %d", xbt_swag_size(var_list));
   xbt_swag_foreach(_var, var_list) {
     var = static_cast<lmm_variable_t>(_var);
-    int nb = 0;
     var->value = 0.0;
     XBT_DEBUG("Handling variable %p", var);
     xbt_swag_insert(var, &(sys->saturated_variable_set));
-    for (int i = 0; i < var->cnsts_number; i++) {
-      if (var->cnsts[i].consumption_weight == 0.0)
-        nb++;
-    }
-    if ((nb == var->cnsts_number) && (var->sharing_weight > 0.0)) {
+    auto weighted = std::find_if(begin(var->cnsts), end(var->cnsts),
+                                 [](s_lmm_element_t const& x) { return x.consumption_weight != 0.0; });
+    if (weighted == end(var->cnsts) && var->sharing_weight > 0.0) {
       XBT_DEBUG("Err, finally, there is no need to take care of variable %p", var);
       xbt_swag_remove(var, &(sys->saturated_variable_set));
       var->value = 1.0;
@@ -115,13 +113,12 @@ void bottleneck_solve(lmm_system_t sys)
     xbt_swag_foreach_safe(_var, _var_next, var_list) {
       var = static_cast<lmm_variable_t>(_var);
       double min_inc = DBL_MAX;
-      for (int i = 0; i < var->cnsts_number; i++) {
-        lmm_element_t elm = &var->cnsts[i];
-        if (elm->consumption_weight > 0)
-          min_inc = MIN(min_inc, elm->constraint->usage / elm->consumption_weight);
+      for (s_lmm_element_t const& elm : var->cnsts) {
+        if (elm.consumption_weight > 0)
+          min_inc = std::min(min_inc, elm.constraint->usage / elm.consumption_weight);
       }
       if (var->bound > 0)
-        min_inc = MIN(min_inc, var->bound - var->value);
+        min_inc = std::min(min_inc, var->bound - var->value);
       var->mu = min_inc;
       XBT_DEBUG("Updating variable %p maximum increment: %g", var, var->mu);
       var->value += var->mu;
@@ -144,7 +141,7 @@ void bottleneck_solve(lmm_system_t sys)
         } else {
           XBT_DEBUG("\tNon-Shared variable. Update constraint usage of %p (%g) with variable %p by %g",
               cnst, cnst->usage, elem->variable, elem->variable->mu);
-          cnst->usage = MIN(cnst->usage, elem->consumption_weight * elem->variable->mu);
+          cnst->usage = std::min(cnst->usage, elem->consumption_weight * elem->variable->mu);
         }
       }
       if (not cnst->sharing_policy) {
index 91073c0..447273b 100644 (file)
@@ -11,6 +11,7 @@
 #include "xbt/sysdep.h"
 #include "maxmin_private.hpp"
 
+#include <algorithm>
 #include <cstdlib>
 #ifndef MATH
 #include <cmath>
@@ -86,8 +87,8 @@ static double new_value(lmm_variable_t var)
 {
   double tmp = 0;
 
-  for (int i = 0; i < var->cnsts_number; i++) {
-    tmp += (var->cnsts[i].constraint)->lambda;
+  for (s_lmm_element_t const& elem : var->cnsts) {
+    tmp += elem.constraint->lambda;
   }
   if (var->bound > 0)
     tmp += var->mu;
@@ -101,8 +102,8 @@ static double new_mu(lmm_variable_t var)
   double mu_i = 0.0;
   double sigma_i = 0.0;
 
-  for (int j = 0; j < var->cnsts_number; j++) {
-    sigma_i += (var->cnsts[j].constraint)->lambda;
+  for (s_lmm_element_t const& elem : var->cnsts) {
+    sigma_i += elem.constraint->lambda;
   }
   mu_i = var->func_fp(var, var->bound) - sigma_i;
   if (mu_i < 0.0)
@@ -126,8 +127,8 @@ static double dual_objective(xbt_swag_t var_list, xbt_swag_t cnst_list)
     if (not var->sharing_weight)
       break;
 
-    for (int j = 0; j < var->cnsts_number; j++)
-      sigma_i += (var->cnsts[j].constraint)->lambda;
+    for (s_lmm_element_t const& elem : var->cnsts)
+      sigma_i += elem.constraint->lambda;
 
     if (var->bound > 0)
       sigma_i += var->mu;
@@ -200,30 +201,27 @@ void lagrange_solve(lmm_system_t sys)
   var_list = &(sys->variable_set);
   i = 0;
   xbt_swag_foreach(_var, var_list) {
-  var = static_cast<lmm_variable_t>(_var);
-  if (not var->sharing_weight)
-    var->value = 0.0;
-  else {
-    int nb = 0;
-    if (var->bound < 0.0) {
-      XBT_DEBUG("#### NOTE var(%d) is a boundless variable", i);
-      var->mu    = -1.0;
-      var->value = new_value(var);
-    } else {
-      var->mu     = 1.0;
-      var->new_mu = 2.0;
-      var->value  = new_value(var);
-    }
-    XBT_DEBUG("#### var(%p) ->weight :  %e", var, var->sharing_weight);
-    XBT_DEBUG("#### var(%p) ->mu :  %e", var, var->mu);
-    XBT_DEBUG("#### var(%p) ->weight: %e", var, var->sharing_weight);
-    XBT_DEBUG("#### var(%p) ->bound: %e", var, var->bound);
-    for (i = 0; i < var->cnsts_number; i++) {
-      if (var->cnsts[i].consumption_weight == 0.0)
-        nb++;
-    }
-    if (nb == var->cnsts_number)
-      var->value = 1.0;
+    var = static_cast<lmm_variable_t>(_var);
+    if (not var->sharing_weight)
+      var->value = 0.0;
+    else {
+      if (var->bound < 0.0) {
+        XBT_DEBUG("#### NOTE var(%d) is a boundless variable", i);
+        var->mu    = -1.0;
+        var->value = new_value(var);
+      } else {
+        var->mu     = 1.0;
+        var->new_mu = 2.0;
+        var->value  = new_value(var);
+      }
+      XBT_DEBUG("#### var(%p) ->weight :  %e", var, var->sharing_weight);
+      XBT_DEBUG("#### var(%p) ->mu :  %e", var, var->mu);
+      XBT_DEBUG("#### var(%p) ->weight: %e", var, var->sharing_weight);
+      XBT_DEBUG("#### var(%p) ->bound: %e", var, var->bound);
+      auto weighted = std::find_if(begin(var->cnsts), end(var->cnsts),
+                                   [](s_lmm_element_t const& x) { return x.consumption_weight != 0.0; });
+      if (weighted == end(var->cnsts))
+        var->value = 1.0;
     }
   }
 
@@ -278,7 +276,7 @@ void lagrange_solve(lmm_system_t sys)
       else {
         tmp = new_value(var);
 
-        overall_modification = MAX(overall_modification, fabs(var->value - tmp));
+        overall_modification = std::max(overall_modification, fabs(var->value - tmp));
 
         var->value = tmp;
         XBT_DEBUG("New value of var (%p)  = %e, overall_modification = %e", var, var->value, overall_modification);
@@ -435,8 +433,8 @@ static double partial_diff_lambda(double lambda, void *param_cnst)
     double sigma_i = 0.0;
 
     // Compute sigma_i
-    for (int j = 0; j < var->cnsts_number; j++) {
-      sigma_i += (var->cnsts[j].constraint)->lambda;
+    for (s_lmm_element_t const& elem : var->cnsts) {
+      sigma_i += elem.constraint->lambda;
     }
 
     //add mu_i if this flow has a RTT constraint associated
index 72d2005..e9fd4ee 100644 (file)
@@ -6,22 +6,20 @@
 /* \file callbacks.h */
 
 #include "maxmin_private.hpp"
+#include "xbt/backtrace.hpp"
 #include "xbt/log.h"
 #include "xbt/mallocator.h"
 #include "xbt/sysdep.h"
+#include <algorithm>
 #include <cmath>
 #include <cstdlib>
 #include <cxxabi.h>
 #include <limits>
+#include <vector>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_maxmin, surf, "Logging specific to SURF (maxmin)");
 
-struct s_dyn_light_t {
-  int *data;
-  int pos;
-  int size;
-};
-typedef s_dyn_light_t* dyn_light_t;
+typedef std::vector<int> dyn_light_t;
 
 double sg_maxmin_precision = 0.00001; /* Change this with --cfg=maxmin/precision:VALUE */
 double sg_surf_precision   = 0.00001; /* Change this with --cfg=surf/precision:VALUE */
@@ -44,7 +42,8 @@ static void lmm_disable_var(lmm_system_t sys, lmm_variable_t var);
 static int lmm_concurrency_slack(lmm_constraint_t cnstr);
 static int lmm_cnstrs_min_concurrency_slack(lmm_variable_t var);
 
-inline int lmm_element_concurrency(lmm_element_t elem) {
+static inline int lmm_element_concurrency(lmm_element_t elem)
+{
   //Ignore element with weight less than one (e.g. cross-traffic)
   return (elem->consumption_weight >= 1) ? 1 : 0;
   //There are other alternatives, but they will change the behaviour of the model..
@@ -55,12 +54,14 @@ inline int lmm_element_concurrency(lmm_element_t elem) {
   //return (int)ceil(elem->weight);//Include element as the rounded-up integer value of the element weight
 }
 
-inline void lmm_decrease_concurrency(lmm_element_t elem) {
+static inline void lmm_decrease_concurrency(lmm_element_t elem)
+{
   xbt_assert(elem->constraint->concurrency_current>=lmm_element_concurrency(elem));
   elem->constraint->concurrency_current-=lmm_element_concurrency(elem);
 }
 
-inline void lmm_increase_concurrency(lmm_element_t elem) {
+static inline void lmm_increase_concurrency(lmm_element_t elem)
+{
   elem->constraint->concurrency_current+= lmm_element_concurrency(elem);
 
   lmm_constraint_t cnstr=elem->constraint;
@@ -110,7 +111,7 @@ static void lmm_check_concurrency(lmm_system_t sys)
   {
     lmm_variable_t var = (lmm_variable_t)varIt;
 
-    if (not var->cnsts_number)
+    if (var->cnsts.empty())
       continue;
 
     lmm_element_t elem     = &var->cnsts[0];
@@ -118,62 +119,54 @@ static void lmm_check_concurrency(lmm_system_t sys)
     int belong_to_disabled = xbt_swag_belongs(elem, &(elem->constraint->disabled_element_set));
     int belong_to_active   = xbt_swag_belongs(elem, &(elem->constraint->active_element_set));
 
-    for (int i = 1; i < var->cnsts_number; i++) {
-      elem = &var->cnsts[i];
-      xbt_assert(belong_to_enabled == xbt_swag_belongs(elem, &(elem->constraint->enabled_element_set)),
+    for (s_lmm_element_t const& elem : var->cnsts) {
+      xbt_assert(belong_to_enabled == xbt_swag_belongs(&elem, &(elem.constraint->enabled_element_set)),
                  "Variable inconsistency (1): enabled_element_set");
-      xbt_assert(belong_to_disabled == xbt_swag_belongs(elem, &(elem->constraint->disabled_element_set)),
+      xbt_assert(belong_to_disabled == xbt_swag_belongs(&elem, &(elem.constraint->disabled_element_set)),
                  "Variable inconsistency (2): disabled_element_set");
-      xbt_assert(belong_to_active == xbt_swag_belongs(elem, &(elem->constraint->active_element_set)),
+      xbt_assert(belong_to_active == xbt_swag_belongs(&elem, &(elem.constraint->active_element_set)),
                  "Variable inconsistency (3): active_element_set");
     }
   }
 }
 
-static inline void lmm_variable_remove(lmm_system_t sys, lmm_variable_t var)
+static void lmm_var_free(lmm_system_t sys, lmm_variable_t var)
 {
   XBT_IN("(sys=%p, var=%p)", sys, var);
   sys->modified = 1;
 
   // TODOLATER Can do better than that by leaving only the variable in only one enabled_element_set, call
   // lmm_update_modified_set, and then remove it..
-  if (var->cnsts_number)
+  if (not var->cnsts.empty())
     lmm_update_modified_set(sys, var->cnsts[0].constraint);
 
-  for (int i = 0; i < var->cnsts_number; i++) {
-    lmm_element_t elem = &var->cnsts[i];
+  for (s_lmm_element_t& elem : var->cnsts) {
     if (var->sharing_weight > 0)
-      lmm_decrease_concurrency(elem);
-    xbt_swag_remove(elem, &(elem->constraint->enabled_element_set));
-    xbt_swag_remove(elem, &(elem->constraint->disabled_element_set));
-    xbt_swag_remove(elem, &(elem->constraint->active_element_set));
-    int nelements = xbt_swag_size(&(elem->constraint->enabled_element_set)) +
-                    xbt_swag_size(&(elem->constraint->disabled_element_set));
+      lmm_decrease_concurrency(&elem);
+    xbt_swag_remove(&elem, &(elem.constraint->enabled_element_set));
+    xbt_swag_remove(&elem, &(elem.constraint->disabled_element_set));
+    xbt_swag_remove(&elem, &(elem.constraint->active_element_set));
+    int nelements = xbt_swag_size(&(elem.constraint->enabled_element_set)) +
+                    xbt_swag_size(&(elem.constraint->disabled_element_set));
     if (nelements == 0)
-      make_constraint_inactive(sys, elem->constraint);
+      make_constraint_inactive(sys, elem.constraint);
     else
-      lmm_on_disabled_var(sys, elem->constraint);
+      lmm_on_disabled_var(sys, elem.constraint);
   }
 
   // Check if we can enable new variables going through the constraints where var was.
-  // Do it after removing all elements, so he first disabled variables get priority over those with smaller requirement
-  for (int i = 0; i < var->cnsts_number; i++) {
-    lmm_element_t elem = &var->cnsts[i];
-    if (xbt_swag_size(&(elem->constraint->disabled_element_set)))
-      lmm_on_disabled_var(sys, elem->constraint);
+  // Do it after removing all elements, so the first disabled variables get priority over those with smaller requirement
+  for (s_lmm_element_t& elem : var->cnsts) {
+    if (xbt_swag_size(&(elem.constraint->disabled_element_set)))
+      lmm_on_disabled_var(sys, elem.constraint);
   }
 
-  var->cnsts_number = 0;
+  var->cnsts.clear();
 
   lmm_check_concurrency(sys);
 
-  XBT_OUT();
-}
-
-static void lmm_var_free(lmm_system_t sys, lmm_variable_t var)
-{
-  lmm_variable_remove(sys, var);
   xbt_mallocator_release(sys->variable_mallocator, var);
+  XBT_OUT();
 }
 
 lmm_system_t lmm_system_new(bool selective_update)
@@ -181,7 +174,7 @@ lmm_system_t lmm_system_new(bool selective_update)
   s_lmm_variable_t var;
   s_lmm_constraint_t cnst;
 
-  lmm_system_t l = xbt_new0(s_lmm_system_t, 1);
+  lmm_system_t l = new s_lmm_system_t();
 
   l->modified = 0;
   l->selective_update_active = selective_update;
@@ -217,25 +210,22 @@ void lmm_system_free(lmm_system_t sys)
     return;
 
   while ((var = (lmm_variable_t) extract_variable(sys))) {
-    int status;
-    char* demangled = abi::__cxa_demangle(typeid(*var->id).name(), 0, 0, &status);
-
-    XBT_WARN("Probable bug: a %s variable (#%d) not removed before the LMM system destruction.", demangled,
+    auto demangled = simgrid::xbt::demangle(typeid(*var->id).name());
+    XBT_WARN("Probable bug: a %s variable (#%d) not removed before the LMM system destruction.", demangled.get(),
              var->id_int);
-    xbt_free(demangled);
     lmm_var_free(sys, var);
   }
   while ((cnst = (lmm_constraint_t) extract_constraint(sys)))
     lmm_cnst_free(sys, cnst);
 
   xbt_mallocator_free(sys->variable_mallocator);
-  free(sys);
+  delete sys;
 }
 
 static inline void lmm_cnst_free(lmm_system_t sys, lmm_constraint_t cnst)
 {
   make_constraint_inactive(sys, cnst);
-  free(cnst);
+  delete cnst;
 }
 
 lmm_constraint_t lmm_constraint_new(lmm_system_t sys, void *id, double bound_value)
@@ -243,8 +233,8 @@ lmm_constraint_t lmm_constraint_new(lmm_system_t sys, void *id, double bound_val
   lmm_constraint_t cnst = nullptr;
   s_lmm_element_t elem;
 
-  cnst = xbt_new0(s_lmm_constraint_t, 1);
-  cnst->id = id;
+  cnst         = new s_lmm_constraint_t();
+  cnst->id     = id;
   cnst->id_int = Global_const_debug_id++;
   xbt_swag_init(&(cnst->enabled_element_set), xbt_swag_offset(elem, enabled_element_set_hookup));
   xbt_swag_init(&(cnst->disabled_element_set), xbt_swag_offset(elem, disabled_element_set_hookup));
@@ -297,32 +287,14 @@ int lmm_constraint_sharing_policy(lmm_constraint_t cnst)
   return (cnst->sharing_policy);
 }
 
-/* @brief Remove a constraint
- * Currently this is dead code, but it is exposed in maxmin.hpp
- * Apparently, this call was designed assuming that constraint would no more have elements in it.
- * If not the case, assertion will fail, and you need to add calls e.g. to lmm_shrink before effectively removing it.
- */
-inline void lmm_constraint_free(lmm_system_t sys,lmm_constraint_t cnst)
-{
-  xbt_assert(not xbt_swag_size(&(cnst->active_element_set)), "Removing constraint but it still has active elements");
-  xbt_assert(not xbt_swag_size(&(cnst->enabled_element_set)), "Removing constraint but it still has enabled elements");
-  xbt_assert(not xbt_swag_size(&(cnst->disabled_element_set)),
-             "Removing constraint but it still has disabled elements");
-  remove_constraint(sys, cnst);
-  lmm_cnst_free(sys, cnst);
-}
-
 static void *lmm_variable_mallocator_new_f()
 {
-  lmm_variable_t var = xbt_new(s_lmm_variable_t, 1);
-  var->cnsts = nullptr; /* will be created by realloc */
-  return var;
+  return new s_lmm_variable_t;
 }
 
 static void lmm_variable_mallocator_free_f(void *var)
 {
-  xbt_free(((lmm_variable_t) var)->cnsts);
-  xbt_free(var);
+  delete static_cast<lmm_variable_t>(var);
 }
 
 lmm_variable_t lmm_variable_new(lmm_system_t sys, simgrid::surf::Action* id, double sharing_weight, double bound,
@@ -333,20 +305,7 @@ lmm_variable_t lmm_variable_new(lmm_system_t sys, simgrid::surf::Action* id, dou
   lmm_variable_t var = (lmm_variable_t)xbt_mallocator_get(sys->variable_mallocator);
   var->id = id;
   var->id_int = Global_debug_id++;
-  var->cnsts = static_cast<s_lmm_element_t*>(xbt_realloc(var->cnsts, number_of_constraints * sizeof(s_lmm_element_t)));
-  for (int i = 0; i < number_of_constraints; i++) {
-    var->cnsts[i].enabled_element_set_hookup.next = nullptr;
-    var->cnsts[i].enabled_element_set_hookup.prev = nullptr;
-    var->cnsts[i].disabled_element_set_hookup.next = nullptr;
-    var->cnsts[i].disabled_element_set_hookup.prev = nullptr;
-    var->cnsts[i].active_element_set_hookup.next = nullptr;
-    var->cnsts[i].active_element_set_hookup.prev = nullptr;
-    var->cnsts[i].constraint = nullptr;
-    var->cnsts[i].variable = nullptr;
-    var->cnsts[i].consumption_weight               = 0.0;
-  }
-  var->cnsts_size = number_of_constraints;
-  var->cnsts_number = 0;
+  var->cnsts.reserve(number_of_constraints);
   var->sharing_weight    = sharing_weight;
   var->staged_weight = 0.0;
   var->bound = bound;
@@ -394,59 +353,6 @@ double lmm_variable_getbound(lmm_variable_t var)
   return (var->bound);
 }
 
-void lmm_shrink(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var)
-{
-  lmm_element_t elem = nullptr;
-  int found = 0;
-
-  for (int i = 0; i < var->cnsts_number; i++) {
-    elem = &(var->cnsts[i]);
-    if (elem->constraint == cnst) {
-      found = 1;
-      break;
-    }
-  }
-
-  if (not found) {
-    XBT_DEBUG("cnst %p is not found in var %p", cnst, var);
-    return;
-  }
-
-  sys->modified = 1;
-
-  XBT_DEBUG("remove elem(value %f, cnst %p, var %p) in var %p", elem->consumption_weight, elem->constraint,
-            elem->variable, var);
-
-  /* We are going to change the constraint object and the variable object.
-   * Propagate this change to other objects. Calling here before removing variable from not active elements
-   * (inactive elements are not visited)
-   */
-  lmm_update_modified_set(sys, cnst);
-  //Useful in case var was already removed from the constraint
-  lmm_update_modified_set(sys, var->cnsts[0].constraint); // will look up enabled_element_set of this constraint, and
-                                                     //then each var in the enabled_element_set, and each var->cnsts[i].
-
-  if(xbt_swag_remove(elem, &(elem->constraint->enabled_element_set)))
-    lmm_decrease_concurrency(elem);
-
-  xbt_swag_remove(elem, &(elem->constraint->active_element_set));
-  elem->constraint = nullptr;
-  elem->variable = nullptr;
-  elem->consumption_weight = 0;
-
-  var->cnsts_number -= 1;
-
-  //No variable in this constraint -> make it inactive
-  if (xbt_swag_size(&(cnst->enabled_element_set))+xbt_swag_size(&(cnst->disabled_element_set)) == 0)
-    make_constraint_inactive(sys, cnst);
-  else {
-    //Check maxconcurrency to see if we can enable new variables
-    lmm_on_disabled_var(sys,elem->constraint);
-  }
-
-  lmm_check_concurrency(sys);
-}
-
 void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, double consumption_weight)
 {
   sys->modified = 1;
@@ -455,10 +361,9 @@ void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, dou
   //If it does, substract it from the required slack
   int current_share = 0;
   if(var->concurrency_share>1){
-    for (int i = 0; i < var->cnsts_number; i++) {
-      if(var->cnsts[i].constraint==cnst &&
-         xbt_swag_belongs(&var->cnsts[i],&(var->cnsts[i].constraint->enabled_element_set)))
-         current_share+=lmm_element_concurrency(&(var->cnsts[i]));
+    for (s_lmm_element_t& elem : var->cnsts) {
+      if (elem.constraint == cnst && xbt_swag_belongs(&elem, &(elem.constraint->enabled_element_set)))
+        current_share += lmm_element_concurrency(&elem);
     }
   }
 
@@ -466,34 +371,35 @@ void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, dou
   if (var->sharing_weight > 0 && var->concurrency_share - current_share > lmm_concurrency_slack(cnst)) {
     double weight = var->sharing_weight;
     lmm_disable_var(sys,var);
-    for (int i = 0; i < var->cnsts_number; i++)
-      lmm_on_disabled_var(sys,var->cnsts[i].constraint);
+    for (s_lmm_element_t const& elem : var->cnsts)
+      lmm_on_disabled_var(sys, elem.constraint);
     consumption_weight = 0;
     var->staged_weight=weight;
     xbt_assert(not var->sharing_weight);
   }
 
-  xbt_assert(var->cnsts_number < var->cnsts_size, "Too much constraints");
+  xbt_assert(var->cnsts.size() < var->cnsts.capacity(), "Too much constraints");
 
-  lmm_element_t elem = &(var->cnsts[var->cnsts_number++]);
+  var->cnsts.resize(var->cnsts.size() + 1);
+  s_lmm_element_t& elem = var->cnsts.back();
 
-  elem->consumption_weight = consumption_weight;
-  elem->constraint = cnst;
-  elem->variable = var;
+  elem.consumption_weight = consumption_weight;
+  elem.constraint         = cnst;
+  elem.variable           = var;
 
   if (var->sharing_weight) {
-    xbt_swag_insert_at_head(elem, &(elem->constraint->enabled_element_set));
-    lmm_increase_concurrency(elem);
+    xbt_swag_insert_at_head(&elem, &(elem.constraint->enabled_element_set));
+    lmm_increase_concurrency(&elem);
   } else
-    xbt_swag_insert_at_tail(elem, &(elem->constraint->disabled_element_set));
+    xbt_swag_insert_at_tail(&elem, &(elem.constraint->disabled_element_set));
 
   if (not sys->selective_update_active) {
     make_constraint_active(sys, cnst);
-  } else if (elem->consumption_weight > 0 || var->sharing_weight > 0) {
+  } else if (elem.consumption_weight > 0 || var->sharing_weight > 0) {
     make_constraint_active(sys, cnst);
     lmm_update_modified_set(sys, cnst);
     //TODOLATER: Why do we need this second call?
-    if (var->cnsts_number > 1)
+    if (var->cnsts.size() > 1)
       lmm_update_modified_set(sys, var->cnsts[0].constraint);
   }
 
@@ -502,36 +408,34 @@ void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, dou
 
 void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, double value)
 {
-  int i;
   sys->modified = 1;
 
   lmm_check_concurrency(sys);
 
   //BEWARE: In case you have multiple elements in one constraint, this will always add value to the first element.
-  for (i = 0; i < var->cnsts_number; i++)
-    if (var->cnsts[i].constraint == cnst)
-      break;
-
-  if (i < var->cnsts_number) {
+  auto elem_it = std::find_if(begin(var->cnsts), end(var->cnsts),
+                              [&cnst](s_lmm_element_t const& x) { return x.constraint == cnst; });
+  if (elem_it != end(var->cnsts)) {
+    s_lmm_element_t& elem = *elem_it;
     if (var->sharing_weight)
-      lmm_decrease_concurrency(&var->cnsts[i]);
+      lmm_decrease_concurrency(&elem);
 
     if (cnst->sharing_policy)
-      var->cnsts[i].consumption_weight += value;
+      elem.consumption_weight += value;
     else
-      var->cnsts[i].consumption_weight = MAX(var->cnsts[i].consumption_weight, value);
+      elem.consumption_weight = std::max(elem.consumption_weight, value);
 
     //We need to check that increasing value of the element does not cross the concurrency limit
     if (var->sharing_weight) {
-      if(lmm_concurrency_slack(cnst)<lmm_element_concurrency(&var->cnsts[i])){
+      if (lmm_concurrency_slack(cnst) < lmm_element_concurrency(&elem)) {
         double weight = var->sharing_weight;
         lmm_disable_var(sys,var);
-        for (int j = 0; j < var->cnsts_number; j++)
-          lmm_on_disabled_var(sys,var->cnsts[j].constraint);
+        for (s_lmm_element_t const& elem2 : var->cnsts)
+          lmm_on_disabled_var(sys, elem2.constraint);
         var->staged_weight=weight;
         xbt_assert(not var->sharing_weight);
       }
-      lmm_increase_concurrency(&var->cnsts[i]);
+      lmm_increase_concurrency(&elem);
     }
     lmm_update_modified_set(sys, cnst);
   } else
@@ -540,17 +444,17 @@ void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var,
   lmm_check_concurrency(sys);
 }
 
-lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t /*sys*/, lmm_variable_t var, int num)
+lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t /*sys*/, lmm_variable_t var, unsigned num)
 {
-  if (num < var->cnsts_number)
+  if (num < var->cnsts.size())
     return (var->cnsts[num].constraint);
   else
     return nullptr;
 }
 
-double lmm_get_cnst_weight_from_var(lmm_system_t /*sys*/, lmm_variable_t var, int num)
+double lmm_get_cnst_weight_from_var(lmm_system_t /*sys*/, lmm_variable_t var, unsigned num)
 {
-  if (num < var->cnsts_number)
+  if (num < var->cnsts.size())
     return (var->cnsts[num].consumption_weight);
   else
     return 0.0;
@@ -558,7 +462,7 @@ double lmm_get_cnst_weight_from_var(lmm_system_t /*sys*/, lmm_variable_t var, in
 
 int lmm_get_number_of_cnst_from_var(lmm_system_t /*sys*/, lmm_variable_t var)
 {
-  return (var->cnsts_number);
+  return (var->cnsts.size());
 }
 
 lmm_variable_t lmm_get_var_from_cnst(lmm_system_t /*sys*/, lmm_constraint_t cnst, lmm_element_t * elem)
@@ -629,40 +533,29 @@ void *lmm_variable_id(lmm_variable_t var)
 }
 
 static inline void saturated_constraint_set_update(double usage, int cnst_light_num,
-                                                   dyn_light_t saturated_constraint_set, double *min_usage)
+                                                   dyn_light_t& saturated_constraint_set, double* min_usage)
 {
   xbt_assert(usage > 0,"Impossible");
 
   if (*min_usage < 0 || *min_usage > usage) {
     *min_usage = usage;
     XBT_HERE(" min_usage=%f (cnst->remaining / cnst->usage =%f)", *min_usage, usage);
-    saturated_constraint_set->data[0] = cnst_light_num;
-    saturated_constraint_set->pos = 1;
+    saturated_constraint_set.assign(1, cnst_light_num);
   } else if (*min_usage == usage) {
-    if(saturated_constraint_set->pos == saturated_constraint_set->size) { // realloc the size
-      saturated_constraint_set->size *= 2;
-      saturated_constraint_set->data =
-        (int*) xbt_realloc(saturated_constraint_set->data, (saturated_constraint_set->size) * sizeof(int));
-    }
-    saturated_constraint_set->data[saturated_constraint_set->pos] = cnst_light_num;
-    saturated_constraint_set->pos++;
+    saturated_constraint_set.emplace_back(cnst_light_num);
   }
 }
 
-static inline void saturated_variable_set_update(s_lmm_constraint_light_t *cnst_light_tab,
-                                                 dyn_light_t saturated_constraint_set, lmm_system_t sys)
+static inline void saturated_variable_set_update(s_lmm_constraint_light_tcnst_light_tab,
+                                                 const dyn_light_t& saturated_constraint_set, lmm_system_t sys)
 {
   /* Add active variables (i.e. variables that need to be set) from the set of constraints to saturate (cnst_light_tab)*/
-  lmm_constraint_light_t cnst = nullptr;
-  void *_elem;
-  lmm_element_t elem = nullptr;
-  xbt_swag_t elem_list = nullptr;
-  int i;
-  for(i = 0; i< saturated_constraint_set->pos; i++){
-    cnst = &cnst_light_tab[saturated_constraint_set->data[i]];
-    elem_list = &(cnst->cnst->active_element_set);
+  for (int const& saturated_cnst : saturated_constraint_set) {
+    lmm_constraint_light_t cnst = &cnst_light_tab[saturated_cnst];
+    void* _elem;
+    xbt_swag_t elem_list = &(cnst->cnst->active_element_set);
     xbt_swag_foreach(_elem, elem_list) {
-      elem = (lmm_element_t)_elem;
+      lmm_element_t elem = (lmm_element_t)_elem;
       //Visiting active_element_set, so, by construction, should never get a zero weight, correct?
       xbt_assert(elem->variable->sharing_weight > 0);
       if (elem->consumption_weight > 0)
@@ -705,7 +598,7 @@ void lmm_print(lmm_system_t sys)
       if(cnst->sharing_policy)
         sum += elem->consumption_weight * elem->variable->value;
       else
-        sum = MAX(sum, elem->consumption_weight * elem->variable->value);
+        sum = std::max(sum, elem->consumption_weight * elem->variable->value);
     }
     //TODO: Adding disabled elements only for test compatibility, but do we really want them to be printed?
     elem_list = &(cnst->disabled_element_set);
@@ -716,7 +609,7 @@ void lmm_print(lmm_system_t sys)
       if(cnst->sharing_policy)
         sum += elem->consumption_weight * elem->variable->value;
       else
-        sum = MAX(sum, elem->consumption_weight * elem->variable->value);
+        sum = std::max(sum, elem->consumption_weight * elem->variable->value);
     }
 
     buf = buf + "0) <= " + std::to_string(cnst->bound) + " ('" + std::to_string(cnst->id_int) + "')";
@@ -774,12 +667,9 @@ void lmm_solve(lmm_system_t sys)
     }
   }
 
-  s_lmm_constraint_light_t* cnst_light_tab =
-      static_cast<s_lmm_constraint_light_t*>(xbt_malloc0(xbt_swag_size(cnst_list) * sizeof(s_lmm_constraint_light_t)));
+  s_lmm_constraint_light_t* cnst_light_tab = new s_lmm_constraint_light_t[xbt_swag_size(cnst_list)]();
   int cnst_light_num = 0;
-  dyn_light_t saturated_constraint_set = xbt_new0(s_dyn_light_t,1);
-  saturated_constraint_set->size = 5;
-  saturated_constraint_set->data = xbt_new0(int, saturated_constraint_set->size);
+  dyn_light_t saturated_constraint_set;
 
   xbt_swag_foreach_safe(_cnst, _cnst_next, cnst_list) {
     lmm_constraint_t cnst = (lmm_constraint_t)_cnst;
@@ -839,14 +729,12 @@ void lmm_solve(lmm_system_t sys)
         if (min_bound < 0)
           min_bound = var->bound * var->sharing_weight;
         else
-          min_bound = MIN(min_bound, (var->bound * var->sharing_weight));
+          min_bound = std::min(min_bound, (var->bound * var->sharing_weight));
         XBT_DEBUG("Updated min_bound=%f", min_bound);
       }
     }
 
     while ((var = (lmm_variable_t)xbt_swag_getFirst(var_list))) {
-      int i;
-
       if (min_bound < 0) {
         //If no variable could reach its bound, deal iteratively the constraints usage ( at worst one constraint is
         // saturated at each cycle)
@@ -868,14 +756,13 @@ void lmm_solve(lmm_system_t sys)
                 var->id_int, var->value);
 
       /* Update the usage of contraints where this variable is involved */
-      for (i = 0; i < var->cnsts_number; i++) {
-        lmm_element_t elem    = &var->cnsts[i];
-        lmm_constraint_t cnst = elem->constraint;
+      for (s_lmm_element_t& elem : var->cnsts) {
+        lmm_constraint_t cnst = elem.constraint;
         if (cnst->sharing_policy) {
-          //Remember: shared constraints require that sum(elem->value * var->value) < cnst->bound
-          double_update(&(cnst->remaining), elem->consumption_weight * var->value, cnst->bound * sg_maxmin_precision);
-          double_update(&(cnst->usage), elem->consumption_weight / var->sharing_weight, sg_maxmin_precision);
-          //If the constraint is saturated, remove it from the set of active constraints (light_tab)
+          // Remember: shared constraints require that sum(elem.value * var->value) < cnst->bound
+          double_update(&(cnst->remaining), elem.consumption_weight * var->value, cnst->bound * sg_maxmin_precision);
+          double_update(&(cnst->usage), elem.consumption_weight / var->sharing_weight, sg_maxmin_precision);
+          // If the constraint is saturated, remove it from the set of active constraints (light_tab)
           if (not double_positive(cnst->usage, sg_maxmin_precision) ||
               not double_positive(cnst->remaining, cnst->bound * sg_maxmin_precision)) {
             if (cnst->cnst_light) {
@@ -890,18 +777,19 @@ void lmm_solve(lmm_system_t sys)
           } else {
             cnst->cnst_light->remaining_over_usage = cnst->remaining / cnst->usage;
           }
-          make_elem_inactive(elem);
+          make_elem_inactive(&elem);
         } else {
-          //Remember: non-shared constraints only require that max(elem->value * var->value) < cnst->bound
+          // Remember: non-shared constraints only require that max(elem.value * var->value) < cnst->bound
           cnst->usage = 0.0;
-          make_elem_inactive(elem);
+          make_elem_inactive(&elem);
           xbt_swag_t elem_list = &(cnst->enabled_element_set);
           xbt_swag_foreach(_elem, elem_list) {
-            elem = (lmm_element_t)_elem;
-            xbt_assert(elem->variable->sharing_weight > 0);
-            if (elem->variable->value > 0) continue;
-            if (elem->consumption_weight > 0)
-              cnst->usage = MAX(cnst->usage, elem->consumption_weight / elem->variable->sharing_weight);
+            lmm_element_t elem2 = static_cast<lmm_element_t>(_elem);
+            xbt_assert(elem2->variable->sharing_weight > 0);
+            if (elem2->variable->value > 0)
+              continue;
+            if (elem2->consumption_weight > 0)
+              cnst->usage = std::max(cnst->usage, elem2->consumption_weight / elem2->variable->sharing_weight);
           }
           //If the constraint is saturated, remove it from the set of active constraints (light_tab)
           if (not double_positive(cnst->usage, sg_maxmin_precision) ||
@@ -929,7 +817,7 @@ void lmm_solve(lmm_system_t sys)
     /* Find out which variables reach the maximum */
     min_usage = -1;
     min_bound = -1;
-    saturated_constraint_set->pos = 0;
+    saturated_constraint_set.clear();
     int pos;
     for(pos=0; pos<cnst_light_num; pos++){
       xbt_assert(cnst_light_tab[pos].cnst->active_element_set.count>0, "Cannot saturate more a constraint that has"
@@ -955,9 +843,7 @@ void lmm_solve(lmm_system_t sys)
 
   lmm_check_concurrency(sys);
 
-  xbt_free(saturated_constraint_set->data);
-  xbt_free(saturated_constraint_set);
-  xbt_free(cnst_light_tab);
+  delete[] cnst_light_tab;
   XBT_OUT();
 }
 
@@ -975,33 +861,30 @@ void lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var, double boun
   sys->modified = 1;
   var->bound = bound;
 
-  if (var->cnsts_number)
+  if (not var->cnsts.empty())
     lmm_update_modified_set(sys, var->cnsts[0].constraint);
 }
 
-int lmm_concurrency_slack(lmm_constraint_t cnstr){
-  //FIXME MARTIN: Replace by infinite value std::numeric_limits<int>::(max)(), or something better within Simgrid?
-  if(cnstr->concurrency_limit<0)
-    return 666;
-
+int lmm_concurrency_slack(lmm_constraint_t cnstr)
+{
+  if (cnstr->concurrency_limit < 0)
+    return std::numeric_limits<int>::max();
   return  cnstr->concurrency_limit - cnstr->concurrency_current;
 }
 
 /** \brief Measure the minimum concurrency slack across all constraints where the given var is involved */
-int lmm_cnstrs_min_concurrency_slack(lmm_variable_t var){
+int lmm_cnstrs_min_concurrency_slack(lmm_variable_t var)
+{
   int minslack = std::numeric_limits<int>::max();
-  for (int i = 0; i < var->cnsts_number; i++) {
-    int slack = lmm_concurrency_slack(var->cnsts[i].constraint);
-
-    //This is only an optimization, to avoid looking at more constraints when slack is already zero
-    //Disable it when debugging to let lmm_concurrency_slack catch nasty things
-    if (not slack && not XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug))
-      return 0;
-
-    if(minslack>slack)
-      minslack=slack;
+  for (s_lmm_element_t const& elem : var->cnsts) {
+    int slack = lmm_concurrency_slack(elem.constraint);
+    if (slack < minslack) {
+      // This is only an optimization, to avoid looking at more constraints when slack is already zero
+      if (slack == 0)
+        return 0;
+      minslack = slack;
+    }
   }
-
   return minslack;
 }
 
@@ -1028,13 +911,12 @@ void lmm_enable_var(lmm_system_t sys, lmm_variable_t var){
 
   xbt_swag_remove(var, &(sys->variable_set));
   xbt_swag_insert_at_head(var, &(sys->variable_set));
-  for (int i = 0; i < var->cnsts_number; i++) {
-    lmm_element_t elem = &var->cnsts[i];
-    xbt_swag_remove(elem, &(elem->constraint->disabled_element_set));
-    xbt_swag_insert_at_head(elem, &(elem->constraint->enabled_element_set));
-    lmm_increase_concurrency(elem);
+  for (s_lmm_element_t& elem : var->cnsts) {
+    xbt_swag_remove(&elem, &(elem.constraint->disabled_element_set));
+    xbt_swag_insert_at_head(&elem, &(elem.constraint->enabled_element_set));
+    lmm_increase_concurrency(&elem);
   }
-  if (var->cnsts_number)
+  if (not var->cnsts.empty())
     lmm_update_modified_set(sys, var->cnsts[0].constraint);
 
   //When used within lmm_on_disabled_var, we would get an assertion fail, because transiently there can be variables
@@ -1048,16 +930,15 @@ void lmm_disable_var(lmm_system_t sys, lmm_variable_t var){
   // moving the last element of var.
   xbt_swag_remove(var, &(sys->variable_set));
   xbt_swag_insert_at_tail(var, &(sys->variable_set));
-  if (var->cnsts_number)
+  if (not var->cnsts.empty())
     lmm_update_modified_set(sys, var->cnsts[0].constraint);
-  for (int i = 0; i < var->cnsts_number; i++) {
-    lmm_element_t elem = &var->cnsts[i];
-    xbt_swag_remove(elem, &(elem->constraint->enabled_element_set));
-    xbt_swag_insert_at_tail(elem, &(elem->constraint->disabled_element_set));
+  for (s_lmm_element_t& elem : var->cnsts) {
+    xbt_swag_remove(&elem, &(elem.constraint->enabled_element_set));
+    xbt_swag_insert_at_tail(&elem, &(elem.constraint->disabled_element_set));
 
-    xbt_swag_remove(elem, &(elem->constraint->active_element_set));
+    xbt_swag_remove(&elem, &(elem.constraint->active_element_set));
 
-    lmm_decrease_concurrency(elem);
+    lmm_decrease_concurrency(&elem);
   }
 
   var->sharing_weight = 0.0;
@@ -1089,13 +970,11 @@ void lmm_on_disabled_var(lmm_system_t sys, lmm_constraint_t cnstr){
 
     lmm_element_t nextelem = (lmm_element_t)xbt_swag_getNext(elem, cnstr->disabled_element_set.offset);
 
-    if (elem->variable->staged_weight>0 ){
+    if (elem->variable->staged_weight > 0 && lmm_can_enable_var(elem->variable)) {
       //Found a staged variable
       //TODOLATER: Add random timing function to model reservation protocol fuzziness? Then how to make sure that
       //staged variables will eventually be called?
-      if(lmm_can_enable_var(elem->variable)){
-        lmm_enable_var(sys,elem->variable);
-      }
+      lmm_enable_var(sys, elem->variable);
     }
 
     xbt_assert(cnstr->concurrency_current<=cnstr->concurrency_limit,"Concurrency overflow!");
@@ -1193,12 +1072,12 @@ static void lmm_update_modified_set_rec(lmm_system_t sys, lmm_constraint_t cnst)
   //TODOLATER: Why lmm_modified_set has been changed in git version 2392B5157...? Looks equivalent logically and less obvious..
   xbt_swag_foreach(_elem, &cnst->enabled_element_set) {
     lmm_variable_t var = ((lmm_element_t)_elem)->variable;
-    s_lmm_element_t *cnsts = var->cnsts;
-    int i;
-    for (i = 0; var->visited != sys->visited_counter && i < var->cnsts_number ; i++) {
-      if (cnsts[i].constraint != cnst && not xbt_swag_belongs(cnsts[i].constraint, &sys->modified_constraint_set)) {
-        xbt_swag_insert(cnsts[i].constraint, &sys->modified_constraint_set);
-        lmm_update_modified_set_rec(sys, cnsts[i].constraint);
+    for (s_lmm_element_t const& elem : var->cnsts) {
+      if (var->visited == sys->visited_counter)
+        break;
+      if (elem.constraint != cnst && not xbt_swag_belongs(elem.constraint, &sys->modified_constraint_set)) {
+        xbt_swag_insert(elem.constraint, &sys->modified_constraint_set);
+        lmm_update_modified_set_rec(sys, elem.constraint);
       }
     }
     //var will be ignored in later visits as long as sys->visited_counter does not move
index 976caa0..0350557 100644 (file)
@@ -11,6 +11,8 @@
 #include "xbt/mallocator.h"
 #include "xbt/swag.h"
 
+#include <vector>
+
 /** @ingroup SURF_lmm
  * @brief LMM element
  * Elements can be seen as glue between constraint objects and variable objects.
@@ -31,8 +33,8 @@ struct s_lmm_element_t {
   //   - If network, then 1 in forward direction and 0.05 backward for the ACKs
   double consumption_weight;
 };
-#define make_elem_active(elem) xbt_swag_insert_at_head(elem,&(elem->constraint->active_element_set))
-#define make_elem_inactive(elem) xbt_swag_remove(elem,&(elem->constraint->active_element_set))
+#define make_elem_active(elem) xbt_swag_insert_at_head((elem), &((elem)->constraint->active_element_set))
+#define make_elem_inactive(elem) xbt_swag_remove((elem), &((elem)->constraint->active_element_set))
 
 struct s_lmm_constraint_light_t {
   double remaining_over_usage;
@@ -83,9 +85,7 @@ struct s_lmm_variable_t {
   s_xbt_swag_hookup_t variable_set_hookup;
   s_xbt_swag_hookup_t saturated_variable_set_hookup;
 
-  s_lmm_element_t *cnsts;
-  int cnsts_size;
-  int cnsts_number;
+  std::vector<s_lmm_element_t> cnsts;
 
   // sharing_weight: variable's impact on the resource during the sharing
   //   if == 0, the variable is not considered by LMM
@@ -132,17 +132,25 @@ struct s_lmm_system_t {
   void (*solve_fun)(lmm_system_t self);
 };
 
-#define extract_variable(sys) xbt_swag_extract(&(sys->variable_set))
-#define extract_constraint(sys) xbt_swag_extract(&(sys->constraint_set))
-#define insert_constraint(sys,cnst) xbt_swag_insert(cnst,&(sys->constraint_set))
-#define remove_variable(sys,var) do {xbt_swag_remove(var,&(sys->variable_set));\
-                                 xbt_swag_remove(var,&(sys->saturated_variable_set));} while(0)
-#define remove_constraint(sys,cnst) do {xbt_swag_remove(cnst,&(sys->constraint_set));\
-                                        xbt_swag_remove(cnst,&(sys->saturated_constraint_set));} while(0)
-#define make_constraint_active(sys,cnst) xbt_swag_insert(cnst,&(sys->active_constraint_set))
-#define make_constraint_inactive(sys,cnst) \
-  do { xbt_swag_remove(cnst, &sys->active_constraint_set);              \
-    xbt_swag_remove(cnst, &sys->modified_constraint_set); } while (0)
+#define extract_variable(sys) xbt_swag_extract(&((sys)->variable_set))
+#define extract_constraint(sys) xbt_swag_extract(&((sys)->constraint_set))
+#define insert_constraint(sys, cnst) xbt_swag_insert((cnst), &((sys)->constraint_set))
+#define remove_variable(sys, var)                                                                                      \
+  do {                                                                                                                 \
+    xbt_swag_remove(var, &((sys)->variable_set));                                                                      \
+    xbt_swag_remove(var, &((sys)->saturated_variable_set));                                                            \
+  } while (0)
+#define remove_constraint(sys, cnst)                                                                                   \
+  do {                                                                                                                 \
+    xbt_swag_remove((cnst), &((sys)->constraint_set));                                                                 \
+    xbt_swag_remove((cnst), &((sys)->saturated_constraint_set));                                                       \
+  } while (0)
+#define make_constraint_active(sys, cnst) xbt_swag_insert((cnst), &((sys)->active_constraint_set))
+#define make_constraint_inactive(sys, cnst)                                                                            \
+  do {                                                                                                                 \
+    xbt_swag_remove((cnst), &(sys)->active_constraint_set);                                                            \
+    xbt_swag_remove((cnst), &(sys)->modified_constraint_set);                                                          \
+  } while (0)
 
 /** @ingroup SURF_lmm
  * @brief Print information about a lmm system
index fe92ad9..c7b6abc 100644 (file)
@@ -150,11 +150,9 @@ NetworkCm02Model::NetworkCm02Model()
   }
 
   maxminSystem_ = lmm_system_new(selectiveUpdate_);
-  loopback_     = createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE);
+  loopback_     = NetworkCm02Model::createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE);
 
   if (getUpdateMechanism() == UM_LAZY) {
-    actionHeap_ = xbt_heap_new(8, nullptr);
-    xbt_heap_set_update_callback(actionHeap_, surf_action_lmm_update_index_heap);
     modifiedSet_ = new ActionLmmList();
     maxminSystem_->keep_track = modifiedSet_;
   }
@@ -173,10 +171,9 @@ LinkImpl* NetworkCm02Model::createLink(const std::string& name, double bandwidth
 
 void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/)
 {
-  while ((xbt_heap_size(actionHeap_) > 0)
-         && (double_equals(xbt_heap_maxkey(actionHeap_), now, sg_surf_precision))) {
+  while (not actionHeapIsEmpty() && double_equals(actionHeapTopDate(), now, sg_surf_precision)) {
 
-    NetworkCm02Action *action = static_cast<NetworkCm02Action*> (xbt_heap_pop(actionHeap_));
+    NetworkCm02Action* action = static_cast<NetworkCm02Action*>(actionHeapPop());
     XBT_DEBUG("Something happened to action %p", action);
     if (TRACE_is_enabled()) {
       int n = lmm_get_number_of_cnst_from_var(maxminSystem_, action->getVariable());
@@ -195,7 +192,7 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/)
     if (action->getHat() == LATENCY) {
       XBT_DEBUG("Latency paid for action %p. Activating", action);
       lmm_update_variable_weight(maxminSystem_, action->getVariable(), action->weight_);
-      action->heapRemove(actionHeap_);
+      action->heapRemove(getActionHeap());
       action->refreshLastUpdate();
 
         // if I am wearing a max_duration or normal hat
@@ -205,7 +202,7 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/)
       XBT_DEBUG("Action %p finished", action);
       action->setRemains(0);
       action->finish(Action::State::done);
-      action->heapRemove(actionHeap_);
+      action->heapRemove(getActionHeap());
     }
   }
 }
@@ -214,12 +211,11 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/)
 void NetworkCm02Model::updateActionsStateFull(double now, double delta)
 {
   ActionList *running_actions = getRunningActionSet();
-
-  for(ActionList::iterator it(running_actions->begin()), itNext=it, itend(running_actions->end())
-     ; it != itend ; it=itNext) {
-    ++itNext;
-
+  ActionList::iterator it(running_actions->begin());
+  ActionList::iterator itend(running_actions->end());
+  while (it != itend) {
     NetworkCm02Action *action = static_cast<NetworkCm02Action*> (&*it);
+    ++it;
     XBT_DEBUG("Something happened to action %p", action);
       double deltap = delta;
       if (action->latency_ > 0) {
@@ -267,24 +263,23 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
 {
   int failed = 0;
   double latency = 0.0;
-  std::vector<LinkImpl*>* back_route = nullptr;
-  std::vector<LinkImpl*>* route = new std::vector<LinkImpl*>();
+  std::vector<LinkImpl*> back_route;
+  std::vector<LinkImpl*> route;
 
   XBT_IN("(%s,%s,%g,%g)", src->getCname(), dst->getCname(), size, rate);
 
   src->routeTo(dst, route, &latency);
-  xbt_assert(not route->empty() || latency,
+  xbt_assert(not route.empty() || latency,
              "You're trying to send data from %s to %s but there is no connecting path between these two hosts.",
              src->getCname(), dst->getCname());
 
-  for (auto const& link : *route)
+  for (auto const& link : route)
     if (link->isOff())
       failed = 1;
 
   if (sg_network_crosstraffic == 1) {
-    back_route = new std::vector<LinkImpl*>();
     dst->routeTo(src, back_route, nullptr);
-    for (auto const& link : *back_route)
+    for (auto const& link : back_route)
       if (link->isOff())
         failed = 1;
   }
@@ -294,16 +289,15 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
   action->latency_ = latency;
   action->rate_ = rate;
   if (getUpdateMechanism() == UM_LAZY) {
-    action->updateIndexHeap(-1);
     action->refreshLastUpdate();
   }
 
   double bandwidth_bound = -1.0;
   if (sg_weight_S_parameter > 0)
-    for (auto const& link : *route)
+    for (auto const& link : route)
       action->weight_ += sg_weight_S_parameter / link->bandwidth();
 
-  for (auto const& link : *route) {
+  for (auto const& link : route) {
     double bb       = bandwidthFactor(size) * link->bandwidth();
     bandwidth_bound = (bandwidth_bound < 0.0) ? bb : std::min(bandwidth_bound, bb);
   }
@@ -312,16 +306,15 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
   action->latency_ *= latencyFactor(size);
   action->rate_ = bandwidthConstraint(action->rate_, bandwidth_bound, size);
 
-  int constraints_per_variable = route->size();
-  if (back_route != nullptr)
-    constraints_per_variable += back_route->size();
+  int constraints_per_variable = route.size();
+  constraints_per_variable += back_route.size();
 
   if (action->latency_ > 0) {
     action->setVariable(lmm_variable_new(maxminSystem_, action, 0.0, -1.0, constraints_per_variable));
     if (getUpdateMechanism() == UM_LAZY) {
       // add to the heap the event when the latency is payed
       XBT_DEBUG("Added action (%p) one latency event at date %f", action, action->latency_ + action->getLastUpdate());
-      action->heapInsert(actionHeap_, action->latency_ + action->getLastUpdate(), route->empty() ? NORMAL : LATENCY);
+      action->heapInsert(getActionHeap(), action->latency_ + action->getLastUpdate(), route.empty() ? NORMAL : LATENCY);
     }
   } else
     action->setVariable(lmm_variable_new(maxminSystem_, action, 1.0, -1.0, constraints_per_variable));
@@ -332,21 +325,18 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
     lmm_update_variable_bound(maxminSystem_, action->getVariable(), (action->latCurrent_ > 0) ? std::min(action->rate_, sg_tcp_gamma / (2.0 * action->latCurrent_)) : action->rate_);
   }
 
-  for (auto const& link : *route)
+  for (auto const& link : route)
     lmm_expand(maxminSystem_, link->constraint(), action->getVariable(), 1.0);
 
-  if (back_route != nullptr) { //  sg_network_crosstraffic was activated
+  if (not back_route.empty()) { //  sg_network_crosstraffic was activated
     XBT_DEBUG("Fullduplex active adding backward flow using 5%%");
-    for (auto const& link : *back_route)
+    for (auto const& link : back_route)
       lmm_expand(maxminSystem_, link->constraint(), action->getVariable(), .05);
 
     //Change concurrency_share here, if you want that cross-traffic is included in the SURF concurrency
     //(You would also have to change lmm_element_concurrency())
     //lmm_variable_concurrency_share_set(action->getVariable(),2);
   }
-
-  delete route;
-  delete back_route;
   XBT_OUT();
 
   simgrid::s4u::Link::onCommunicate(action, src, dst);
index 9f0e10c..8a051ec 100644 (file)
@@ -183,18 +183,18 @@ void NetworkIBModel::computeIBfactors(IBNode* root)
   XBT_DEBUG("Finished computing IB penalties");
 }
 
-void NetworkIBModel::updateIBfactors_rec(IBNode* root, bool* updatedlist)
+void NetworkIBModel::updateIBfactors_rec(IBNode* root, std::vector<bool>& updatedlist)
 {
-  if (updatedlist[root->id] == 0) {
+  if (not updatedlist[root->id]) {
     XBT_DEBUG("IB - Updating rec %d", root->id);
     computeIBfactors(root);
-    updatedlist[root->id] = 1;
+    updatedlist[root->id] = true;
     for (std::vector<ActiveComm*>::iterator it = root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) {
-      if (updatedlist[(*it)->destination->id] != 1)
+      if (not updatedlist[(*it)->destination->id])
         updateIBfactors_rec((*it)->destination, updatedlist);
     }
     for (std::map<IBNode*, int>::iterator it = root->ActiveCommsDown.begin(); it != root->ActiveCommsDown.end(); ++it) {
-      if (updatedlist[it->first->id] != 1)
+      if (not updatedlist[it->first->id])
         updateIBfactors_rec(it->first, updatedlist);
     }
   }
@@ -205,7 +205,6 @@ void NetworkIBModel::updateIBfactors(NetworkAction* action, IBNode* from, IBNode
   if (from == to) // disregard local comms (should use loopback)
     return;
 
-  bool* updated    = (bool*)xbt_malloc0(active_nodes.size() * sizeof(bool));
   ActiveComm* comm = nullptr;
   if (remove) {
     if (to->ActiveCommsDown[from] == 1)
@@ -233,11 +232,10 @@ void NetworkIBModel::updateIBfactors(NetworkAction* action, IBNode* from, IBNode
     to->nbActiveCommsDown++;
   }
   XBT_DEBUG("IB - Updating %d", from->id);
+  std::vector<bool> updated(active_nodes.size(), false);
   updateIBfactors_rec(from, updated);
   XBT_DEBUG("IB - Finished updating %d", from->id);
-  if (comm)
-    delete comm;
-  xbt_free(updated);
+  delete comm;
 }
 }
 }
index ceab7b9..df41a88 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2015. The SimGrid Team.
+/* Copyright (c) 2014-2017. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -11,6 +11,7 @@
 #include "xbt/base.h"
 
 #include <unordered_map>
+#include <vector>
 
 namespace simgrid {
   namespace surf {
@@ -42,7 +43,7 @@ namespace simgrid {
 
     class XBT_PRIVATE NetworkIBModel : public NetworkSmpiModel {
     private:
-      void updateIBfactors_rec(IBNode *root, bool* updatedlist);
+      void updateIBfactors_rec(IBNode* root, std::vector<bool>& updatedlist);
       void computeIBfactors(IBNode *root);
     public:
       NetworkIBModel();
index 6521cfd..54c4bb8 100644 (file)
@@ -70,7 +70,6 @@ namespace simgrid {
     NetworkModel::~NetworkModel()
     {
       lmm_system_free(maxminSystem_);
-      xbt_heap_free(actionHeap_);
       delete modifiedSet_;
     }
 
@@ -90,7 +89,7 @@ namespace simgrid {
     {
       double minRes = Model::nextOccuringEventFull(now);
 
-      for(auto it(getRunningActionSet()->begin()), itend(getRunningActionSet()->end()); it != itend ; it++) {
+      for (auto it(getRunningActionSet()->begin()); it != getRunningActionSet()->end(); it++) {
         NetworkAction *action = static_cast<NetworkAction*>(&*it);
         if (action->latency_ > 0)
           minRes = (minRes < 0) ? action->latency_ : std::min(minRes, action->latency_);
index 3ac508d..7c30095 100644 (file)
@@ -81,10 +81,10 @@ static void clusterCreation_cb(ClusterCreationArgs* cluster)
 static void routeCreation_cb(bool symmetrical, simgrid::kernel::routing::NetPoint* src,
                              simgrid::kernel::routing::NetPoint* dst, simgrid::kernel::routing::NetPoint* gw_src,
                              simgrid::kernel::routing::NetPoint* gw_dst,
-                             std::vector<simgrid::surf::LinkImpl*>* link_list)
+                             std::vector<simgrid::surf::LinkImpl*>& link_list)
 {
-  if (link_list->size() == 1) {
-    simgrid::surf::LinkNS3* link = static_cast<simgrid::surf::LinkNS3*>(link_list->at(0));
+  if (link_list.size() == 1) {
+    simgrid::surf::LinkNS3* link = static_cast<simgrid::surf::LinkNS3*>(link_list[0]);
 
     XBT_DEBUG("Route from '%s' to '%s' with link '%s' %s", src->getCname(), dst->getCname(), link->getCname(),
               (symmetrical ? "(symmetrical)" : "(not symmetrical)"));
@@ -109,7 +109,7 @@ static void routeCreation_cb(bool symmetrical, simgrid::kernel::routing::NetPoin
                "of length 1.\n"
                "WARNING: Remove long routes to avoid this harmless message; subsequent long routes will be silently "
                "ignored.",
-               src->getCname(), dst->getCname(), link_list->size());
+               src->getCname(), dst->getCname(), link_list.size());
     warned_about_long_routes = true;
   }
 }
@@ -219,7 +219,7 @@ void NetworkNS3Model::updateActionsState(double now, double delta)
 
       std::vector<LinkImpl*> route = std::vector<LinkImpl*>();
 
-      action->src_->routeTo(action->dst_, &route, nullptr);
+      action->src_->routeTo(action->dst_, route, nullptr);
       for (auto const& link : route)
         TRACE_surf_link_set_utilization(link->getCname(), action->getCategory(), (data_delta_sent) / delta, now - delta,
                                         delta);
index 9c6f389..47b0d16 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "network_smpi.hpp"
 #include "simgrid/sg_config.h"
-#include "smpi/smpi_utils.hpp"
+#include "smpi_utils.hpp"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network);
 
index 17f312c..bc65a38 100644 (file)
@@ -65,7 +65,7 @@ NetworkL07Model::NetworkL07Model(HostL07Model *hmodel, lmm_system_t sys)
   , hostModel_(hmodel)
 {
   maxminSystem_ = sys;
-  loopback_     = createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE);
+  loopback_     = NetworkL07Model::createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE);
 }
 
 NetworkL07Model::~NetworkL07Model()
@@ -182,8 +182,8 @@ L07Action::L07Action(Model *model, int host_nb, sg_host_t *host_list,
           double lat=0.0;
 
           std::vector<LinkImpl*> route;
-          hostList_->at(i)->routeTo(hostList_->at(j), &route, &lat);
-          latency = MAX(latency, lat);
+          hostList_->at(i)->routeTo(hostList_->at(j), route, &lat);
+          latency = std::max(latency, lat);
 
           for (auto const& link : route)
             affected_links.insert(link->getCname());
@@ -210,7 +210,7 @@ L07Action::L07Action(Model *model, int host_nb, sg_host_t *host_list,
       for (int j = 0; j < host_nb; j++) {
         if (bytes_amount[i * host_nb + j] > 0.0) {
           std::vector<LinkImpl*> route;
-          hostList_->at(i)->routeTo(hostList_->at(j), &route, nullptr);
+          hostList_->at(i)->routeTo(hostList_->at(j), route, nullptr);
 
           for (auto const& link : route)
             lmm_expand_add(model->getMaxminSystem(), link->constraint(), this->getVariable(),
@@ -407,9 +407,9 @@ void L07Action::updateBound()
         if (communicationAmount_[i * hostNb + j] > 0) {
           double lat = 0.0;
           std::vector<LinkImpl*> route;
-          hostList_->at(i)->routeTo(hostList_->at(j), &route, &lat);
+          hostList_->at(i)->routeTo(hostList_->at(j), route, &lat);
 
-          lat_current = MAX(lat_current, lat * communicationAmount_[i * hostNb + j]);
+          lat_current = std::max(lat_current, lat * communicationAmount_[i * hostNb + j]);
         }
       }
     }
index ee0542c..81a15d0 100644 (file)
@@ -195,7 +195,6 @@ void sg_platf_new_cluster(ClusterCreationArgs* cluster)
     XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\">", host_id.c_str(), cluster->speeds.front());
 
     s_sg_platf_host_cbarg_t host;
-    memset(&host, 0, sizeof(host));
     host.id = host_id.c_str();
     if ((cluster->properties != nullptr) && (not cluster->properties->empty())) {
       host.properties = new std::map<std::string, std::string>;
@@ -316,7 +315,6 @@ void sg_platf_new_cabinet(CabinetCreationArgs* cabinet)
   for (int const& radical : *cabinet->radicals) {
     std::string hostname = cabinet->prefix + std::to_string(radical) + cabinet->suffix;
     s_sg_platf_host_cbarg_t host;
-    memset(&host, 0, sizeof(host));
     host.pstate           = 0;
     host.core_amount      = 1;
     host.id               = hostname.c_str();
@@ -442,14 +440,14 @@ void sg_platf_new_process(sg_platf_process_cbarg_t process)
   double kill_time  = process->kill_time;
   int auto_restart = process->on_failure == SURF_ACTOR_ON_FAILURE_DIE ? 0 : 1;
 
-  std::vector<std::string> args(process->argv, process->argv + process->argc);
-  std::function<void()> code = factory(std::move(args));
+  std::string process_name   = process->args[0];
+  std::function<void()> code = factory(std::move(process->args));
   std::shared_ptr<std::map<std::string, std::string>> properties(process->properties);
 
   smx_process_arg_t arg = nullptr;
 
   arg = new simgrid::simix::ProcessArg();
-  arg->name = std::string(process->argv[0]);
+  arg->name = process_name;
   arg->code = code;
   arg->data = nullptr;
   arg->host = host;
@@ -461,7 +459,7 @@ void sg_platf_new_process(sg_platf_process_cbarg_t process)
   if (start_time > SIMIX_get_clock()) {
 
     arg = new simgrid::simix::ProcessArg();
-    arg->name = std::string(process->argv[0]);
+    arg->name = process_name;
     arg->code = std::move(code);
     arg->data = nullptr;
     arg->host = host;
index e25812c..2bbfd74 100644 (file)
@@ -76,21 +76,16 @@ double StorageN11Model::nextOccuringEvent(double now)
 void StorageN11Model::updateActionsState(double /*now*/, double delta)
 {
   ActionList *actionSet = getRunningActionSet();
-  for (ActionList::iterator it(actionSet->begin()), itNext = it, itend(actionSet->end()); it != itend; it = itNext) {
-    ++itNext;
-
+  ActionList::iterator it(actionSet->begin());
+  ActionList::iterator itend(actionSet->end());
+  while (it != itend) {
     StorageAction *action = static_cast<StorageAction*>(&*it);
-
+    ++it;
     double current_progress = lrint(lmm_variable_getvalue(action->getVariable()) * delta);
 
     action->updateRemains(current_progress);
     if (action->type_ == WRITE) {
       action->storage_->usedSize_ += current_progress;
-      action->file_->incrPosition(current_progress);
-      action->file_->setSize(action->file_->tell());
-
-      action->storage_->getContent()->erase(action->file_->getCname());
-      action->storage_->getContent()->insert({action->file_->getCname(), action->file_->size()});
     }
 
     if (action->getMaxDuration() > NO_MAX_DURATION)
index e57f843..cac3a86 100644 (file)
@@ -6,6 +6,7 @@
 #include "simgrid/s4u/Engine.hpp"
 #include "src/instr/instr_private.hpp"
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
+#include <algorithm>
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_kernel);
 
@@ -74,10 +75,10 @@ double surf_solve(double max_date)
     XBT_DEBUG("Next TRACE event: %f", next_event_date);
 
     if (not surf_network_model->nextOccuringEventIsIdempotent()) { // NS3, I see you
-      if (next_event_date!=-1.0 && time_delta!=-1.0) {
-        time_delta = MIN(next_event_date - NOW, time_delta);
+      if (next_event_date != -1.0) {
+        time_delta = std::min(next_event_date - NOW, time_delta);
       } else {
-        time_delta = MAX(next_event_date - NOW, time_delta); // Get the positive component
+        time_delta = std::max(next_event_date - NOW, time_delta); // Get the positive component
       }
 
       XBT_DEBUG("Run the NS3 network at most %fs", time_delta);
@@ -85,18 +86,16 @@ double surf_solve(double max_date)
       model_next_action_end = surf_network_model->nextOccuringEvent(time_delta);
 
       XBT_DEBUG("Min for network : %f", model_next_action_end);
-      if(model_next_action_end>=0.0)
+      if (model_next_action_end >= 0.0)
         time_delta = model_next_action_end;
     }
 
-    if (next_event_date < 0.0) {
-      XBT_DEBUG("no next TRACE event. Stop searching for it");
+    if (next_event_date < 0.0 || (next_event_date > NOW + time_delta)) {
+      // next event may have already occurred or will after the next resource change, then bail out
+      XBT_DEBUG("no next usable TRACE event. Stop searching for it");
       break;
     }
 
-    if ((time_delta == -1.0) || (next_event_date > NOW + time_delta))
-      break; // next event occurs after the next resource change, bail out
-
     XBT_DEBUG("Updating models (min = %g, NOW = %g, next_event_date = %g)", time_delta, NOW, next_event_date);
 
     while ((event = future_evt_set->pop_leq(next_event_date, &value, &resource))) {
@@ -129,9 +128,9 @@ double surf_solve(double max_date)
   NOW = NOW + time_delta;
 
   // Inform the models of the date change
-  for (auto const& model : *all_existing_models) {
+  for (auto const& model : *all_existing_models)
     model->updateActionsState(NOW, time_delta);
-  }
+
   simgrid::s4u::onTimeAdvance(time_delta);
 
   TRACE_paje_dump_buffer(false);
index f9c9679..999fca9 100644 (file)
@@ -365,7 +365,6 @@ Model::Model()
   doneActionSet_ = new ActionList();
 
   modifiedSet_ = nullptr;
-  actionHeap_ = nullptr;
   updateMechanism_ = UM_UNDEFINED;
   selectiveUpdate_ = 0;
 }
@@ -377,6 +376,14 @@ Model::~Model(){
   delete doneActionSet_;
 }
 
+Action* Model::actionHeapPop()
+{
+  Action* action = actionHeap_.top().second;
+  actionHeap_.pop();
+  action->clearHeapHandle();
+  return action;
+}
+
 double Model::nextOccuringEvent(double now)
 {
   //FIXME: set the good function once and for all
@@ -442,8 +449,8 @@ double Model::nextOccuringEventLazy(double now)
   }
 
   //hereafter must have already the min value for this resource model
-  if (xbt_heap_size(actionHeap_) > 0) {
-    double min = xbt_heap_maxkey(actionHeap_) - now;
+  if (not actionHeapIsEmpty()) {
+    double min = actionHeapTopDate() - now;
     XBT_DEBUG("minimum with the HEAP %f", min);
     return min;
   } else {
@@ -456,7 +463,8 @@ double Model::nextOccuringEventFull(double /*now*/) {
   maxminSystem_->solve_fun(maxminSystem_);
 
   double min = -1;
-  for (auto it(getRunningActionSet()->begin()), itend(getRunningActionSet()->end()); it != itend ; ++it) {
+
+  for (auto it(getRunningActionSet()->begin()); it != getRunningActionSet()->end(); ++it) {
     Action *action = &*it;
     double value = lmm_variable_getvalue(action->getVariable());
     if (value > 0) {
@@ -572,11 +580,6 @@ const char *surf_action_state_names[6] = {
   "SURF_ACTION_NOT_IN_THE_SYSTEM"
 };
 
-/* added to manage the communication action's heap */
-void surf_action_lmm_update_index_heap(void *action, int i) {
-  static_cast<simgrid::surf::Action*>(action)->updateIndexHeap(i);
-}
-
 namespace simgrid {
 namespace surf {
 
@@ -605,7 +608,7 @@ void Action::finish(Action::State state)
   setState(state);
 }
 
-Action::State Action::getState()
+Action::State Action::getState() const
 {
   if (stateSet_ == model_->getReadyActionSet())
     return Action::State::ready;
@@ -642,7 +645,7 @@ void Action::setState(Action::State state)
     stateSet_->push_back(*this);
 }
 
-double Action::getBound()
+double Action::getBound() const
 {
   return (variable_) ? lmm_variable_getbound(variable_) : 0;
 }
@@ -658,21 +661,6 @@ void Action::setBound(double bound)
   XBT_OUT();
 }
 
-double Action::getStartTime()
-{
-  return start_;
-}
-
-double Action::getFinishTime()
-{
-  return finishTime_;
-}
-
-void Action::setData(void* data)
-{
-  data_ = data;
-}
-
 void Action::setCategory(const char *category)
 {
   category_ = xbt_strdup(category);
@@ -769,34 +757,31 @@ bool Action::isSuspended()
  * LATENCY = this is a heap entry to warn us when the latency is payed
  * MAX_DURATION =this is a heap entry to warn us when the max_duration limit is reached
  */
-void Action::heapInsert(xbt_heap_t heap, double key, enum heap_action_type hat)
+void Action::heapInsert(heap_type& heap, double key, enum heap_action_type hat)
 {
   hat_ = hat;
-  xbt_heap_push(heap, this, key);
+  heapHandle_ = heap.emplace(std::make_pair(key, this));
 }
 
-void Action::heapRemove(xbt_heap_t heap)
+void Action::heapRemove(heap_type& heap)
 {
   hat_ = NOTSET;
-  if (indexHeap_ >= 0) {
-    xbt_heap_remove(heap, indexHeap_);
+  if (heapHandle_) {
+    heap.erase(*heapHandle_);
+    clearHeapHandle();
   }
 }
 
-void Action::heapUpdate(xbt_heap_t heap, double key, enum heap_action_type hat)
+void Action::heapUpdate(heap_type& heap, double key, enum heap_action_type hat)
 {
   hat_ = hat;
-  if (indexHeap_ >= 0) {
-    xbt_heap_update(heap, indexHeap_, key);
-  }else{
-    xbt_heap_push(heap, this, key);
+  if (heapHandle_) {
+    heap.update(*heapHandle_, std::make_pair(key, this));
+  } else {
+    heapHandle_ = heap.emplace(std::make_pair(key, this));
   }
 }
 
-void Action::updateIndexHeap(int i) {
-  indexHeap_ = i;
-}
-
 double Action::getRemains()
 {
   XBT_IN("(%p)", this);
@@ -807,10 +792,5 @@ double Action::getRemains()
   return remains_;
 }
 
-double Action::getRemainsNoUpdate()
-{
-  return remains_;
-}
-
 }
 }
index 5cad6fe..38bdbe0 100644 (file)
@@ -7,12 +7,15 @@
 #define SURF_MODEL_H_
 
 #include "xbt/signal.hpp"
+#include "xbt/utility.hpp"
 
 #include "src/surf/surf_private.hpp"
 #include "surf/surf.hpp"
 #include "xbt/str.h"
 
+#include <boost/heap/pairing_heap.hpp>
 #include <boost/intrusive/list.hpp>
+#include <boost/optional.hpp>
 #include <set>
 #include <string>
 #include <unordered_map>
@@ -65,8 +68,6 @@ enum heap_action_type{
  * Action *
  **********/
 
-XBT_PRIVATE void surf_action_lmm_update_index_heap(void *action, int i);
-
 /** \ingroup SURF_models
  *  \brief List of initialized models
  */
@@ -75,6 +76,11 @@ XBT_PUBLIC_DATA(std::vector<surf_model_t>*) all_existing_models;
 namespace simgrid {
 namespace surf {
 
+typedef std::pair<double, simgrid::surf::Action*> heap_element_type;
+typedef boost::heap::pairing_heap<heap_element_type, boost::heap::constant_time_size<false>, boost::heap::stable<true>,
+                                  boost::heap::compare<simgrid::xbt::HeapComparator<heap_element_type>>>
+    heap_type;
+
 /** @ingroup SURF_interface
  * @brief SURF action interface class
  * @details An action is an event generated by a resource (e.g.: a communication for the network)
@@ -126,27 +132,27 @@ public:
   void finish(Action::State state);
 
   /** @brief Get the [state](\ref simgrid::surf::Action::State) of the current Action */
-  Action::State getState(); /**< get the state*/
+  Action::State getState() const; /**< get the state*/
   /** @brief Set the [state](\ref simgrid::surf::Action::State) of the current Action */
   virtual void setState(Action::State state);
 
   /** @brief Get the bound of the current Action */
-  double getBound();
+  double getBound() const;
   /** @brief Set the bound of the current Action */
   void setBound(double bound);
 
   /** @brief Get the start time of the current action */
-  double getStartTime();
+  double getStartTime() const { return start_; }
   /** @brief Get the finish time of the current action */
-  double getFinishTime();
+  double getFinishTime() const { return finishTime_; }
 
   /** @brief Get the user data associated to the current action */
-  void *getData() {return data_;}
+  void* getData() const { return data_; }
   /** @brief Set the user data associated to the current action */
-  void setData(void* data);
+  void setData(void* data) { data_ = data; }
 
   /** @brief Get the cost of the current action */
-  double getCost() {return cost_;}
+  double getCost() const { return cost_; }
   /** @brief Set the cost of the current action */
   void setCost(double cost) {cost_ = cost;}
 
@@ -163,7 +169,7 @@ public:
   /** @brief Get the remaining time of the current action after updating the resource */
   virtual double getRemains();
   /** @brief Get the remaining time of the current action without updating the resource */
-  double getRemainsNoUpdate();
+  double getRemainsNoUpdate() const { return remains_; }
 
   /** @brief Set the finish time of the current action */
   void setFinishTime(double value) {finishTime_ = value;}
@@ -188,27 +194,27 @@ public:
   virtual bool isSuspended();
 
   /** @brief Get the maximum duration of the current action */
-  double getMaxDuration() {return maxDuration_;}
+  double getMaxDuration() const { return maxDuration_; }
   /** @brief Set the maximum duration of the current Action */
   virtual void setMaxDuration(double duration);
 
   /** @brief Get the tracing category associated to the current action */
-  char *getCategory() {return category_;}
+  char* getCategory() const { return category_; }
   /** @brief Set the tracing category of the current Action */
   void setCategory(const char *category);
 
   /** @brief Get the priority of the current Action */
-  double getPriority() { return sharingWeight_; };
+  double getPriority() const { return sharingWeight_; };
   /** @brief Set the priority of the current Action */
   virtual void setSharingWeight(double priority);
   void setSharingWeightNoUpdate(double weight) { sharingWeight_ = weight; }
 
   /** @brief Get the state set in which the action is */
-  ActionList* getStateSet() {return stateSet_;};
+  ActionList* getStateSet() const { return stateSet_; };
 
   s_xbt_swag_hookup_t stateHookup_ = {nullptr,nullptr};
 
-  simgrid::surf::Model* getModel() { return model_; }
+  simgrid::surf::Model* getModel() const { return model_; }
 
 protected:
   ActionList* stateSet_;
@@ -232,23 +238,22 @@ private:
   double lastValue_          = 0;
   lmm_variable_t variable_   = nullptr;
   enum heap_action_type hat_ = NOTSET;
-  int indexHeap_;
+  boost::optional<heap_type::handle_type> heapHandle_ = boost::none;
 
 public:
   virtual void updateRemainingLazy(double now) { THROW_IMPOSSIBLE; };
-  void heapInsert(xbt_heap_t heap, double key, enum heap_action_type hat);
-  void heapRemove(xbt_heap_t heap);
-  void heapUpdate(xbt_heap_t heap, double key, enum heap_action_type hat);
-  virtual void updateIndexHeap(int i);
-  lmm_variable_t getVariable() {return variable_;}
+  void heapInsert(heap_type& heap, double key, enum heap_action_type hat);
+  void heapRemove(heap_type& heap);
+  void heapUpdate(heap_type& heap, double key, enum heap_action_type hat);
+  void clearHeapHandle() { heapHandle_ = boost::none; }
+  lmm_variable_t getVariable() const { return variable_; }
   void setVariable(lmm_variable_t var) { variable_ = var; }
-  double getLastUpdate() {return lastUpdate_;}
+  double getLastUpdate() const { return lastUpdate_; }
   void refreshLastUpdate() {lastUpdate_ = surf_get_clock();}
-  double getLastValue() { return lastValue_; }
+  double getLastValue() const { return lastValue_; }
   void setLastValue(double val) { lastValue_ = val; }
-  enum heap_action_type getHat() { return hat_; }
-  bool is_linked() {return action_lmm_hook.is_linked();}
-  int getIndexHeap() { return indexHeap_; }
+  enum heap_action_type getHat() const { return hat_; }
+  bool is_linked() const { return action_lmm_hook.is_linked(); }
 protected:
   int suspended_ = 0;
 };
@@ -274,32 +279,36 @@ public:
   virtual ~Model();
 
   /** @brief Get the set of [actions](@ref Action) in *ready* state */
-  virtual ActionList* getReadyActionSet() {return readyActionSet_;}
+  virtual ActionList* getReadyActionSet() const { return readyActionSet_; }
 
   /** @brief Get the set of [actions](@ref Action) in *running* state */
-  virtual ActionList* getRunningActionSet() {return runningActionSet_;}
+  virtual ActionList* getRunningActionSet() const { return runningActionSet_; }
 
   /** @brief Get the set of [actions](@ref Action) in *failed* state */
-  virtual ActionList* getFailedActionSet() {return failedActionSet_;}
+  virtual ActionList* getFailedActionSet() const { return failedActionSet_; }
 
   /** @brief Get the set of [actions](@ref Action) in *done* state */
-  virtual ActionList* getDoneActionSet() {return doneActionSet_;}
+  virtual ActionList* getDoneActionSet() const { return doneActionSet_; }
 
   /** @brief Get the set of modified [actions](@ref Action) */
-  virtual ActionLmmListPtr getModifiedSet() {return modifiedSet_;}
+  virtual ActionLmmListPtr getModifiedSet() const { return modifiedSet_; }
 
   /** @brief Get the maxmin system of the current Model */
-  lmm_system_t getMaxminSystem() {return maxminSystem_;}
+  lmm_system_t getMaxminSystem() const { return maxminSystem_; }
 
   /**
    * @brief Get the update mechanism of the current Model
    * @see e_UM_t
    */
-  e_UM_t getUpdateMechanism() {return updateMechanism_;}
+  e_UM_t getUpdateMechanism() const { return updateMechanism_; }
   void setUpdateMechanism(e_UM_t mechanism) { updateMechanism_ = mechanism; }
 
   /** @brief Get Action heap */
-  xbt_heap_t getActionHeap() {return actionHeap_;}
+  heap_type& getActionHeap() { return actionHeap_; }
+
+  double actionHeapTopDate() const { return actionHeap_.top().first; }
+  Action* actionHeapPop();
+  bool actionHeapIsEmpty() const { return actionHeap_.empty(); }
 
   /**
    * @brief Share the resources between the actions
@@ -332,7 +341,6 @@ protected:
   ActionLmmListPtr modifiedSet_;
   lmm_system_t maxminSystem_ = nullptr;
   bool selectiveUpdate_;
-  xbt_heap_t actionHeap_;
 
 private:
   e_UM_t updateMechanism_ = UM_UNDEFINED;
@@ -340,6 +348,7 @@ private:
   ActionList* runningActionSet_; /**< Actions in state SURF_ACTION_RUNNING */
   ActionList* failedActionSet_; /**< Actions in state SURF_ACTION_FAILED */
   ActionList* doneActionSet_; /**< Actions in state SURF_ACTION_DONE */
+  heap_type actionHeap_;
 };
 
 }
index 66e0d9e..d5e70c1 100644 (file)
@@ -50,9 +50,12 @@ trace::trace()
 }
 trace::~trace()                  = default;
 future_evt_set::future_evt_set() = default;
-simgrid::trace_mgr::future_evt_set::~future_evt_set()
+future_evt_set::~future_evt_set()
 {
-  xbt_heap_free(heap_);
+  while (not heap_.empty()) {
+    delete heap_.top().second;
+    heap_.pop();
+  }
 }
 }
 }
@@ -122,14 +125,15 @@ tmgr_trace_event_t simgrid::trace_mgr::future_evt_set::add_trace(tmgr_trace_t tr
 {
   tmgr_trace_event_t trace_iterator = nullptr;
 
-  trace_iterator = xbt_new0(s_tmgr_trace_event_t, 1);
-  trace_iterator->trace = trace;
-  trace_iterator->idx = 0;
+  trace_iterator           = new s_tmgr_trace_event_t;
+  trace_iterator->trace    = trace;
+  trace_iterator->idx      = 0;
   trace_iterator->resource = resource;
+  trace_iterator->free_me  = false;
 
   xbt_assert((trace_iterator->idx < trace->event_list.size()), "Your trace should have at least one event!");
 
-  xbt_heap_push(heap_, trace_iterator, 0. /*start_time*/);
+  heap_.emplace(0.0 /* start time */, trace_iterator);
 
   return trace_iterator;
 }
@@ -137,9 +141,7 @@ tmgr_trace_event_t simgrid::trace_mgr::future_evt_set::add_trace(tmgr_trace_t tr
 /** @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(heap_))
-    return (xbt_heap_maxkey(heap_));
-  return -1.0;
+  return heap_.empty() ? -1.0 : heap_.top().first;
 }
 
 /** @brief Retrieves the next occurring event, or nullptr if none happens before #date */
@@ -150,9 +152,10 @@ tmgr_trace_event_t simgrid::trace_mgr::future_evt_set::pop_leq(double date, doub
   if (event_date > date)
     return nullptr;
 
-  tmgr_trace_event_t trace_iterator = (tmgr_trace_event_t)xbt_heap_pop(heap_);
-  if (trace_iterator == nullptr)
+  if (heap_.empty())
     return nullptr;
+  tmgr_trace_event_t trace_iterator = heap_.top().second;
+  heap_.pop();
 
   tmgr_trace_t trace = trace_iterator->trace;
   *resource = trace_iterator->resource;
@@ -162,13 +165,13 @@ tmgr_trace_event_t simgrid::trace_mgr::future_evt_set::pop_leq(double date, doub
   *value = dateVal.value_;
 
   if (trace_iterator->idx < trace->event_list.size() - 1) {
-    xbt_heap_push(heap_, trace_iterator, event_date + dateVal.date_);
+    heap_.emplace(event_date + dateVal.date_, trace_iterator);
     trace_iterator->idx++;
   } else if (dateVal.date_ > 0) { /* Last element. Shall we loop? */
-    xbt_heap_push(heap_, trace_iterator, event_date + dateVal.date_);
+    heap_.emplace(event_date + dateVal.date_, trace_iterator);
     trace_iterator->idx = 1; /* idx=0 is a placeholder to store when events really start */
   } else {                   /* If we don't loop, we don't need this trace_event anymore */
-    trace_iterator->free_me = 1;
+    trace_iterator->free_me = true;
   }
 
   return trace_iterator;
@@ -184,7 +187,7 @@ void tmgr_finalize()
 void tmgr_trace_event_unref(tmgr_trace_event_t* trace_event)
 {
   if ((*trace_event)->free_me) {
-    xbt_free(*trace_event);
+    delete *trace_event;
     *trace_event = nullptr;
   }
 }
index b687772..955ff2a 100644 (file)
@@ -7,8 +7,8 @@
 #define SURF_TMGR_H
 
 #include "simgrid/forward.h"
-#include "xbt/heap.h"
 #include "xbt/sysdep.h"
+#include <queue>
 #include <vector>
 
 extern "C" {
@@ -18,7 +18,7 @@ struct s_tmgr_trace_event_t {
   tmgr_trace_t trace;
   unsigned int idx;
   sg_resource_t resource;
-  int free_me;
+  bool free_me;
 };
 typedef s_tmgr_trace_event_t* tmgr_trace_event_t;
 
@@ -91,8 +91,8 @@ public:
   tmgr_trace_event_t add_trace(tmgr_trace_t trace, simgrid::surf::Resource * resource);
 
 private:
-  // TODO: use a boost type for the heap (or a ladder queue)
-  xbt_heap_t heap_ = xbt_heap_new(8, xbt_free_f); /* Content: only trace_events (yep, 8 is an arbitrary value) */
+  typedef std::pair<double, tmgr_trace_event_t> Qelt;
+  std::priority_queue<Qelt, std::vector<Qelt>, std::greater<Qelt>> heap_;
 };
 
 }} // namespace simgrid::trace_mgr
index db80cd7..13b3012 100644 (file)
@@ -42,14 +42,14 @@ enum e_surf_cluster_topology_t {
  */
 
 struct s_sg_platf_host_cbarg_t {
-  const char* id;
+  const char* id = nullptr;
   std::vector<double> speed_per_pstate;
-  int pstate;
-  int core_amount;
-  tmgr_trace_t speed_trace;
-  tmgr_trace_t state_trace;
-  const char* coord;
-  std::map<std::string, std::string>* properties;
+  int pstate               = 0;
+  int core_amount          = 0;
+  tmgr_trace_t speed_trace = nullptr;
+  tmgr_trace_t state_trace = nullptr;
+  const char* coord        = nullptr;
+  std::map<std::string, std::string>* properties = nullptr;
 };
 typedef s_sg_platf_host_cbarg_t* sg_platf_host_cbarg_t;
 
@@ -84,12 +84,12 @@ public:
 };
 
 struct s_sg_platf_route_cbarg_t {
-  bool symmetrical                                 = false;
-  sg_netpoint_t src                                = nullptr;
-  sg_netpoint_t dst                                = nullptr;
-  sg_netpoint_t gw_src                             = nullptr;
-  sg_netpoint_t gw_dst                             = nullptr;
-  std::vector<simgrid::surf::LinkImpl*>* link_list = nullptr;
+  bool symmetrical     = false;
+  sg_netpoint_t src    = nullptr;
+  sg_netpoint_t dst    = nullptr;
+  sg_netpoint_t gw_src = nullptr;
+  sg_netpoint_t gw_dst = nullptr;
+  std::vector<simgrid::surf::LinkImpl*> link_list;
 };
 typedef s_sg_platf_route_cbarg_t* sg_platf_route_cbarg_t;
 
@@ -174,14 +174,13 @@ public:
 };
 
 struct s_sg_platf_process_cbarg_t {
-  const char **argv;
-  int argc;
-  std::map<std::string, std::string>* properties;
-  const char *host;
-  const char *function;
-  double start_time;
-  double kill_time;
-  e_surf_process_on_failure_t on_failure;
+  std::vector<std::string> args;
+  std::map<std::string, std::string>* properties = nullptr;
+  const char* host                       = nullptr;
+  const char* function                   = nullptr;
+  double start_time                      = 0.0;
+  double kill_time                       = 0.0;
+  e_surf_process_on_failure_t on_failure = {};
 };
 typedef s_sg_platf_process_cbarg_t* sg_platf_process_cbarg_t;
 
@@ -235,8 +234,6 @@ XBT_PUBLIC(void) surf_parse_set_out(FILE * out_str);
 XBT_PUBLIC(int) surf_parse_get_debug();
 XBT_PUBLIC(void) surf_parse_set_debug(int bdebug);
 XBT_PUBLIC(int) surf_parse_lex_destroy();
-
-XBT_PUBLIC(void) routing_route_free(sg_platf_route_cbarg_t route);
 }
 
 namespace simgrid {
index 6730a35..3d6ead1 100644 (file)
@@ -427,7 +427,6 @@ void STag_surfxml_prop()
 
 void ETag_surfxml_host()    {
   s_sg_platf_host_cbarg_t host;
-  memset(&host,0,sizeof(host));
 
   host.properties = current_property_set;
   current_property_set = nullptr;
@@ -694,21 +693,16 @@ void STag_surfxml_bypassZoneRoute(){
 
 void ETag_surfxml_route(){
   s_sg_platf_route_cbarg_t route;
-  memset(&route,0,sizeof(route));
 
   route.src         = sg_netpoint_by_name_or_null(A_surfxml_route_src); // tested to not be nullptr in start tag
   route.dst         = sg_netpoint_by_name_or_null(A_surfxml_route_dst); // tested to not be nullptr in start tag
   route.gw_src    = nullptr;
   route.gw_dst    = nullptr;
-  route.link_list   = new std::vector<simgrid::surf::LinkImpl*>();
   route.symmetrical = (A_surfxml_route_symmetrical == A_surfxml_route_symmetrical_YES);
 
-  for (auto const& link : parsed_link_list)
-    route.link_list->push_back(link);
-  parsed_link_list.clear();
+  route.link_list.swap(parsed_link_list);
 
   sg_platf_new_route(&route);
-  delete route.link_list;
 }
 
 void ETag_surfxml_ASroute()
@@ -723,7 +717,6 @@ void ETag_surfxml_ASroute()
 void ETag_surfxml_zoneRoute()
 {
   s_sg_platf_route_cbarg_t ASroute;
-  memset(&ASroute,0,sizeof(ASroute));
 
   ASroute.src = sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_src); // tested to not be nullptr in start tag
   ASroute.dst = sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_dst); // tested to not be nullptr in start tag
@@ -731,11 +724,7 @@ void ETag_surfxml_zoneRoute()
   ASroute.gw_src = sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_gw___src); // tested to not be nullptr in start tag
   ASroute.gw_dst = sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_gw___dst); // tested to not be nullptr in start tag
 
-  ASroute.link_list = new std::vector<simgrid::surf::LinkImpl*>();
-
-  for (auto const& link : parsed_link_list)
-    ASroute.link_list->push_back(link);
-  parsed_link_list.clear();
+  ASroute.link_list.swap(parsed_link_list);
 
   switch (A_surfxml_zoneRoute_symmetrical) {
   case AU_surfxml_zoneRoute_symmetrical:
@@ -750,26 +739,20 @@ void ETag_surfxml_zoneRoute()
   }
 
   sg_platf_new_route(&ASroute);
-  delete ASroute.link_list;
 }
 
 void ETag_surfxml_bypassRoute(){
   s_sg_platf_route_cbarg_t route;
-  memset(&route,0,sizeof(route));
 
   route.src         = sg_netpoint_by_name_or_null(A_surfxml_bypassRoute_src); // tested to not be nullptr in start tag
   route.dst         = sg_netpoint_by_name_or_null(A_surfxml_bypassRoute_dst); // tested to not be nullptr in start tag
   route.gw_src = nullptr;
   route.gw_dst = nullptr;
   route.symmetrical = false;
-  route.link_list   = new std::vector<simgrid::surf::LinkImpl*>();
 
-  for (auto const& link : parsed_link_list)
-    route.link_list->push_back(link);
-  parsed_link_list.clear();
+  route.link_list.swap(parsed_link_list);
 
   sg_platf_new_bypassRoute(&route);
-  delete route.link_list;
 }
 
 void ETag_surfxml_bypassASroute()
@@ -783,14 +766,10 @@ void ETag_surfxml_bypassASroute()
 void ETag_surfxml_bypassZoneRoute()
 {
   s_sg_platf_route_cbarg_t ASroute;
-  memset(&ASroute,0,sizeof(ASroute));
 
   ASroute.src         = sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_src);
   ASroute.dst         = sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_dst);
-  ASroute.link_list   = new std::vector<simgrid::surf::LinkImpl*>();
-  for (auto const& link : parsed_link_list)
-    ASroute.link_list->push_back(link);
-  parsed_link_list.clear();
+  ASroute.link_list.swap(parsed_link_list);
 
   ASroute.symmetrical = false;
 
@@ -798,7 +777,6 @@ void ETag_surfxml_bypassZoneRoute()
   ASroute.gw_dst = sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_gw___dst);
 
   sg_platf_new_bypassRoute(&ASroute);
-  delete ASroute.link_list;
 }
 
 void ETag_surfxml_trace(){
@@ -899,8 +877,7 @@ void ETag_surfxml_config()
   current_property_set = nullptr;
 }
 
-static int argc;
-static char **argv;
+static std::vector<std::string> arguments;
 
 void STag_surfxml_process()
 {
@@ -911,9 +888,7 @@ void STag_surfxml_process()
 void STag_surfxml_actor()
 {
   ZONE_TAG  = 0;
-  argc    = 1;
-  argv    = xbt_new(char *, 1);
-  argv[0] = xbt_strdup(A_surfxml_actor_function);
+  arguments.assign(1, A_surfxml_actor_function);
   xbt_assert(current_property_set == nullptr, "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
 }
 
@@ -930,13 +905,11 @@ void ETag_surfxml_process()
 void ETag_surfxml_actor()
 {
   s_sg_platf_process_cbarg_t actor;
-  memset(&actor,0,sizeof(actor));
 
   actor.properties     = current_property_set;
   current_property_set = nullptr;
 
-  actor.argc       = argc;
-  actor.argv       = (const char **)argv;
+  actor.args.swap(arguments);
   actor.host       = A_surfxml_actor_host;
   actor.function   = A_surfxml_actor_function;
   actor.start_time = surf_parse_get_double(A_surfxml_actor_start___time);
@@ -956,17 +929,10 @@ void ETag_surfxml_actor()
   }
 
   sg_platf_new_process(&actor);
-
-  for (int i = 0; i != argc; ++i)
-    xbt_free(argv[i]);
-  xbt_free(argv);
-  argv = nullptr;
 }
 
 void STag_surfxml_argument(){
-  argc++;
-  argv = (char**)xbt_realloc(argv, (argc) * sizeof(char **));
-  argv[(argc) - 1] = xbt_strdup(A_surfxml_argument_value);
+  arguments.push_back(A_surfxml_argument_value);
 }
 
 void STag_surfxml_model___prop(){
index 63bbc44..c6a637c 100644 (file)
@@ -119,7 +119,7 @@ extern "C" void xbt_dynar_free_data(xbt_dynar_t dynar)
 {
   xbt_dynar_reset(dynar);
   if (dynar)
-    free(dynar->data);
+    xbt_free(dynar->data);
 }
 
 /** @brief Destructor of the structure not touching to the content
@@ -133,8 +133,8 @@ extern "C" void xbt_dynar_free_container(xbt_dynar_t* dynar)
 {
   if (dynar && *dynar) {
     xbt_dynar_t d = *dynar;
-    free(d->data);
-    free(d);
+    xbt_free(d->data);
+    xbt_free(d);
     *dynar = nullptr;
   }
 }
@@ -627,7 +627,7 @@ extern "C" void* xbt_dynar_to_array(xbt_dynar_t dynar)
   xbt_dynar_shrink(dynar, 1);
   memset(xbt_dynar_push_ptr(dynar), 0, dynar->elmsize);
   res = dynar->data;
-  free(dynar);
+  xbt_free(dynar);
   return res;
 }
 
@@ -1025,7 +1025,7 @@ XBT_TEST_UNIT("string", test_dynar_string, "Dynars of strings")
     snprintf(buf,1023, "%d", cpt);
     xbt_dynar_shift(d, &s2);
     xbt_test_assert(not strcmp(buf, s2), "The retrieved value is not the same than the injected one (%s!=%s)", buf, s2);
-    free(s2);
+    xbt_free(s2);
   }
   xbt_dynar_free(&d);           /* This code is used both as example and as regression test, so we try to */
   xbt_dynar_free(&d);           /* free the struct twice here to check that it's ok, but freeing  it only once */
@@ -1048,7 +1048,7 @@ XBT_TEST_UNIT("string", test_dynar_string, "Dynars of strings")
     snprintf(buf,1023, "%d", cpt);
     xbt_dynar_pop(d, &s2);
     xbt_test_assert(not strcmp(buf, s2), "The retrieved value is not the same than the injected one (%s!=%s)", buf, s2);
-    free(s2);
+    xbt_free(s2);
   }
   /* 4. Free the resources */
   xbt_dynar_free(&d);           /* This code is used both as example and as regression test, so we try to */
@@ -1073,21 +1073,21 @@ XBT_TEST_UNIT("string", test_dynar_string, "Dynars of strings")
     xbt_dynar_shift(d, &s2);
     xbt_test_assert(not strcmp(buf, s2),
                     "The retrieved value is not the same than the injected one at the begining (%s!=%s)", buf, s2);
-    free(s2);
+    xbt_free(s2);
   }
   for (int cpt = (NB_ELEM / 5) - 1; cpt >= 0; cpt--) {
     snprintf(buf,1023, "%d", cpt);
     xbt_dynar_shift(d, &s2);
     xbt_test_assert(not strcmp(buf, s2),
                     "The retrieved value is not the same than the injected one in the middle (%s!=%s)", buf, s2);
-    free(s2);
+    xbt_free(s2);
   }
   for (int cpt = NB_ELEM / 2; cpt < NB_ELEM; cpt++) {
     snprintf(buf,1023, "%d", cpt);
     xbt_dynar_shift(d, &s2);
     xbt_test_assert(not strcmp(buf, s2),
                     "The retrieved value is not the same than the injected one at the end (%s!=%s)", buf, s2);
-    free(s2);
+    xbt_free(s2);
   }
   xbt_dynar_free(&d);           /* This code is used both as example and as regression test, so we try to */
   xbt_dynar_free(&d);           /* free the struct twice here to check that it's ok, but freeing  it only once */
@@ -1104,7 +1104,7 @@ XBT_TEST_UNIT("string", test_dynar_string, "Dynars of strings")
     snprintf(buf,1023, "%d", cpt);
     xbt_dynar_remove_at(d, 2 * (NB_ELEM / 5), &s2);
     xbt_test_assert(not strcmp(buf, s2), "Remove a bad value. Got %s, expected %s", s2, buf);
-    free(s2);
+    xbt_free(s2);
   }
   xbt_dynar_free(&d);           /* end_of_doxygen */
 }
index e6dfd96..c439569 100644 (file)
@@ -65,7 +65,7 @@ xbt_ex::~xbt_ex() = default;
 void _xbt_throw(char* message, xbt_errcat_t errcat, int value, const char* file, int line, const char* func)
 {
   xbt_ex e(simgrid::xbt::ThrowPoint(file, line, func), message);
-  free(message);
+  xbt_free(message);
   e.category = errcat;
   e.value = value;
   throw e;
index a07efb9..121a842 100644 (file)
@@ -11,7 +11,6 @@
 #include "xbt/graph.h"
 #include "graph_private.h"
 #include "xbt/dict.h"
-#include "xbt/heap.h"
 
 #include <errno.h>
 #include <stdio.h>
diff --git a/src/xbt/heap.c b/src/xbt/heap.c
deleted file mode 100644 (file)
index db2431e..0000000
+++ /dev/null
@@ -1,282 +0,0 @@
-/* a generic and efficient heap                                             */
-
-/* Copyright (c) 2004-2005, 2007-2017. The SimGrid Team.
- * All rights reserved.                                                     */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#include "xbt/sysdep.h"
-#include "xbt/log.h"
-#include "heap_private.h"
-
-#include <stdio.h>
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_heap, xbt, "Heap");
-
-static void xbt_heap_max_heapify(xbt_heap_t H, int i);
-static void xbt_heap_increase_key(xbt_heap_t H, int i);
-
-/** @addtogroup XBT_heap
- *  \brief This section describes the API to generic heap with O(log(n)) access.
- */
-
-/**
- * @brief Creates a new heap.
- * \param init_size initial size of the heap
- * \param free_func function to call on each element when you want to free the whole heap (or NULL if nothing to do).
- *
- * Creates a new heap.
- */
-inline xbt_heap_t xbt_heap_new(int init_size, void_f_pvoid_t const free_func)
-{
-  xbt_heap_t H = xbt_new0(struct xbt_heap, 1);
-  H->size = init_size;
-  H->count = 0;
-  H->items = (xbt_heap_item_t) xbt_new0(struct xbt_heap_item, init_size);
-  H->free = free_func;
-  return H;
-}
-
-/**
- * @brief Set the update callback function.
- * @param H the heap we're working on
- * \param update_callback function to call on each element to update its index when needed.
- */
-inline void xbt_heap_set_update_callback(xbt_heap_t H, void (*update_callback) (void*, int))
-{
-  H->update_callback = update_callback;
-}
-
-/**
- * @brief kilkil a heap and its content
- * @param H poor victim
- */
-void xbt_heap_free(xbt_heap_t H)
-{
-  if (!H)
-    return;
-
-  if (H->free)
-    for (int i = 0; i < H->count; i++)
-      H->free(H->items[i].content);
-  free(H->items);
-  free(H);
-}
-
-/**
- * @brief returns the number of elements in the heap
- * @param H the heap we're working on
- * @return the number of elements in the heap
- */
-inline int xbt_heap_size(xbt_heap_t H)
-{
-  return (H->count);
-}
-
-/**
- * @brief Add an element into the heap.
- * \param H the heap we're working on
- * \param content the object you want to add to the heap
- * \param key the key associated to this object
- *
- * The element with the smallest key is automatically moved at the top of the heap.
- */
-void xbt_heap_push(xbt_heap_t H, void *content, double key)
-{
-  H->count += 1;
-  int count = H->count;
-
-  int size = H->size;
-  xbt_heap_item_t item;
-
-  if (count > size) {
-    H->size = (size << 1) + 1;
-    H->items = (void *) xbt_realloc(H->items, (H->size) * sizeof(struct xbt_heap_item));
-    xbt_assert(H->items != NULL);
-  }
-
-  item = &(H->items[count - 1]);
-  item->key = key;
-  item->content = content;
-  xbt_heap_increase_key(H, count - 1);
-  XBT_DEBUG("Heap has now %d elements and max elem is %g",xbt_heap_size(H),xbt_heap_maxkey(H));
-}
-
-/**
- * @brief Extracts from the heap and returns the element with the smallest key.
- * \param H the heap we're working on
- * \return the element with the smallest key
- *
- * Extracts from the heap and returns the element with the smallest key. The element with the next smallest key is
- * automatically moved at the top of the heap.
- */
-void *xbt_heap_pop(xbt_heap_t H)
-{
-  xbt_heap_item_t items = H->items;
-  int size = H->size;
-  void *max;
-
-  if (H->count == 0)
-    return NULL;
-
-  XBT_DEBUG("Heap has %d elements before extraction and max elem was %g",xbt_heap_size(H),xbt_heap_maxkey(H));
-
-  max = CONTENT(H, 0);
-
-  items[0] = items[(H->count) - 1];
-  (H->count)--;
-  xbt_heap_max_heapify(H,0);
-  if (H->count < size >> 2 && size > 16) {
-    size = (size >> 1) + 1;
-    H->items = (void *) xbt_realloc(items, size * sizeof(struct xbt_heap_item));
-    H->size = size;
-  }
-
-  if (H->update_callback)
-    H->update_callback(max, -1);
-  return max;
-}
-
-/**
- * @brief Extracts from the heap and returns the element at position i.
- * \param H the heap we're working on
- * \param i  element position
- * \return the element at position i if ok, NULL otherwise
- *
- * Extracts from the heap and returns the element at position i. The heap is automatically reordered.
- */
-void *xbt_heap_remove(xbt_heap_t H, int i)
-{
-  XBT_DEBUG("Heap has %d elements: extracting element %d",xbt_heap_size(H),i);
-
-  if ((i < 0) || (i > H->count - 1))
-    return NULL;
-  /* put element i at head */
-  if (i > 0) {
-    KEY(H, i) = MIN_KEY_VALUE;
-    xbt_heap_increase_key(H, i);
-  }
-
-  return xbt_heap_pop(H);
-}
-
-/** @brief Remove an arbitrary element from the heap
- *  \param H the heap we're working on
- *  \param content the object you want to remove from the heap
- *  \param key the key associated to this object
- *  \return the removed element if found, NULL otherwise
- */
-void *xbt_heap_rm_elm(xbt_heap_t H, void *content, double key)
-{
-  int i=0;
-  while (i < H->count && (KEY(H, i) != key || CONTENT(H, i) != content))
-    i++;
-  return xbt_heap_remove(H, i);
-}
-
-/**
- * @brief Updates an element of the heap with a new value.
- * \param H the heap we're working on
- * \param i  element position
- * \param key new value for the element
- *
- * Updates an element of the heap with a new value.
- */
-void xbt_heap_update(xbt_heap_t H, int i, double key)
-{
-  XBT_DEBUG("Heap has %d elements: updating element %d : was %1.12f to %1.12f ",xbt_heap_size(H),i,KEY(H, i), key);
-
-  if ((i < 0) || (i > H->count - 1) || key == KEY(H, i))
-    return ;
-
-  if(key< KEY(H, i)){
-    KEY(H, i)=key;
-    xbt_heap_increase_key(H, i);
-  }else{
-    KEY(H, i)=key;
-    xbt_heap_max_heapify(H,i);
-  }
-}
-
-/**
- * @brief returns the smallest key in the heap (heap unchanged)
- * \param H the heap we're working on
- *
- * \return the smallest key in the heap without modifying the heap.
- */
-inline double xbt_heap_maxkey(xbt_heap_t H)
-{
-  xbt_assert(H->count != 0, "Empty heap");
-  return KEY(H, 0);
-}
-
-/**
- * @brief returns the value associated to the smallest key in the heap (heap unchanged)
- * \param H the heap we're working on
- *
- * \return the value associated to the smallest key in the heap
- * without modifying the heap.
- */
-void *xbt_heap_maxcontent(xbt_heap_t H)
-{
-  xbt_assert(H->count != 0, "Empty heap");
-  return CONTENT(H, 0);
-}
-
-/* <<<< private >>>>
- * \param H the heap we're working on
- *
- * Restores the heap property once an element has been deleted.
- */
-static void xbt_heap_max_heapify(xbt_heap_t H, int index)
-{
-  int i = index;
-  int count = H->count;
-  xbt_heap_item_t items = H->items;
-
-  while (1) {
-    int greatest = i;
-    int l = LEFT(i);
-    int r = l + 1;
-    if (l < count && items[l].key < items[i].key)
-      greatest = l;
-    if (r < count && items[r].key < items[greatest].key)
-      greatest = r;
-    if (greatest != i) {
-      struct xbt_heap_item tmp = items[i];
-      items[i] = items[greatest];
-      items[greatest] = tmp;
-      if (H->update_callback)
-        H->update_callback(items[i].content, i);
-      i = greatest;
-    } else {
-      if (H->update_callback)
-        H->update_callback(items[i].content, i);
-      return;
-    }
-  }
-}
-
-/* <<<< private >>>>
- * \param H the heap we're working on
- * \param i an item position in the heap
- *
- * Moves up an item at position i to its correct position. Works only when called from xbt_heap_push.
- * Do not use otherwise.
- */
-static void xbt_heap_increase_key(xbt_heap_t H, int i)
-{
-  xbt_heap_item_t items = H->items;
-  int p = PARENT(i);
-  while (i > 0 && items[p].key > items[i].key) {
-    struct xbt_heap_item tmp = items[i];
-    items[i] = items[p];
-    items[p] = tmp;
-    if (H->update_callback)
-      H->update_callback(items[i].content, i);
-    i = p;
-    p = PARENT(i);
-  }
-  if (H->update_callback)
-    H->update_callback(items[i].content, i);
-}
diff --git a/src/xbt/heap_private.h b/src/xbt/heap_private.h
deleted file mode 100644 (file)
index aeed373..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright (c) 2004-2017. The SimGrid Team. All rights reserved.          */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#ifndef XBT_HEAP_PRIVATE_H
-#define XBT_HEAP_PRIVATE_H
-
-#include <float.h>
-#include <xbt/dynar.h>
-#include <xbt/heap.h>
-
-typedef struct xbt_heap_item {
-  void *content;
-  double key;
-} s_xbt_heap_item_t;
-typedef s_xbt_heap_item_t* xbt_heap_item_t;
-
-typedef struct xbt_heap {
-  int size;
-  int count;
-  s_xbt_heap_item_t* items; /* array of structs */
-  void_f_pvoid_t free;
-  void (*update_callback) (void *, int);
-} s_xbt_heap_t;
-
-#define PARENT(i)  (i >> 1)
-#define LEFT(i)    (i << 1)
-#define RIGHT(i)   ((i << 1) + 1)
-
-#define KEY(H,i)     ((H->items)[i]).key
-#define CONTENT(H,i) ((H->items)[i]).content
-
-#define MIN_KEY_VALUE -DBL_MAX
-
-#endif
index 5479e4d..6969b59 100644 (file)
@@ -112,7 +112,6 @@ static void xbt_log_connect_categories(void)
   XBT_LOG_CONNECT(xbt_backtrace);
   XBT_LOG_CONNECT(xbt_exception);
   XBT_LOG_CONNECT(xbt_graph);
-  XBT_LOG_CONNECT(xbt_heap);
   XBT_LOG_CONNECT(xbt_mallocator);
   XBT_LOG_CONNECT(xbt_memory_map);
   XBT_LOG_CONNECT(xbt_parmap);
index 92a311b..810cd26 100644 (file)
@@ -124,8 +124,8 @@ void xbt_init(int *argc, char **argv)
 {
   simgrid::xbt::installExceptionHandler();
 
-  if (xbt_initialized) {
-    xbt_initialized++;
+  xbt_initialized++;
+  if (xbt_initialized > 1) {
     XBT_DEBUG("XBT has been initialized %d times.", xbt_initialized);
     return;
   }
@@ -139,16 +139,16 @@ void xbt_init(int *argc, char **argv)
 }
 
 /* these two functions belong to xbt/sysdep.h, which have no corresponding .c file */
-/** @brief like free, but you can be sure that it is a function  */
+/** @brief like xbt_free, but you can be sure that it is a function  */
 void xbt_free_f(void *p)
 {
-  free(p);
+  xbt_free(p);
 }
 
 /** @brief should be given a pointer to pointer, and frees the second one */
 void xbt_free_ref(void *d)
 {
-  free(*(void **) d);
+  xbt_free(*(void**)d);
 }
 
 /** @brief Kill the program in silence */
index 9a1a893..06f1860 100644 (file)
@@ -188,7 +188,7 @@ xbt_dynar_t xbt_str_split_quoted(const char *s)
     char *q=xbt_strdup(p);
     xbt_dynar_push(res,&q);
   }
-  free(str_to_free);
+  xbt_free(str_to_free);
   xbt_dynar_shrink(res, 0);
   xbt_dynar_free(&parsed);
   return res;
index de1555f..c1eb4fa 100644 (file)
@@ -110,7 +110,7 @@ struct s_foo {
   int i;
 };
 
-static void test_type_by_name(simgrid::mc::RemoteClient& process, s_foo my_foo)
+static void test_type_by_name(simgrid::mc::RemoteClient& process, s_foo /*my_foo*/)
 {
   assert(process.binary_info->full_types_by_name.find("struct s_foo") != process.binary_info->full_types_by_name.end());
 }
index c6c2296..3ff450c 100644 (file)
@@ -37,8 +37,8 @@ $ $SG_TEST_EXENV ${bindir:=.}/cloud-sharing$EXEEXT --log=root.fmt:%m%n ${srcdir:
 > Passed: (Xx)2 with 1 load (100000000flops) took 0.1s as expected
 > ### Test '( ooo )2'. 3 tasks on a bicore PM
 > Passed: (xxX)2 with 0.6667 load (66666666flops) took 0.1s as expected
-> Passed: (Xxx)2 with 0.6667 load (66666666flops) took 0.1s as expected
 > Passed: (xXx)2 with 0.6667 load (66666666flops) took 0.1s as expected
+> Passed: (Xxx)2 with 0.6667 load (66666666flops) took 0.1s as expected
 > # TEST ON TWO-CORE PMs AND SINGLE-CORE VMs
 > ## Check impact of a single VM (no degradation for the moment)
 > ### Test '( [o]1 )2'. A task in a VM on a bicore PM
@@ -62,8 +62,8 @@ $ $SG_TEST_EXENV ${bindir:=.}/cloud-sharing$EXEEXT --log=root.fmt:%m%n ${srcdir:
 > Passed: ( [x]1 [X]1 [ ]1 )2 with 1 load (100000000flops) took 0.1s as expected
 > ### Put three VMs on a PM, and put a task to each VM
 > Passed: ( [X]1 [o]1 [o]1 )2 with 0.6667 load (66666666flops) took 0.1s as expected
-> Passed: ( [o]1 [o]1 [X]1 )2 with 0.6667 load (66666666flops) took 0.1s as expected
 > Passed: ( [o]1 [X]1 [o]1 )2 with 0.6667 load (66666666flops) took 0.1s as expected
+> Passed: ( [o]1 [o]1 [X]1 )2 with 0.6667 load (66666666flops) took 0.1s as expected
 > # TEST ON TWO-CORE PMs AND TWO-CORE VMs
 > ## Check impact of a single VM (there is no degradation for the moment)
 > ### Put a VM on a PM, and put a task to the VM
@@ -73,8 +73,8 @@ $ $SG_TEST_EXENV ${bindir:=.}/cloud-sharing$EXEEXT --log=root.fmt:%m%n ${srcdir:
 > Passed: ( [Xo]2 )2 with 1 load (100000000flops) took 0.1s as expected
 > ### Put a VM on a PM, and put three tasks to the VM
 > Passed: ( [ooX]2 )2 with 0.6667 load (66666666flops) took 0.1s as expected
-> Passed: ( [Xoo]2 )2 with 0.6667 load (66666666flops) took 0.1s as expected
 > Passed: ( [oXo]2 )2 with 0.6667 load (66666666flops) took 0.1s as expected
+> Passed: ( [Xoo]2 )2 with 0.6667 load (66666666flops) took 0.1s as expected
 > ## Check impact of a single VM collocated with a task (there is no degradation for the moment)
 > ### Put a VM on a PM, and put a task to the PM
 > Passed: ( [ ]2 X )2 with 1 load (100000000flops) took 0.1s as expected
@@ -88,26 +88,26 @@ $ $SG_TEST_EXENV ${bindir:=.}/cloud-sharing$EXEEXT --log=root.fmt:%m%n ${srcdir:
 > ### Put a VM on a PM, put one task to the PM and three tasks to the VM
 > Passed: ( [ooo]2 X )2 with 0.6667 load (66666666flops) took 0.1s as expected
 > Passed: ( [ooX]2 o )2 with 0.4444 load (44444444flops) took 0.1s as expected
-> Passed: ( [Xoo]2 o )2 with 0.4444 load (44444444flops) took 0.1s as expected
 > Passed: ( [oXo]2 o )2 with 0.4444 load (44444444flops) took 0.1s as expected
+> Passed: ( [Xoo]2 o )2 with 0.4444 load (44444444flops) took 0.1s as expected
 > ### Put a VM on a PM, and put two tasks to the PM
 > Passed: ( [ ]2 oX )2 with 1 load (100000000flops) took 0.1s as expected
 > Passed: ( [ ]2 Xo )2 with 1 load (100000000flops) took 0.1s as expected
 > ### Put a VM on a PM, put one task to the PM and one task to the VM
-> Passed: ( [o]2 Xo )2 with 0.6667 load (66666666flops) took 0.1s as expected
 > Passed: ( [o]2 oX )2 with 0.6667 load (66666666flops) took 0.1s as expected
+> Passed: ( [o]2 Xo )2 with 0.6667 load (66666666flops) took 0.1s as expected
 > Passed: ( [X]2 oo )2 with 0.6667 load (66666666flops) took 0.1s as expected
 > ### Put a VM on a PM, put one task to the PM and two tasks to the VM
-> Passed: ( [oo]2 Xo )2 with 0.5 load (50000000flops) took 0.1s as expected
 > Passed: ( [oo]2 oX )2 with 0.5 load (50000000flops) took 0.1s as expected
+> Passed: ( [oo]2 Xo )2 with 0.5 load (50000000flops) took 0.1s as expected
 > Passed: ( [oX]2 oo )2 with 0.5 load (50000000flops) took 0.1s as expected
 > Passed: ( [Xo]2 oo )2 with 0.5 load (50000000flops) took 0.1s as expected
 > ### Put a VM on a PM, put one task to the PM and three tasks to the VM
-> Passed: ( [ooo]2 Xo )2 with 0.5 load (50000000flops) took 0.1s as expected
 > Passed: ( [ooo]2 oX )2 with 0.5 load (50000000flops) took 0.1s as expected
+> Passed: ( [ooo]2 Xo )2 with 0.5 load (50000000flops) took 0.1s as expected
 > Passed: ( [ooX]2 oo )2 with 0.3333 load (33333333flops) took 0.1s as expected
-> Passed: ( [Xoo]2 oo )2 with 0.3333 load (33333333flops) took 0.1s as expected
 > Passed: ( [oXo]2 oo )2 with 0.3333 load (33333333flops) took 0.1s as expected
+> Passed: ( [Xoo]2 oo )2 with 0.3333 load (33333333flops) took 0.1s as expected
 > # TEST ON FOUR-CORE PMs AND TWO-CORE VMs
 > ## Check impact of a single VM
 > ### Put a VM on a PM, and put a task to the VM
@@ -117,8 +117,8 @@ $ $SG_TEST_EXENV ${bindir:=.}/cloud-sharing$EXEEXT --log=root.fmt:%m%n ${srcdir:
 > Passed: ( [Xo]2 )4 with 1 load (100000000flops) took 0.1s as expected
 > ### ( [ooo]2 )4: Put a VM on a PM, and put three tasks to the VM
 > Passed: ( [ooX]2 )4 with 0.6667 load (66666666flops) took 0.1s as expected
-> Passed: ( [Xoo]2 )4 with 0.6667 load (66666666flops) took 0.1s as expected
 > Passed: ( [oXo]2 )4 with 0.6667 load (66666666flops) took 0.1s as expected
+> Passed: ( [Xoo]2 )4 with 0.6667 load (66666666flops) took 0.1s as expected
 > ## Check impact of a single empty VM collocated with tasks
 > ### Put a VM on a PM, and put a task to the PM
 > Passed: ( [ ]2 X )4 with 1 load (100000000flops) took 0.1s as expected
@@ -127,8 +127,8 @@ $ $SG_TEST_EXENV ${bindir:=.}/cloud-sharing$EXEEXT --log=root.fmt:%m%n ${srcdir:
 > Passed: ( [ ]2 Xo )4 with 1 load (100000000flops) took 0.1s as expected
 > ### Put a VM on a PM, and put three tasks to the PM
 > Passed: ( [ ]2 ooX )4 with 1 load (100000000flops) took 0.1s as expected
-> Passed: ( [ ]2 Xoo )4 with 1 load (100000000flops) took 0.1s as expected
 > Passed: ( [ ]2 oXo )4 with 1 load (100000000flops) took 0.1s as expected
+> Passed: ( [ ]2 Xoo )4 with 1 load (100000000flops) took 0.1s as expected
 > ### Put a VM on a PM, and put four tasks to the PM
 > Passed: ( [ ]2 oooX )4 with 1 load (100000000flops) took 0.1s as expected
 > Passed: ( [ ]2 ooXo )4 with 1 load (100000000flops) took 0.1s as expected
@@ -139,32 +139,32 @@ $ $SG_TEST_EXENV ${bindir:=.}/cloud-sharing$EXEEXT --log=root.fmt:%m%n ${srcdir:
 > Passed: ( [o]2 X )4 with 1 load (100000000flops) took 0.1s as expected
 > Passed: ( [X]2 o )4 with 1 load (100000000flops) took 0.1s as expected
 > ### Put a VM on a PM, and put two tasks to the PM and one task to the VM
-> Passed: ( [o]2 Xo )4 with 1 load (100000000flops) took 0.1s as expected
 > Passed: ( [o]2 oX )4 with 1 load (100000000flops) took 0.1s as expected
+> Passed: ( [o]2 Xo )4 with 1 load (100000000flops) took 0.1s as expected
 > Passed: ( [X]2 oo )4 with 1 load (100000000flops) took 0.1s as expected
 > ### Put a VM on a PM, and put two tasks to the PM and two tasks to the VM
-> Passed: ( [oo]2 Xo )4 with 1 load (100000000flops) took 0.1s as expected
 > Passed: ( [oo]2 oX )4 with 1 load (100000000flops) took 0.1s as expected
+> Passed: ( [oo]2 Xo )4 with 1 load (100000000flops) took 0.1s as expected
 > Passed: ( [oX]2 oo )4 with 1 load (100000000flops) took 0.1s as expected
 > Passed: ( [Xo]2 oo )4 with 1 load (100000000flops) took 0.1s as expected
 > ### Put a VM on a PM, and put three tasks to the PM and one tasks to the VM
 > Passed: ( [o]2 ooX )4 with 1 load (100000000flops) took 0.1s as expected
-> Passed: ( [o]2 Xoo )4 with 1 load (100000000flops) took 0.1s as expected
 > Passed: ( [o]2 oXo )4 with 1 load (100000000flops) took 0.1s as expected
+> Passed: ( [o]2 Xoo )4 with 1 load (100000000flops) took 0.1s as expected
 > Passed: ( [X]2 ooo )4 with 1 load (100000000flops) took 0.1s as expected
 > ### Put a VM on a PM, and put three tasks to the PM and two tasks to the VM
 > Passed: ( [oo]2 ooX )4 with 0.8 load (80000000flops) took 0.1s as expected
-> Passed: ( [oo]2 Xoo )4 with 0.8 load (80000000flops) took 0.1s as expected
 > Passed: ( [oo]2 oXo )4 with 0.8 load (80000000flops) took 0.1s as expected
+> Passed: ( [oo]2 Xoo )4 with 0.8 load (80000000flops) took 0.1s as expected
 > Passed: ( [oX]2 ooo )4 with 0.8 load (80000000flops) took 0.1s as expected
 > Passed: ( [Xo]2 ooo )4 with 0.8 load (80000000flops) took 0.1s as expected
 > ### Put a VM on a PM, and put three tasks to the PM and three tasks to the VM
 > Passed: ( [ooo]2 ooX )4 with 0.8 load (80000000flops) took 0.1s as expected
-> Passed: ( [ooo]2 Xoo )4 with 0.8 load (80000000flops) took 0.1s as expected
 > Passed: ( [ooo]2 oXo )4 with 0.8 load (80000000flops) took 0.1s as expected
+> Passed: ( [ooo]2 Xoo )4 with 0.8 load (80000000flops) took 0.1s as expected
 > Passed: ( [ooX]2 ooo )4 with 0.5333 load (53333333flops) took 0.1s as expected
-> Passed: ( [Xoo]2 ooo )4 with 0.5333 load (53333333flops) took 0.1s as expected
 > Passed: ( [oXo]2 ooo )4 with 0.5333 load (53333333flops) took 0.1s as expected
+> Passed: ( [Xoo]2 ooo )4 with 0.5333 load (53333333flops) took 0.1s as expected
 >    
 >    
 > ## 0 test failed
index 7de0dc6..7b14f78 100644 (file)
@@ -5,7 +5,7 @@
     <argument value="25"/>
     <argument value="1.0"/>
   </actor>
-  <actor host="Cpu B" function="test_trace" start_time="10">
+  <actor host="Cpu B" function="test_trace" start_time="10.5">
     <argument value="75"/>
     <argument value="3.0"/>
   </actor>
index 0048734..e846646 100644 (file)
@@ -5,7 +5,7 @@
     <argument value="50"/>
     <argument value="2.5"/>
   </actor>
-  <actor host="Cpu B" function="test_trace" start_time="10">
+  <actor host="Cpu B" function="test_trace" start_time="10.5">
     <argument value="70"/>
     <argument value="1.5"/>
   </actor>
index 3ba862d..58b9ad9 100644 (file)
@@ -123,26 +123,26 @@ $ ./trace_integration ${srcdir:=.}/../../../examples/platforms/two_hosts_platfor
 > [ 10.000000] (1:test_trace@Cpu B) Testing the trace integration cpu model: CpuTI
 > [ 10.000000] (1:test_trace@Cpu B) Task size: 50.000000
 > [ 10.000000] (1:test_trace@Cpu B) Task prio: 2.500000
-> [ 10.000000] (2:test_trace@Cpu B) Testing the trace integration cpu model: CpuTI
-> [ 10.000000] (2:test_trace@Cpu B) Task size: 70.000000
-> [ 10.000000] (2:test_trace@Cpu B) Task prio: 1.500000
-> [ 20.000000] (1:test_trace@Cpu B) Test finished
+> [ 10.500000] (2:test_trace@Cpu B) Testing the trace integration cpu model: CpuTI
+> [ 10.500000] (2:test_trace@Cpu B) Task size: 70.000000
+> [ 10.500000] (2:test_trace@Cpu B) Task prio: 1.500000
+> [ 19.700000] (1:test_trace@Cpu B) Test finished
 > [ 30.000000] (2:test_trace@Cpu B) Test finished
 
-p Testing trace integration using trace_B.txt and test-hbp2.5-hbp1.5.xml, two process with different priority
+p Testing trace integration using trace_B.txt and test-hbp2.5-hbp1.5.xml, two process with different priority (included)
 
 ! output sort
-$ ./trace_integration ${srcdir:=.}/../../../examples/platforms/two_hosts_platform_with_availability.xml  ${srcdir:=.}/test-hbp2.5-hbp1.5.xml --cfg=host/model:compound --cfg=network/model:CM02 --cfg=cpu/optim:TI --log=simix.thresh:warning "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ./trace_integration ${srcdir:=.}/../../../examples/platforms/two_hosts_platform_with_availability_included.xml  ${srcdir:=.}/test-hbp2.5-hbp1.5.xml --cfg=host/model:compound --cfg=network/model:CM02 --cfg=cpu/optim:TI --log=simix.thresh:warning "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
 > [  0.000000] (0:maestro@) Configuration change: Set 'host/model' to 'compound'
 > [  0.000000] (0:maestro@) Configuration change: Set 'network/model' to 'CM02'
 > [  0.000000] (0:maestro@) Configuration change: Set 'cpu/optim' to 'TI'
 > [ 10.000000] (1:test_trace@Cpu B) Testing the trace integration cpu model: CpuTI
 > [ 10.000000] (1:test_trace@Cpu B) Task size: 50.000000
 > [ 10.000000] (1:test_trace@Cpu B) Task prio: 2.500000
-> [ 10.000000] (2:test_trace@Cpu B) Testing the trace integration cpu model: CpuTI
-> [ 10.000000] (2:test_trace@Cpu B) Task size: 70.000000
-> [ 10.000000] (2:test_trace@Cpu B) Task prio: 1.500000
-> [ 20.000000] (1:test_trace@Cpu B) Test finished
+> [ 10.500000] (2:test_trace@Cpu B) Testing the trace integration cpu model: CpuTI
+> [ 10.500000] (2:test_trace@Cpu B) Task size: 70.000000
+> [ 10.500000] (2:test_trace@Cpu B) Task prio: 1.500000
+> [ 19.700000] (1:test_trace@Cpu B) Test finished
 > [ 30.000000] (2:test_trace@Cpu B) Test finished
 
 p Testing trace integration using trace_B.txt and test-hbp1.0-hbp1.0-hbp1.0.xml, three process with same priority
@@ -165,26 +165,6 @@ $ ./trace_integration ${srcdir:=.}/../../../examples/platforms/two_hosts_platfor
 > [ 50.000000] (2:test_trace@Cpu B) Test finished
 > [ 60.000000] (3:test_trace@Cpu B) Test finished
 
-p Testing trace integration using trace_B.txt and test-hbp1.0-hbp3.0-hbp4.0.xml, three process with same priority
-
-! output sort
-$ ./trace_integration ${srcdir:=.}/../../../examples/platforms/two_hosts_platform_with_availability.xml  ${srcdir:=.}/test-hbp1.0-hbp3.0-hbp4.0.xml --cfg=host/model:compound --cfg=network/model:CM02 --cfg=cpu/optim:TI --log=simix.thresh:warning "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
-> [  0.000000] (0:maestro@) Configuration change: Set 'host/model' to 'compound'
-> [  0.000000] (0:maestro@) Configuration change: Set 'network/model' to 'CM02'
-> [  0.000000] (0:maestro@) Configuration change: Set 'cpu/optim' to 'TI'
-> [ 10.000000] (1:test_trace@Cpu B) Testing the trace integration cpu model: CpuTI
-> [ 10.000000] (1:test_trace@Cpu B) Task size: 25.000000
-> [ 10.000000] (1:test_trace@Cpu B) Task prio: 1.000000
-> [ 10.000000] (2:test_trace@Cpu B) Testing the trace integration cpu model: CpuTI
-> [ 10.000000] (2:test_trace@Cpu B) Task size: 75.000000
-> [ 10.000000] (2:test_trace@Cpu B) Task prio: 3.000000
-> [ 20.000000] (3:test_trace@Cpu B) Testing the trace integration cpu model: CpuTI
-> [ 20.000000] (3:test_trace@Cpu B) Task size: 120.000000
-> [ 20.000000] (3:test_trace@Cpu B) Task prio: 4.000000
-> [ 30.000000] (1:test_trace@Cpu B) Test finished
-> [ 30.000000] (2:test_trace@Cpu B) Test finished
-> [ 40.000000] (3:test_trace@Cpu B) Test finished
-
 p Testing trace integration using trace_B.txt and test-hbp1.0-hbp3.0-hbp4.0.xml, three process with different priority
 
 ! output sort
@@ -195,14 +175,14 @@ $ ./trace_integration ${srcdir:=.}/../../../examples/platforms/two_hosts_platfor
 > [ 10.000000] (1:test_trace@Cpu B) Testing the trace integration cpu model: CpuTI
 > [ 10.000000] (1:test_trace@Cpu B) Task size: 25.000000
 > [ 10.000000] (1:test_trace@Cpu B) Task prio: 1.000000
-> [ 10.000000] (2:test_trace@Cpu B) Testing the trace integration cpu model: CpuTI
-> [ 10.000000] (2:test_trace@Cpu B) Task size: 75.000000
-> [ 10.000000] (2:test_trace@Cpu B) Task prio: 3.000000
+> [ 10.500000] (2:test_trace@Cpu B) Testing the trace integration cpu model: CpuTI
+> [ 10.500000] (2:test_trace@Cpu B) Task size: 75.000000
+> [ 10.500000] (2:test_trace@Cpu B) Task prio: 3.000000
 > [ 20.000000] (3:test_trace@Cpu B) Testing the trace integration cpu model: CpuTI
 > [ 20.000000] (3:test_trace@Cpu B) Task size: 120.000000
 > [ 20.000000] (3:test_trace@Cpu B) Task prio: 4.000000
-> [ 30.000000] (1:test_trace@Cpu B) Test finished
-> [ 30.000000] (2:test_trace@Cpu B) Test finished
+> [ 24.000000] (1:test_trace@Cpu B) Test finished
+> [ 30.400000] (2:test_trace@Cpu B) Test finished
 > [ 40.000000] (3:test_trace@Cpu B) Test finished
 
 p Testing trace integration using trace_B.txt and test-hbp1.0-hbp3.0-hbp4.0.xml, three process with different priority (included)
@@ -215,12 +195,12 @@ $ ./trace_integration ${srcdir:=.}/../../../examples/platforms/two_hosts_platfor
 > [ 10.000000] (1:test_trace@Cpu B) Testing the trace integration cpu model: CpuTI
 > [ 10.000000] (1:test_trace@Cpu B) Task size: 25.000000
 > [ 10.000000] (1:test_trace@Cpu B) Task prio: 1.000000
-> [ 10.000000] (2:test_trace@Cpu B) Testing the trace integration cpu model: CpuTI
-> [ 10.000000] (2:test_trace@Cpu B) Task size: 75.000000
-> [ 10.000000] (2:test_trace@Cpu B) Task prio: 3.000000
+> [ 10.500000] (2:test_trace@Cpu B) Testing the trace integration cpu model: CpuTI
+> [ 10.500000] (2:test_trace@Cpu B) Task size: 75.000000
+> [ 10.500000] (2:test_trace@Cpu B) Task prio: 3.000000
 > [ 20.000000] (3:test_trace@Cpu B) Testing the trace integration cpu model: CpuTI
 > [ 20.000000] (3:test_trace@Cpu B) Task size: 120.000000
 > [ 20.000000] (3:test_trace@Cpu B) Task prio: 4.000000
-> [ 30.000000] (1:test_trace@Cpu B) Test finished
-> [ 30.000000] (2:test_trace@Cpu B) Test finished
+> [ 24.000000] (1:test_trace@Cpu B) Test finished
+> [ 30.400000] (2:test_trace@Cpu B) Test finished
 > [ 40.000000] (3:test_trace@Cpu B) Test finished
index 8be078f..6e2576a 100644 (file)
@@ -19,16 +19,16 @@ $ ./concurrent_rw$EXEEXT ${srcdir:=.}/../../../examples/platforms/storage/storag
 > [  4.600000] (host@bob) process 4 goes to sleep for 2 seconds
 > [  5.500000] (host@bob) process 5 is writing again!
 > [  5.600000] (host@bob) process 5 goes to sleep for 1 seconds
-> [  6.600000] (host@bob) process 4 is reading!
-> [  6.600000] (host@bob) process 5 is reading!
 > [  6.600000] (host@bob) process 1 is reading!
 > [  6.600000] (host@bob) process 2 is reading!
 > [  6.600000] (host@bob) process 3 is reading!
-> [  6.750000] (host@bob) process 4 goes to sleep for 4 seconds
-> [  6.750000] (host@bob) process 5 goes to sleep for 5 seconds
+> [  6.600000] (host@bob) process 4 is reading!
+> [  6.600000] (host@bob) process 5 is reading!
 > [  6.750000] (host@bob) process 1 goes to sleep for 1 seconds
 > [  6.750000] (host@bob) process 2 goes to sleep for 2 seconds
 > [  6.750000] (host@bob) process 3 goes to sleep for 3 seconds
+> [  6.750000] (host@bob) process 4 goes to sleep for 4 seconds
+> [  6.750000] (host@bob) process 5 goes to sleep for 5 seconds
 > [  7.750000] (host@bob) process 1 is reading again!
 > [  7.780000] (host@bob) process 1 => Size of /home/doc/simgrid/examples/platforms/g5k.xml1: 6000000
 > [  8.750000] (host@bob) process 2 is reading again!
index 52d9ace..9ef8840 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "simgrid/s4u.hpp"
 #include <string>
+#include <xbt/string.hpp>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(storage, "Messages specific for this simulation");
 
@@ -22,37 +23,33 @@ static void display_storage_properties(simgrid::s4u::Storage* storage)
   }
 }
 
-static sg_size_t write_local_file(const char* dest, sg_size_t file_size)
+static sg_size_t write_local_file(const std::string& dest, sg_size_t file_size)
 {
-  simgrid::s4u::File* file = new simgrid::s4u::File(dest, nullptr);
-  sg_size_t written        = file->write(file_size);
+  simgrid::s4u::File file(dest, nullptr);
+  sg_size_t written = file.write(file_size);
   XBT_INFO("%llu bytes on %llu bytes have been written by %s on /sd1", written, file_size,
            simgrid::s4u::Actor::self()->getCname());
-  delete file;
   return written;
 }
 
-static sg_size_t read_local_file(const char* src)
+static sg_size_t read_local_file(const std::string& src)
 {
-  simgrid::s4u::File* file = new simgrid::s4u::File(src, nullptr);
-  sg_size_t file_size      = file->size();
-  sg_size_t read           = file->read(file_size);
-
-  XBT_INFO("%s has read %llu on %s", simgrid::s4u::Actor::self()->getCname(), read, src);
-  delete file;
-
+  simgrid::s4u::File file(src, nullptr);
+  sg_size_t file_size = file.size();
+  sg_size_t read      = file.read(file_size);
+  XBT_INFO("%s has read %llu on %s", simgrid::s4u::Actor::self()->getCname(), read, src.c_str());
   return read;
 }
 
 // Read src file on local disk and send a put message to remote host (size of message = size of src file)
-static void hsm_put(const char* remote_host, const char* src, const char* dest)
+static void hsm_put(const std::string& remote_host, const std::string& src, const std::string& dest)
 {
   // Read local src file, and return the size that was actually read
   sg_size_t read_size = read_local_file(src);
 
   // Send file
-  XBT_INFO("%s sends %llu to %s", simgrid::s4u::this_actor::getCname(), read_size, remote_host);
-  char* payload                    = bprintf("%s %llu", dest, read_size);
+  XBT_INFO("%s sends %llu to %s", simgrid::s4u::this_actor::getCname(), read_size, remote_host.c_str());
+  std::string* payload             = new std::string(simgrid::xbt::string_printf("%s %llu", dest.c_str(), read_size));
   simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(remote_host);
   mailbox->put(payload, static_cast<double>(read_size));
   simgrid::s4u::this_actor::sleep_for(.4);
@@ -70,16 +67,16 @@ static void display_storage_content(simgrid::s4u::Storage* storage)
   }
 }
 
-static void dump_storage_by_name(const char* name)
+static void dump_storage_by_name(const std::string& name)
 {
   XBT_INFO("*** Dump a storage element ***");
   simgrid::s4u::Storage* storage = simgrid::s4u::Storage::byName(name);
   display_storage_content(storage);
 }
 
-static void get_set_storage_data(const char* storage_name)
+static void get_set_storage_data(const std::string& storage_name)
 {
-  XBT_INFO("*** GET/SET DATA for storage element: %s ***", storage_name);
+  XBT_INFO("*** GET/SET DATA for storage element: %s ***", storage_name.c_str());
   simgrid::s4u::Storage* storage = simgrid::s4u::Storage::byName(storage_name);
 
   char* data = static_cast<char*>(storage->getUserdata());
@@ -106,9 +103,9 @@ static void storage_info(simgrid::s4u::Host* host)
   XBT_INFO("*** Storage info on %s ***", host->getCname());
 
   for (auto const& elm : host->getMountedStorages()) {
-    const char* mount_name         = elm.first.c_str();
+    const std::string& mount_name  = elm.first;
     simgrid::s4u::Storage* storage = elm.second;
-    XBT_INFO("\tStorage name: %s, mount name: %s", storage->getCname(), mount_name);
+    XBT_INFO("\tStorage name: %s, mount name: %s", storage->getCname(), mount_name.c_str());
 
     sg_size_t free_size = storage->getSizeFree();
     sg_size_t used_size = storage->getSizeUsed();
@@ -128,7 +125,7 @@ static void client()
   hsm_put("alice", "/home/doc/simgrid/examples/msg/alias/masterslave_forwarder_with_alias.c", "c:\\Windows\\tata.c");
 
   simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName("alice");
-  mailbox->put(xbt_strdup("finalize"), 0);
+  mailbox->put(new std::string("finalize"), 0);
 
   get_set_storage_data("Disk1");
 }
@@ -140,16 +137,16 @@ static void server()
 
   XBT_INFO("Server waiting for transfers ...");
   while (1) {
-    char* msg = static_cast<char*>(mailbox->get());
-    if (not strcmp(msg, "finalize")) { // Shutdown ...
-      xbt_free(msg);
+    std::string* msg = static_cast<std::string*>(mailbox->get());
+    if (*msg == "finalize") { // Shutdown ...
+      delete msg;
       break;
     } else { // Receive file to save
-      char* saveptr;
-      char* dest              = strtok_r(msg, " ", &saveptr);
-      sg_size_t size_to_write = std::stoull(strtok_r(nullptr, " ", &saveptr));
+      size_t pos              = msg->find(' ');
+      std::string dest        = msg->substr(0, pos);
+      sg_size_t size_to_write = std::stoull(msg->substr(pos + 1));
       write_local_file(dest, size_to_write);
-      xbt_free(dest);
+      delete msg;
     }
   }
 
@@ -159,17 +156,15 @@ static void server()
 
 int main(int argc, char* argv[])
 {
-  simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+  simgrid::s4u::Engine e(&argc, argv);
   xbt_assert(argc == 2, "Usage: %s platform_file\n", argv[0]);
-  e->loadPlatform(argv[1]);
+  e.loadPlatform(argv[1]);
 
   simgrid::s4u::Actor::createActor("server", simgrid::s4u::Host::by_name("alice"), server);
   simgrid::s4u::Actor::createActor("client", simgrid::s4u::Host::by_name("bob"), client);
 
-  e->run();
-
-  XBT_INFO("Simulated time: %g", e->getClock());
+  e.run();
 
-  delete e;
+  XBT_INFO("Simulated time: %g", e.getClock());
   return 0;
 }
index 622d3bc..cd94fdc 100644 (file)
@@ -47,17 +47,9 @@ static void create_environment(xbt_os_timer_t parse_time, const char *platformFi
   }
 }
 
-static void dump_platform()
+static void dump_hosts()
 {
-  int version = 4;
   std::map<std::string, std::string>* props = nullptr;
-
-  std::printf("<?xml version='1.0'?>\n");
-  std::printf("<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n");
-  std::printf("<platform version=\"%d\">\n", version);
-  std::printf("<AS id=\"AS0\" routing=\"Full\">\n");
-
-  // Hosts
   unsigned int totalHosts = sg_host_count();
   sg_host_t* hosts        = sg_host_list();
   std::sort(hosts, hosts + totalHosts,
@@ -79,20 +71,11 @@ static void dump_platform()
       std::printf("/>\n");
     }
   }
+  std::free(hosts);
+}
 
-  // Routers
-  std::vector<simgrid::kernel::routing::NetPoint*> netcardList;
-  simgrid::s4u::Engine::getInstance()->getNetpointList(&netcardList);
-  std::sort(netcardList.begin(), netcardList.end(),
-            [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) {
-              return a->getName() < b->getName();
-            });
-
-  for (auto const& srcCard : netcardList)
-    if (srcCard->isRouter())
-      std::printf("  <router id=\"%s\"/>\n", srcCard->getCname());
-
-  // Links
+static void dump_links()
+{
   unsigned int totalLinks    = sg_link_count();
   simgrid::s4u::Link** links = sg_link_list();
 
@@ -111,6 +94,36 @@ static void dump_platform()
     }
   }
 
+  std::free(links);
+}
+
+static void dump_routers()
+{
+  std::vector<simgrid::kernel::routing::NetPoint*> netcardList;
+  simgrid::s4u::Engine::getInstance()->getNetpointList(&netcardList);
+  std::sort(netcardList.begin(), netcardList.end(),
+            [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) {
+              return a->getName() < b->getName();
+            });
+
+  for (auto const& srcCard : netcardList)
+    if (srcCard->isRouter())
+      std::printf("  <router id=\"%s\"/>\n", srcCard->getCname());
+}
+
+static void dump_routes()
+{
+  unsigned int totalHosts = sg_host_count();
+  sg_host_t* hosts        = sg_host_list();
+  std::sort(hosts, hosts + totalHosts,
+            [](sg_host_t a, sg_host_t b) { return strcmp(sg_host_get_name(a), sg_host_get_name(b)) < 0; });
+  std::vector<simgrid::kernel::routing::NetPoint*> netcardList;
+  simgrid::s4u::Engine::getInstance()->getNetpointList(&netcardList);
+  std::sort(netcardList.begin(), netcardList.end(),
+            [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) {
+              return a->getName() < b->getName();
+            });
+
   for (unsigned int it_src = 0; it_src < totalHosts; it_src++) { // Routes from host
     simgrid::s4u::Host* host1                      = hosts[it_src];
     simgrid::kernel::routing::NetPoint* netcardSrc = host1->pimpl_netpoint;
@@ -118,7 +131,7 @@ static void dump_platform()
       simgrid::s4u::Host* host2 = hosts[it_dst];
       std::vector<simgrid::surf::LinkImpl*> route;
       simgrid::kernel::routing::NetPoint* netcardDst = host2->pimpl_netpoint;
-      simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(netcardSrc, netcardDst, &route, nullptr);
+      simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(netcardSrc, netcardDst, route, nullptr);
       if (not route.empty()) {
         std::printf("  <route src=\"%s\" dst=\"%s\">\n  ", host1->getCname(), host2->getCname());
         for (auto const& link : route)
@@ -126,11 +139,12 @@ static void dump_platform()
         std::printf("\n  </route>\n");
       }
     }
+
     for (auto const& netcardDst : netcardList) { // to router
       if (netcardDst->isRouter()) {
         std::printf("  <route src=\"%s\" dst=\"%s\">\n  ", host1->getCname(), netcardDst->getCname());
         std::vector<simgrid::surf::LinkImpl*> route;
-        simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(netcardSrc, netcardDst, &route, nullptr);
+        simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(netcardSrc, netcardDst, route, nullptr);
         for (auto const& link : route)
           std::printf("<link_ctn id=\"%s\"/>", link->getCname());
         std::printf("\n  </route>\n");
@@ -144,7 +158,7 @@ static void dump_platform()
         if (value2->isRouter()) {
           std::printf("  <route src=\"%s\" dst=\"%s\">\n  ", value1->getCname(), value2->getCname());
           std::vector<simgrid::surf::LinkImpl*> route;
-          simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(value1, value2, &route, nullptr);
+          simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(value1, value2, route, nullptr);
           for (auto const& link : route)
             std::printf("<link_ctn id=\"%s\"/>", link->getCname());
           std::printf("\n  </route>\n");
@@ -155,18 +169,39 @@ static void dump_platform()
         std::printf("  <route src=\"%s\" dst=\"%s\">\n  ", value1->getCname(), host2->getCname());
         std::vector<simgrid::surf::LinkImpl*> route;
         simgrid::kernel::routing::NetPoint* netcardDst = host2->pimpl_netpoint;
-        simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(value1, netcardDst, &route, nullptr);
+        simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(value1, netcardDst, route, nullptr);
         for (auto const& link : route)
           std::printf("<link_ctn id=\"%s\"/>", link->getCname());
         std::printf("\n  </route>\n");
       }
     }
   }
+  std::free(hosts);
+}
+
+static void dump_platform()
+{
+  int version = 4;
+
+  std::printf("<?xml version='1.0'?>\n");
+  std::printf("<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n");
+  std::printf("<platform version=\"%d\">\n", version);
+  std::printf("<AS id=\"AS0\" routing=\"Full\">\n");
+
+  // Hosts
+  dump_hosts();
+
+  // Routers
+  dump_routers();
+
+  // Links
+  dump_links();
+
+  // Routes
+  dump_routes();
 
   std::printf("</AS>\n");
   std::printf("</platform>\n");
-  std::free(hosts);
-  std::free(links);
 }
 
 int main(int argc, char** argv)
index 3ae06a0..c7eb726 100644 (file)
@@ -18,6 +18,10 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test, "my log messages");
 
 namespace example {
 
+class exception : public std::runtime_error {
+  using std::runtime_error::runtime_error;
+};
+
 /** Create a future which becomes ready when the date is reached */
 static
 simgrid::kernel::Future<void> kernel_wait_until(double date)
@@ -53,12 +57,11 @@ static int master(int argc, char *argv[])
     simgrid::simix::kernelSync([] {
       return kernel_wait_until(20).then([](simgrid::kernel::Future<void> future) {
         future.get();
-        throw std::runtime_error("Exception throwed from kernel_defer");
+        throw example::exception("Exception throwed from kernel_defer");
       });
     });
     XBT_ERROR("No exception caught!");
-  }
-  catch(std::runtime_error& e) {
+  } catch (const example::exception& e) {
     XBT_INFO("Exception caught: %s", e.what());
   }
 
index fcf19e4..cc7f9c7 100644 (file)
@@ -208,7 +208,7 @@ if(enable_smpi AND enable_model-checking AND enable_smpi_ISP_testsuite)
   foreach (test ${umpire_tests_passing} ${umpire_tests_deadlock} ${umpire_tests_problematic} )
     add_executable(${test} ${test}.c)
     target_link_libraries(${test} simgrid)
-    set_source_files_properties(${test}.c PROPERTIES COMPILE_FLAGS "-Wno-error -Wno-return-type")
+    set_source_files_properties(${test}.c PROPERTIES COMPILE_FLAGS "-Dlint -Wno-error -Wno-return-type")
     set(umpire_tesh ${umpire_tesh} ${test})
     set(files_to_clean ${files_to_clean} ${CMAKE_CURRENT_BINARY_DIR}/${test}.tesh)
   endforeach(test)
index 4d21ed5..e3c9d3e 100644 (file)
@@ -34,7 +34,6 @@ main (int argc, char **argv)
   MPI_Get_processor_name (processor_name, &namelen);
   printf ("(%d) is alive on %s\n", rank, processor_name);
   fflush (stdout);
-int j, k;
   for (i = 0; i < 128; i++)
     {
       buf0[i] = i;
index c6e54ca..7acfc01 100644 (file)
@@ -24,7 +24,6 @@ main (int argc, char **argv)
   int key = -1;
   int nrank;
   int nsize;
-  int dat = 0;
   int color = -1;
 
 
index c1a16fe..a4ab3d0 100644 (file)
@@ -15,7 +15,6 @@ main (int argc, char **argv)
   char processor_name[128];
   int namelen = 128;
   int buf0[buf_size];
-  int buf1[buf_size];
   MPI_Status status;
   MPI_Request req;
 
index 4a6051b..9eee182 100644 (file)
@@ -14,7 +14,7 @@ static char *rcsid =
 
 #define buf_size 128
 
-int mydelay ()                 /* about 6 seconds */
+static int mydelay(void) /* about 6 seconds */
 {
   int i;
   int val;
@@ -37,8 +37,8 @@ main (int argc, char **argv)
   int namelen = 128;
   int buf0[buf_size];
   int buf1[buf_size];
-  MPI_Request req, req0, req1;
-  MPI_Status status, status0, status1;
+  MPI_Request req;
+  MPI_Status status;
   MPI_Request areq[10];
   MPI_Status astatus[10];
 
index 75bdb65..f7924fd 100644 (file)
@@ -47,7 +47,7 @@ main (int argc, char **argv)
        MPI_Send (&flipbit, 1, MPI_INT, 1, i, MPI_COMM_WORLD);
 
        flag = 0;
-printf ("req = %0x", (unsigned int)reqs);
+       printf("req = %p", reqs);
        while (!flag)
            MPI_Testany (i, reqs, &done, &flag, &status);
 
index 67acdc0..e528524 100644 (file)
@@ -26,7 +26,6 @@ main (int argc, char **argv)
   MPI_Get_processor_name (processor_name, &namelen);
   printf ("(%d) is alive on %s\n", rank, processor_name);
   fflush (stdout);
-       int i;
   MPI_Barrier (MPI_COMM_WORLD);
 
   if (nprocs < 2)
index a9ac647..e92bcd1 100644 (file)
@@ -17,7 +17,7 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite)
 endif()
 
 if (enable_smpi_MPICH3_testsuite AND HAVE_RAW_CONTEXTS)
-  ADD_TEST(test-smpi-mpich3-perf-raw       ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/perf ${PERL_EXECUTABLE} ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests ${TESH_OPTION} -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/perf -tests=testlist -execarg=--cfg=contexts/factory:raw -execarg=--cfg=smpi/host-speed:-1)
+  ADD_TEST(test-smpi-mpich3-perf-raw       ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/perf ${PERL_EXECUTABLE} ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests ${TESH_OPTION} -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -tests=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/perf/testlist -execarg=-platform\ ${CMAKE_HOME_DIRECTORY}/examples/platforms/cluster.xml -execarg=--log=root.thr:critical -execarg=--cfg=smpi/async-small-thresh:65536 -execarg=--cfg=contexts/factory:raw -execarg=--cfg=smpi/host-speed:-1)
 endif()
 
 foreach(file allredtrace commcreatep non_zero_root sendrecvl timer transp-datatype twovec dtpack indexperf manyrma 
index ea6c304..8793198 100755 (executable)
@@ -282,6 +282,7 @@ else {
         print "TAP formatted results in $tapfullfile\n";
     }
 }
+exit ($err_count > 0);
 #\f
 # ---------------------------------------------------------------------------
 # Routines
index ac869f5..71c2fd4 100644 (file)
@@ -12,6 +12,7 @@
 #include "xbt/log.h"
 #include "xbt/module.h"
 #include "xbt/sysdep.h"
+#include <algorithm>
 #include <cmath>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example");
@@ -145,10 +146,10 @@ static void test1(method_t method)
     lagrange_solve(Sys);
 
     double max_deviation = 0.0;
-    max_deviation = MAX(max_deviation, fabs(lmm_variable_getvalue(R_1) - x));
-    max_deviation = MAX(max_deviation, fabs(lmm_variable_getvalue(R_3) - x));
-    max_deviation = MAX(max_deviation, fabs(lmm_variable_getvalue(R_2) - (b - a + x)));
-    max_deviation = MAX(max_deviation, fabs(lmm_variable_getvalue(R_1_2_3) - (a - x)));
+    max_deviation        = std::max(max_deviation, fabs(lmm_variable_getvalue(R_1) - x));
+    max_deviation        = std::max(max_deviation, fabs(lmm_variable_getvalue(R_3) - x));
+    max_deviation        = std::max(max_deviation, fabs(lmm_variable_getvalue(R_2) - (b - a + x)));
+    max_deviation        = std::max(max_deviation, fabs(lmm_variable_getvalue(R_1_2_3) - (a - x)));
 
     if (max_deviation > 0.00001) { // Legacy value used in lagrange.c
       XBT_WARN("Max Deviation from optimal solution : %g", max_deviation);
index 90914d6..57b800a 100644 (file)
@@ -67,40 +67,32 @@ int main(int argc, char **argv)
     XBT_DEBUG("\t CPU actions");
 
     simgrid::surf::ActionList* action_list = surf_cpu_model_pm->getFailedActionSet();
-    for(simgrid::surf::ActionList::iterator it(action_list->begin()), itNext = it, itend(action_list->end()) ;
-        it != itend ; it=itNext) {
-      ++itNext;
-      simgrid::surf::Action *action = static_cast<simgrid::surf::CpuAction*>(&*it);
-       XBT_INFO("   CPU Failed action");
-       XBT_DEBUG("\t * Failed : %p", action);
-       action->unref();
+    while (not action_list->empty()) {
+      simgrid::surf::Action* action = &*action_list->begin();
+      XBT_INFO("   CPU Failed action");
+      XBT_DEBUG("\t * Failed : %p", action);
+      action->unref();
     }
 
     action_list = surf_cpu_model_pm->getDoneActionSet();
-    for(simgrid::surf::ActionList::iterator it(action_list->begin()), itNext = it, itend(action_list->end()) ;
-        it != itend ; it=itNext) {
-      ++itNext;
-      simgrid::surf::Action *action = static_cast<simgrid::surf::CpuAction*>(&*it);
+    while (not action_list->empty()) {
+      simgrid::surf::Action* action = &*action_list->begin();
       XBT_INFO("   CPU Done action");
       XBT_DEBUG("\t * Done : %p", action);
       action->unref();
     }
 
     action_list = surf_network_model->getFailedActionSet();
-    for(simgrid::surf::ActionList::iterator it(action_list->begin()), itNext = it, itend(action_list->end()) ;
-        it != itend ; it=itNext) {
-      ++itNext;
-      simgrid::surf::Action *action = static_cast<simgrid::surf::NetworkAction*>(&*it);
-       XBT_INFO("   Network Failed action");
-       XBT_DEBUG("\t * Failed : %p", action);
-       action->unref();
+    while (not action_list->empty()) {
+      simgrid::surf::Action* action = &*action_list->begin();
+      XBT_INFO("   Network Failed action");
+      XBT_DEBUG("\t * Failed : %p", action);
+      action->unref();
     }
 
     action_list = surf_network_model->getDoneActionSet();
-    for(simgrid::surf::ActionList::iterator it(action_list->begin()), itNext = it, itend(action_list->end()) ;
-        it != itend ; it=itNext) {
-      ++itNext;
-      simgrid::surf::Action *action = static_cast<simgrid::surf::NetworkAction*>(&*it);
+    while (not action_list->empty()) {
+      simgrid::surf::Action* action = &*action_list->begin();
       XBT_INFO("   Network Done action");
       XBT_DEBUG("\t * Done : %p", action);
       action->unref();
index 70f58b3..8a16af4 100644 (file)
@@ -1,4 +1,4 @@
-foreach(x heap_bench log_large log_usage mallocator parallel_log_crashtest)
+foreach(x log_large log_usage mallocator parallel_log_crashtest)
   add_executable       (${x}  ${x}/${x}.c)
   target_link_libraries(${x}  simgrid)
   set_target_properties(${x}  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
@@ -27,7 +27,7 @@ set(tesh_files    ${tesh_files}     ${CMAKE_CURRENT_SOURCE_DIR}/log_usage/log_us
                                     ${CMAKE_CURRENT_SOURCE_DIR}/mmalloc/mmalloc_32.tesh          PARENT_SCOPE)
 set(teshsuite_src ${teshsuite_src}  ${CMAKE_CURRENT_SOURCE_DIR}/mmalloc/mmalloc_test.cpp           PARENT_SCOPE)
 
-foreach(x heap_bench log_large parallel_log_crashtest parmap_test) #mallocator parmap_bench
+foreach(x log_large parallel_log_crashtest parmap_test) #mallocator parmap_bench
   ADD_TESH(tesh-xbt-${x} --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/xbt/${x} --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/xbt/${x} ${x}.tesh)
 endforeach()
 
diff --git a/teshsuite/xbt/heap_bench/heap_bench.c b/teshsuite/xbt/heap_bench/heap_bench.c
deleted file mode 100644 (file)
index 47797d2..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/* A few tests for the xbt_heap module                                      */
-
-/* Copyright (c) 2004-2010, 2012-2015. The SimGrid Team.
- * All rights reserved.                                                     */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#include <stdio.h>
-#include <math.h>
-#include <xbt/xbt_os_time.h>
-
-#include "simgrid/msg.h"
-#include "xbt/heap.h"
-#include "xbt/sysdep.h"
-
-#define MAX_TEST 1000000
-
-static int compare_double(const void *a, const void *b)
-{
-  double pa = *((double *) a);
-  double pb = *((double *) b);
-
-  if (pa > pb)
-    return 1;
-  if (pa < pb)
-    return -1;
-  return 0;
-}
-
-static void test_reset_heap(xbt_heap_t * heap, int size)
-{
-  xbt_heap_free(*heap);
-  *heap = xbt_heap_new(size, NULL);
-
-  for (int i = 0; i < size; i++) {
-    xbt_heap_push(*heap, NULL, (10.0 * rand() / (RAND_MAX + 1.0)));
-  }
-}
-
-static void test_heap_validity(int size)
-{
-  xbt_heap_t heap = xbt_heap_new(size, NULL);
-  double *tab = xbt_new0(double, size);
-  int i;
-
-  for (i = 0; i < size; i++) {
-    tab[i] = (double) (10.0 * rand() / (RAND_MAX + 1.0));
-    xbt_heap_push(heap, NULL, (double) tab[i]);
-  }
-
-  qsort(tab, size, sizeof(double), compare_double);
-
-  for (i = 0; i < size; i++) {
-    if (fabs(xbt_heap_maxkey(heap) - tab[i]) > 1e-9) {
-      fprintf(stderr, "Problem !\n");
-      exit(1);
-    }
-    xbt_heap_pop(heap);
-  }
-  xbt_heap_free(heap);
-  free(tab);
-  printf("Validity test complete!\n");
-}
-
-static void test_heap_mean_operation(int size)
-{
-  xbt_heap_t heap = xbt_heap_new(size, NULL);
-
-  double date = xbt_os_time() * 1000000;
-  for (int i = 0; i < size; i++)
-    xbt_heap_push(heap, NULL, (10.0 * rand() / (RAND_MAX + 1.0)));
-
-  date = xbt_os_time() * 1000000 - date;
-  printf("Creation time  %d size heap : %g\n", size, date);
-
-  date = xbt_os_time() * 1000000;
-  for (int j = 0; j < MAX_TEST; j++) {
-
-    if (!(j % size) && j)
-      test_reset_heap(&heap, size);
-
-    double val = xbt_heap_maxkey(heap);
-    xbt_heap_pop(heap);
-    xbt_heap_push(heap, NULL, 3.0 * val);
-  }
-  date = xbt_os_time() * 1000000 - date;
-  printf("Mean access time for a %d size heap : %g\n", size, date * 1.0 / (MAX_TEST + 0.0));
-
-  xbt_heap_free(heap);
-}
-
-int main(int argc, char** argv)
-{
-  MSG_init(&argc, argv);
-
-  for (int size = 100; size < 10000; size *= 10) {
-    test_heap_validity(size);
-    test_heap_mean_operation(size);
-  }
-  return 0;
-}
diff --git a/teshsuite/xbt/heap_bench/heap_bench.tesh b/teshsuite/xbt/heap_bench/heap_bench.tesh
deleted file mode 100644 (file)
index a07abd4..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#! ./tesh
-
-! output display
-$ $SG_TEST_EXENV ${bindir:=.}/heap_bench
-> Validity test complete!
-> Creation time  100 size heap : 6
-> Mean access time for a 100 size heap : 0.14687
-> Validity test complete!
-> Creation time  1000 size heap : 38
-> Mean access time for a 1000 size heap : 0.179765
index 8b29daf..cff4bca 100644 (file)
@@ -6,7 +6,6 @@ set(EXTRA_DIST
   src/include/mc/datatypes.h
   src/include/mc/mc.h
   src/include/simgrid/sg_config.h
-  src/include/smpi/smpi_utils.hpp
   src/include/surf/datatypes.h
   src/include/surf/maxmin.hpp
   src/include/surf/surf.hpp
@@ -35,6 +34,7 @@ set(EXTRA_DIST
   src/smpi/colls/colls_private.hpp
   src/smpi/colls/smpi_mvapich2_selector_stampede.hpp
   src/smpi/include/private.hpp
+  src/smpi/include/smpi_utils.hpp
   src/surf/cpu_cas01.hpp
   src/surf/cpu_interface.hpp
   src/surf/cpu_ti.hpp
@@ -71,7 +71,6 @@ set(EXTRA_DIST
   src/xbt/backtrace_linux.cpp
   src/xbt/dict_private.h
   src/xbt/graph_private.h
-  src/xbt/heap_private.h
   src/xbt/log_private.h
   src/xbt/mallocator_private.h
 
@@ -275,7 +274,6 @@ set(XBT_SRC
   src/xbt/ex.cpp
   src/xbt/exception.cpp
   src/xbt/graph.c
-  src/xbt/heap.c
   src/xbt/log.c
   src/xbt/mallocator.c
   src/xbt/memory_map.cpp
@@ -727,7 +725,6 @@ set(headers_to_install
   include/xbt/function_types.h
   include/xbt/future.hpp
   include/xbt/graph.h
-  include/xbt/heap.h
   include/xbt/log.h
   include/xbt/log.hpp
   include/xbt/mallocator.h
index 432441c..94aaffd 100644 (file)
@@ -44,10 +44,10 @@ if(enable_compile_warnings)
   # the one specific to C but refused by C++
   set(warnCFLAGS "${warnCFLAGS} -Wmissing-prototypes") 
 
-  if(CMAKE_Fotran_COMPILER_ID MATCHES "GCC|PGI")
+  if(CMAKE_Fortran_COMPILER_ID MATCHES "GCC|PGI")
     set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Wall")
   endif()
-  if(CMAKE_Fotran_COMPILER_ID MATCHES "Intel")
+  if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
     set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -warn all")
   endif()
   set(CMAKE_JAVA_COMPILE_FLAGS "-Xlint")
@@ -145,11 +145,10 @@ if(enable_model-checking AND enable_compile_optimizations)
       src/xbt/log.c src/xbt/xbt_log_appender_file.c
       src/xbt/xbt_log_layout_format.c src/xbt/xbt_log_layout_simple.c
       src/xbt/dict.cpp src/xbt/dict_elm.c src/xbt/dict_cursor.c
-      src/xbt/dynar.cpp src/xbt/heap.c src/xbt/swag.c
-      src/xbt/str.c src src/xbt/snprintf.c
-      src/xbt/queue.c
+      src/xbt/dynar.cpp src/xbt/swag.c
+      src/xbt/xbt_str.cpp src/xbt/snprintf.c
       src/xbt/xbt_os_time.c src/xbt/xbt_os_thread.c
-      src/xbt/backtrace_linux.c
+      src/xbt/backtrace_linux.cpp
       ${MC_SRC_BASE} ${MC_SRC})
       set (mcCFLAGS "-O3  -funroll-loops -fno-strict-aliasing")
        if(CMAKE_COMPILER_IS_GNUCC)