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
- 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.
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
- \ref XBT_dynar
- \ref XBT_dict
- \ref XBT_swag
- - \ref XBT_heap
- \ref XBT_misc
- \ref XBT_graph
/** @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 */
/** @} */
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
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.
--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.
--cfg=tracing:yes \
--cfg=tracing/categorized:yes \
--cfg=tracing/filename:mytracefile.trace \
- --cfg=viva/categorized:cat.plist
\endverbatim
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
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.
-
*/
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.
> [ 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!
> [ 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.
$ 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
> [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
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>.
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>.
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
> [ 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!
> [ 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
> [ 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
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.
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.
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
#! ./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
> [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
$ $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
> [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
<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>
@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).
/* 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>
#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
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_
* 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");
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 {
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),
> 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
> [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
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
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
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
/** 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;
};
*/
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
*
/*** 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;
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);
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 */
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);
#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;
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));
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));
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));
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));
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,
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,
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));
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));
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,
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;
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));
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));
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));
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));
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));
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));
/** 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; )
#include <xbt/dynar.h>
#include <xbt/dict.h>
#include <xbt/swag.h>
-#include <xbt/heap.h>
#include <xbt/parmap.h>
#include <xbt/config.h>
#ifndef XBT_ALGORITHM_HPP
#define XBT_ALGORITHM_HPP
+#include <utility>
+
namespace simgrid {
namespace xbt {
+++ /dev/null
-/* 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 */
*
* @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);
}
}
-/* 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.
}
}
+#endif
/** 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). */
/**
* 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)
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
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");
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);
}
}
}
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);
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);
}
}
}
lua_pop(L,1);
sg_platf_new_route(&ASroute);
- delete ASroute.link_list;
return 0;
}
*/
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
*/
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
* @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
* @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
#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;
} 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);
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;
"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");
" 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"
" 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"
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 ()
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);
}
{
}
-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
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;
#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_;
}
}
}
namespace simgrid {
namespace instr {
class EntityValue;
+class TIData;
enum e_event_type : unsigned int {
PAJE_DefineContainerType,
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;
};
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));
}
~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();
};
}
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;
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();
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
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
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);
}
#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:
{
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;
}
}
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;
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();
}
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);
}
}
}
}
}
-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);
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 */
/* 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;
#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");
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 */
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);
}
}
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();
}
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;
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;
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 */
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();
}
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) {
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;
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
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++;
}
}
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;
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) {
// 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_) +
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]];
// 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]];
// 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();
}
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();
}
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;
/* 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;
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;
}
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);
}
/* 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_;
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();
}
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)
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 */
}
}
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;
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;
}
}
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_;
}
}
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();
}
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(),
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(),
/* 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 */
/* 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())
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();
}
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();
}
}
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());
/* 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());
/* 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)
-/* 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. */
/** @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
* @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;
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 ************************* */
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);
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;
new_xbt_graph_edge(graph, previous, current, edges);
XBT_DEBUG(" %s -> %s", previous_name, current_name);
- delete route->link_list;
delete route;
}
}
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.");
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;
}
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);
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());
}
{
}
-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
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;
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();
}
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;
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();
}
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();
}
#include <vector>
#include "xbt/automaton.h"
+#include "xbt/backtrace.hpp"
#include "xbt/dynar.h"
#include "xbt/swag.h"
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));
}
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) {
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:
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);
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; }
"\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);
}
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);
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())) {
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());
#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;
msg_vm_t vm = new simgrid::s4u::VirtualMachine(name, pm, coreAmount);
s_vm_params_t params;
- memset(¶ms, 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
/* 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[])
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
// 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
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;
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);
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)
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
}
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);
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;
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
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()
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()
* 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());
}
}
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;
/* 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 {
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();
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 *
*************/
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]);
}
}
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);
}
{
std::vector<simgrid::s4u::Link*> vlinks;
double res = 0;
- from->routeTo(to, &vlinks, &res);
+ from->routeTo(to, vlinks, &res);
return res;
}
/**
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)
* \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);
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)
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);
}
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
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)
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;
"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_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:
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)
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]];
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);
/* 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>
#include <xbt/algorithm.hpp>
#include <xbt/functional.hpp>
+#include <xbt/utility.hpp>
#include "simgrid/s4u/Engine.hpp"
#include "simgrid/s4u/Host.hpp"
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)) {}
/********************************* 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)
});
}
- 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);
/* 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();
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;
}
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) */
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);
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);
#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);
} 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);
/* 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)
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;
}
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();
}
{
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;
}
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;
}
}
-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
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;
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi);
-
/* PMPI User level calls */
extern "C" { // Obviously, the C MPI interface should use the C linkage
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;
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);
retval = MPI_SUCCESS;
- TRACE_smpi_collective_out(rank, __FUNCTION__);
+ TRACE_smpi_comm_out(rank);
}
smpi_bench_begin();
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();
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();
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();
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;
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();
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();
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();
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();
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);
xbt_free(sendtmpbuf);
retval = MPI_SUCCESS;
- TRACE_smpi_collective_out(rank, __FUNCTION__);
+ TRACE_smpi_comm_out(rank);
}
smpi_bench_begin();
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();
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);
}
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);
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);
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;
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);
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);
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;
}
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);
} 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();
} 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();
} 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();
} 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;
TRACE_smpi_recv(src_traced, rank, tag);
}
}
- TRACE_smpi_ptp_out(rank, rank, __FUNCTION__);
+ TRACE_smpi_comm_out(rank);
}
smpi_bench_begin();
} 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());
}
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();
} 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();
} 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();
} 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);
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;
}
}
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);
: 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);
}
}
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);
}
}
}
- TRACE_smpi_ptp_out(rank_traced, -1, __FUNCTION__);
+ TRACE_smpi_comm_out(rank_traced);
xbt_free(savedvals);
smpi_bench_begin();
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) {
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){
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;
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;
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;
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;
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;
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;
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;
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;
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;
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) {
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
#include "../colls_private.hpp"
#include "smpi_status.hpp"
+#include <algorithm>
namespace simgrid{
namespace smpi{
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);
*/
#include "../colls_private.hpp"
+#include <algorithm>
+
namespace simgrid{
namespace smpi{
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);
*/
#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
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;
* 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;
* 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{
/* 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)) {
*/
#include "../colls_private.hpp"
+#include <algorithm>
+
extern int mv2_reduce_intra_knomial_factor;
extern int mv2_reduce_inter_knomial_factor;
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);
}
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);
}
*/
#include "../colls_private.hpp"
+#include <algorithm>
+
#define MV2_INTRA_SHMEM_REDUCE_MSG 2048
#define mv2_g_shmem_coll_max_msg_size (1 << 17)
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);
}
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);
}
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) {
*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,
* 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)
{
}
/* 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);
/* 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);
#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>
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);
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();
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_;
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{
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_;
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.
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);
// 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;
#include "SmpiHost.hpp"
#include "simgrid/s4u/VirtualMachine.hpp"
-#include "smpi/smpi_utils.hpp"
+#include "smpi_utils.hpp"
#include <string>
#include <vector>
"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)
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)
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())
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()){
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)
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)
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);
}
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);
#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) {
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);
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());
}
}
}
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;
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)
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";
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();
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);
}
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)
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);
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);
}
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;
//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);
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);
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++) {
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);
}
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);
}
}
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);
}
}
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);
}
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);
}
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);
}
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
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
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
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());
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);
}
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);
}
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);
}
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];
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);
}
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);
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);
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());
}
"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 "
/* 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)");
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){
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);
if(leaders_map_==nullptr){
leaders_map_= leaders_map;
}else{
- xbt_free(leaders_map);
+ delete[] leaders_map;
}
int j=0;
int leader_group_size = 0;
}else{
is_blocked_=global_blocked;
}
- xbt_free(leader_list);
+ delete[] leader_list;
if(replaying)
smpi_process()->set_replaying(true);
return (flags_ & DT_FLAG_COMMITED);
}
+bool Datatype::is_basic()
+{
+ return (flags_ & DT_FLAG_BASIC);
+}
+
size_t Datatype::size(){
return size_;
}
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);
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();
}
}
}
-
void Type_Hvector::unserialize( void* contiguous_buf, void *noncontiguous_buf,
int count, MPI_Op op){
char* contiguous_buf_char = static_cast<char*>(contiguous_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_;
}
}
+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];
}
+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++) {
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);
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;
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) {
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){
-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)
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"
TRACE_RESOURCE="true"
shift 1
;;
- "-trace-viva")
- TRACE_VIVA="true"
- shift 1
- ;;
"-keep-temps")
KEEP="true"
SIMOPTS="$SIMOPTS --cfg=smpi/keep-temps:yes"
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 ---------------------------------
}
}
-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) {
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_;
#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>
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);
e_surf_action_storage_type_t type_;
StorageImpl* storage_;
- FileImpl* file_ = nullptr;
};
class StorageType {
#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");
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_;
}
{
lmm_system_free(maxminSystem_);
maxminSystem_ = nullptr;
- xbt_heap_free(actionHeap_);
delete modifiedSet_;
surf_cpu_model_pm = nullptr;
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());
, requestedCore_(requestedCore)
{
if (model->getUpdateMechanism() == UM_LAZY) {
- updateIndexHeap(-1);
refreshLastUpdate();
setLastValue(0.0);
}
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)));
* 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_
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 *
*********/
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()
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)
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);
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 */
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());
}
}
}
/* 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())
}
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 */
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());
/* 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())
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);
: CpuAction(model_, cost, failed)
, cpu_(cpu)
{
- updateIndexHeap(-1);
cpu_->modified(true);
}
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;
void CpuTiAction::cancel()
{
this->setState(Action::State::failed);
- xbt_heap_remove(getModel()->getActionHeap(), getIndexHeap());
+ heapRemove(getModel()->getActionHeap());
cpu_->modified(true);
}
XBT_IN("(%p)", this);
if (suspended_ != 2) {
suspended_ = 1;
- xbt_heap_remove(getModel()->getActionHeap(), getIndexHeap());
+ heapRemove(getModel()->getActionHeap());
cpu_->modified(true);
}
XBT_OUT();
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();
}
-/* 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
ActionList *runningActionSetThatDoesNotNeedBeingChecked_;
CpuTiList *modifiedCpu_;
- xbt_heap_t tiActionHeap_;
};
}
#include "maxmin_private.hpp"
#include "xbt/log.h"
#include "xbt/sysdep.h"
+#include <algorithm>
#include <cfloat>
#include <cmath>
#include <cstdlib>
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;
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;
} 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) {
#include "xbt/sysdep.h"
#include "maxmin_private.hpp"
+#include <algorithm>
#include <cstdlib>
#ifndef MATH
#include <cmath>
{
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;
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)
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;
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;
}
}
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);
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
/* \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 */
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..
//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;
{
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];
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)
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;
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)
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));
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,
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;
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;
//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);
}
}
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);
}
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
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;
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)
}
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_t* cnst_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)
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);
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) + "')";
}
}
- 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;
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)
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) {
} 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) ||
/* 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"
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();
}
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;
}
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
// 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;
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!");
//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
#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.
// - 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;
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
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
}
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_;
}
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());
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
XBT_DEBUG("Action %p finished", action);
action->setRemains(0);
action->finish(Action::State::done);
- action->heapRemove(actionHeap_);
+ action->heapRemove(getActionHeap());
}
}
}
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) {
{
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;
}
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);
}
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));
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);
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);
}
}
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)
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;
}
}
}
-/* 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
#include "xbt/base.h"
#include <unordered_map>
+#include <vector>
namespace simgrid {
namespace surf {
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();
NetworkModel::~NetworkModel()
{
lmm_system_free(maxminSystem_);
- xbt_heap_free(actionHeap_);
delete modifiedSet_;
}
{
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_);
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)"));
"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;
}
}
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);
#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);
, 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()
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());
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(),
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]);
}
}
}
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>;
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();
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;
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;
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)
#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);
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);
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))) {
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);
doneActionSet_ = new ActionList();
modifiedSet_ = nullptr;
- actionHeap_ = nullptr;
updateMechanism_ = UM_UNDEFINED;
selectiveUpdate_ = 0;
}
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
}
//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 {
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) {
"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 {
setState(state);
}
-Action::State Action::getState()
+Action::State Action::getState() const
{
if (stateSet_ == model_->getReadyActionSet())
return Action::State::ready;
stateSet_->push_back(*this);
}
-double Action::getBound()
+double Action::getBound() const
{
return (variable_) ? lmm_variable_getbound(variable_) : 0;
}
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);
* 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);
return remains_;
}
-double Action::getRemainsNoUpdate()
-{
- return remains_;
-}
-
}
}
#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>
* Action *
**********/
-XBT_PRIVATE void surf_action_lmm_update_index_heap(void *action, int i);
-
/** \ingroup SURF_models
* \brief List of initialized 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)
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;}
/** @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;}
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_;
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;
};
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
ActionLmmListPtr modifiedSet_;
lmm_system_t maxminSystem_ = nullptr;
bool selectiveUpdate_;
- xbt_heap_t actionHeap_;
private:
e_UM_t updateMechanism_ = UM_UNDEFINED;
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_;
};
}
}
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();
+ }
}
}
}
{
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;
}
/** @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 */
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;
*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;
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;
}
}
#define SURF_TMGR_H
#include "simgrid/forward.h"
-#include "xbt/heap.h"
#include "xbt/sysdep.h"
+#include <queue>
#include <vector>
extern "C" {
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;
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
*/
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;
};
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;
};
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;
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 {
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;
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()
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
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:
}
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()
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;
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(){
current_property_set = nullptr;
}
-static int argc;
-static char **argv;
+static std::vector<std::string> arguments;
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)");
}
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);
}
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(){
{
xbt_dynar_reset(dynar);
if (dynar)
- free(dynar->data);
+ xbt_free(dynar->data);
}
/** @brief Destructor of the structure not touching to the content
{
if (dynar && *dynar) {
xbt_dynar_t d = *dynar;
- free(d->data);
- free(d);
+ xbt_free(d->data);
+ xbt_free(d);
*dynar = nullptr;
}
}
xbt_dynar_shrink(dynar, 1);
memset(xbt_dynar_push_ptr(dynar), 0, dynar->elmsize);
res = dynar->data;
- free(dynar);
+ xbt_free(dynar);
return res;
}
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 */
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 */
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 */
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 */
}
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;
#include "xbt/graph.h"
#include "graph_private.h"
#include "xbt/dict.h"
-#include "xbt/heap.h"
#include <errno.h>
#include <stdio.h>
+++ /dev/null
-/* 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);
-}
+++ /dev/null
-/* 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
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);
{
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;
}
}
/* 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 */
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;
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());
}
> 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
> 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
> 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
> ### 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
> 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
> 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
> 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
<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>
<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>
> [ 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
> [ 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
> [ 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)
> [ 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
> [ 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!
#include "simgrid/s4u.hpp"
#include <string>
+#include <xbt/string.hpp>
XBT_LOG_NEW_DEFAULT_CATEGORY(storage, "Messages specific for this simulation");
}
}
-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);
}
}
-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());
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();
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");
}
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;
}
}
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;
}
}
}
-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,
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();
}
}
+ 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;
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)
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");
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");
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)
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)
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());
}
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)
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;
int key = -1;
int nrank;
int nsize;
- int dat = 0;
int color = -1;
char processor_name[128];
int namelen = 128;
int buf0[buf_size];
- int buf1[buf_size];
MPI_Status status;
MPI_Request req;
#define buf_size 128
-int mydelay () /* about 6 seconds */
+static int mydelay(void) /* about 6 seconds */
{
int i;
int val;
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];
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);
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)
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
print "TAP formatted results in $tapfullfile\n";
}
}
+exit ($err_count > 0);
#\f
# ---------------------------------------------------------------------------
# Routines
#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");
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);
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();
-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})
${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()
+++ /dev/null
-/* 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;
-}
+++ /dev/null
-#! ./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
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
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
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
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
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
# 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")
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)