# This is the configuration file for the https://circleci.com/ continuous integration server
#
-# Copyright (c) 2017-2019. The SimGrid team. All rights reserved.
+# Copyright (c) 2017-2020. 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.
examples/s4u/exec-ptask/s4u-exec-ptask
examples/s4u/exec-remote/s4u-exec-remote
examples/s4u/exec-waitany/s4u-exec-waitany
+examples/s4u/exec-waitfor/s4u-exec-waitfor
examples/s4u/io-async/s4u-io-async
examples/s4u/io-file-remote/s4u-io-file-remote
examples/s4u/io-file-system/s4u-io-file-system
- make -j4
- pip3 install --requirement docs/requirements.txt
- cd docs
- - LC_ALL=C.UTF-8 SPHINXOPTS=-vv ./Build.sh
+ - LC_ALL=C.UTF-8 ./Build.sh
- mv build/html ../public
# - The CSS contains a reference to a font or something, not something we gonna fix on our side
# - The javasphinx output does not exist in the git, so the "edit on FramaGit" link is broken.
- sudo apt-get update -qq
- sudo apt-get install cmake valgrind gfortran libboost-dev libboost-all-dev libdw-dev libevent-dev libunwind8-dev pybind11-dev
- (cmake -Denable_model-checking=ON -Denable_documentation=OFF -Denable_coverage=ON -Denable_java=ON -Denable_lua=OFF -Denable_compile_optimizations=ON -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=ON -Denable_compile_warnings=ON . || (echo XXX CMakeOutput.log; cat /home/travis/build/simgrid/simgrid/CMakeFiles/CMakeOutput.log; echo XXX CMakeError.log;cat /home/travis/build/simgrid/simgrid/CMakeFiles/CMakeError.log; exit 1))
- - make -j2 VERBOSE=1 all tests && ctest -j2 --output-on-failure
+ - make -j2 VERBOSE=1 all && make -j2 tests && ctest -j2 --output-on-failure
- os: windows
script:
- mv "C:/Program Files/Git/usr/bin/sh.exe" "sh-ignored.exe"
script:
- export LIBRARY_PATH=/usr/local/lib/gcc/9
- cmake -Denable_model-checking=OFF -Denable_documentation=OFF -Denable_coverage=ON -Denable_java=ON -Denable_lua=OFF -Denable_compile_optimizations=ON -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=OFF -Denable_compile_warnings=ON .
- - make -j2 VERBOSE=1 all tests && ctest -j2 --output-on-failure
+ - make -j2 VERBOSE=1 all && make -j2 tests && ctest -j2 --output-on-failure
notifications:
recipients:
- martin.quinson@ens-rennes.fr
# This little script rebuilds and runs the SimGrid archive in parallel, extracting a log
# This is almost an internal script, but others may find this useful
#
-# Copyright (c) 2017-2019 The SimGrid Team. Licence: LGPL of WDFPL, as you want.
+# Copyright (c) 2017-2020 The SimGrid Team. Licence: LGPL of WDFPL, as you want.
if [ ! -e Makefile ] ; then
if [ -e build/default/Makefile ] ; then
fi
target=tests
+ncores=$(grep -c processor /proc/cpuinfo)
install_path=$(sed -n 's/^CMAKE_INSTALL_PREFIX:PATH=//p' CMakeCache.txt)
if [ -e ${install_path} ] && [ -d ${install_path} ] && [ -x ${install_path} ] && [ -w ${install_path} ] ; then
(
echo "install_path: ${install_path}"
echo "Target: ${target}"
- (nice make -j4 ${target} tests || make ${target} tests) && nice ctest -j4 --output-on-failure ; date
+ echo "Cores: ${ncores}"
+ (nice make -j${ncores} ${target} tests || make ${target} tests) && nice ctest -j${ncores} --output-on-failure ; date
) 2>&1 | tee BuildSimGrid.sh.log
## Save compiler flags preset with environment variables CFLAGS or CXXFLAGS;
## they will used within smpicc, smpicxx.
## Do it early so that we get their genuine values. The same will be done later for Fortran.
-set(SMPI_C_FLAGS "${CMAKE_C_FLAGS}")
-set(SMPI_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+string(REGEX REPLACE " *-f[a-z]+-prefix-map=[^ ]*" "" SMPI_C_FLAGS "${CMAKE_C_FLAGS}")
+string(REGEX REPLACE " *-f[a-z]+-prefix-map=[^ ]*" "" SMPI_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# Check for the compiler #
set(SMPI_Fortran_LIBS "")
set(SMPI_FLANG 1)
endif()
- set(SMPI_Fortran_FLAGS "${SMPI_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS}")
+ string(REGEX REPLACE " *-f[a-z]+-prefix-map=[^ ]*" "" SMPI_Fortran_FLAGS "${SMPI_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS}")
## Request debugging flags for Fortran too
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g")
Source: https://simgrid.org/
Files: *
-Copyright: 2003-2019. The SimGrid team. All rights reserved.
+Copyright: 2003-2020. The SimGrid team. All rights reserved.
License: LGPL-2.1
Files: src/xbt/snprintf.c
Files: src/xbt/mmalloc/* src/include/xbt/mmalloc.h
Copyright:
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
- Copyright (C) 2003-2019. The SimGrid team.
+ Copyright (C) 2003-2020. The SimGrid team.
License: LGPL-2.1
Comment: these files used to be part of gdb, but were removed there
Copyright:
FleXML is Copyright (C) 1999-2005 Kristoffer Rose. All rights reserved.
FleXML is Copyright (C) 2003-2013 Martin Quinson. All rights reserved.
- Copyright (C) 2003-2019. The SimGrid team.
+ Copyright (C) 2003-2020. The SimGrid team.
License: GPL-2+ and LGPL-2.1
Comment: Generated with the FleXML XML processor generator (which is GPL-2+) using SimGrid configuration files (that are LGPL-2.1)
Files: src/xbt/automaton/parserPromela.tab.cacc
Copyright:
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
- Copyright (C) 2003-2019. The SimGrid team.
+ Copyright (C) 2003-2020. The SimGrid team.
License: GPL-3+ and LGPL-2.1
Comment: Generated with the Bison processor generator (which is GPL-3+) using SimGrid configuration files (that are LGPL-2.1)
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2020. 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. */
SimGrid (3.24.1) NOT RELEASED YET (v3.25 expected December 22. 2029, 04:19 UTC)
+General:
+- Upgrade documented Java dependency to Java 8 (earlier versions don't work).
+- Drop support for Viva/Triva (old visualization tools), hence removed
+ TRACE_get_node_types() and TRACE_get_edge_types() functions.
+
S4U:
- Actor: Merge signals on_migration_start/end into on_host_change
- Actor: Rename migrate() into set_host()
- Disk: Allow users to get the read and write nominal bandwidth values
+- Exec: Implement wait_for(timeout)
+- Io: Implement wait_for(timeout)
XML:
- Parse errors now raise a simgrid::ParseError that you may want to catch.
XBT:
- Remove unused parameter 'free_ctn' for xbt_dict_set() and xbt_dict_set_ext().
+- Drop unused functions for dicts and dynars: xbt_dict_cursor_get_elm,
+ xbt_dict_get, xbt_dict_get_elm, xbt_dict_get_ext, xbt_dict_get_key,
+ xbt_dict_remove, xbt_dict_reset, xbt_dynar_compare, xbt_dynar_dump,
+ xbt_dynar_foreach_ptr, xbt_dynar_free_data, xbt_dynar_free_voidp,
+ xbt_dynar_init, xbt_dynar_insert_at_as, xbt_dynar_merge,
+ xbt_dynar_remove_n_at, xbt_dynar_replace, xbt_dynar_search, xbt_dynar_set.
- New module: random, providing classical random numbers generators.
+SMPI:
+- New option : "smpi/auto-shared-malloc-thresh" which sets a value for
+ allocations' size above which they are considered "shared" by default (as if
+ they were performed through SMPI_SHARED_MALLOC macros).
+ Default = 0 = disabled feature.
+ Note : malloc, calloc and free are now overriden by smpicc/cxx by default.
+ This can cause some troubles if codes are already overriding these. If this
+ is the case, defining SMPI_NO_OVERRIDE_MALLOC in the compilation flags can
+ help, but will make this feature unusable.
+- Input check is now performed much more consistently and outputs precise
+ warnings for each error found
+- New supported calls : MPI_File_set_view, MPI_File_get_view
+- MPI I/O now only supports disks, as storage is discontinued.
+- MPI I/O allows opening files without specifying absolute path
+- Note : SMPI configuration options are now initialized by smpi_init_options()
+ call, which should be called if SMPI is not being used through smpirun.
+
Fixed bugs (FG#.. -> framagit bugs; FG!.. -> framagit merge requests):
+ - FG#39: Missing s4u::Comm::wait_any_for example
+ - FG#42: Add support for ThreadSanitizer (TSan)
+ - FG!19: Removing RngStream
+ - FG!20: A module for RNG calls
+ - FG!21: Choice between ad-hoc and standard distributions implementations
+ - FG!23: Master
+ - FG!25: Fix link in Mutex doc
+ - FG!26: Fix links in SMPI interface doc
- GH#31: [MC] please provide an option to make MPI_Send asynchronous
- GH#305: Unscheduled tasks are still excuted
+ - GH#313: smpirun: manual outdated w.r.t. --help
+ - GH#321: [S4U] Get task remaining work ratio
- GH#323: Crash when an actor turn off his physical host
- - FG!19: Removing RngStream
+ - GH#335: Missing links on dragonfly example svg
+ - https://lists.gforge.inria.fr/pipermail/simgrid-user/2019-November/004653.html:
+ MPI_Cart_sub was not working properly. Kudos to Jonathan Borne for the report.
----------------------------------------------------------------------------
# CMake find module to search for the SimGrid library.
-# Copyright (c) 2016-2019. The SimGrid Team.
+# Copyright (c) 2016-2020. The SimGrid Team.
#
# This file 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 examples/s4u/exec-remote/s4u-exec-remote.tesh
include examples/s4u/exec-waitany/s4u-exec-waitany.cpp
include examples/s4u/exec-waitany/s4u-exec-waitany.tesh
+include examples/s4u/exec-waitfor/s4u-exec-waitfor.cpp
+include examples/s4u/exec-waitfor/s4u-exec-waitfor.tesh
include examples/s4u/io-async/s4u-io-async.cpp
include examples/s4u/io-async/s4u-io-async.tesh
include examples/s4u/io-disk-raw/s4u-io-disk-raw.cpp
include examples/s4u/routing-get-clusters/s4u-routing-get-clusters.tesh
include examples/s4u/synchro-barrier/s4u-synchro-barrier.cpp
include examples/s4u/synchro-barrier/s4u-synchro-barrier.tesh
+include examples/s4u/synchro-condition-variable/s4u-synchro-condition-variable.cpp
+include examples/s4u/synchro-condition-variable/s4u-synchro-condition-variable.tesh
include examples/s4u/synchro-mutex/s4u-synchro-mutex.cpp
include examples/s4u/synchro-mutex/s4u-synchro-mutex.tesh
include examples/s4u/synchro-semaphore/s4u-synchro-semaphore.cpp
include doc/doxygen/uhood_arch.doc
include doc/doxygen/uhood_switch.doc
include docs/Build.sh
+include docs/find-missing.ignore
include docs/find-missing.py
include docs/ignored_symbols
include docs/manpages/smpicc.1
include docs/source/Installing_SimGrid.rst
include docs/source/Introduction.rst
include docs/source/Platform_Examples.rst
+include docs/source/Platform_Routing.rst
include docs/source/Plugins.rst
include docs/source/Start_Your_Own_Project.rst
include docs/source/Tutorial_Algorithms.rst
include src/kernel/context/ContextThread.hpp
include src/kernel/context/ContextUnix.cpp
include src/kernel/context/ContextUnix.hpp
-include src/kernel/context/context_private.hpp
include src/kernel/future.cpp
include src/kernel/lmm/fair_bottleneck.cpp
include src/kernel/lmm/maxmin.cpp
include tools/cmake/test_prog/prog_makecontext.c
include tools/cmake/test_prog/prog_stackgrowth.c
include tools/cmake/test_prog/prog_stacksetup.c
+include tools/cmake/test_prog/prog_tsan.cpp
include tools/doxygen/fig2dev_postprocessor.pl
include tools/doxygen/list_routing_models_examples.sh
include tools/doxygen/xbt_log_extract_hierarchy.pl
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
@ref msg_file ; access functions are organized as a POSIX-like
interface.
-@subsubsection pf_sto_conc Storage - Main Concepts
-
-The storage facilities implemented in SimGrid help to model (and account for)
-storage devices, such as tapes, hard-drives, CD or DVD devices etc.
-A typical situation is depicted in the figure below:
-
-@image html ./webcruft/storage_sample_scenario.png
-@image latex ./webcruft/storage_sample_scenario.png "storage_sample_scenario" width=@textwidth
-
-In this figure, two hosts called Bob and Alice are interconnected via a network
-and each host is physically attached to a disk; it is not only possible for each host to
-mount the disk they are attached to directly, but they can also mount disks
-that are in a remote location. In this example, Bob mounts Alice's disk remotely
-and accesses the storage via the network.
-
-SimGrid provides 3 different entities that can be used to model setups
-that include storage facilities:
-
-Entity name | Description
---------------- | -----------
-@ref pf_storage_entity_storage_type "storage_type" | Defines a template for a particular kind of storage (such as a hard-drive) and specifies important features of the storage, such as capacity, performance (read/write), contents, ... Different models of hard-drives use different storage_types (because the difference between an SSD and an HDD does matter), as they differ in some specifications (e.g., different sizes or read/write performance).
-@ref pf_tag_storage "storage" | Defines an actual instance of a storage type (disk, RAM, ...); uses a ``storage_type`` template (see line above) so that you don't need to re-specify the same details over and over again.
-@ref pf_tag_mount "mount" | Must be wrapped by a @ref pf_tag_host tag; declares which storage(s) this host has mounted and where (i.e., the mountpoint).
-
-
-@anchor pf_storage_content_file
-### %Storage Content File ###
-
-In order to assess exactly how much time is spent reading from the storage,
-SimGrid needs to know what is stored on the storage device (identified by distinct (file-)name, like in a file system)
-and what size this content has.
-
-@note
- The content file is never changed by the simulation; it is parsed once
- per simulation and kept in memory afterwards. When the content of the
- storage changes, only the internal SimGrid data structures change.
-
-@anchor pf_storage_content_file_structure
-#### Structure of a %Storage Content File ####
-
-Here is an excerpt from two storage content file; if you want to see the whole file, check
-the file ``examples/platforms/content/storage_content.txt`` that comes with the
-SimGrid source code.
-
-SimGrid essentially supports two different formats: UNIX-style filepaths should
-follow the well known format:
-
-@verbatim
-/lib/libsimgrid.so.3.6.2 12710497
-/bin/smpicc 918
-/bin/smpirun 7292
-/bin/smpif2c 1990
-/bin/simgrid_update_xml 5018
-/bin/graphicator 66986
-/bin/simgrid-colorizer 2993
-/bin/smpiff 820
-/bin/tesh 356434
-@endverbatim
-
-Windows filepaths, unsurprisingly, use the windows style:
-
-@verbatim
-@Windows@avastSS.scr 41664
-@Windows@bfsvc.exe 75264
-@Windows@bootstat.dat 67584
-@Windows@CoreSingleLanguage.xml 31497
-@Windows@csup.txt 12
-@Windows@dchcfg64.exe 335464
-@Windows@dcmdev64.exe 93288
-@endverbatim
-
-@note
- The different file formats come at a cost; in version 3.12 (and most likely
- in later versions, too), copying files from windows-style storages to unix-style
- storages (and vice versa) is not supported.
-
-@anchor pf_storage_content_file_create
-#### Generate a %Storage Content File ####
-
-If you want to generate a storage content file based on your own filesystem (or at least a filesystem you have access to),
-try running this command (works only on unix systems):
-
-@verbatim
-find . -type f -exec ls -1s --block=1 {} @; 2>/dev/null | awk '{ print $2 " " $1}' > ./content.txt
-@endverbatim
-
-@subsubsection pf_storage_entities The Storage Entities
-
-These are the entities that you can use in your platform files to include
-storage in your model. See also the list of our @ref pf_storage_example_files "example files";
-these might also help you to get started.
-
-@anchor pf_storage_entity_storage_type
-#### @<storage_type@> ####
-
-Attribute name | Mandatory | Values | Description
---------------- | --------- | ------ | -----------
-id | yes | string | Identifier of this storage_type; used when referring to it
-model | no | string | In the future, this will allow one to change the performance model to use
-size | yes | string | Specifies the amount of available storage space; you can specify storage like "500GiB" or "500GB" if you want. (TODO add a link to all the available abbreviations)
-content | yes | string | Path to a @ref pf_storage_content_file "Storage Content File" on your system. This file must exist.
-
-This tag must contain some predefined model properties, specified via the <model_prop> tag. Here is a list,
-see below for an example:
-
-Property id | Mandatory | Values | Description
---------------- | --------- | ------ | -----------
-Bwrite | yes | string | Bandwidth for write access; in B/s (but you can also specify e.g. "30MBps")
-Bread | yes | string | Bandwidth for read access; in B/s (but you can also specify e.g. "30MBps")
-
-@note
- A storage_type can also contain the <b><prop></b> tag. The <prop> tag allows you
- to associate additional information to this <storage_type> and follows the
- attribute/value schema; see the example below. You may want to use it to give information to
- the tool you use for rendering your simulation, for example.
-
-Here is a complete example for the ``storage_type`` tag:
-@verbatim
-<storage_type id="single_HDD" size="4000">
- <model_prop id="Bwrite" value="30MBps" />
- <model_prop id="Bread" value="100MBps" />
- <prop id="Brand" value="Western Digital" />
-</storage_type>
-@endverbatim
-
-@subsubsection pf_tag_storage <storage>
-
-Attributes | Mandatory | Values | Description
--------------- | --------- | ------ | -----------
-id | yes | string | Identifier of this ``storage``; used when referring to it
-typeId | yes | string | Here you need to refer to an already existing @ref pf_storage_entity_storage_type "@<storage_type@>"; the storage entity defined by this tag will then inherit the properties defined there.
-attach | yes | string | Name of a host (see Section @ref pf_tag_host) to which this storage is <i>physically</i> attached to (e.g., a hard drive in a computer)
-content | no | string | When specified, overwrites the content attribute of @ref pf_storage_entity_storage_type "@<storage_type@>"
-
-Here are two examples:
-
-@verbatim
- <storage id="Disk1" typeId="single_HDD" attach="bob" />
-
- <storage id="Disk2" typeId="single_SSD"
- content="content/win_storage_content.txt" />
-@endverbatim
-
-The first example is straightforward: A disk is defined and called "Disk1"; it is
-of type "single_HDD" (shown as an example of @ref pf_storage_entity_storage_type "@<storage_type@>" above) and attached
-to a host called "bob" (the definition of this host is omitted here).
-
-The second storage is called "Disk2", is still of the same type as Disk1 but
-now specifies a new content file (so the contents will be different from Disk1)
-and the filesystem uses the windows style; finally, it is attached to a second host,
-called alice (which is again not defined here).
-
-@subsubsection pf_tag_mount <mount>
-
-| Attribute | Mandatory | Values | Description |
-| ----------- | ----------- | -------- | ------------- |
-| id | yes | string | Refers to a @ref pf_tag_storage "<storage>" entity that will be mounted on that computer |
-| name | yes | string | Path/location to/of the logical reference (mount point) of this disk
-
-This tag must be enclosed by a @ref pf_tag_host tag. It then specifies where the mountpoint of a given storage device (defined by the ``id`` attribute)
-is; this location is specified by the ``name`` attribute.
-
-Here is a simple example, taken from the file ``examples/platform/storage.xml``:
-
-@verbatim
- <storage_type id="single_SSD" size="500GiB">
- <model_prop id="Bwrite" value="60MBps" />
- <model_prop id="Bread" value="200MBps" />
- </storage_type>
-
- <storage id="Disk2" typeId="single_SSD"
- content="content/win_storage_content.txt"
- attach="alice" />
- <storage id="Disk4" typeId="single_SSD"
- content="content/small_content.txt"
- attach="denise"/>
-
- <host id="alice" speed="1Gf">
- <mount storageId="Disk2" name="c:"/>
- </host>
-
- <host id="denise" speed="1Gf">
- <mount storageId="Disk2" name="c:"/>
- <mount storageId="Disk4" name="/home"/>
- </host>
-@endverbatim
-
-This example is quite interesting, as the same device, called "Disk2", is mounted by
-two hosts at the same time! Note, however, that the host called ``alice`` is actually
-attached to this storage, as can be seen in the @ref pf_tag_storage "<storage>"
-tag. This means that ``denise`` must access this storage through the network, but SimGrid automatically takes
-care of that for you.
-
-Furthermore, this example shows that ``denise`` has mounted two storages with different
-filesystem types (unix and windows). In general, a host can mount as many storage devices as
-required.
-
-@note
- Again, the difference between ``attach`` and ``mount`` is simply that
- an attached storage is always physically inside (or connected to) that machine;
- for instance, a USB stick is attached to one and only one machine (where it's plugged-in)
- but it can only be mounted on others, as mounted storage can also be a remote location.
-
-###### Example files #####
-
-@verbinclude example_filelist_xmltag_mount
-
-@subsubsection pf_storage_example_files Example files
-
-Several examples were already discussed above; if you're interested in full examples,
-check the the following platforms:
-
-1. ``examples/platforms/storage.xml``
-2. ``examples/platforms/remote_io.xml``
-
-If you're looking for some examplary C code, you may find the source code
-available in the directory ``examples/msg/io/`` useful.
-
-@subsubsection pf_storage_examples_modelling Modelling different situations
-
-The storage functionality of SimGrid is type-agnostic, that is, the implementation
-does not presume any type of storage, such as HDDs/SSDs, RAM,
-CD/DVD devices, USB sticks etc.
-
-This allows the user to apply the simulator for a wide variety of scenarios; one
-common scenario would be the access of remote RAM.
-
-#### Modelling the access of remote RAM ####
-
-How can this be achieved in SimGrid? Let's assume we have a setup where three hosts
-(HostA, HostB, HostC) need to access remote RAM:
-
-@verbatim
- Host A
- /
-RAM -- Host B
- @
- Host C
-@endverbatim
-
-An easy way to model this scenario is to setup and define the RAM via the
-@ref pf_tag_storage "storage" and @ref pf_storage_entity_storage_type "storage type"
-entities and attach it to a remote dummy host; then, every host can have their own links
-to this host (modelling for instance certain scenarios, such as PCIe ...)
-
-@verbatim
- Host A
- /
-RAM - Dummy -- Host B
- @
- Host C
-@endverbatim
-
-Now, if read from this storage, the host that mounts this storage
-communicates to the dummy host which reads from RAM and
-sends the information back.
-
@section pf_routing Routing
#
# Simplistic script to rebuild our documentation with sphinx-build
+# If you are missing some dependencies, try: pip3 install --requirement docs/requirements.txt
+
# Python needs to find simgrid on my machine, but not ctest -- sorry for the hack
if [ -e /opt/simgrid ] ; then chmod +x /opt/simgrid; fi
echo "javasphinx relaunched"
fi
-PYTHONPATH=../lib sphinx-build -M html source build ${SPHINXOPTS}
+PYTHONPATH=../lib sphinx-build -M html source build ${SPHINXOPTS} 2>&1 \
+ | grep -v 'WARNING: cpp:identifier reference target not found: simgrid$' \
+ | grep -v 'WARNING: cpp:identifier reference target not found: simgrid::s4u$' \
+ | grep -v 'WARNING: cpp:identifier reference target not found: boost'
set +x
--- /dev/null
+This file lists the symbols ignored in the documentation.
+It follows the RST syntact but is completely ignored by sphinx.
+It is only used by find-missing, that will not report any definition linked here as missing.
+
+# I don't plan to document MSG in the new way.
+.. autodoxymethod:: ::MSG_barrier_destroy(const_sg_bar_t bar)
+.. autodoxymethod:: ::MSG_barrier_init(unsigned int count)
+.. autodoxymethod:: ::MSG_barrier_wait(msg_bar_t bar)
+.. autodoxymethod:: ::MSG_comm_destroy(const_msg_comm_t comm)
+.. autodoxymethod:: ::MSG_comm_get_status(const_msg_comm_t comm)
+.. autodoxymethod:: ::MSG_comm_get_task(const_msg_comm_t comm)
+.. autodoxymethod:: ::MSG_comm_test(msg_comm_t comm)
+.. autodoxymethod:: ::MSG_comm_testany(const_xbt_dynar_t comms)
+.. autodoxymethod:: ::MSG_comm_wait(msg_comm_t comm, double timeout)
+.. autodoxymethod:: ::MSG_comm_waitall(msg_comm_t *comm, int nb_elem, double timeout)
+.. autodoxymethod:: ::MSG_comm_waitany(const_xbt_dynar_t comms)
+.. autodoxymethod:: ::MSG_config(const char *key, const char *value)
+.. autodoxymethod:: ::MSG_create_environment(const char *file)
+.. autodoxymethod:: ::MSG_function_register(const char *name, xbt_main_func_t code)
+.. autodoxymethod:: ::MSG_function_register_default(xbt_main_func_t code)
+.. autodoxymethod:: ::MSG_get_clock()
+.. autodoxymethod:: ::MSG_get_host_by_name(const char *name)
+.. autodoxymethod:: ::MSG_get_host_number()
+.. autodoxymethod:: ::MSG_get_sent_msg()
+.. autodoxymethod:: ::MSG_host_by_name(const char *name)
+.. autodoxymethod:: ::MSG_host_get_attached_storage_lists(const_sg_host_t host)
+.. autodoxymethod:: ::MSG_host_get_core_number(const_sg_host_t host)
+.. autodoxymethod:: ::MSG_host_get_data(const_sg_host_t host)
+.. autodoxymethod:: ::MSG_host_get_load(const_sg_host_t host)
+.. autodoxymethod:: ::MSG_host_get_mounted_storage_list(sg_host_t host)
+.. autodoxymethod:: ::MSG_host_get_name(const_sg_host_t host)
+.. autodoxymethod:: ::MSG_host_get_nb_pstates(const_sg_host_t host)
+.. autodoxymethod:: ::MSG_host_get_power_peak_at(const_sg_host_t host, int pstate_index)
+.. autodoxymethod:: ::MSG_host_get_process_list(const_sg_host_t host, xbt_dynar_t whereto)
+.. autodoxymethod:: ::MSG_host_get_properties(const_sg_host_t host)
+.. autodoxymethod:: ::MSG_host_get_property_value(const_sg_host_t host, const char *name)
+.. autodoxymethod:: ::MSG_host_get_pstate(const_sg_host_t host)
+.. autodoxymethod:: ::MSG_host_get_speed(const_sg_host_t host)
+.. autodoxymethod:: ::MSG_host_is_on(const_sg_host_t h)
+.. autodoxymethod:: ::MSG_host_off(sg_host_t h)
+.. autodoxymethod:: ::MSG_host_on(sg_host_t h)
+.. autodoxymethod:: ::MSG_host_self()
+.. autodoxymethod:: ::MSG_host_set_data(sg_host_t host, void *data)
+.. autodoxymethod:: ::MSG_host_set_property_value(sg_host_t host, const char *name, const char *value)
+.. autodoxymethod:: ::MSG_host_set_pstate(sg_host_t host, int pstate)
+.. autodoxymethod:: ::MSG_hosts_as_dynar()
+.. autodoxymethod:: ::MSG_init_nocheck(int *argc, char **argv)
+.. autodoxymethod:: ::MSG_launch_application(const char *file)
+.. autodoxymethod:: ::MSG_mailbox_set_async(const char *alias)
+.. autodoxymethod:: ::MSG_main()
+.. autodoxymethod:: ::MSG_parallel_task_create(const char *name, int host_nb, const msg_host_t *host_list, double *flops_amount, double *bytes_amount, void *data)
+.. autodoxymethod:: ::MSG_parallel_task_execute(msg_task_t task)
+.. autodoxymethod:: ::MSG_parallel_task_execute_with_timeout(msg_task_t task, double timeout)
+.. autodoxymethod:: ::MSG_process_attach(const char *name, void *data, msg_host_t host, xbt_dict_t properties)
+.. autodoxymethod:: ::MSG_process_auto_restart_set(msg_process_t process, int auto_restart)
+.. autodoxymethod:: ::MSG_process_create(const char *name, xbt_main_func_t code, void *data, msg_host_t host)
+.. autodoxymethod:: ::MSG_process_create_with_arguments(const char *name, xbt_main_func_t code, void *data, msg_host_t host, int argc, char **argv)
+.. autodoxymethod:: ::MSG_process_create_with_environment(const char *name, xbt_main_func_t code, void *data, msg_host_t host, int argc, char **argv, xbt_dict_t properties)
+.. autodoxymethod:: ::MSG_process_daemonize(msg_process_t process)
+.. autodoxymethod:: ::MSG_process_detach()
+.. autodoxymethod:: ::MSG_process_from_PID(int pid)
+.. autodoxymethod:: ::MSG_process_get_PID(const_sg_actor_t process)
+.. autodoxymethod:: ::MSG_process_get_PPID(const_sg_actor_t process)
+.. autodoxymethod:: ::MSG_process_get_data(const_sg_actor_t process)
+.. autodoxymethod:: ::MSG_process_get_host(const_sg_actor_t process)
+.. autodoxymethod:: ::MSG_process_get_name(const_sg_actor_t process)
+.. autodoxymethod:: ::MSG_process_get_number()
+.. autodoxymethod:: ::MSG_process_get_properties(const_sg_actor_t process)
+.. autodoxymethod:: ::MSG_process_get_property_value(const_sg_actor_t process, const char *name)
+.. autodoxymethod:: ::MSG_process_is_suspended(msg_process_t process)
+.. autodoxymethod:: ::MSG_process_join(msg_process_t process, double timeout)
+.. autodoxymethod:: ::MSG_process_kill(msg_process_t process)
+.. autodoxymethod:: ::MSG_process_killall()
+.. autodoxymethod:: ::MSG_process_migrate(msg_process_t process, msg_host_t host)
+.. autodoxymethod:: ::MSG_process_on_exit(int_f_int_pvoid_t fun, void *data)
+.. autodoxymethod:: ::MSG_process_ref(const_sg_actor_t process)
+.. autodoxymethod:: ::MSG_process_restart(msg_process_t process)
+.. autodoxymethod:: ::MSG_process_resume(msg_process_t process)
+.. autodoxymethod:: ::MSG_process_self()
+.. autodoxymethod:: ::MSG_process_self_PID()
+.. autodoxymethod:: ::MSG_process_self_PPID()
+.. autodoxymethod:: ::MSG_process_self_name()
+.. autodoxymethod:: ::MSG_process_set_data(msg_process_t process, void *data)
+.. autodoxymethod:: ::MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup)
+.. autodoxymethod:: ::MSG_process_set_kill_time(msg_process_t process, double kill_time)
+.. autodoxymethod:: ::MSG_process_sleep(double nb_sec)
+.. autodoxymethod:: ::MSG_process_suspend(msg_process_t process)
+.. autodoxymethod:: ::MSG_process_unref(const_sg_actor_t process)
+.. autodoxymethod:: ::MSG_process_yield()
+.. autodoxymethod:: ::MSG_processes_as_dynar()
+.. autodoxymethod:: ::MSG_sem_acquire(msg_sem_t sem)
+.. autodoxymethod:: ::MSG_sem_acquire_timeout(msg_sem_t sem, double timeout)
+.. autodoxymethod:: ::MSG_sem_destroy(const_sg_sem_t sem)
+.. autodoxymethod:: ::MSG_sem_get_capacity(msg_sem_t sem)
+.. autodoxymethod:: ::MSG_sem_init(int initial_value)
+.. autodoxymethod:: ::MSG_sem_release(msg_sem_t sem)
+.. autodoxymethod:: ::MSG_sem_would_block(msg_sem_t sem)
+.. autodoxymethod:: ::MSG_storage_get_by_name(const char *name)
+.. autodoxymethod:: ::MSG_storage_get_data(const_sg_storage_t storage)
+.. autodoxymethod:: ::MSG_storage_get_host(const_sg_storage_t storage)
+.. autodoxymethod:: ::MSG_storage_get_name(const_sg_storage_t storage)
+.. autodoxymethod:: ::MSG_storage_get_properties(const_sg_storage_t storage)
+.. autodoxymethod:: ::MSG_storage_get_property_value(const_sg_storage_t storage, const char *name)
+.. autodoxymethod:: ::MSG_storage_read(msg_storage_t storage, sg_size_t size)
+.. autodoxymethod:: ::MSG_storage_set_data(msg_storage_t storage, void *data)
+.. autodoxymethod:: ::MSG_storage_set_property_value(msg_storage_t storage, const char *name, const char *value)
+.. autodoxymethod:: ::MSG_storage_write(msg_storage_t storage, sg_size_t size)
+.. autodoxymethod:: ::MSG_storages_as_dynar()
+.. autodoxymethod:: ::MSG_task_cancel(msg_task_t task)
+.. autodoxymethod:: ::MSG_task_create(const char *name, double flops_amount, double bytes_amount, void *data)
+.. autodoxymethod:: ::MSG_task_destroy(msg_task_t task)
+.. autodoxymethod:: ::MSG_task_dsend(msg_task_t task, const char *alias, void_f_pvoid_t cleanup)
+.. autodoxymethod:: ::MSG_task_dsend_bounded(msg_task_t task, const char *alias, void_f_pvoid_t cleanup, double maxrate)
+.. autodoxymethod:: ::MSG_task_execute(msg_task_t task)
+.. autodoxymethod:: ::MSG_task_get_bytes_amount(const_msg_task_t task)
+.. autodoxymethod:: ::MSG_task_get_category(const_msg_task_t task)
+.. autodoxymethod:: ::MSG_task_get_data(const_msg_task_t task)
+.. autodoxymethod:: ::MSG_task_get_flops_amount(const_msg_task_t task)
+.. autodoxymethod:: ::MSG_task_get_name(const_msg_task_t task)
+.. autodoxymethod:: ::MSG_task_get_remaining_communication(const_msg_task_t task)
+.. autodoxymethod:: ::MSG_task_get_remaining_work_ratio(const_msg_task_t task)
+.. autodoxymethod:: ::MSG_task_get_sender(const_msg_task_t task)
+.. autodoxymethod:: ::MSG_task_get_source(const_msg_task_t task)
+.. autodoxymethod:: ::MSG_task_irecv(msg_task_t *task, const char *alias)
+.. autodoxymethod:: ::MSG_task_irecv_bounded(msg_task_t *task, const char *alias, double rate)
+.. autodoxymethod:: ::MSG_task_isend(msg_task_t task, const char *alias)
+.. autodoxymethod:: ::MSG_task_isend_bounded(msg_task_t task, const char *alias, double maxrate)
+.. autodoxymethod:: ::MSG_task_listen(const char *alias)
+.. autodoxymethod:: ::MSG_task_listen_from(const char *alias)
+.. autodoxymethod:: ::MSG_task_receive(msg_task_t *task, const char *alias)
+.. autodoxymethod:: ::MSG_task_receive_bounded(msg_task_t *task, const char *alias, double rate)
+.. autodoxymethod:: ::MSG_task_receive_with_timeout(msg_task_t *task, const char *alias, double timeout)
+.. autodoxymethod:: ::MSG_task_receive_with_timeout_bounded(msg_task_t *task, const char *alias, double timeout, double rate)
+.. autodoxymethod:: ::MSG_task_send(msg_task_t task, const char *alias)
+.. autodoxymethod:: ::MSG_task_send_bounded(msg_task_t task, const char *alias, double rate)
+.. autodoxymethod:: ::MSG_task_send_with_timeout(msg_task_t task, const char *alias, double timeout)
+.. autodoxymethod:: ::MSG_task_send_with_timeout_bounded(msg_task_t task, const char *alias, double timeout, double maxrate)
+.. autodoxymethod:: ::MSG_task_set_bound(msg_task_t task, double bound)
+.. autodoxymethod:: ::MSG_task_set_bytes_amount(msg_task_t task, double bytes_amount)
+.. autodoxymethod:: ::MSG_task_set_category(msg_task_t task, const char *category)
+.. autodoxymethod:: ::MSG_task_set_data(msg_task_t task, void *data)
+.. autodoxymethod:: ::MSG_task_set_flops_amount(msg_task_t task, double flops_amount)
+.. autodoxymethod:: ::MSG_task_set_name(msg_task_t task, const char *name)
+.. autodoxymethod:: ::MSG_task_set_priority(msg_task_t task, double priority)
+.. autodoxymethod:: ::MSG_vm_create_core(msg_host_t pm, const char *name)
+.. autodoxymethod:: ::MSG_vm_create_multicore(msg_host_t pm, const char *name, int coreAmount)
+.. autodoxymethod:: ::MSG_vm_destroy(msg_vm_t vm)
+.. autodoxymethod:: ::MSG_vm_get_name(const_sg_vm_t vm)
+.. autodoxymethod:: ::MSG_vm_get_pm(const_sg_vm_t vm)
+.. autodoxymethod:: ::MSG_vm_get_ramsize(const_sg_vm_t vm)
+.. autodoxymethod:: ::MSG_vm_is_created(msg_vm_t vm)
+.. autodoxymethod:: ::MSG_vm_is_running(msg_vm_t vm)
+.. autodoxymethod:: ::MSG_vm_is_suspended(msg_vm_t vm)
+.. autodoxymethod:: ::MSG_vm_resume(msg_vm_t vm)
+.. autodoxymethod:: ::MSG_vm_set_bound(msg_vm_t vm, double bound)
+.. autodoxymethod:: ::MSG_vm_set_ramsize(msg_vm_t vm, size_t size)
+.. autodoxymethod:: ::MSG_vm_shutdown(msg_vm_t vm)
+.. autodoxymethod:: ::MSG_vm_start(msg_vm_t vm)
+.. autodoxymethod:: ::MSG_vm_suspend(msg_vm_t vm)
+.. autodoxymethod:: ::MSG_zone_get_by_name(const char *name)
+.. autodoxymethod:: ::MSG_zone_get_hosts(const_sg_netzone_t zone, xbt_dynar_t whereto)
+.. autodoxymethod:: ::MSG_zone_get_name(const_sg_netzone_t zone)
+.. autodoxymethod:: ::MSG_zone_get_property_value(const_sg_netzone_t zone, const char *name)
+.. autodoxymethod:: ::MSG_zone_get_root()
+.. autodoxymethod:: ::MSG_zone_get_sons(const_sg_netzone_t zone, xbt_dict_t whereto)
+.. autodoxymethod:: ::MSG_zone_set_property_value(msg_netzone_t zone, const char *name, const char *value)
+
+# These ones are a bug of Doxygen, that parse them as variables instead of types.
+# So we don't use this bogus parse result, but go directly for cpp:type directives in app_s4u.rst
+.. autodoxyvar:: ::const_sg_actor_t
+.. autodoxyvar:: ::const_sg_bar_t
+.. autodoxyvar:: ::const_sg_mutex_t
+.. autodoxyvar:: ::const_sg_sem_t
+
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
-# Copyright (c) 2019. The SimGrid Team.
-# All rights reserved.
+# Copyright (c) 2019-2020. 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.
but not documented with autodoxy in the RST files.
This script is tailored to SimGrid own needs and should be made more generic for autodoxy.
+
+If you are missing some dependencies, try: pip3 install --requirement docs/requirements.txt
"""
import fnmatch
'build/xml/classsimgrid_1_1s4u_1_1Mutex.xml',
'build/xml/classsimgrid_1_1s4u_1_1NetZone.xml',
'build/xml/classsimgrid_1_1s4u_1_1Semaphore.xml',
- 'build/xml/classsimgrid_1_1s4u_1_1VirtualMachine.xml'
+ 'build/xml/classsimgrid_1_1s4u_1_1VirtualMachine.xml',
+ 'build/xml/namespacesimgrid_1_1s4u_1_1this__actor.xml',
+ 'build/xml/actor_8h.xml',
+ 'build/xml/barrier_8h.xml',
+ 'build/xml/cond_8h.xml',
+ 'build/xml/engine_8h.xml',
+ 'build/xml/forward_8h.xml',
+ 'build/xml/host_8h.xml',
+ 'build/xml/link_8h.xml',
+ 'build/xml/mailbox_8h.xml',
+ 'build/xml/msg_8h.xml',
+ 'build/xml/mutex_8h.xml',
+ 'build/xml/semaphore_8h.xml',
+ 'build/xml/vm_8h.xml',
+ 'build/xml/zone_8h.xml'
]
python_modules = [
def found_decl(kind, obj):
"""Helper function that add an object in the python_decl data structure"""
- if kind not in python_decl: python_decl[kind] = []
+ if kind not in python_decl:
+ python_decl[kind] = []
python_decl[kind].append(obj)
try:
module = __import__(name)
except Exception:
- print("Cannot import {}. Did you set PYTHONPATH=../lib accordingly?".format(name))
- sys.exit(1)
+ if os.path.exists("../lib") and "../lib" not in sys.path:
+ print("Adding ../lib to PYTHONPATH as {} cannot be imported".format(name))
+ sys.path.append("../lib")
+ try:
+ module = __import__(name)
+ except Exception:
+ print("Cannot import {}, even with PYTHONPATH=../lib".format(name))
+ sys.exit(1)
+ else:
+ print("Cannot import {}".format(name))
+ sys.exit(1)
for sub in dir(module):
if sub[0] == '_':
continue
doxy_vars = {} # {classname: [names]}
# find the declarations in the XML files
-for arg in xml_files[:3]:
+for arg in xml_files:
if arg[-4:] != '.xml':
print ("Argument '{}' does not end with '.xml'".format(arg))
continue
- print("Parse file {}".format(arg))
+ #print("Parse file {}".format(arg))
tree = ET.parse(arg)
for elem in tree.findall(".//compounddef"):
- if elem.attrib["prot"] != "public":
- continue
- if "compoundname" in elem:
- raise Exception("Compound {} has no 'compoundname' child tag.".format(elem))
- compoundname = elem.find("compoundname").text
- #print ("compoundname {}".format(compoundname))
+ if elem.attrib["kind"] == "class":
+ if elem.attrib["prot"] != "public":
+ continue
+ if "compoundname" in elem:
+ raise Exception("Compound {} has no 'compoundname' child tag.".format(elem))
+ compoundname = elem.find("compoundname").text
+ #print ("compoundname {}".format(compoundname))
+ elif elem.attrib["kind"] == "file":
+ compoundname = ""
+ elif elem.attrib["kind"] == "namespace":
+ compoundname = elem.find("compoundname").text
+ else:
+ print("Element {} is of kind {}".format(elem.attrib["id"], elem.attrib["kind"]))
+
for member in elem.findall('.//memberdef'):
if member.attrib["prot"] != "public":
continue
kind = member.attrib["kind"]
name = member.find("name").text
+ #print("kind:{} compoundname:{} name:{}".format( kind,compoundname, name))
if kind == "variable":
- if compoundname not in doxy_vars: doxy_vars[compoundname] = []
+ if compoundname not in doxy_vars:
+ doxy_vars[compoundname] = []
doxy_vars[compoundname].append(name)
elif kind == "function":
args = member.find('argsstring').text
args = re.sub('\)[^)]*$', ')', args) # ignore what's after the parameters (eg, '=0' or ' const')
- if compoundname not in doxy_funs: doxy_funs[compoundname] = {}
- if name not in doxy_funs[compoundname]: doxy_funs[compoundname][name] = []
+ if compoundname not in doxy_funs:
+ doxy_funs[compoundname] = {}
+ if name not in doxy_funs[compoundname]:
+ doxy_funs[compoundname][name] = []
doxy_funs[compoundname][name].append(args)
+ elif kind == "friend":
+ pass # Ignore friendship
else:
print ("member {}::{} is of kind {}".format(compoundname, name, kind))
# Forget about the declarations that are done in the RST
-with os.popen('grep autodoxymethod:: source/*rst|sed \'s/^.*autodoxymethod:: //\'') as pse:
+with os.popen('grep autodoxymethod:: find-missing.ignore source/*rst|sed \'s/^.*autodoxymethod:: //\'') as pse:
for line in (l.strip() for l in pse):
(klass, obj, args) = (None, None, None)
if "(" in line:
(line, args) = line.split('(', 1)
args = "({}".format(args)
- (klass, obj) = line.rsplit('::', 1)
+ if '::' in line:
+ (klass, obj) = line.rsplit('::', 1)
+ else:
+ (klass, obj) = ("", line)
if klass not in doxy_funs:
print("Warning: {} documented, but class {} not found in doxygen.".format(line, klass))
continue
if obj not in doxy_funs[klass]:
- print("Warning: Object {} documented but not found in {}".format(line, klass))
+ print("Warning: Object '{}' documented but not found in '{}'".format(line, klass))
+# for obj in doxy_funs[klass]:
+# print(" found: {}::{}".format(klass, obj))
elif len(doxy_funs[klass][obj])==1:
del doxy_funs[klass][obj]
elif args not in doxy_funs[klass][obj]:
print("Warning: Function {}{} not found in {}".format(obj, args, klass))
else:
-# print("Found {} in {}".format(line, klass))
+ #print("Found {} in {}".format(line, klass))
doxy_funs[klass][obj].remove(args)
if len(doxy_funs[klass][obj]) == 0:
del doxy_funs[klass][obj]
-with os.popen('grep autodoxyvar:: source/*rst|sed \'s/^.*autodoxyvar:: //\'') as pse:
+with os.popen('grep autodoxyvar:: find-missing.ignore source/*rst|sed \'s/^.*autodoxyvar:: //\'') as pse:
for line in (l.strip() for l in pse):
(klass, var) = line.rsplit('::', 1)
get_filtered_netzones_recursive
simgrid::s4u::Storage
simgrid::s4u::Activity_T
+simgrid::s4u::Engine::get_storage_count
+simgrid::s4u::Engine::storage_by_name
+simgrid::s4u::Engine::storage_by_name_or_null
\ No newline at end of file
.SH AUTHORS
The SimGrid team (simgrid-devel@lists.gforge.inria.fr)
.SH COPYRIGHT AND LICENCE
-Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.
+Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.
This program is free software; you may redistribute it and/or modify it under the terms of GNU LGPL (v2.1) license.
.SH SEE ALSO
.SH AUTHORS
The SimGrid team (simgrid-devel@lists.gforge.inria.fr)
.SH COPYRIGHT AND LICENCE
-Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.
+Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.
This program is free software; you may redistribute it and/or modify it under the terms of GNU LGPL (v2.1) license.
.SH SEE ALSO
.SH AUTHORS
The SimGrid team (simgrid-devel@lists.gforge.inria.fr)
.SH COPYRIGHT AND LICENCE
-Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.
+Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.
This program is free software; you may redistribute it and/or modify it under the terms of GNU LGPL (v2.1) license.
.SH SEE ALSO
.SH AUTHORS
The SimGrid team (simgrid-devel@lists.gforge.inria.fr)
.SH COPYRIGHT AND LICENCE
-Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.
+Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.
This program is free software; you may redistribute it and/or modify it under the terms of GNU LGPL (v2.1) license.
.SH SEE ALSO
.TH smpirun 1
.SH NAME
-smpirun \- Exectute MPI programs in the SimGrid simulator
+smpirun \- Execute MPI programs in the SimGrid simulator
.SH SYNOPSIS
smpirun [\fISMPI OPTIONS\fR]… \fB\-platform\fR <platform.xml> \fB\-hostfile\fR <hostfile> program [\fISIMULATION OPTIONS\fR] [\fIPROGRAM OPTIONS\fR]
.SH DESCRIPTION
-smpirun car run MPI programs that were compiled with smpicc on top of
-the simulator. Basically, it generates a deployment files from the
+smpirun can run MPI programs that were compiled with smpicc on top of
+the simulator. Basically, it generates a deployment file from the
provided hostfile (if needed), and launches the simulation with the right
arguments. It is intended to be easy to use to regular MPI users.
.SH MANDATORY PARAMETERS
Use command to run the program (e.g. "valgrind", "gdb --args", "rr record").
You usually want to use the "-foreground" option as well in order to have a TTY.
.TP
+\fB\-gdb\fR
+Run within GDB (equivalent to -wrapper "gdb --args" -keep-temps).
+.TP
+\fB\-lldb\fR
+Run within LLDB (equivalent to -wrapper "lldb --" -keep-temps).
+.TP
+\fB\-vgdb\fR
+Run within Valgrind+GDB (equivalent to -wrapper "valgrind --vgdb=yes --vgdb-error=0" -keep-temps).
+.TP
\fB\-foreground\fR
Run the child process in the foreground.
This gives the child process access to the TTY.
Use that amount of processes. By default, there is the same number of processes as there are of hosts in the hostfile.
.TP
\fB\-no-privatize\fR
-Disable the globals privatization, that is activated by default.
+Disable the privatization of global variables, that is activated by default.
This should only be necessary if you use dynamic libraries, but you
should probably link statically instead of disabling this. Do not link
-statically against SimGrid, only the others.
+statically against SimGrid, only against the other libraries.
.TP
\fB\-trace\fR
Activate the trace mechanism if available (equivalent to \fB--cfg\fR=\fItracing\fR:\fIyes\fR \fB--cfg\fR=\fItracing/smpi\fR:\fIyes\fR)
\fB\-trace-file\fR <tracefile>
Name of the tracefile
.TP
+\fB\-replay\fR <tracefile>
+Replay a trace instead of actually executing an application.
+.TP
\fB\-quiet\fR
Reduce output verbosity. This is useful to make tests reproducible.
-
+.TP
+\fB\-version\fR
+Displays the SimGrid version (human readable).
+.TP
+\fB\-git-version\fR
+Displays the git hash of SimGrid.
+.TP
.SH SIMULATION OPTIONS
-You can change many simulation parameter on the command line by passing
+You can change many simulation parameters on command line by passing
\fB--cfg\fR=\fIparameter\fR:\fIvalue\fR after the program name.
-A full list of existing parameters and their meaning can be found at
+A full list of the existing parameters and their meaning can be found at
https://simgrid.org/doc/latest/Configuring_SimGrid.html
Here are some options commonly used with SMPI:
.SH AUTHORS
The SimGrid team (simgrid-devel@lists.gforge.inria.fr)
.SH COPYRIGHT AND LICENCE
-Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.
+Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.
This program is free software; you may redistribute it and/or modify
it under the terms of GNU LGPL (v2.1) license.
.. code-block:: shell
- --cfg=tracing:yes --cfg=tracing/uncategorized:yes --cfg=triva/uncategorized:uncat.plist
+ --cfg=tracing:yes --cfg=tracing/uncategorized:yes
- The first parameter activates the tracing subsystem, the second
+ The first parameter activates the tracing subsystem, and the second
tells it to trace host and link utilization (without any
- categorization) and the third creates a graph configuration file to
- configure Triva when analysing the resulting trace file.
+ categorization).
- MSG or SimDag-based simulator and categorized traces (you need to
declare categories and classify your tasks according to them)
.. code-block:: shell
- --cfg=tracing:yes --cfg=tracing/categorized:yes --cfg=triva/categorized:cat.plist
+ --cfg=tracing:yes --cfg=tracing/categorized:yes
- The first parameter activates the tracing subsystem, the second
- tells it to trace host and link categorized utilization and the
- third creates a graph configuration file to configure Triva when
- analysing the resulting trace file.
+ The first parameter activates the tracing subsystem, and the second
+ tells it to trace host and link categorized utilization.
- SMPI simulator and traces for a space/time view:
FULL_PATH_NAMES = NO # Don't leak the path on which it was built
XML_PROGRAMLISTING = NO # No program listings, please
CREATE_SUBDIRS = NO # Mandatory for exhale
+AUTOLINK_SUPPORT = NO # Don't try to link words that correspond to documented classes to their corresponding doc
# Allow for rst directives and advanced functions e.g. grid tables
-ALIASES = "beginrst=\verbatim "
+ALIASES = "beginrst=\verbatim embed:rst:leading-asterisk"
+ALIASES += "rst=\verbatim "
ALIASES += "endrst=\endverbatim"
# Enable preprocessing and related preprocessor necessities
EXPAND_ONLY_PREDEF = NO
SKIP_FUNCTION_MACROS = NO
+QUIET=YES
+
PREDEFINED += \
__cplusplus \
DOXYGEN \
XBT_PRIVATE= \
XBT_ATTRIB_NORETURN= \
XBT_ATTRIB_UNUSED= \
+ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s,c,l)= \
XBT_ATTRIB_DEPRECATED_v328(m)= \
XBT_ATTRIB_DEPRECATED_v329(m)=
-.. Copyright 2005-2019
+.. Copyright 2005-2020
.. _install:
Platform Examples
=================
-SimGrid comes with an extensive set of platforms in the
-`examples/platforms <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms>`_
-directory.
+Simple Example with 3 hosts
+---------------------------
-.. todo:: Write this page of the manual.
+Imagine you want to describe a little platform with three hosts,
+interconnected as follows:
- Gather here the examples described elsewhere in the doc (SMPI tutorial, Platform intro), and describe the other ones.
+.. image:: /tuto_smpi/3hosts.png
+ :align: center
+
+This can be done with the following platform file, that considers the
+simulated platform as a graph of hosts and network links.
+
+.. literalinclude:: /tuto_smpi/3hosts.xml
+ :language: xml
+
+The elements basic elements (with :ref:`pf_tag_host` and
+:ref:`pf_tag_link`) are described first, and then the routes between
+any pair of hosts are explicitly given with :ref:`pf_tag_route`.
+
+Any host must be given a computational speed in flops while links must
+be given a latency and a bandwidth. You can write 1Gf for
+1,000,000,000 flops (full list of units in the reference guide of
+:ref:`pf_tag_host` and :ref:`pf_tag_link`).
+
+Routes defined with :ref:`pf_tag_route` are symmetrical by default,
+meaning that the list of traversed links from A to B is the same as
+from B to A. Explicitly define non-symmetrical routes if you prefer.
+
+The last thing you must know on SimGrid platform files is that the
+root tag must be :ref:`pf_tag_platform`. If the ``version`` attribute
+does not match what SimGrid expects, you will be hinted to use to the
+``simgrid_update_xml`` utility to update your file.
+
+Cluster with a Crossbar
+-----------------------
+
+A very common parallel computing platform is a homogeneous cluster in
+which hosts are interconnected via a crossbar switch with as many
+ports as hosts, so that any disjoint pairs of hosts can communicate
+concurrently at full speed. For instance:
+
+.. literalinclude:: ../../examples/platforms/cluster_crossbar.xml
+ :language: xml
+ :lines: 1-3,18-
+
+One specifies a name prefix and suffix for each host, and then give an
+integer range. In the example the cluster contains 65535 hosts (!),
+named ``node-0.simgrid.org`` to ``node-65534.simgrid.org``. All hosts
+have the same power (1 Gflop/sec) and are connected to the switch via
+links with same bandwidth (125 MBytes/sec) and latency (50
+microseconds).
+
+.. todo::
+
+ Add the picture.
+
+Cluster with a Shared Backbone
+------------------------------
+
+Another popular model for a parallel platform is that of a set of
+homogeneous hosts connected to a shared communication medium, a
+backbone, with some finite bandwidth capacity and on which
+communicating host pairs can experience contention. For instance:
+
+
+.. literalinclude:: ../../examples/platforms/cluster_backbone.xml
+ :language: xml
+ :lines: 1-3,18-
+
+The only differences with the crossbar cluster above are the ``bb_bw``
+and ``bb_lat`` attributes that specify the backbone characteristics
+(here, a 500 microseconds latency and a 2.25 GByte/sec
+bandwidth). This link is used for every communication within the
+cluster. The route from ``node-0.simgrid.org`` to ``node-1.simgrid.org``
+counts 3 links: the private link of ``node-0.simgrid.org``, the backbone
+and the private link of ``node-1.simgrid.org``.
+
+.. todo::
+
+ Add the picture.
+
+Torus Cluster
+-------------
+
+Many HPC facilities use torus clusters to reduce sharing and
+performance loss on concurrent internal communications. Modeling this
+in SimGrid is very easy. Simply add a ``topology="TORUS"`` attribute
+to your cluster. Configure it with the ``topo_parameters="X,Y,Z"``
+attribute, where ``X``, ``Y`` and ``Z`` are the dimension of your
+torus.
+
+.. image:: ../../examples/platforms/cluster_torus.svg
+ :align: center
+
+.. literalinclude:: ../../examples/platforms/cluster_torus.xml
+ :language: xml
+
+Note that in this example, we used ``loopback_bw`` and
+``loopback_lat`` to specify the characteristics of the loopback link
+of each node (i.e., the link allowing each node to communicate with
+itself). We could have done so in previous example too. When no
+loopback is given, the communication from a node to itself is handled
+as if it were two distinct nodes: it goes twice through the private
+link and through the backbone (if any).
+
+Fat-Tree Cluster
+----------------
+
+This topology was introduced to reduce the amount of links in the
+cluster (and thus reduce its price) while maintaining a high bisection
+bandwidth and a relatively low diameter. To model this in SimGrid,
+pass a ``topology="FAT_TREE"`` attribute to your cluster. The
+``topo_parameters=#levels;#downlinks;#uplinks;link count`` follows the
+semantic introduced in the `Figure 1B of this article
+<http://webee.eedev.technion.ac.il/wp-content/uploads/2014/08/publication_574.pdf>`_.
+
+Here is the meaning of this example: ``2 ; 4,4 ; 1,2 ; 1,2``
+
+- That's a two-level cluster (thus the initial ``2``).
+- Routers are connected to 4 elements below them, regardless of its
+ level. Thus the ``4,4`` component that is used as
+ ``#downlinks``. This means that the hosts are grouped by 4 on a
+ given router, and that there is 4 level-1 routers (in the middle of
+ the figure).
+- Hosts are connected to only 1 router above them, while these routers
+ are connected to 2 routers above them (thus the ``1,2`` used as
+ ``#uplink``).
+- Hosts have only one link to their router while every path between a
+ level-1 routers and level-2 routers use 2 parallel links. Thus the
+ ``1,2`` that is used as ``link count``.
+
+.. image:: ../../examples/platforms/cluster_fat_tree.svg
+ :align: center
+
+.. literalinclude:: ../../examples/platforms/cluster_fat_tree.xml
+ :language: xml
+ :lines: 1-3,10-
+
+
+Dragonfly Cluster
+-----------------
+
+This topology was introduced to further reduce the amount of links
+while maintaining a high bandwidth for local communications. To model
+this in SimGrid, pass a ``topology="DRAGONFLY"`` attribute to your
+cluster. It's based on the implementation of the topology used on
+Cray XC systems, described in paper
+`Cray Cascade: A scalable HPC system based on a Dragonfly network <https://dl.acm.org/citation.cfm?id=2389136>`_.
+
+System description follows the format ``topo_parameters=#groups;#chassis;#routers;#nodes``
+For example, ``3,4 ; 3,2 ; 3,1 ; 2``:
+
+- ``3,4``: There are 3 groups with 4 links between each (blue level).
+ Links to nth group are attached to the nth router of the group
+ on our implementation.
+- ``3,2``: In each group, there are 3 chassis with 2 links between each nth router
+ of each group (black level)
+- ``3,1``: In each chassis, 3 routers are connected together with a single link
+ (green level)
+- ``2``: Each router has two nodes attached (single link)
+
+.. image:: ../../examples/platforms/cluster_dragonfly.svg
+ :align: center
+
+.. literalinclude:: ../../examples/platforms/cluster_dragonfly.xml
+ :language: xml
+
+
+.. todo:: Complete this page of the manual.
+
+ SimGrid comes with an extensive set of platforms in the
+ `examples/platforms <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms>`_
+ directory that should be described here.
--- /dev/null
+.. raw:: html
+
+ <object id="TOC" data="graphical-toc.svg" type="image/svg+xml"></object>
+ <script>
+ window.onload=function() { // Wait for the SVG to be loaded before changing it
+ var elem=document.querySelector("#TOC").contentDocument.getElementById("RoutingBox")
+ elem.style="opacity:0.93999999;fill:#ff0000;fill-opacity:0.1;stroke:#000000;stroke-width:0.35277778;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1";
+ }
+ </script>
+ <br/>
+ <br/>
+
+.. _platform_routing:
+
+Defining a Routing
+##################
+
+Networking zones (:ref:`pf_tag_zone`) are an advanced concept used to factorize the description
+to reduce the size of your platform on disk and in memory. Then, when
+a host wants to communicate with another host belonging to the same
+zone, it is the zone's duty to find the list of links that are
+involved in the communication. In the above examples, since we use
+``routing="Full"``, all routes must be explicitly given using the
+:ref:`pf_tag_route` and :ref:`pf_tag_link_ctn` tags (this :ref:`routing
+model <pf_rm>` is both simple and inefficient :) It is OK to not
+specify each and every route between hosts, as long as you do not try
+to start a communication on any of the missing routes during your
+simulation.
+
+Any zone may contain sub-zones, allowing for a hierarchical
+decomposition of the platform. Routing can be made more efficient (as the
+inter-zone routing gets factored with :ref:`pf_tag_zoneroute`), and
+allows you to have more than one routing model in your platform. For
+example, you can have a coordinate-based routing for the WAN parts
+of your platforms, a full routing within each datacenter, and a highly
+optimized routing within each cluster of the datacenter. In this
+case, determining the route between two given hosts gets :ref:`routing_basics`
+"somewhat more complex" but SimGrid still computes
+these routes for you in a time- and space-efficient manner.
+Here is an illustration of these concepts:
+
+.. image:: img/zone_hierarchy.png
+
+Circles represent processing units and squares represent network
+routers. Bold lines represent communication links. The zone "AS2" models the core of a national network interconnecting a
+small flat cluster (AS4) and a larger hierarchical cluster (AS5), a
+subset of a LAN (AS6), and a set of peers scattered around the world
+(AS7).
+
+.. todo:: Add more examples, such as the cloud example described in
+ previous paragraph
+
elem.style="opacity:0.93999999;fill:#ff0000;fill-opacity:0.1;stroke:#000000;stroke-width:0.35277778;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1";
}
</script>
- <br/>
- <br/>
+ <br>
+ <br>
You can extend SimGrid without modifying it, thanks to our plugin
mechanism. This page describes how to write your own plugin, and
.. _plugin_host_energy:
-Host Energy Plugin
-==================
+Host Energy
+===========
+
+.. doxygengroup:: plugin_host_energy
+
-.. doxygengroup:: Plugin_host_energy
.. _plugin_link_energy:
-Link Energy Plugin
-==================
+Link Energy
+===========
+
+.. doxygengroup:: plugin_link_energy
+
-.. doxygengroup:: Plugin_link_energy
.. _plugin_host_load:
-Host Load Plugin
-================
+Host Load
+=========
+
+.. doxygengroup:: plugin_host_load
+
+
+
+.. _plugin_filesystem:
+
+File System
+===========
+
+.. doxygengroup:: plugin_filesystem
-.. doxygengroup:: Plugin_host_load
.. LocalWords: SimGrid
+
-------------------------------------------------------------------------------
+.. _pf_tag_disk:
+
+<disk>
+------
+
+SimGrid can simulate the time it takes to read or write data on disk, even if the stored data is not made persistent in
+any way by SimGrid. This means that your application will correctly be slowed down when doing simulated I/O, but there
+is no way to get the data stored this way.
+
+We decided to not model anything beyond raw access in SimGrid because we believe that there is not single way of doing so.
+We provide an example model of file system as a plugin, (sparsely) documented in :ref:`plugin_filesystem`.
+
+**Parent tags:** :ref:`pf_tag_host` |br|
+**Children tags:** :ref:`pf_tag_prop` |br|
+**Attributes:**
+
+:``id``: A name of your choice (must be unique on this host).
+:``read_bw``: Read bandwidth for this disk. You must specify a unit as follows.
+
+ **Units in bytes and powers of 2** (1 KiBps = 1,024 Bps):
+ Bps, KiBps, MiBps, GiBps, TiBps, PiBps, or EiBps. |br|
+ **Units in bits and powers of 2** (1 Bps = 8 bps):
+ bps, Kibps, Mibps, Gibps, Tibps, Pibps, or Eibps. |br|
+ **Units in bytes and powers of 10** (1 KBps = 1,000 Bps):
+ Bps, KBps, MBps, GBps, TBps, PBps, or EBps. |br|
+ **Units in bits and powers of 10:**
+ bps, Kbps, Mbps, Gbps, Tbps, Pbps, or Ebps.
+
+:``write_bw``: Write bandwidth for this disk. You must specify a unit as for the read bandwidth.
+
+.. code-block:: xml
+
+ <host id="alice" speed="1Gf">
+ <disk id="Disk1" read_bw="200MBps" write_bw="80MBps">
+ <!-- you can add properties for anything you want: they are not used by SimGrid -->
+ <prop id="content" value="storage/content/small_content.txt"/>
+ </disk>
+ <prop id="ram" value="100B" />
+ </host>
+
+-------------------------------------------------------------------------------
+
.. _pf_tag_config:
<config>
self.continue_line = True
def visit_parameterlist(self, node):
- lines = [l for l in type(self)().generic_visit(node).lines if l is not '']
+ lines = [l for l in type(self)().generic_visit(node).lines if l != '']
self.lines.extend([':parameters:', ''] + ['* %s' % l for l in lines] + [''])
def visit_simplesect(self, node):
'members': members_option,
}
- def __init__(self, directive, name, indent=u'', id=None):
+ def __init__(self, directive, name, indent=u'', my_id = None):
super(DoxygenDocumenter, self).__init__(directive, name, indent)
- if id is not None:
- self.parse_id(id)
+ if my_id is not None:
+ self.parse_id(my_id)
- def parse_id(self, id):
+ def parse_id(self, id_to_parse):
return False
def parse_name(self):
directive = getattr(self, 'directivetype', self.objtype)
name = self.format_name()
sourcename = self.get_sourcename()
+ #print('.. %s:%s:: %s%s' % (domain, directive, name, sig))
self.add_line(u'.. %s:%s:: %s%s' % (domain, directive, name, sig),
sourcename)
if want_all:
return False, ((m.find('name').text, m) for m in all_members)
- else:
- if not self.options.members:
- return False, []
- else:
- return False, ((m.find('name').text, m) for m in all_members
- if m.find('name').text in self.options.members)
+ if not self.options.members:
+ return False, []
+ return False, ((m.find('name').text, m) for m in all_members if m.find('name').text in self.options.members)
def filter_members(self, members, want_all):
ret = []
return True
return False
- def parse_id(self, id):
- xp = './/*[@id="%s"]' % id
+ def parse_id(self, id_to_parse):
+ xp = './/*[@id="%s"]' % id_to_parse
match = get_doxygen_root().xpath(xp)
- if len(match) > 0:
+ if match:
match = match[0]
self.fullname = match.find('./definition').text.split()[-1]
self.modname = self.fullname
# classname or method name
return True
- (obj, meth) = self.fullname.rsplit('::', 1)
+ if '::' in self.fullname:
+ (obj, meth) = self.fullname.rsplit('::', 1)
+ # 'public-func' and 'public-static-func' are for classes while 'func' alone is for namespaces
+ prefix = './/compoundname[text()="{:s}"]/../sectiondef[@kind="public-func" or @kind="public-static-func" or @kind="func"]'.format(obj)
+ obj = "{:s}::".format(obj)
+ else:
+ meth = self.fullname
+ prefix = './'
+ obj = ''
- xpath_query_noparam = ('.//compoundname[text()="{:s}"]/../sectiondef[@kind="public-func" or @kind="public-static-func"]'
- '/memberdef[@kind="function"]/name[text()="{:s}"]/..').format(obj, meth)
+ xpath_query_noparam = ('{:s}/memberdef[@kind="function"]/name[text()="{:s}"]/..').format(prefix, meth)
xpath_query = ""
-# print("fullname {}".format(self.fullname))
if self.argsstring != None:
- xpath_query = ('.//compoundname[text()="{:s}"]/../sectiondef[@kind="public-func" or @kind="public-static-func"]'
- '/memberdef[@kind="function" and argsstring/text()="{:s}"]/name[text()="{:s}"]/..').format(obj,self.argsstring,meth)
+ xpath_query = ('{:s}/memberdef[@kind="function" and argsstring/text()="{:s}"]/name[text()="{:s}"]/..').format(prefix,self.argsstring,meth)
else:
xpath_query = xpath_query_noparam
match = get_doxygen_root().xpath(xpath_query)
- if len(match) == 0:
+ if not match:
logger = logging.getLogger(__name__)
if self.argsstring != None:
candidates = get_doxygen_root().xpath(xpath_query_noparam)
if len(candidates) == 1:
- logger.warning("[autodoxy] Using method '{}::{}{}' instead of '{}::{}{}'. You may want to drop your specification of the signature, or to fix it."
+ logger.warning("[autodoxy] Using method '{}{}{}' instead of '{}{}{}'. You may want to drop your specification of the signature, or to fix it."
.format(obj, meth, candidates[0].find('argsstring').text, obj, meth, self.argsstring))
self.object = candidates[0]
return True
- logger.warning("[autodoxy] WARNING: Could not find method {}::{}{}".format(obj, meth, self.argsstring))
+ logger.warning("[autodoxy] WARNING: Could not find method {}{}{}".format(obj, meth, self.argsstring))
+ if not candidates:
+ logger.warning("[autodoxy] WARNING: (no candidate found)")
for cand in candidates:
- logger.warning("[autodoxy] WARNING: Existing candidate: {}::{}{}".format(obj, meth, cand.find('argsstring').text))
+ logger.warning("[autodoxy] WARNING: Existing candidate: {}{}{}".format(obj, meth, cand.find('argsstring').text))
else:
- logger.warning("[autodoxy] WARNING: could not find method {}::{} in Doxygen files".format(obj, meth))
+ logger.warning("[autodoxy] WARNING: Could not find method {}{} in Doxygen files\nQuery: {}".format(obj, meth, xpath_query))
return False
self.object = match[0]
return True
def format_template_name(self):
types = [e.text for e in self.object.findall('templateparamlist/param/type')]
- if len(types) == 0:
+ if not types:
return ''
ret = 'template <%s>' % ','.join(types)
# print ("template: {}".format(ret))
'/memberdef[@kind="variable"]/name[text()="{:s}"]/..').format(obj, var)
# print("fullname {}".format(self.fullname))
match = get_doxygen_root().xpath(xpath_query)
- if len(match) == 0:
+ if not match:
logger = logging.getLogger(__name__)
logger.warning("[autodoxy] WARNING: could not find variable {}::{} in Doxygen files".format(obj, var))
self.object = match[0]
return True
- def parse_id(self, id):
- xp = './/*[@id="%s"]' % id
+ def parse_id(self, id_to_parse):
+ xp = './/*[@id="%s"]' % id_to_parse
match = get_doxygen_root().xpath(xp)
- if len(match) > 0:
+ if match:
match = match[0]
self.fullname = match.find('./definition').text.split()[-1]
self.modname = self.fullname
def format_template_name(self):
types = [e.text for e in self.object.findall('templateparamlist/param/type')]
- if len(types) == 0:
+ if not types:
return ''
ret = 'template <%s>' % ','.join(types)
# print ("template: {}".format(ret))
files = [os.path.join(app.config.doxygen_xml, f)
for f in os.listdir(app.config.doxygen_xml)
if f.lower().endswith('.xml') and not f.startswith('._')]
- if len(files) == 0:
+ if not files:
raise err
setup.DOXYGEN_ROOT = ET.ElementTree(ET.Element('root')).getroot()
- for file in files:
- root = ET.parse(file).getroot()
+ for current_file in files:
+ root = ET.parse(current_file).getroot()
for node in root:
setup.DOXYGEN_ROOT.append(node)
memory gets properly reclaimed. This call should be at the end of the
actor's function, not in a on_exit callback.
+.. _s4u_raii:
+
Memory Management
*****************
API Reference
*************
-.. _API_s4u_this_actor:
-
-==================================
-Interacting with the current actor
-==================================
-
-Static methods working on the current actor (see :ref:`API_s4u_Actor`).
+.. _API_s4u_simulation_object:
-.. doxygennamespace:: simgrid::s4u::this_actor
+==================
+Simulation objects
+==================
-.. _API_s4u_Activity:
+.. _API_s4u_Actor:
==============
-class Activity
+ class Actor
==============
-.. autodoxyclass:: simgrid::s4u::Activity
-
- **Known subclasses:**
- :ref:`Communications <API_s4u_Comm>` (started on Mailboxes and consuming links),
- :ref:`Executions <API_s4u_Exec>` (started on Host and consuming CPU resources)
- :ref:`I/O <API_s4u_Io>` (started on and consumming disks).
- See also the :ref:`section on activities <s4u_Activities>` above.
-
-Querying info about activities
-------------------------------
-
- .. autodoxymethod:: simgrid::s4u::Activity::get_remaining()
- .. autodoxymethod:: simgrid::s4u::Activity::get_state()
- .. autodoxymethod:: simgrid::s4u::Activity::set_remaining(double remains)
- .. autodoxymethod:: simgrid::s4u::Activity::get_impl
-
-Activities lifecycle
---------------------
-
- .. autodoxymethod:: simgrid::s4u::Activity::start
- .. autodoxymethod:: simgrid::s4u::Activity::cancel
- .. autodoxymethod:: simgrid::s4u::Activity::test
- .. autodoxymethod:: simgrid::s4u::Activity::wait
- .. autodoxymethod:: simgrid::s4u::Activity::wait_for
- .. autodoxymethod:: simgrid::s4u::Activity::wait_until(double time_limit)
-
-
-.. _API_s4u_Actor:
-
-===========
-class Actor
-===========
+.. autodoxyclass:: simgrid::s4u::Actor
.. doxygentypedef:: ActorPtr
.. doxygentypedef:: aid_t
-.. autodoxyclass:: simgrid::s4u::Actor
-
Creating actors
---------------
.. group-tab:: C++
+ .. code:: C++
+
+ #include <simgrid/s4u/Engine.hpp>
+
.. autodoxymethod:: simgrid::s4u::Actor::create(const std::string &name, s4u::Host *host, const std::function< void()> &code)
.. autodoxymethod:: simgrid::s4u::Actor::create(const std::string &name, s4u::Host *host, F code)
.. autodoxymethod:: simgrid::s4u::Actor::create(const std::string &name, s4u::Host *host, F code, Args... args)
.. group-tab:: Python
+ .. code:: Python
+
+ from simgrid import Actor
+
.. automethod:: simgrid.Actor.create
+ .. group-tab:: C
+
+ .. code:: C
+
+ #include <simgrid/actor.h>
+
+ .. doxygentypedef:: sg_actor_t
+ .. cpp:type:: const s4u_Actor* const_sg_actor_t
+
+ Pointer to a constant actor object.
+
+ .. autodoxymethod:: sg_actor_init(const char *name, sg_host_t host)
+ .. autodoxymethod:: sg_actor_start(sg_actor_t actor, xbt_main_func_t code, int argc, char **argv)
+
+ .. autodoxymethod:: sg_actor_attach(const char *name, void *data, sg_host_t host, xbt_dict_t properties)
+ .. autodoxymethod:: sg_actor_detach()
+
+ .. autodoxymethod:: sg_actor_ref(const_sg_actor_t actor)
+ .. autodoxymethod:: sg_actor_unref(const_sg_actor_t actor)
+
Searching specific actors
-------------------------
.. automethod:: simgrid.Actor.by_pid
.. automethod:: simgrid.Actor.self
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_actor_by_PID(aid_t pid)
+ .. autodoxymethod:: sg_actor_self()
+
Querying info about actors
--------------------------
.. autoattribute:: simgrid.Actor.pid
.. autoattribute:: simgrid.Actor.ppid
- .. automethod:: simgrid.Actor.migrate
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_actor_get_name(const_sg_actor_t actor)
+ .. autodoxymethod:: sg_actor_get_PID(const_sg_actor_t actor)
+ .. autodoxymethod:: sg_actor_get_PPID(const_sg_actor_t actor)
+ .. autodoxymethod:: sg_actor_get_properties(const_sg_actor_t actor)
+ .. autodoxymethod:: sg_actor_get_property_value(const_sg_actor_t actor, const char *name)
+
+ .. autodoxymethod:: sg_actor_get_host(const_sg_actor_t actor)
+ .. autodoxymethod:: sg_actor_set_host(sg_actor_t actor, sg_host_t host)
+
+ .. autodoxymethod:: sg_actor_data(const_sg_actor_t actor)
+ .. autodoxymethod:: sg_actor_data_set(sg_actor_t actor, void *userdata)
Suspending and resuming actors
------------------------------
.. automethod:: simgrid.Actor.suspend
.. automethod:: simgrid.Actor.is_suspended
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_actor_suspend(sg_actor_t actor)
+ .. autodoxymethod:: sg_actor_resume(sg_actor_t actor)
+ .. autodoxymethod:: sg_actor_is_suspended(sg_actor_t actor)
+
Specifying when actors should terminate
---------------------------------------
.. automethod:: simgrid.Actor.daemonize
.. automethod:: simgrid.Actor.is_daemon
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_actor_kill(sg_actor_t actor)
+ .. autodoxymethod:: sg_actor_kill_all()
+ .. autodoxymethod:: sg_actor_set_kill_time(sg_actor_t actor, double kill_time)
+
+ .. autodoxymethod:: sg_actor_restart(sg_actor_t actor)
+ .. autodoxymethod:: sg_actor_daemonize(sg_actor_t actor)
+
+.. _API_s4u_Actor_end:
+
Reacting to the end of actors
-----------------------------
.. automethod:: simgrid.Actor.join
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_actor_join(sg_actor_t actor, double timeout)
+ .. autodoxymethod:: sg_actor_set_auto_restart(sg_actor_t actor, int auto_restart)
+
Signals
-------
.. autodoxyvar:: simgrid::s4u::Actor::on_resume
.. autodoxyvar:: simgrid::s4u::Actor::on_sleep
.. autodoxyvar:: simgrid::s4u::Actor::on_wake_up
- .. autodoxyvar:: simgrid::s4u::Actor::on_migration_start
- .. autodoxyvar:: simgrid::s4u::Actor::on_migration_end
.. autodoxyvar:: simgrid::s4u::Actor::on_termination
.. autodoxyvar:: simgrid::s4u::Actor::on_destruction
-.. _API_s4u_Barrier:
+.. _API_s4u_this_actor:
-=============
-class Barrier
-=============
+====================
+ The current actor
+====================
-.. doxygentypedef:: BarrierPtr
+These functions can be used in your user code to interact with the actor
+currently running (the one retrieved with :cpp:func:`simgrid::s4u::Actor::self`).
+Using these functions can greatly improve the code readability.
-.. autodoxyclass:: simgrid::s4u::Barrier
+Querying info
+-------------
- .. tabs::
+.. tabs::
- .. group-tab:: C++
+ .. group-tab:: C++
- .. autodoxymethod:: simgrid::s4u::Barrier::Barrier(unsigned int count)
- .. autodoxymethod:: simgrid::s4u::Barrier::create(unsigned int expected_actors)
- .. autodoxymethod:: simgrid::s4u::Barrier::wait()
+ .. autodoxymethod:: simgrid::s4u::this_actor::get_cname()
+ .. autodoxymethod:: simgrid::s4u::this_actor::get_name()
+ .. autodoxymethod:: simgrid::s4u::this_actor::get_pid()
+ .. autodoxymethod:: simgrid::s4u::this_actor::get_ppid()
+ .. autodoxymethod:: simgrid::s4u::this_actor::is_maestro()
+ .. autodoxymethod:: simgrid::s4u::this_actor::get_host()
+ .. autodoxymethod:: simgrid::s4u::this_actor::set_host(Host *new_host)
-.. _API_s4u_Comm:
+ .. group-tab:: Python
+
+ .. autofunction:: simgrid.this_actor.get_host
+ .. autofunction:: simgrid.this_actor.set_host
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_actor_self_data()
+ .. autodoxymethod:: sg_actor_self_data_set(void *data)
+ .. autodoxymethod:: sg_actor_self_get_name()
+ .. autodoxymethod:: sg_actor_self_get_pid()
+ .. autodoxymethod:: sg_actor_self_get_ppid()
+ .. autodoxymethod:: sg_host_self()
+ .. autodoxymethod:: sg_host_self_get_name()
+
+Suspending and resuming
+-----------------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::this_actor::suspend()
+ .. autodoxymethod:: simgrid::s4u::this_actor::yield()
+
+ .. group-tab:: Python
+
+ .. autofunction:: simgrid.this_actor.suspend
+ .. autofunction:: simgrid.this_actor.yield_
+
+Logging messages
+----------------
+
+.. tabs::
+
+ .. group-tab:: Python
+
+ .. autofunction:: simgrid.this_actor.info
+ .. autofunction:: simgrid.this_actor.error
+
+Sleeping
+--------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::this_actor::sleep_for(double duration)
+ .. autodoxymethod:: simgrid::s4u::this_actor::sleep_for(std::chrono::duration< Rep, Period > duration)
+ .. autodoxymethod:: simgrid::s4u::this_actor::sleep_until(const SimulationTimePoint< Duration > &wakeup_time)
+ .. autodoxymethod:: simgrid::s4u::this_actor::sleep_until(double wakeup_time)
+
+ .. group-tab:: Python
+
+ .. autofunction:: simgrid.this_actor.sleep_for
+ .. autofunction:: simgrid.this_actor.sleep_until
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_actor_sleep_for(double duration)
+
+Simulating executions
+---------------------
+
+Simulate the execution of some code on this actor. You can either simulate
+parallel or sequential code, and you can either block upon the termination of
+the execution, or start an asynchronous activity.
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::this_actor::exec_async(double flops_amounts)
+ .. autodoxymethod:: simgrid::s4u::this_actor::exec_init(const std::vector< s4u::Host * > &hosts, const std::vector< double > &flops_amounts, const std::vector< double > &bytes_amounts)
+ .. autodoxymethod:: simgrid::s4u::this_actor::exec_init(double flops_amounts)
+ .. autodoxymethod:: simgrid::s4u::this_actor::execute(double flop)
+ .. autodoxymethod:: simgrid::s4u::this_actor::execute(double flop, double priority)
+ .. autodoxymethod:: simgrid::s4u::this_actor::parallel_execute(const std::vector< s4u::Host * > &hosts, const std::vector< double > &flops_amounts, const std::vector< double > &bytes_amounts)
+ .. autodoxymethod:: simgrid::s4u::this_actor::parallel_execute(const std::vector< s4u::Host * > &hosts, const std::vector< double > &flops_amounts, const std::vector< double > &bytes_amounts, double timeout)
+
+ .. group-tab:: Python
+
+ .. autofunction:: simgrid.this_actor.exec_init
+ .. autofunction:: simgrid.this_actor.execute
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_actor_self_execute(double flops)
+
+Exiting
+-------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::this_actor::exit()
+ .. autodoxymethod:: simgrid::s4u::this_actor::on_exit(const std::function< void(bool)> &fun)
+
+ .. group-tab:: Python
+
+ .. autofunction:: simgrid.this_actor.exit
+ .. autofunction:: simgrid.this_actor.on_exit
+
+.. _API_s4u_Engine:
+
+====================
+ Simulation Engine
+====================
+
+.. autodoxyclass:: simgrid::s4u::Engine
+
+Initialization
+--------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Engine::Engine(int *argc, char **argv)
+ .. autodoxymethod:: simgrid::s4u::Engine::is_initialized()
+ .. autodoxymethod:: simgrid::s4u::Engine::shutdown()
+ .. autodoxymethod:: simgrid::s4u::Engine::set_config(const std::string &str)
+
+ .. autodoxymethod:: simgrid::s4u::Engine::load_deployment(const std::string &deploy)
+ .. autodoxymethod:: simgrid::s4u::Engine::load_platform(const std::string &platf)
+ .. autodoxymethod:: simgrid::s4u::Engine::register_actor(const std::string &name)
+ .. autodoxymethod:: simgrid::s4u::Engine::register_actor(const std::string &name, F code)
+ .. autodoxymethod:: simgrid::s4u::Engine::register_default(int(*code)(int, char **))
+ .. autodoxymethod:: simgrid::s4u::Engine::register_function(const std::string &name, int(*code)(int, char **))
+ .. autodoxymethod:: simgrid::s4u::Engine::register_function(const std::string &name, void(*code)(std::vector< std::string >))
+
+ .. group-tab:: Python
+
+ .. automethod:: simgrid.Engine.load_deployment
+ .. automethod:: simgrid.Engine.load_platform
+ .. automethod:: simgrid.Engine.register_actor
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: simgrid_init
+
+ .. autodoxymethod:: simgrid_load_deployment
+ .. autodoxymethod:: simgrid_load_platform
+ .. autodoxymethod:: simgrid_register_default
+ .. autodoxymethod:: simgrid_register_function
+
+Run the simulation
+------------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Engine::get_clock()
+ .. autodoxymethod:: simgrid::s4u::Engine::run()
+
+ .. group-tab:: Python
+
+ .. automethod:: simgrid.Engine.get_clock
+ .. automethod:: simgrid.Engine.run
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: simgrid_get_clock
+ .. autodoxymethod:: simgrid_run
+
+Retrieving actors
+-----------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Engine::get_actor_count()
+ .. autodoxymethod:: simgrid::s4u::Engine::get_all_actors()
+ .. autodoxymethod:: simgrid::s4u::Engine::get_filtered_actors(const std::function< bool(ActorPtr)> &filter)
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: simgrid_get_actor_count()
+
+Retrieving hosts
+----------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Engine::get_all_hosts()
+ .. autodoxymethod:: simgrid::s4u::Engine::get_host_count()
+ .. autodoxymethod:: simgrid::s4u::Engine::get_filtered_hosts(const std::function< bool(Host *)> &filter)
+ .. autodoxymethod:: simgrid::s4u::Engine::host_by_name(const std::string &name)
+ .. autodoxymethod:: simgrid::s4u::Engine::host_by_name_or_null(const std::string &name)
+
+ .. group-tab:: Python
+
+ .. automethod:: simgrid.Engine.get_all_hosts
+
+Retrieving links
+----------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Engine::get_all_links()
+ .. autodoxymethod:: simgrid::s4u::Engine::get_link_count()
+ .. autodoxymethod:: simgrid::s4u::Engine::get_filtered_links
+ .. autodoxymethod:: simgrid::s4u::Engine::link_by_name(const std::string &name)
+ .. autodoxymethod:: simgrid::s4u::Engine::link_by_name_or_null(const std::string &name)
+
+Interacting with the routing
+----------------------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Engine::get_all_netpoints()
+ .. autodoxymethod:: simgrid::s4u::Engine::get_filtered_netzones()
+ .. autodoxymethod:: simgrid::s4u::Engine::get_instance()
+ .. autodoxymethod:: simgrid::s4u::Engine::get_netzone_root()
+ .. autodoxymethod:: simgrid::s4u::Engine::netpoint_by_name_or_null(const std::string &name)
+ .. autodoxymethod:: simgrid::s4u::Engine::netzone_by_name_or_null(const std::string &name)
+ .. autodoxymethod:: simgrid::s4u::Engine::set_netzone_root(const NetZone *netzone)
+
+Signals
+-------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxyvar:: simgrid::s4u::Engine::on_deadlock
+ .. autodoxyvar:: simgrid::s4u::Engine::on_platform_created
+ .. autodoxyvar:: simgrid::s4u::Engine::on_platform_creation
+ .. autodoxyvar:: simgrid::s4u::Engine::on_simulation_end
+ .. autodoxyvar:: simgrid::s4u::Engine::on_time_advance
+
+.. _API_s4u_Mailbox:
+
+================
+ class Mailbox
+================
+
+.. autodoxyclass:: simgrid::s4u::Mailbox
+
+Please also refer to the :ref:`full doc on s4u::Mailbox <s4u_mailbox>`.
+
+Basic management
+----------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. code-block:: C++
+
+ #include <simgrid/s4u/Mailbox.hpp>
+
+ Note that there is no MailboxPtr type, and that you cannot use the RAII
+ idiom on mailboxes because they are internal objects to the simulation
+ engine. Once created, there is no way to destroy a mailbox before the end
+ of the simulation.
+
+ .. autodoxymethod:: simgrid::s4u::Mailbox::by_name(const std::string &name)
+
+ .. group-tab:: Python
+
+ .. automethod:: simgrid.Mailbox.by_name
+
+Querying info
+.............
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Mailbox::get_cname()
+ .. autodoxymethod:: simgrid::s4u::Mailbox::get_name()
+
+ .. group-tab:: Python
+
+ .. autoattribute:: simgrid.Mailbox.name
+
+Sending data
+............
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Mailbox::put(void *payload, uint64_t simulated_size_in_bytes)
+ .. autodoxymethod:: simgrid::s4u::Mailbox::put(void *payload, uint64_t simulated_size_in_bytes, double timeout)
+ .. autodoxymethod:: simgrid::s4u::Mailbox::put_async(void *data, uint64_t simulated_size_in_bytes)
+ .. autodoxymethod:: simgrid::s4u::Mailbox::put_init()
+ .. autodoxymethod:: simgrid::s4u::Mailbox::put_init(void *data, uint64_t simulated_size_in_bytes)
+
+ .. group-tab:: Python
+
+ .. automethod:: simgrid.Mailbox.put
+ .. automethod:: simgrid.Mailbox.put_async
+
+
+Receiving data
+..............
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Mailbox::empty()
+ .. autodoxymethod:: simgrid::s4u::Mailbox::front()
+ .. autodoxymethod:: simgrid::s4u::Mailbox::get()
+ .. autodoxymethod:: simgrid::s4u::Mailbox::get(double timeout)
+ .. autodoxymethod:: simgrid::s4u::Mailbox::get_async(void **data)
+ .. autodoxymethod:: simgrid::s4u::Mailbox::get_init()
+ .. autodoxymethod:: simgrid::s4u::Mailbox::iprobe(int type, bool(*match_fun)(void *, void *, kernel::activity::CommImpl *), void *data)
+ .. autodoxymethod:: simgrid::s4u::Mailbox::listen()
+ .. autodoxymethod:: simgrid::s4u::Mailbox::ready()
+
+ .. group-tab:: Python
+
+ .. automethod:: simgrid.Mailbox.get
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_mailbox_listen(const char *alias)
+
+Receiving actor
+...............
+
+See :ref:`s4u_receiving_actor`.
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Mailbox::get_receiver()
+ .. autodoxymethod:: simgrid::s4u::Mailbox::set_receiver(ActorPtr actor)
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: ::sg_mailbox_set_receiver(const char *alias)
+
+.. _API_s4u_Resource:
=========
-s4u::Comm
+Resources
=========
-.. doxygentypedef:: CommPtr
+.. _API_s4u_Disk:
-.. doxygenclass:: simgrid::s4u::Comm
+=============
+ class Disk
+=============
+
+.. doxygenclass:: simgrid::s4u::Disk
:members:
:protected-members:
:undoc-members:
-.. _API_s4u_ConditionVariable:
-======================
-s4u::ConditionVariable
-======================
-.. doxygentypedef:: ConditionVariablePtr
+.. _API_s4u_Host:
-.. doxygenclass:: simgrid::s4u::ConditionVariable
+=============
+ class Host
+=============
+
+.. doxygenclass:: simgrid::s4u::Host
:members:
:protected-members:
:undoc-members:
-.. _API_s4u_Disk:
+.. _API_s4u_Link:
+
+=============
+ class Link
+=============
+
+.. doxygenclass:: simgrid::s4u::Link
+ :members:
+ :protected-members:
+ :undoc-members:
-============
-s4u::Disk
-============
+.. _API_s4u_NetZone:
-.. doxygenclass:: simgrid::s4u::Disk
+================
+ class NetZone
+================
+
+.. doxygenclass:: simgrid::s4u::NetZone
:members:
:protected-members:
:undoc-members:
-.. _API_s4u_Engine:
+.. _API_s4u_VirtualMachine:
-===========
-s4u::Engine
-===========
+=======================
+ class VirtualMachine
+=======================
-.. doxygenclass:: simgrid::s4u::Engine
+.. doxygenclass:: simgrid::s4u::VirtualMachine
+ :members:
+ :protected-members:
+ :undoc-members:
+
+.. autodoxymethod:: sg_vm_create_core
+.. autodoxymethod:: sg_vm_create_multicore
+.. autodoxymethod:: sg_vm_get_name
+.. autodoxymethod:: sg_vm_get_pm
+.. autodoxymethod:: sg_vm_is_created
+.. autodoxymethod:: sg_vm_is_running
+.. autodoxymethod:: sg_vm_is_suspended
+.. autodoxymethod:: sg_vm_start
+.. autodoxymethod:: sg_vm_suspend
+.. autodoxymethod:: sg_vm_resume
+.. autodoxymethod:: sg_vm_shutdown
+.. autodoxymethod:: sg_vm_destroy
+
+.. _API_s4u_Activity:
+
+==============
+class Activity
+==============
+
+.. autodoxyclass:: simgrid::s4u::Activity
+
+ **Known subclasses:**
+ :ref:`Communications <API_s4u_Comm>` (started on Mailboxes and consuming links),
+ :ref:`Executions <API_s4u_Exec>` (started on Host and consuming CPU resources)
+ :ref:`I/O <API_s4u_Io>` (started on and consumming disks).
+ See also the :ref:`section on activities <s4u_Activities>` above.
+
+Querying info about activities
+------------------------------
+
+ .. autodoxymethod:: simgrid::s4u::Activity::get_remaining()
+ .. autodoxymethod:: simgrid::s4u::Activity::get_state()
+ .. autodoxymethod:: simgrid::s4u::Activity::set_remaining(double remains)
+ .. autodoxymethod:: simgrid::s4u::Activity::get_impl
+
+Activities lifecycle
+--------------------
+
+ .. autodoxymethod:: simgrid::s4u::Activity::start
+ .. autodoxymethod:: simgrid::s4u::Activity::cancel
+ .. autodoxymethod:: simgrid::s4u::Activity::test
+ .. autodoxymethod:: simgrid::s4u::Activity::wait
+ .. autodoxymethod:: simgrid::s4u::Activity::wait_for
+ .. autodoxymethod:: simgrid::s4u::Activity::wait_until(double time_limit)
+
+.. _API_s4u_Comm:
+
+=============
+ class Comm
+=============
+
+.. doxygentypedef:: CommPtr
+
+.. doxygenclass:: simgrid::s4u::Comm
:members:
:protected-members:
:undoc-members:
.. _API_s4u_Exec:
-=========
-s4u::Exec
-=========
+=============
+ class Exec
+=============
.. doxygentypedef:: ExecPtr
.. _API_s4u_ExecSeq:
-============
-s4u::ExecSeq
-============
+==================
+ class ExecSeq
+==================
.. doxygentypedef:: ExecSeqPtr
.. _API_s4u_ExecPar:
-============
-s4u::ExecPar
-============
+==================
+ class ExecPar
+==================
.. doxygentypedef:: ExecParPtr
:protected-members:
:undoc-members:
-.. _API_s4u_Host:
-
-=========
-s4u::Host
-=========
-
-.. doxygenclass:: simgrid::s4u::Host
- :members:
- :protected-members:
- :undoc-members:
-
.. _API_s4u_Io:
-=======
-s4u::Io
-=======
+===========
+ class Io
+===========
.. doxygentypedef:: IoPtr
:protected-members:
:undoc-members:
-.. _API_s4u_Link:
+.. _API_s4u_Synchronizations:
-=========
-s4u::Link
-=========
+=======================
+Synchronization Objects
+=======================
-.. doxygenclass:: simgrid::s4u::Link
- :members:
- :protected-members:
- :undoc-members:
+.. _API_s4u_Mutex:
-.. _API_s4u_Mailbox:
+==============
+ Mutex
+==============
-============
-s4u::Mailbox
-============
+.. autodoxyclass:: simgrid::s4u::Mutex
-Please also refer to the :ref:`full doc on s4u::Mailbox <s4u_mailbox>`.
+Basic management
+----------------
-.. doxygenclass:: simgrid::s4u::Mailbox
- :members:
- :protected-members:
- :undoc-members:
+ .. tabs::
-.. _API_s4u_Mutex:
+ .. group-tab:: C++
-==========
-s4u::Mutex
-==========
+ .. code-block:: C++
-.. doxygentypedef:: MutexPtr
+ #include <simgrid/s4u/Mutex.hpp>
-.. doxygenclass:: simgrid::s4u::Mutex
- :members:
- :protected-members:
- :undoc-members:
+ .. doxygentypedef:: MutexPtr
-.. _API_s4u_NetZone:
+ .. autodoxymethod:: simgrid::s4u::Mutex::Mutex(kernel::activity::MutexImpl *mutex)
+ .. autodoxymethod:: simgrid::s4u::Mutex::create()
+ .. autodoxymethod:: simgrid::s4u::Mutex::~Mutex()
-============
-s4u::NetZone
-============
+ .. group-tab:: C
-.. doxygenclass:: simgrid::s4u::NetZone
- :members:
- :protected-members:
- :undoc-members:
+ .. code-block:: C
-.. _API_s4u_Semaphore:
+ #include <simgrid/mutex.h>
-==============
-s4u::Semaphore
-==============
+ .. doxygentypedef:: sg_mutex_t
+ .. cpp:type:: const s4u_Mutex* const_sg_mutex_t
-.. doxygentypedef:: SemaphorePtr
+ Pointer to a constant mutex object.
-.. doxygenclass:: simgrid::s4u::Semaphore
- :members:
- :protected-members:
- :undoc-members:
+ .. autodoxymethod:: sg_mutex_init()
+ .. autodoxymethod:: sg_mutex_destroy(const_sg_mutex_t mutex)
-.. _API_s4u_VirtualMachine:
+Locking
+-------
-===================
-s4u::VirtualMachine
-===================
+ .. tabs::
-.. doxygenclass:: simgrid::s4u::VirtualMachine
- :members:
- :protected-members:
- :undoc-members:
+ .. group-tab:: C++
-C API Reference
-***************
+ .. autodoxymethod:: simgrid::s4u::Mutex::lock()
+ .. autodoxymethod:: simgrid::s4u::Mutex::try_lock()
+ .. autodoxymethod:: simgrid::s4u::Mutex::unlock()
-==============
-Main functions
-==============
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_mutex_lock(sg_mutex_t mutex)
+ .. autodoxymethod:: sg_mutex_try_lock(sg_mutex_t mutex)
+ .. autodoxymethod:: sg_mutex_unlock(sg_mutex_t mutex)
+
+.. _API_s4u_Barrier:
+
+================
+ Barrier
+================
+
+.. autodoxyclass:: simgrid::s4u::Barrier
+
+ .. tabs::
+
+ .. group-tab:: C++
+
+ .. code-block:: C++
+
+ #include <simgrid/s4u/Barrier.hpp>
+
+ .. doxygentypedef:: BarrierPtr
+
+ .. autodoxymethod:: simgrid::s4u::Barrier::Barrier(unsigned int expected_actors)
+ .. autodoxymethod:: simgrid::s4u::Barrier::create(unsigned int expected_actors)
+ .. autodoxymethod:: simgrid::s4u::Barrier::wait()
+
+ .. group-tab:: C
+
+ .. code-block:: C
+
+ #include <simgrid/barrier.hpp>
-.. doxygenfunction:: simgrid_init
-.. doxygenfunction:: simgrid_get_clock
-.. doxygenfunction:: simgrid_load_deployment
-.. doxygenfunction:: simgrid_load_platform
-.. doxygenfunction:: simgrid_register_default
-.. doxygenfunction:: simgrid_register_function
-.. doxygenfunction:: simgrid_run
+ .. doxygentypedef:: sg_bar_t
+ .. cpp:type:: const s4u_Barrier* const_sg_bar_t
+
+ Pointer to a constant barrier object.
+
+ .. autodoxymethod:: sg_barrier_init(unsigned int count)
+ .. autodoxymethod:: sg_barrier_destroy(const_sg_bar_t bar)
+ .. autodoxymethod:: sg_barrier_wait(sg_bar_t bar)
+
+
+.. _API_s4u_ConditionVariable:
+
+==========================
+ Condition variable
+==========================
+
+.. autodoxyclass:: simgrid::s4u::ConditionVariable
+
+Basic management
+----------------
+
+ .. tabs::
+
+ .. group-tab:: C++
+
+ .. code-block:: C++
+
+ #include <simgrid/s4u/ConditionVariable.hpp>
+
+ .. doxygentypedef:: ConditionVariablePtr
+
+ .. autodoxymethod:: simgrid::s4u::ConditionVariable::create()
+
+ .. group-tab:: C
+
+ .. code-block:: C
+
+ #include <simgrid/cond.h>
+
+ .. doxygentypedef:: sg_cond_t
+ .. doxygenfunction:: sg_cond_init
+ .. doxygenfunction:: sg_cond_destroy
+
+Waiting and notifying
+---------------------
+
+ .. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::ConditionVariable::notify_all()
+ .. autodoxymethod:: simgrid::s4u::ConditionVariable::notify_one()
+ .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait(s4u::MutexPtr lock)
+ .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait(const std::unique_lock< s4u::Mutex > &lock)
+ .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait(const std::unique_lock< Mutex > &lock, P pred)
+ .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait_for(const std::unique_lock< s4u::Mutex > &lock, double duration)
+ .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait_for(const std::unique_lock< s4u::Mutex > &lock, double duration, P pred)
+ .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait_for(const std::unique_lock< s4u::Mutex > &lock, std::chrono::duration< Rep, Period > duration)
+ .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait_for(const std::unique_lock< s4u::Mutex > &lock, std::chrono::duration< Rep, Period > duration, P pred)
+ .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait_until(const std::unique_lock< s4u::Mutex > &lock, const SimulationTimePoint< Duration > &timeout_time)
+ .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait_until(const std::unique_lock< s4u::Mutex > &lock, const SimulationTimePoint< Duration > &timeout_time, P pred)
+ .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait_until(const std::unique_lock< s4u::Mutex > &lock, double timeout_time)
+ .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait_until(const std::unique_lock< s4u::Mutex > &lock, double timeout_time, P pred)
+
+ .. group-tab:: C
+
+ .. doxygenfunction:: sg_cond_notify_all
+ .. doxygenfunction:: sg_cond_notify_one
+ .. doxygenfunction:: sg_cond_wait
+ .. doxygenfunction:: sg_cond_wait_for
+
+.. _API_s4u_Semaphore:
==================
-Condition Variable
+ Semaphore
==================
-See also the :ref:`C++ API <API_s4u_ConditionVariable>`.
+.. autodoxyclass:: simgrid::s4u::Semaphore
+
-.. doxygenfunction:: sg_cond_init
-.. doxygenfunction:: sg_cond_notify_all
-.. doxygenfunction:: sg_cond_notify_one
-.. doxygenfunction:: sg_cond_wait
-.. doxygenfunction:: sg_cond_wait_for
+Basic management
+----------------
+
+ .. tabs::
+
+ .. group-tab:: C++
+
+ .. code-block:: C++
+
+ #include <simgrid/s4u/Semaphore.hpp>
+
+ .. doxygentypedef:: SemaphorePtr
+ .. autodoxymethod:: simgrid::s4u::Semaphore::Semaphore(unsigned int initial_capacity)
+ .. autodoxymethod:: simgrid::s4u::Semaphore::~Semaphore()
+ .. autodoxymethod:: simgrid::s4u::Semaphore::create(unsigned int initial_capacity)
+
+ .. group-tab:: C
+
+ .. code-block:: C
+
+ #include <simgrid/semaphore.h>
+
+ .. doxygentypedef:: sg_sem_t
+ .. cpp:type:: const s4u_Semaphore* const_sg_sem_t
+
+ Pointer to a constant semaphore object.
+
+ .. autodoxymethod:: sg_sem_init(int initial_value)
+ .. autodoxymethod:: sg_sem_destroy(const_sg_sem_t sem)
+
+Locking
+-------
+
+ .. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Semaphore::acquire()
+ .. autodoxymethod:: simgrid::s4u::Semaphore::acquire_timeout(double timeout)
+ .. autodoxymethod:: simgrid::s4u::Semaphore::get_capacity()
+ .. autodoxymethod:: simgrid::s4u::Semaphore::release()
+ .. autodoxymethod:: simgrid::s4u::Semaphore::would_block()
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_sem_acquire(sg_sem_t sem)
+ .. autodoxymethod:: sg_sem_acquire_timeout(sg_sem_t sem, double timeout)
+ .. autodoxymethod:: sg_sem_get_capacity(sg_sem_t sem)
+ .. autodoxymethod:: sg_sem_release(sg_sem_t sem)
+ .. autodoxymethod:: sg_sem_would_block(sg_sem_t sem)
Python API Reference
********************
.. automodule:: simgrid.this_actor
:members:
-===========
-Class Actor
-===========
-
-.. autoclass:: simgrid.Actor
- :members:
-
==========
Class Comm
==========
.. autoclass:: simgrid.Comm
:members:
-============
-Class Engine
-============
-
-.. autoclass:: simgrid.Engine
- :members:
-
==========
Class Exec
==========
- mvapich2: use mvapich2 selector for the alltoall operations
- impi: use intel mpi selector for the alltoall operations
- automatic (experimental): use an automatic self-benchmarking algorithm
- - bruck: Described by Bruck et.al. in <a href="http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=642949">this paper</a>
+ - bruck: Described by Bruck et.al. in `this paper <http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=642949>`_
- 2dmesh: organizes the nodes as a two dimensional mesh, and perform allgather
along the dimensions
- 3dmesh: adds a third dimension to the previous algorithm
- impi: use intel mpi selector for the allreduce operations
- automatic (experimental): use an automatic self-benchmarking algorithm
- lr: logical ring reduce-scatter then logical ring allgather
- - rab1: variations of the <a href="https://fs.hlrs.de/projects/par/mpi//myreduce.html">Rabenseifner</a> algorithm: reduce_scatter then allgather
- - rab2: variations of the <a href="https://fs.hlrs.de/projects/par/mpi//myreduce.html">Rabenseifner</a> algorithm: alltoall then allgather
- - rab_rsag: variation of the <a href="https://fs.hlrs.de/projects/par/mpi//myreduce.html">Rabenseifner</a> algorithm: recursive doubling
+ - rab1: variations of the `Rabenseifner <https://fs.hlrs.de/projects/par/mpi//myreduce.html>`_ algorithm: reduce_scatter then allgather
+ - rab2: variations of the `Rabenseifner <https://fs.hlrs.de/projects/par/mpi//myreduce.html>`_ algorithm: alltoall then allgather
+ - rab_rsag: variation of the `Rabenseifner <https://fs.hlrs.de/projects/par/mpi//myreduce.html>`_ algorithm: recursive doubling
reduce_scatter then recursive doubling allgather
- rdb: recursive doubling
- smp_binomial: binomial tree with smp: binomial intra
# -- Project information -----------------------------------------------------
project = u'SimGrid'
-copyright = u'2002-2019, The SimGrid Team'
+copyright = u'2002-2020, The SimGrid Team'
author = u'The SimGrid Team'
# The short X.Y version
"gitlab_version": "master", # Version
"conf_py_path": "/docs/source/", # Path in the checkout to the docs root
}
+
+# -- Other options
+
+nitpicky = True # Generate a warning for all a cross-reference (such as :func:`myfunc`) that cannot be found
:caption: User Manual:
Introduction <Introduction.rst>
- Installing SimGrid <Installing_SimGrid.rst>
- Start your Own Project <Start_Your_Own_Project.rst>
+ Installing SimGrid <Installing_SimGrid.rst>
+ Start your Own Project <Start_Your_Own_Project.rst>
Describing your Application <application.rst>
- The S4U Interface <app_s4u.rst>
- The SMPI Interface <app_smpi.rst>
- The MSG Interface <app_msg.rst>
+ The S4U Interface <app_s4u.rst>
+ The SMPI Interface <app_smpi.rst>
+ The MSG Interface <app_msg.rst>
Describing the Simulated Platform <platform.rst>
- Examples <Platform_Examples.rst>
- Modeling Hints <platform_howtos.rst>
- XML Reference <XML_Reference.rst>
+ Examples <Platform_Examples.rst>
+ Modeling Hints <platform_howtos.rst>
+ Defining a Routing <Platform_Routing.rst>
+ XML Reference <XML_Reference.rst>
Describing the Experimental Setup <Experimental_Setup.rst>
- Configuring SimGrid <Configuring_SimGrid.rst>
- Deploying your Application <Deploying_your_Application.rst>
+ Configuring SimGrid <Configuring_SimGrid.rst>
+ Deploying your Application <Deploying_your_Application.rst>
The SimGrid Models <models.rst>
- ns-3 as a SimGrid model <ns3.rst>
+ ns-3 as a SimGrid model <ns3.rst>
SimGrid Plugins <Plugins.rst>
Simulation Outcomes <outcomes.rst>
The SimGrid Community <community.rst>
the :ref:`lua bindings <platform_lua>` (it is not yet possible to do so in
python or directly in C++).
-We understand that writing a complex platform description can be tricky, we thus included
-:ref:`many examples <platform_examples>` in the archive. This
-documentation also contains some :ref:`hints and howtos <howto>`, as well
-as the full :ref:`XML reference guide <platform_reference>`.
-
-
-Any simulated platform must contain **basic elements**, such as hosts, links, disks, etc. SimGrid gives you a great
-liberty when defining the **routing of your platform**, i.e., the network path taken between each pair of hosts.
+Any simulated platform must contain **basic elements**, such as
+:ref:`pf_tag_host`, :ref:`pf_tag_link`, :ref:`pf_tag_disk`, and similar.
+SimGrid makes no assumption about the **routing of your platform**, so you must declare
+explicitly the network path taken between each pair of hosts.
+This can be done through a flat list of :ref:`pf_tag_route` for each pair of hosts (routes
+are symmetrical by default), or you may use the advanced concept of :ref:`networking zone <platform_routing>`
+to efficiently express the routing of your platform.
Finally, you may also describe an **experimental scenario**, with qualitative (e.g., bandwidth variations representing
an external load) and qualitative (e.g., representing how some elements fail and restart over time) changes.
-
-First Example
-*************
-
-Imagine you want to describe a little platform with three hosts,
-interconnected as follows:
-
-.. image:: /tuto_smpi/3hosts.png
- :align: center
-
-This can be done with the following platform file, that considers the
-simulated platform as a graph of hosts and network links.
-
-.. literalinclude:: /tuto_smpi/3hosts.xml
- :language: xml
-
-The most important elements are the basic ones: :ref:`pf_tag_host`,
-:ref:`pf_tag_link`, and similar. Then come the routes between any pair
-of hosts, that are given explicitly with :ref:`pf_tag_route` (routes
-are symmetrical by default). Any host must be given a computational
-speed (in flops) while links must be given a latency (in seconds) and
-a bandwidth (in bytes per second). Note that you can write 1Gflops
-instead of 1000000000flops, and similar.
-
-Every platform element must be located within a given **networking
-zone** . Zones are in
-charge of the routing, see below.
-
-The last thing you must know on SimGrid platform files is that the
-root tag must be :ref:`pf_tag_platform`. If the ``version`` attribute
-does not match what SimGrid expects, you will be hinted to use to the
-``simgrid_update_xml`` utility to update your file.
-
-
-Defining a Routing
-******************
-
-Networking zones (:ref:`pf_tag_zone`) are used to factorize the description
-to reduce the size of your platform on disk and in memory. Then, when
-a host wants to communicate with another host belonging to the same
-zone, it is the zone's duty to find the list of links that are
-involved in the communication. In the above examples, since we use
-``routing="Full"``, all routes must be explicitly given using the
-:ref:`pf_tag_route` and :ref:`pf_tag_link_ctn` tags (this :ref:`routing
-model <pf_rm>` is both simple and inefficient :) It is OK to not
-specify each and every route between hosts, as long as you do not try
-to start a communication on any of the missing routes during your
-simulation.
-
-Any zone may contain sub-zones, allowing for a hierarchical
-decomposition of the platform. Routing can be made more efficient (as the
-inter-zone routing gets factored with :ref:`pf_tag_zoneroute`), and
-allows you to have more than one routing model in your platform. For
-example, you can have a coordinate-based routing for the WAN parts
-of your platforms, a full routing within each datacenter, and a highly
-optimized routing within each cluster of the datacenter. In this
-case, determining the route between two given hosts gets :ref:`routing_basics`
-"somewhat more complex" but SimGrid still computes
-these routes for you in a time- and space-efficient manner.
-Here is an illustration of these concepts:
-
-.. image:: img/zone_hierarchy.png
-
-Circles represent processing units and squares represent network
-routers. Bold lines represent communication links. The zone "AS2" models the core of a national network interconnecting a
-small flat cluster (AS4) and a larger hierarchical cluster (AS5), a
-subset of a LAN (AS6), and a set of peers scattered around the world
-(AS7).
-
-.. todo:: Add more examples, such as the cloud example described in
- previous paragraph
-
-Performance Profiles and Churn
-******************************
+The most efficient way to learn about platform description is to look at the
+:ref:`many examples <platform_examples>` included in the archive and described
+in the next section. This documentation also contains some :ref:`hints and
+howtos <howto>`, as well as the full :ref:`XML reference guide
+<platform_reference>`.
.. LocalWords: SimGrid
-.. _platform:
-
.. raw:: html
<object id="TOC" data="graphical-toc.svg" type="image/svg+xml"></object>
.. code-block:: xml
- <host id="A" speed="1Gf"/>
- <host id="B" speed="1Gf"/>
+ <host id="A" speed="1Gf" />
+ <host id="B" speed="1Gf" />
- <link id="link1" latency="10ms" bandwidth="1Mbps"/>
+ <link id="link1" latency="10ms" bandwidth="1Mbps" />
- <route src="A" dst="B>
- <link_ctn id="link1/>
+ <route src="A" dst="B">
+ <link_ctn id="link1" />
</route>
If host `A` sends `100kB` (a hundred kilobytes) to host `B`, one could expect
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
.. example-tab:: examples/platforms/energy_platform.xml
+.. _s4u_ex_disk_io:
+
I/O on Disks and Files
----------------------
Classical synchronization objects
---------------------------------
- - **Mutex:**
- Shows how to use simgrid::s4u::Mutex synchronization objects.
+ - **Barrier:**
+ Shows how to use :cpp:type:`simgrid::s4u::Barrier` synchronization objects.
.. tabs::
- .. example-tab:: examples/s4u/synchro-mutex/s4u-synchro-mutex.cpp
+ .. example-tab:: examples/s4u/synchro-barrier/s4u-synchro-barrier.cpp
- - **Barrier:**
- Shows how to use simgrid::s4u::Barrier synchronization objects.
+ - **Condition variable:**
+ Shows how to use :cpp:type:`simgrid::s4u::ConditionVariable` synchronization objects.
.. tabs::
- .. example-tab:: examples/s4u/synchro-barrier/s4u-synchro-barrier.cpp
+ .. example-tab:: examples/s4u/synchro-condition-variable/s4u-synchro-condition-variable.cpp
+
+ - **Mutex:**
+ Shows how to use :cpp:type:`simgrid::s4u::Mutex` synchronization objects.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/synchro-mutex/s4u-synchro-mutex.cpp
- **Semaphore:**
- Shows how to use simgrid::s4u::Semaphore synchronization objects.
+ Shows how to use :cpp:type:`simgrid::s4u::Semaphore` synchronization objects.
.. tabs::
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#!/usr/bin/env python
-# Copyright (c) 2013-2019. The SimGrid Team.
+# Copyright (c) 2013-2020. The SimGrid Team.
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* Master of a basic master/worker example in Java */
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2014-2019. The SimGrid Team.
+/* Copyright (c) 2014-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2014-2019. The SimGrid Team.
+/* Copyright (c) 2014-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
}
}
- EnergyVMRunner(Host host, String name, String[] args) throws HostNotFoundException {
+ EnergyVMRunner(Host host, String name, String[] args) {
super(host, name, args);
}
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
package energy.vm;
import org.simgrid.msg.Host;
-import org.simgrid.msg.HostNotFoundException;
import org.simgrid.msg.Msg;
class Main {
throw new IllegalAccessError("Utility class");
}
- public static void main(String[] args) throws HostNotFoundException {
+ public static void main(String[] args) {
Msg.energyInit();
Msg.init(args);
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
package io.storage;
import java.util.Arrays;
-import java.util.Comparator;
import org.simgrid.msg.Msg;
import org.simgrid.msg.Host;
import org.simgrid.msg.Process;
// Retrieve all mount points of current host
Storage[] storages = getHost().getMountedStorage();
- Arrays.sort(storages, new Comparator<Storage>() {
- public int compare(Storage a, Storage b) {
- return a.getName().compareTo(b.getName());
- }
- });
+ Arrays.sort(storages, (Storage a, Storage b) -> a.getName().compareTo(b.getName()));
for (int i = 0; i < storages.length; i++) {
// For each disk mounted on host
Msg.info("------------------------------------");
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
msg_vm_t vm;
unsigned int i;
- xbt_dynar_t worker_pms = MSG_process_get_data(MSG_process_self());
+ const_xbt_dynar_t worker_pms = MSG_process_get_data(MSG_process_self());
int nb_workers = xbt_dynar_length(worker_pms);
xbt_dynar_t vms = xbt_dynar_new(sizeof(msg_vm_t), NULL);
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
}
/** @brief Prints a answer_t, for debugging purposes */
-void answer_print(answer_t answer)
+void answer_print(const_answer_t answer)
{
unsigned int cpt;
node_contact_t contact;
* @param destination the destination in which the nodes will be put
* @param source the source of the nodes to add
*/
-unsigned int answer_merge(answer_t destination, answer_t source)
+unsigned int answer_merge(answer_t destination, const_answer_t source)
{
node_contact_t contact;
node_contact_t contact_copy;
/** Helper to sort answer_t objects */
static int _answer_sort_function(const void *e1, const void *e2)
{
- node_contact_t c1 = *(void **) e1;
- node_contact_t c2 = *(void **) e2;
+ const s_node_contact_t* c1 = *(const node_contact_t*)e1;
+ const s_node_contact_t* c2 = *(const node_contact_t*)e2;
if (c1->distance == c2->distance)
return 0;
else
* @param answer the answer to sort
* @param destination_id the id of the guy we are trying to find
*/
-void answer_sort(answer_t answer)
+void answer_sort(const_answer_t answer)
{
xbt_dynar_sort(answer->nodes, &_answer_sort_function);
}
* @param answer the answer object we're going to put the data in
* @param destination_id the id of the guy we are trying to find.
*/
-void answer_add_bucket(bucket_t bucket, answer_t answer)
+void answer_add_bucket(const_bucket_t bucket, answer_t answer)
{
xbt_assert((bucket != NULL), "Provided a NULL bucket");
xbt_assert((bucket->nodes != NULL), "Provided a bucket which nodes are NULL");
/** @brief Returns if the id supplied is in the answer.
* @param id : id we're looking for
*/
-unsigned int answer_contains(answer_t answer, unsigned int id)
+unsigned int answer_contains(const_answer_t answer, unsigned int id)
{
unsigned int i = 0;
node_contact_t contact;
* @param answer the answer
* @return if the destination is found.
*/
-unsigned int answer_destination_found(answer_t answer)
+unsigned int answer_destination_found(const_answer_t answer)
{
if (xbt_dynar_is_empty(answer->nodes)) {
return 0;
}
- node_contact_t contact_tail = xbt_dynar_get_as(answer->nodes, 0, node_contact_t);
+ const s_node_contact_t* contact_tail = xbt_dynar_get_as(answer->nodes, 0, node_contact_t);
return contact_tail->distance == 0;
}
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
} s_answer_t;
typedef s_answer_t *answer_t;
+typedef const s_answer_t* const_answer_t;
answer_t answer_init(unsigned int destination_id);
void answer_free(answer_t answer);
-void answer_print(answer_t answer);
-unsigned int answer_merge(answer_t destination, answer_t source);
-void answer_sort(answer_t answer);
+void answer_print(const_answer_t answer);
+unsigned int answer_merge(answer_t destination, const_answer_t source);
+void answer_sort(const_answer_t answer);
void answer_trim(answer_t answer);
-void answer_add_bucket(bucket_t bucket, answer_t answer);
-unsigned int answer_contains(answer_t answer, unsigned int id);
-unsigned int answer_destination_found(answer_t answer);
+void answer_add_bucket(const_bucket_t bucket, answer_t answer);
+unsigned int answer_contains(const_answer_t answer, unsigned int id);
+unsigned int answer_destination_found(const_answer_t answer);
#endif /* _KADEMLIA_EXAMPLES_ANSWER_H_ */
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
*/
unsigned int join(node_t node, unsigned int id_known)
{
- answer_t node_list;
+ const s_answer_t* node_list;
msg_error_t status;
unsigned int trial = 0;
unsigned int i;
XBT_DEBUG("Received an answer from the node I know.");
answer_got = 1;
//retrieve the node list and ping them.
- task_data_t data = MSG_task_get_data(node->task_received);
+ const s_task_data_t* data = MSG_task_get_data(node->task_received);
xbt_assert((data != NULL), "Null data received");
if (data->type == TASK_FIND_NODE_ANSWER) {
node_contact_t contact;
if (status == MSG_OK) {
xbt_assert((node->task_received != NULL), "Invalid task received");
//Figure out if we received an answer or something else
- task_data_t data = MSG_task_get_data(node->task_received);
+ const s_task_data_t* data = MSG_task_get_data(node->task_received);
xbt_assert((data != NULL), "No data in the task");
//Check if what we have received is what we are looking for.
* Sends to the best "KADEMLIA_ALPHA" nodes in the "node_list" array a "FIND_NODE" request, to ask them for their best
* nodes
*/
-unsigned int send_find_node_to_best(node_t node, answer_t node_list)
+unsigned int send_find_node_to_best(node_t node, const_answer_t node_list)
{
unsigned int i = 0;
unsigned int j = 0;
while (j < KADEMLIA_ALPHA && i < node_list->size) {
/* We need to have at most "KADEMLIA_ALPHA" requests each time, according to the protocol */
/* Gets the node we want to send the query to */
- node_contact_t node_to_query = xbt_dynar_get_as(node_list->nodes, i, node_contact_t);
+ const s_node_contact_t* node_to_query = xbt_dynar_get_as(node_list->nodes, i, node_contact_t);
if (node_to_query->id != node->id) { /* No need to query ourselves */
send_find_node(node, node_to_query->id, destination);
j++;
/** @brief Handles an incoming received task */
void handle_task(node_t node, msg_task_t task)
{
- task_data_t data = MSG_task_get_data(task);
+ const_task_data_t data = MSG_task_get_data(task);
xbt_assert((data != NULL), "Received NULL data");
//Adding/updating the guy to our routing table
node_routing_table_update(node, data->sender_id);
}
/** @brief Handles the answer to an incoming "find_node" task */
-void handle_find_node(node_t node, task_data_t data)
+void handle_find_node(node_t node, const_task_data_t data)
{
XBT_VERB("Received a FIND_NODE from %s (%s), he's trying to find %08x",
data->answer_to, data->issuer_host_name, data->destination_id);
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
void random_lookup(node_t node);
void send_find_node(node_t node, unsigned int id, unsigned int destination);
-unsigned int send_find_node_to_best(node_t node, answer_t node_list);
+unsigned int send_find_node_to_best(node_t node, const_answer_t node_list);
void handle_task(node_t node, msg_task_t task);
-void handle_find_node(node_t node, task_data_t data);
+void handle_find_node(node_t node, const_task_data_t data);
#endif /* _MSG_EXAMPLES_KADEMLIA_H */
#!/usr/bin/env python
-# Copyright (c) 2012-2019. The SimGrid Team.
+# Copyright (c) 2012-2020. The SimGrid Team.
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
* @param node Our node data
* @param id The id of the node we need to add unsigned into our routing table
*/
-void node_routing_table_update(node_t node, unsigned int id)
+void node_routing_table_update(const_node_t node, unsigned int id)
{
- routing_table_t table = node->table;
+ const_routing_table_t table = node->table;
//retrieval of the bucket in which the should be
- bucket_t bucket = routing_table_find_bucket(table, id);
+ const_bucket_t bucket = routing_table_find_bucket(table, id);
//check if the id is already in the bucket.
unsigned int id_pos = bucket_find_id(bucket, id);
* @param node : our node
* @param destination_id : the id of the guy we are trying to find
*/
-answer_t node_find_closest(node_t node, unsigned int destination_id)
+answer_t node_find_closest(const_node_t node, unsigned int destination_id)
{
int i;
answer_t answer = answer_init(destination_id);
/* We find the corresponding bucket for the id */
- bucket_t bucket = routing_table_find_bucket(node->table, destination_id);
+ const_bucket_t bucket = routing_table_find_bucket(node->table, destination_id);
int bucket_id = bucket->id;
xbt_assert((bucket_id <= IDENTIFIER_SIZE), "Bucket found has a wrong identifier");
/* So, we copy the contents of the bucket unsigned into our result dynar */
for (i = 1; answer->size < BUCKET_SIZE && ((bucket_id - i > 0) || (bucket_id + i < IDENTIFIER_SIZE)); i++) {
/* We check the previous buckets */
if (bucket_id - i >= 0) {
- bucket_t bucket_p = &node->table->buckets[bucket_id - i];
+ const_bucket_t bucket_p = &node->table->buckets[bucket_id - i];
answer_add_bucket(bucket_p, answer);
}
/* We check the next buckets */
if (bucket_id + i <= IDENTIFIER_SIZE) {
- bucket_t bucket_n = &node->table->buckets[bucket_id + i];
+ const_bucket_t bucket_n = &node->table->buckets[bucket_id + i];
answer_add_bucket(bucket_n, answer);
}
}
}
/** Builds a contact information from a contact information */
-node_contact_t node_contact_copy(node_contact_t node_contact)
+node_contact_t node_contact_copy(const_node_contact_t node_contact)
{
node_contact_t contact = xbt_new(s_node_contact_t, 1);
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
} s_node_contact_t;
typedef s_node_contact_t *node_contact_t;
+typedef const s_node_contact_t* const_node_contact_t;
/* Node data */
typedef struct s_node {
} s_node_t;
typedef s_node_t *node_t;
+typedef const s_node_t* const_node_t;
// node functions
node_t node_init(unsigned int id);
void node_free(node_t node);
-void node_routing_table_update(node_t node, unsigned int id);
-answer_t node_find_closest(node_t node, unsigned int destination_id);
+void node_routing_table_update(const_node_t node, unsigned int id);
+answer_t node_find_closest(const_node_t node, unsigned int destination_id);
// identifier functions
unsigned int get_id_in_prefix(unsigned int id, unsigned int prefix);
// node contact functions
node_contact_t node_contact_new(unsigned int id, unsigned int distance);
-node_contact_t node_contact_copy(node_contact_t node_contact);
+node_contact_t node_contact_copy(const_node_contact_t node_contact);
void node_contact_free(node_contact_t contact);
#endif /* _MSG_EXAMPLES_ROUTING_H */
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
xbt_free(table);
}
-/** Returns if the routing table contains the id. */
-unsigned int routing_table_contains(routing_table_t table, unsigned int node_id)
-{
- bucket_t bucket = routing_table_find_bucket(table, node_id);
- return bucket_contains(bucket, node_id);
-}
-
/**@brief prints the routing table, to debug stuff. */
-void routing_table_print(routing_table_t table)
+void routing_table_print(const_routing_table_t table)
{
unsigned int j;
unsigned int value;
* @param bucket the bucket in which we try to find our identifier
* @param id the id
*/
-unsigned int bucket_find_id(bucket_t bucket, unsigned int id)
+unsigned int bucket_find_id(const_bucket_t bucket, unsigned int id)
{
unsigned int i;
unsigned int current_id;
return -1;
}
-/** Returns if the bucket contains an identifier. */
-unsigned int bucket_contains(bucket_t bucket, unsigned int id)
-{
- return xbt_dynar_member(bucket->nodes, &id);
-}
-
/** @brief Finds the corresponding bucket in a routing table for a given identifier
* @param table the routing table
* @param id the identifier
* @return the bucket in which the the identifier would be.
*/
-bucket_t routing_table_find_bucket(routing_table_t table, unsigned int id)
+bucket_t routing_table_find_bucket(const_routing_table_t table, unsigned int id)
{
unsigned int xor_number = table->id ^ id;
unsigned int prefix = get_node_prefix(xor_number, IDENTIFIER_SIZE);
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
} s_bucket_t;
typedef s_bucket_t *bucket_t;
+typedef const s_bucket_t* const_bucket_t;
/* Node routing table */
typedef struct s_routing_table {
} s_routing_table_t;
typedef s_routing_table_t *routing_table_t;
+typedef const s_routing_table_t* const_routing_table_t;
// bucket functions
-unsigned int bucket_find_id(bucket_t bucket, unsigned int id);
-unsigned int bucket_contains(bucket_t bucket, unsigned int id);
+unsigned int bucket_find_id(const_bucket_t bucket, unsigned int id);
// routing table functions
routing_table_t routing_table_init(unsigned int node_id);
void routing_table_free(routing_table_t table);
-unsigned int routing_table_contains(routing_table_t table, unsigned int node_id);
-void routing_table_print(routing_table_t table);
-bucket_t routing_table_find_bucket(routing_table_t table, unsigned int id);
+void routing_table_print(const_routing_table_t table);
+bucket_t routing_table_find_bucket(const_routing_table_t table, unsigned int id);
#endif /* _MSG_KADEMLIA_EXAMPLES_ROUTING_TABLE */
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
} s_task_data_t;
typedef s_task_data_t *task_data_t;
+typedef const s_task_data_t* const_task_data_t;
//Task handling functions
msg_task_t task_new_find_node(unsigned int sender_id, unsigned int destination_id, char *mailbox, const char *hostname);
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
xbt_dynar_t pending_tasks;
} s_node_t;
typedef s_node_t* node_t;
+typedef const s_node_t* const_node_t;
typedef struct s_state {
int id;
} s_task_data_t;
typedef s_task_data_t* task_data_t;
-static int domain(unsigned int a, unsigned int level);
-static int shl(int a, int b);
-static int closest_in_namespace_set(node_t node, int dest);
-static int routing_next(node_t node, int dest);
-
/**
* @brief Gets the mailbox name of a host given its chord id.
* @param node_id id of a node
}
/* Get the closest id to the dest in the node namespace_set */
-static int closest_in_namespace_set(node_t node, int dest) {
+static int closest_in_namespace_set(const_node_t node, int dest)
+{
int res = -1;
if ((node->namespace_set[NAMESPACE_SIZE-1] <= dest) && (dest <= node->namespace_set[0])) {
int best_dist = abs(node->id - dest);
}
/* Find the next node to forward a message to */
-static int routing_next(node_t node, int dest) {
+static int routing_next(const_node_t node, int dest)
+{
int closest = closest_in_namespace_set(node, dest);
if (closest!=-1)
return closest;
}
/* Get the corresponding state of a node */
-static state_t node_get_state(node_t node) {
+static state_t node_get_state(const_node_t node)
+{
state_t state = xbt_new0(s_state_t,1);
state->id = node->id;
for (int i=0; i<NEIGHBORHOOD_SIZE; i++)
return state;
}
-static void print_node_id(node_t node) {
+static void print_node_id(const_node_t node)
+{
XBT_INFO(" Id: %i '%08x' ", node->id, (unsigned)node->id);
}
-static void print_node_neighborood_set(node_t node) {
+static void print_node_neighborood_set(const_node_t node)
+{
XBT_INFO(" Neighborhood:");
for (int i=0; i<NEIGHBORHOOD_SIZE; i++)
XBT_INFO(" %08x", (unsigned)node->neighborhood_set[i]);
}
-static void print_node_routing_table(node_t node) {
+static void print_node_routing_table(const_node_t node)
+{
XBT_INFO(" Routing table:");
for (int i=0; i<LEVELS_COUNT; i++){
for (int j=0; j<LEVEL_SIZE; j++)
}
}
/* Print the node namespace set */
-static void print_node_namespace_set(node_t node) {
+static void print_node_namespace_set(const_node_t node)
+{
XBT_INFO(" Namespace:");
for (int i=0; i<NAMESPACE_SIZE; i++)
XBT_INFO(" %08x", (unsigned)node->namespace_set[i]);
}
/* Print the node information */
-static void print_node(node_t node) {
+static void print_node(const_node_t node)
+{
XBT_INFO("Node:");
print_node_id(node);
print_node_neighborood_set(node);
}
/* Join the ring */
-static int join(node_t node){
+static int join(const_node_t node)
+{
task_data_t req_data = xbt_new0(s_task_data_t,1);
req_data->type = TASK_JOIN;
req_data->sender_id = node->id;
#!/usr/bin/env python
-# Copyright (c) 2011-2019. The SimGrid Team.
+# Copyright (c) 2011-2020. The SimGrid Team.
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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 <simgrid/modelchecker.h>
#include <simgrid/msg.h>
+#include <xbt/dynar.h>
XBT_LOG_NEW_DEFAULT_CATEGORY(bugged1_liveness, "my log messages");
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
MSG_task_receive(&task, "coordinator");
const char *kind = MSG_task_get_name(task); //is it a request or a release?
if (!strcmp(kind, "request")) { // that's a request
- char *req = MSG_task_get_data(task);
+ const char* req = MSG_task_get_data(task);
if (CS_used) {
XBT_INFO("CS already used.");
msg_task_t answer = MSG_task_create("not grant", 0, 1000, NULL);
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
}
xbt_dynar_free (&link_variables);
}
-
- xbt_dynar_t nodes_type = TRACE_get_node_types ();
- if (nodes_type){
- XBT_INFO ("Node types in the trace:");
- char *node_type;
- xbt_dynar_foreach (nodes_type, cursor, node_type){
- XBT_INFO ("%s", node_type);
- }
- xbt_dynar_free (&nodes_type);
- }
- xbt_dynar_t edges_type = TRACE_get_edge_types ();
- if (edges_type){
- XBT_INFO("Edge types in the trace:");
- char *edge_type;
- xbt_dynar_foreach (edges_type, cursor, edge_type){
- XBT_INFO ("%s", edge_type);
- }
- xbt_dynar_free (&edges_type);
- }
-
return 0;
}
> [0.004078] [msg_test/INFO] HDD_capacity
> [0.004078] [msg_test/INFO] HDD_utilization
> [0.004078] [msg_test/INFO] Declared link variables:
-> [0.004078] [msg_test/INFO] Node types in the trace:
-> [0.004078] [msg_test/INFO] HOST
-> [0.004078] [msg_test/INFO] LINK
-> [0.004078] [msg_test/INFO] Edge types in the trace:
-> [0.004078] [msg_test/INFO] 0-HOST1-LINK4
-> [0.004078] [msg_test/INFO] 0-LINK4-HOST1
-> [0.004078] [msg_test/INFO] 0-LINK4-LINK4
$ rm -f simgrid.trace
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
/* simple test trying to load a DOT file. */
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
}
char *tracefilename;
- char *last = strrchr(argv[2], '.');
+ const char* last = strrchr(argv[2], '.');
tracefilename = bprintf("%.*s.trace", (int) (last == NULL ? strlen(argv[2]) : last - argv[2]),argv[2]);
if (argc == 4)
tracefilename = xbt_strdup(argv[3]);
/* simple test trying to load a DAX file. */
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
static int name_compare_hosts(const void *n1, const void *n2)
{
- return strcmp(sg_host_get_name(*(sg_host_t *) n1), sg_host_get_name(*(sg_host_t *) n2));
+ return strcmp(sg_host_get_name(*(const sg_host_t*)n1), sg_host_get_name(*(const sg_host_t*)n2));
}
int main(int argc, char **argv)
xbt_assert(argc > 2, "Usage: %s platform_file dax_file [jedule_file]\n"
"\tExample: %s simulacrum_7_hosts.xml Montage_25.xml Montage_25.jed", argv[0], argv[0]);
- char *last = strrchr(argv[2], '.');
+ const char* last = strrchr(argv[2], '.');
char * tracefilename = bprintf("%.*s.trace",(int) (last == NULL ? strlen(argv[2]):last - argv[2]), argv[2]);
if (argc == 4)
tracefilename = xbt_strdup(argv[3]);
XBT_INFO("------------------- Run the schedule ---------------------------");
SD_simulate(-1);
XBT_INFO("------------------- Produce the trace file---------------------------");
- char* basename = strrchr(tracefilename, '/');
+ const char* basename = strrchr(tracefilename, '/');
XBT_INFO("Producing the trace of the run into %s", basename ? basename + 1 : tracefilename);
FILE *out = fopen(tracefilename, "w");
xbt_assert(out, "Cannot write to %s", tracefilename);
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* simple test trying to load a DOT file. */
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
}
char *tracefilename;
- char *last = strrchr(argv[2], '.');
+ const char* last = strrchr(argv[2], '.');
tracefilename = bprintf("%.*s.trace", (int) (last == NULL ? strlen(argv[2]) : last - argv[2]),argv[2]);
if (argc == 4)
tracefilename = xbt_strdup(argv[3]);
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
SD_task_t last_scheduled_task;
};
-static double sg_host_get_available_at(sg_host_t host)
+static double sg_host_get_available_at(const_sg_host_t host)
{
- HostAttribute attr = (HostAttribute)sg_host_data(host);
+ const struct _HostAttribute* attr = (HostAttribute)sg_host_data(host);
return attr->available_at;
}
sg_host_data_set(host, attr);
}
-static SD_task_t sg_host_get_last_scheduled_task( sg_host_t host){
- HostAttribute attr = (HostAttribute)sg_host_data(host);
+static SD_task_t sg_host_get_last_scheduled_task(const_sg_host_t host)
+{
+ const struct _HostAttribute* attr = (HostAttribute)sg_host_data(host);
return attr->last_scheduled_task;
}
sg_host_data_set(host, attr);
}
-static xbt_dynar_t get_ready_tasks(xbt_dynar_t dax)
+static xbt_dynar_t get_ready_tasks(const_xbt_dynar_t dax)
{
unsigned int i;
xbt_dynar_t ready_tasks;
return ready_tasks;
}
-static double finish_on_at(SD_task_t task, sg_host_t host)
+static double finish_on_at(const_SD_task_t task, const_sg_host_t host)
{
double result;
return result;
}
-static sg_host_t SD_task_get_best_host(SD_task_t task)
+static sg_host_t SD_task_get_best_host(const_SD_task_t task)
{
sg_host_t *hosts = sg_host_list();
int nhosts = sg_host_count();
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
SD_task_schedule(taskC, 2, host_list, computation_amount, communication_amount, -1);
SD_task_schedule(taskD, 2, host_list, computation_amount, communication_amount, -1);
- std::set<SD_task_t> *changed_tasks = simgrid::sd::simulate(-1.0);
+ const std::set<SD_task_t>* changed_tasks = simgrid::sd::simulate(-1.0);
for (auto const& task : *changed_tasks) {
XBT_INFO("Task '%s' start time: %f, finish time: %f", SD_task_get_name(task),
SD_task_get_start_time(task), SD_task_get_finish_time(task));
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
viewBox="0 0 150.00001 99.999999"
version="1.1"
id="svg8"
- inkscape:version="0.92.3 (2405546, 2018-03-11)"
+ inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
sodipodi:docname="cluster_dragonfly.svg">
<defs
id="defs2">
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="2.5600001"
- inkscape:cx="230.61674"
- inkscape:cy="214.04712"
+ inkscape:zoom="4.012"
+ inkscape:cx="239.60111"
+ inkscape:cy="213.26587"
inkscape:document-units="mm"
- inkscape:current-layer="g995-3"
+ inkscape:current-layer="layer1"
showgrid="true"
showguides="true"
- inkscape:window-width="1920"
- inkscape:window-height="1001"
- inkscape:window-x="-9"
- inkscape:window-y="-9"
+ inkscape:window-width="3700"
+ inkscape:window-height="2032"
+ inkscape:window-x="140"
+ inkscape:window-y="54"
inkscape:window-maximized="1"
fit-margin-top="0"
fit-margin-left="0"
y="23.342285"
x="114.7258"
sodipodi:role="line">...</tspan></text>
+ <path
+ inkscape:connector-curvature="0"
+ id="path967-0-1-3-8-3"
+ d="m 132.29167,13.895832 c -11.55606,-11.9062503 -22.06158,-11.9062503 -35.71875,0"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.23615019;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:nodetypes="cc" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path967-0-1-3-8-3-6"
+ d="m 133.61458,13.895832 c -11.55605,-11.9062504 -22.06157,-11.9062504 -35.718743,0"
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.23615018;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:nodetypes="cc" />
</g>
</svg>
--- Copyright (c) 2011-2019. The SimGrid Team.
+-- Copyright (c) 2011-2020. The SimGrid Team.
-- All rights reserved.
-- This program is free software; you can redistribute it and/or modify it
<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
<!-- Describe a dogbone graph, with 4 hosts:
- --
- -- S1 ---[ 1 ]--- ---[ 3 ]--- C1
- -- \ /
- -- R1 --[ 2 ]-- R2
- -- / \
- -- S2 ---[ 4 ]--- ---[ 5 ]--- C2
- --
- --
- -- This platform is a valid ns-3 platform, even if it exhibits routes of length >1,
- -- because when you only keep the routes of length 1,
- -- you get a graph where every host can speak to any other host.
- --
- -- For example, S1--C1 is (l1,l2,l3) of length >1
- -- But it's also S1--C1 = S1--R1, R1--R2, R2--C1 which are all of length 1
- --
- -- https://simgrid.org/doc/latest/ns3.html
+ -
+ - S1 ___[ 1 ]___ ___[ 3 ]___ C1
+ - \ /
+ - R1 __[ 2 ]__ R2
+ - / \
+ - S2 ___[ 4 ]__/ \__[ 5 ]___ C2
+ -
+ - This platform is a valid ns-3 platform, even if it exhibits routes of length >1,
+ - because when you only keep the routes of length 1,
+ - you get a graph where every host can speak to any other host.
+ -
+ - For example, S1__C1 is (l1,l2,l3) of length >1
+ - But it's also S1__C1 = S1__R1, R1__R2, R2__C1 which are all of length 1
+ -
+ - https://simgrid.org/doc/latest/ns3.html
-->
<platform version="4.1">
#!/usr/bin/env perl
-# Copyright (c) 2011-2019. The SimGrid Team.
+# Copyright (c) 2011-2020. The SimGrid Team.
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it
--- Copyright (c) 2011-2019. The SimGrid Team.
+-- Copyright (c) 2011-2020. The SimGrid Team.
-- All rights reserved.
-- This program is free software; you can redistribute it and/or modify it
#!/usr/bin/env perl
-# Copyright (c) 2011-2019. The SimGrid Team.
+# Copyright (c) 2011-2020. The SimGrid Team.
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it
-# Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2006-2020. 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.
-# Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2017-2020. 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.
-# Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2017-2020. 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.
def master():
- this_actor.info("Start sleeper")
- actor = Actor.create("sleeper from master", Host.current(), sleeper)
- this_actor.info("Join the sleeper (timeout 2)")
+ this_actor.info("Start 1st sleeper")
+ actor = Actor.create("1st sleeper from master", Host.current(), sleeper)
+ this_actor.info("Join the 1st sleeper (timeout 2)")
actor.join(2)
- this_actor.info("Start sleeper")
- actor = Actor.create("sleeper from master", Host.current(), sleeper)
- this_actor.info("Join the sleeper (timeout 4)")
+ this_actor.info("Start 2nd sleeper")
+ actor = Actor.create("2nd sleeper from master", Host.current(), sleeper)
+ this_actor.info("Join the 2nd sleeper (timeout 4)")
actor.join(4)
- this_actor.info("Start sleeper")
- actor = Actor.create("sleeper from master", Host.current(), sleeper)
- this_actor.info("Join the sleeper (timeout 2)")
+ this_actor.info("Start 3rd sleeper")
+ actor = Actor.create("3rd sleeper from master", Host.current(), sleeper)
+ this_actor.info("Join the 3rd sleeper (timeout 2)")
actor.join(2)
- this_actor.info("Start sleeper")
- actor = Actor.create("sleeper from master", Host.current(), sleeper)
+ this_actor.info("Start 4th sleeper")
+ actor = Actor.create("4th sleeper from master", Host.current(), sleeper)
this_actor.info("Waiting 4")
this_actor.sleep_for(4)
- this_actor.info("Join the sleeper after its end (timeout 1)")
+ this_actor.info("Join the 4th sleeper after its end (timeout 1)")
actor.join(1)
this_actor.info("Goodbye now!")
$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/actor-join.py ${platfdir}/small_platform.xml
-> [Tremblay:master:(1) 0.000000] [python/INFO] Start sleeper
-> [Tremblay:sleeper from master:(2) 0.000000] [python/INFO] Sleeper started
-> [Tremblay:master:(1) 0.000000] [python/INFO] Join the sleeper (timeout 2)
-> [Tremblay:master:(1) 2.000000] [python/INFO] Start sleeper
-> [Tremblay:sleeper from master:(3) 2.000000] [python/INFO] Sleeper started
-> [Tremblay:master:(1) 2.000000] [python/INFO] Join the sleeper (timeout 4)
-> [Tremblay:sleeper from master:(2) 3.000000] [python/INFO] I'm done. See you!
-> [Tremblay:sleeper from master:(3) 5.000000] [python/INFO] I'm done. See you!
-> [Tremblay:master:(1) 5.000000] [python/INFO] Start sleeper
-> [Tremblay:sleeper from master:(4) 5.000000] [python/INFO] Sleeper started
-> [Tremblay:master:(1) 5.000000] [python/INFO] Join the sleeper (timeout 2)
-> [Tremblay:master:(1) 7.000000] [python/INFO] Start sleeper
-> [Tremblay:sleeper from master:(5) 7.000000] [python/INFO] Sleeper started
+> [Tremblay:master:(1) 0.000000] [python/INFO] Start 1st sleeper
+> [Tremblay:1st sleeper from master:(2) 0.000000] [python/INFO] Sleeper started
+> [Tremblay:master:(1) 0.000000] [python/INFO] Join the 1st sleeper (timeout 2)
+> [Tremblay:master:(1) 2.000000] [python/INFO] Start 2nd sleeper
+> [Tremblay:2nd sleeper from master:(3) 2.000000] [python/INFO] Sleeper started
+> [Tremblay:master:(1) 2.000000] [python/INFO] Join the 2nd sleeper (timeout 4)
+> [Tremblay:1st sleeper from master:(2) 3.000000] [python/INFO] I'm done. See you!
+> [Tremblay:2nd sleeper from master:(3) 5.000000] [python/INFO] I'm done. See you!
+> [Tremblay:master:(1) 5.000000] [python/INFO] Start 3rd sleeper
+> [Tremblay:3rd sleeper from master:(4) 5.000000] [python/INFO] Sleeper started
+> [Tremblay:master:(1) 5.000000] [python/INFO] Join the 3rd sleeper (timeout 2)
+> [Tremblay:master:(1) 7.000000] [python/INFO] Start 4th sleeper
+> [Tremblay:4th sleeper from master:(5) 7.000000] [python/INFO] Sleeper started
> [Tremblay:master:(1) 7.000000] [python/INFO] Waiting 4
-> [Tremblay:sleeper from master:(4) 8.000000] [python/INFO] I'm done. See you!
-> [Tremblay:sleeper from master:(5) 10.000000] [python/INFO] I'm done. See you!
-> [Tremblay:master:(1) 11.000000] [python/INFO] Join the sleeper after its end (timeout 1)
+> [Tremblay:3rd sleeper from master:(4) 8.000000] [python/INFO] I'm done. See you!
+> [Tremblay:4th sleeper from master:(5) 10.000000] [python/INFO] I'm done. See you!
+> [Tremblay:master:(1) 11.000000] [python/INFO] Join the 4th sleeper after its end (timeout 1)
> [Tremblay:master:(1) 11.000000] [python/INFO] Goodbye now!
> [Tremblay:master:(1) 12.000000] [python/INFO] Goodbye now!
> [12.000000] [python/INFO] Simulation time 12.0
-# Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2017-2020. 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.
-# Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2007-2020. 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.
"""This actor just sleeps until termination"""
def __init__(self, *args):
- # sys.exit(1); simgrid.info("Exiting now (done sleeping or got killed)."))
- this_actor.on_exit(lambda: print("BAAA"))
+ this_actor.on_exit(lambda: this_actor.info("Exiting now (done sleeping or got killed)."))
def __call__(self):
this_actor.info("Hello! I go to sleep.")
-# Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2017-2020. 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.
-# Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2017-2020. 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.
-# Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2017-2020. 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.
-# Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2010-2020. 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.
-# Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2010-2020. 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.
-# Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2010-2020. 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.
-# Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2018-2020. 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.
def __call__(self):
computation_amount = this_actor.get_host().speed
- this_actor.info("Execute {:.0f} flops, should take 1 second.".format(computation_amount))
+ this_actor.info("Waiter executes {:.0f} flops, should take 1 second.".format(computation_amount))
activity = this_actor.exec_init(computation_amount)
activity.start()
activity.wait()
- this_actor.info("Goodbye now!")
+ this_actor.info("Goodbye from waiter!")
class Monitor:
def __call__(self):
computation_amount = this_actor.get_host().speed
- this_actor.info("Execute {:.0f} flops, should take 1 second.".format(computation_amount))
+ this_actor.info("Monitor executes {:.0f} flops, should take 1 second.".format(computation_amount))
activity = this_actor.exec_init(computation_amount).start()
while not activity.test():
this_actor.sleep_for(0.3)
activity.wait()
- this_actor.info("Goodbye now!")
+ this_actor.info("Goodbye from monitor!")
class Canceller:
def __call__(self):
computation_amount = this_actor.get_host().speed
- this_actor.info("Execute {:.0f} flops, should take 1 second.".format(computation_amount))
+ this_actor.info("Canceller executes {:.0f} flops, should take 1 second.".format(computation_amount))
activity = this_actor.exec_init(computation_amount).start()
this_actor.sleep_for(0.5)
this_actor.info("I changed my mind, cancel!")
activity.cancel()
- this_actor.info("Goodbye now!")
+ this_actor.info("Goodbye from canceller!")
if __name__ == '__main__':
#!/usr/bin/env tesh
$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/exec-async.py ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
-> [ 0.000000] (1:wait@Fafard) Execute 76296000 flops, should take 1 second.
-> [ 0.000000] (2:monitor@Ginette) Execute 48492000 flops, should take 1 second.
-> [ 0.000000] (3:cancel@Boivin) Execute 98095000 flops, should take 1 second.
+> [ 0.000000] (1:wait@Fafard) Waiter executes 76296000 flops, should take 1 second.
+> [ 0.000000] (2:monitor@Ginette) Monitor executes 48492000 flops, should take 1 second.
+> [ 0.000000] (3:cancel@Boivin) Canceller executes 98095000 flops, should take 1 second.
> [ 0.000000] (2:monitor@Ginette) Remaining amount of flops: 48492000 (100%)
> [ 0.300000] (2:monitor@Ginette) Remaining amount of flops: 33944400 (70%)
> [ 0.500000] (3:cancel@Boivin) I changed my mind, cancel!
-> [ 0.500000] (3:cancel@Boivin) Goodbye now!
+> [ 0.500000] (3:cancel@Boivin) Goodbye from canceller!
> [ 0.600000] (2:monitor@Ginette) Remaining amount of flops: 19396800 (40%)
> [ 0.900000] (2:monitor@Ginette) Remaining amount of flops: 4849200 (10%)
-> [ 1.000000] (1:wait@Fafard) Goodbye now!
-> [ 1.200000] (2:monitor@Ginette) Goodbye now!
+> [ 1.000000] (1:wait@Fafard) Goodbye from waiter!
+> [ 1.200000] (2:monitor@Ginette) Goodbye from monitor!
-# Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2018-2020. 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.
# quite quickly.
-i = 0
-if "--" in sys.argv:
- i = sys.argv.index("--")
-e = Engine(sys.argv[0:i])
-e.load_platform(sys.argv[i + 1])
+if __name__ == '__main__':
+ e = Engine(sys.argv)
+ e.load_platform(sys.argv[1])
-Actor.create("executor", Host.by_name("Tremblay"), executor)
-Actor.create("privileged", Host.by_name("Tremblay"), privileged)
+ Actor.create("executor", Host.by_name("Tremblay"), executor)
+ Actor.create("privileged", Host.by_name("Tremblay"), privileged)
-e.run()
+ e.run()
-# Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2007-2020. 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.
host.pstate = new_pstate
- this_actor.info("Current power peak={:f}".format(host.speed))
+ this_actor.info("Changed power peak={:f}".format(host.speed))
# Run a second task
this_actor.execute(workload)
host2 = Host.by_name("MyHost2")
this_actor.info("Count of Processor states={:d}".format(host2.get_pstate_count()))
- this_actor.info("Current power peak={:f}".format(host2.speed))
+ this_actor.info("Final power peak={:f}".format(host2.speed))
if __name__ == '__main__':
e = Engine(sys.argv)
> [ 1.000000] (1:dvfs_test@MyHost1) Changing power peak value to 20000000.000000 (at index 2)
> [ 1.000000] (2:dvfs_test@MyHost2) Task1 duration: 1.00
> [ 1.000000] (2:dvfs_test@MyHost2) Changing power peak value to 20000000.000000 (at index 2)
-> [ 1.000000] (1:dvfs_test@MyHost1) Current power peak=20000000.000000
-> [ 1.000000] (2:dvfs_test@MyHost2) Current power peak=20000000.000000
+> [ 1.000000] (1:dvfs_test@MyHost1) Changed power peak=20000000.000000
+> [ 1.000000] (2:dvfs_test@MyHost2) Changed power peak=20000000.000000
> [ 6.000000] (1:dvfs_test@MyHost1) Task2 duration: 5.00
> [ 6.000000] (1:dvfs_test@MyHost1) Count of Processor states=3
-> [ 6.000000] (1:dvfs_test@MyHost1) Current power peak=20000000.000000
+> [ 6.000000] (1:dvfs_test@MyHost1) Final power peak=20000000.000000
> [ 6.000000] (2:dvfs_test@MyHost2) Task2 duration: 5.00
> [ 6.000000] (2:dvfs_test@MyHost2) Count of Processor states=3
-> [ 6.000000] (2:dvfs_test@MyHost2) Current power peak=20000000.000000
+> [ 6.000000] (2:dvfs_test@MyHost2) Final power peak=20000000.000000
$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/exec-dvfs.py ${platfdir}/energy_cluster.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:dvfs_test@MyHost1) Count of Processor states=3
> [ 1.000000] (1:dvfs_test@MyHost1) Changing power peak value to 20000000.000000 (at index 2)
> [ 1.000000] (2:dvfs_test@MyHost2) Task1 duration: 1.00
> [ 1.000000] (2:dvfs_test@MyHost2) Changing power peak value to 20000000.000000 (at index 2)
-> [ 1.000000] (1:dvfs_test@MyHost1) Current power peak=20000000.000000
-> [ 1.000000] (2:dvfs_test@MyHost2) Current power peak=20000000.000000
+> [ 1.000000] (1:dvfs_test@MyHost1) Changed power peak=20000000.000000
+> [ 1.000000] (2:dvfs_test@MyHost2) Changed power peak=20000000.000000
> [ 6.000000] (1:dvfs_test@MyHost1) Task2 duration: 5.00
> [ 6.000000] (1:dvfs_test@MyHost1) Count of Processor states=3
-> [ 6.000000] (1:dvfs_test@MyHost1) Current power peak=20000000.000000
+> [ 6.000000] (1:dvfs_test@MyHost1) Final power peak=20000000.000000
> [ 6.000000] (2:dvfs_test@MyHost2) Task2 duration: 5.00
> [ 6.000000] (2:dvfs_test@MyHost2) Count of Processor states=3
-> [ 6.000000] (2:dvfs_test@MyHost2) Current power peak=20000000.000000
+> [ 6.000000] (2:dvfs_test@MyHost2) Final power peak=20000000.000000
-# Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2018-2020. 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.
cloud-capping cloud-migration cloud-simple
energy-exec energy-boot energy-link energy-vm energy-exec-ptask
engine-filtering
- exec-async exec-basic exec-dvfs exec-ptask exec-remote exec-waitany exec-dependent
+ exec-async exec-basic exec-dvfs exec-ptask exec-remote exec-waitany exec-waitfor exec-dependent
io-async io-file-system io-file-remote io-disk-raw
platform-failures platform-profile platform-properties
plugin-hostload
replay-comm replay-io
routing-get-clusters
- synchro-barrier synchro-mutex synchro-semaphore)
+ synchro-barrier synchro-condition-variable synchro-mutex synchro-semaphore)
add_executable (s4u-${example} EXCLUDE_FROM_ALL ${example}/s4u-${example}.cpp)
add_dependencies (tests s4u-${example})
target_link_libraries(s4u-${example} simgrid)
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
XBT_INFO("Hello s4u, I'm ready to get any message you'd want on %s", mailbox->get_cname());
- std::string* msg1 = static_cast<std::string*>(mailbox->get());
- std::string* msg2 = static_cast<std::string*>(mailbox->get());
- std::string* msg3 = static_cast<std::string*>(mailbox->get());
+ const std::string* msg1 = static_cast<std::string*>(mailbox->get());
+ const std::string* msg2 = static_cast<std::string*>(mailbox->get());
+ const std::string* msg3 = static_cast<std::string*>(mailbox->get());
XBT_INFO("I received '%s', '%s' and '%s'", msg1->c_str(), msg2->c_str(), msg3->c_str());
delete msg1;
delete msg2;
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor_migration, "Messages specific for this s4u example");
-static void worker(simgrid::s4u::Host* first, simgrid::s4u::Host* second)
+static void worker(simgrid::s4u::Host* first, const simgrid::s4u::Host* second)
{
double flopAmount = first->get_speed() * 5 + second->get_speed() * 5;
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
std::string Peer::getStatus()
{
- std::string res = std::string("");
- for (int i = FILE_PIECES - 1; i >= 0; i--)
- res = std::string((bitfield_ & (1U << i)) ? "1" : "0") + res;
+ std::string res;
+ for (unsigned i = 0; i < FILE_PIECES; i++)
+ res += (bitfield_ & (1U << i)) ? '1' : '0';
return res;
}
}
/** Indicates if the remote peer has a piece not stored by the local peer */
-bool Peer::isInterestedBy(Connection* remote_peer)
+bool Peer::isInterestedBy(const Connection* remote_peer) const
{
return remote_peer->bitfield & (bitfield_ ^ ((1 << FILE_PIECES) - 1));
}
-bool Peer::isInterestedByFree(Connection* remote_peer)
+bool Peer::isInterestedByFree(const Connection* remote_peer) const
{
for (unsigned int i = 0; i < FILE_PIECES; i++)
if (hasNotPiece(i) && remote_peer->hasPiece(i) && isNotDownloadingPiece(i))
* @param remote_peer: information about the connection
* @return the piece to download if possible. -1 otherwise
*/
-int Peer::selectPieceToDownload(Connection* remote_peer)
+int Peer::selectPieceToDownload(const Connection* remote_peer)
{
int piece = partiallyDownloadedPiece(remote_peer);
// strict priority policy
int nb_interesting_pieces = 0;
// compute the number of interesting pieces
for (unsigned int i = 0; i < FILE_PIECES; i++)
- if (hasNotPiece(i) && remote_peer->hasPiece(i))
+ if (remotePeerHasMissingPiece(remote_peer, i))
nb_interesting_pieces++;
xbt_assert(nb_interesting_pieces != 0);
int random_piece_index = simgrid::xbt::random::uniform_int(0, nb_interesting_pieces - 1);
int current_index = 0;
for (unsigned int i = 0; i < FILE_PIECES; i++) {
- if (hasNotPiece(i) && remote_peer->hasPiece(i)) {
+ if (remotePeerHasMissingPiece(remote_peer, i)) {
if (random_piece_index == current_index) {
piece = i;
break;
int nb_interesting_pieces = 0;
// compute the number of interesting pieces
for (unsigned int i = 0; i < FILE_PIECES; i++)
- if (hasNotPiece(i) && remote_peer->hasPiece(i) && isNotDownloadingPiece(i))
+ if (remotePeerHasMissingPiece(remote_peer, i) && isNotDownloadingPiece(i))
nb_interesting_pieces++;
xbt_assert(nb_interesting_pieces != 0);
// get a random interesting piece
int random_piece_index = simgrid::xbt::random::uniform_int(0, nb_interesting_pieces - 1);
int current_index = 0;
for (unsigned int i = 0; i < FILE_PIECES; i++) {
- if (hasNotPiece(i) && remote_peer->hasPiece(i) && isNotDownloadingPiece(i)) {
+ if (remotePeerHasMissingPiece(remote_peer, i) && isNotDownloadingPiece(i)) {
if (random_piece_index == current_index) {
piece = i;
break;
int current_index = 0;
// compute the smallest number of copies of available pieces
for (unsigned int i = 0; i < FILE_PIECES; i++) {
- if (pieces_count[i] < min && hasNotPiece(i) && remote_peer->hasPiece(i) && isNotDownloadingPiece(i))
+ if (pieces_count[i] < min && remotePeerHasMissingPiece(remote_peer, i) && isNotDownloadingPiece(i))
min = pieces_count[i];
}
xbt_assert(min != SHRT_MAX || not isInterestedByFree(remote_peer));
// compute the number of rarest pieces
for (unsigned int i = 0; i < FILE_PIECES; i++)
- if (pieces_count[i] == min && hasNotPiece(i) && remote_peer->hasPiece(i) && isNotDownloadingPiece(i))
+ if (pieces_count[i] == min && remotePeerHasMissingPiece(remote_peer, i) && isNotDownloadingPiece(i))
nb_min_pieces++;
xbt_assert(nb_min_pieces != 0 || not isInterestedByFree(remote_peer));
random_rarest_index = simgrid::xbt::random::uniform_int(0, nb_min_pieces - 1);
}
for (unsigned int i = 0; i < FILE_PIECES; i++)
- if (pieces_count[i] == min && hasNotPiece(i) && remote_peer->hasPiece(i) && isNotDownloadingPiece(i)) {
+ if (pieces_count[i] == min && remotePeerHasMissingPiece(remote_peer, i) && isNotDownloadingPiece(i)) {
if (random_rarest_index == current_index) {
piece = i;
break;
bool interested = false;
// Check if the peer still has a piece we want.
for (unsigned int i = 0; i < FILE_PIECES; i++)
- if (hasNotPiece(i) && remote_peer.hasPiece(i)) {
+ if (remotePeerHasMissingPiece(&remote_peer, i)) {
interested = true;
break;
}
}
/** Returns a piece that is partially downloaded and stored by the remote peer if any -1 otherwise. */
-int Peer::partiallyDownloadedPiece(Connection* remote_peer)
+int Peer::partiallyDownloadedPiece(const Connection* remote_peer)
{
for (unsigned int i = 0; i < FILE_PIECES; i++)
- if (hasNotPiece(i) && remote_peer->hasPiece(i) && isNotDownloadingPiece(i) && getFirstMissingBlockFrom(i) > 0)
+ if (remotePeerHasMissingPiece(remote_peer, i) && isNotDownloadingPiece(i) && getFirstMissingBlockFrom(i) > 0)
return i;
return -1;
}
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
explicit Connection(int id) : id(id), mailbox_(simgrid::s4u::Mailbox::by_name(std::to_string(id))){};
void addSpeedValue(double speed) { peer_speed = peer_speed * 0.6 + speed * 0.4; }
- bool hasPiece(unsigned int piece) { return bitfield & 1U << piece; }
+ bool hasPiece(unsigned int piece) const { return bitfield & 1U << piece; }
};
class Peer {
std::string getStatus();
bool hasFinished();
int nbInterestedPeers();
- bool isInterestedBy(Connection* remote_peer);
- bool isInterestedByFree(Connection* remote_peer);
+ bool isInterestedBy(const Connection* remote_peer) const;
+ bool isInterestedByFree(const Connection* remote_peer) const;
void updateActivePeersSet(Connection* remote_peer);
void updateInterestedAfterReceive();
void updateChokedPeers();
- bool hasNotPiece(unsigned int piece) { return not(bitfield_ & 1U << piece); }
+ bool hasNotPiece(unsigned int piece) const { return not(bitfield_ & 1U << piece); }
+ bool remotePeerHasMissingPiece(const Connection* remote_peer, unsigned int piece)
+ {
+ return hasNotPiece(piece) && remote_peer->hasPiece(piece);
+ }
bool hasCompletedPiece(unsigned int piece);
unsigned int countPieces(unsigned int bitfield);
/** Check that a piece is not currently being download by the peer. */
- bool isNotDownloadingPiece(unsigned int piece) { return not(current_pieces & 1U << piece); }
- int partiallyDownloadedPiece(Connection* remote_peer);
+ bool isNotDownloadingPiece(unsigned int piece) const { return not(current_pieces & 1U << piece); }
+ int partiallyDownloadedPiece(const Connection* remote_peer);
void updatePiecesCountFromBitfield(unsigned int bitfield);
void removeCurrentPiece(Connection* remote_peer, unsigned int current_piece);
void updateBitfieldBlocks(int piece, int block_index, int block_length);
int getFirstMissingBlockFrom(int piece);
- int selectPieceToDownload(Connection* remote_peer);
+ int selectPieceToDownload(const Connection* remote_peer);
void requestNewPieceTo(Connection* remote_peer);
bool getPeersFromTracker();
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. 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 BITTORRENT_TRACKER_HPP_
-#define BITTORRENT_TRACKER_HPP_
+#ifndef BITTORRENT_TRACKER_HPP
+#define BITTORRENT_TRACKER_HPP
#include "s4u-bittorrent.hpp"
#include <set>
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
void joinChain()
{
- ChainMessage* msg = static_cast<ChainMessage*>(me->get());
+ const ChainMessage* msg = static_cast<ChainMessage*>(me->get());
prev = msg->prev_;
next = msg->next_;
total_pieces = msg->num_pieces;
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
{
double compute_cost;
do {
- double* msg = static_cast<double*>(mailbox->get());
+ const double* msg = static_cast<double*>(mailbox->get());
compute_cost = *msg;
delete msg;
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
{
xbt_assert(args.size() == 1, "The worker expects no argument");
- simgrid::s4u::Host* my_host = simgrid::s4u::this_actor::get_host();
+ const simgrid::s4u::Host* my_host = simgrid::s4u::this_actor::get_host();
simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(my_host->get_name());
double compute_cost;
do {
- double* msg = static_cast<double*>(mailbox->get());
+ const double* msg = static_cast<double*>(mailbox->get());
compute_cost = *msg;
delete msg;
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
mailbox_out->put(payload, 1);
/* - ... then wait for the (large) pong */
- double* sender_time = static_cast<double*>(mailbox_in->get());
+ const double* sender_time = static_cast<double*>(mailbox_in->get());
double communication_time = simgrid::s4u::Engine::get_clock() - *sender_time;
XBT_INFO("Task received : large communication (bandwidth bound)");
XBT_INFO("Pong from mailbox %s to mailbox %s", mailbox_in->get_name().c_str(), mailbox_out->get_name().c_str());
/* - Receive the (small) ping first ....*/
- double* sender_time = static_cast<double*>(mailbox_in->get());
+ const double* sender_time = static_cast<double*>(mailbox_in->get());
double communication_time = simgrid::s4u::Engine::get_clock() - *sender_time;
XBT_INFO("Task received : small communication (latency bound)");
XBT_INFO(" Ping time (latency bound) %f", communication_time);
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
{
try {
rank = std::stoi(simgrid::s4u::this_actor::get_name());
- } catch (std::invalid_argument& ia) {
+ } catch (const std::invalid_argument& ia) {
throw std::invalid_argument(std::string("Processes of this example must have a numerical name, not ") +
ia.what());
}
XBT_INFO("Host \"%u\" send 'Token' to Host \"%s\"", rank, neighbor_mailbox->get_cname());
std::string msg = "Token";
neighbor_mailbox->put(&msg, task_comm_size);
- std::string* res = static_cast<std::string*>(my_mailbox->get());
+ const std::string* res = static_cast<std::string*>(my_mailbox->get());
XBT_INFO("Host \"%u\" received \"%s\"", rank, res->c_str());
} else {
std::string* res = static_cast<std::string*>(my_mailbox->get());
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
while (pending_finalize_messages > 0) {
if (my_mbox->ready()) {
double start = simgrid::s4u::Engine::get_clock();
- std::string* received = static_cast<std::string*>(my_mbox->get());
+ const std::string* received = static_cast<std::string*>(my_mbox->get());
double waiting_time = simgrid::s4u::Engine::get_clock() - start;
xbt_assert(waiting_time == 0, "Expecting the waiting time to be 0 because the communication was supposedly ready, but got %f instead", waiting_time);
XBT_INFO("I got a '%s'.", received->c_str());
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
XBT_INFO("Wait for my first message");
for (bool cont = true; cont;) {
- std::string* received = static_cast<std::string*>(mbox->get());
+ const std::string* received = static_cast<std::string*>(mbox->get());
XBT_INFO("I got a '%s'.", received->c_str());
if (*received == "finalize")
cont = false; // If it's a finalize message, we're done.
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
{
XBT_INFO("Wait for my first message");
for (bool cont = true; cont;) {
- std::string* received = static_cast<std::string*>(mbox->get());
+ const std::string* received = static_cast<std::string*>(mbox->get());
XBT_INFO("I got a '%s'.", received->c_str());
cont = (*received != "finalize"); // If it's a finalize message, we're done
// Receiving the message was all we were supposed to do
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
{
XBT_INFO("Wait for my first message");
for (bool cont = true; cont;) {
- std::string* received = static_cast<std::string*>(mbox->get());
+ const std::string* received = static_cast<std::string*>(mbox->get());
XBT_INFO("I got a '%s'.", received->c_str());
cont = (*received != "finalize"); // If it's a finalize message, we're done
// Receiving the message was all we were supposed to do
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
XBT_INFO("Wait for my first message");
for (bool cont = true; cont;) {
- std::string* received = static_cast<std::string*>(mbox->get());
+ const std::string* received = static_cast<std::string*>(mbox->get());
XBT_INFO("I got a '%s'.", received->c_str());
if (*received == "finalize")
cont = false; // If it's a finalize message, we're done.
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
static void vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm)
{
- simgrid::s4u::Host* src_pm = vm->get_pm();
+ const simgrid::s4u::Host* src_pm = vm->get_pm();
double mig_sta = simgrid::s4u::Engine::get_clock();
sg_vm_migrate(vm, dst_pm);
double mig_end = simgrid::s4u::Engine::get_clock();
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
const char* host_name = simgrid::s4u::this_actor::get_host()->get_cname();
simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(args.at(0));
- struct s_payload* payload = static_cast<struct s_payload*>(mbox->get());
+ const s_payload* payload = static_cast<struct s_payload*>(mbox->get());
double clock_end = simgrid::s4u::Engine::get_clock();
XBT_INFO("%s:%s to %s:%s => %g sec", payload->tx_host->get_cname(), payload->tx_actor_name, host_name, actor_name,
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
* @param id id to check
* @param start lower bound
* @param end upper bound
- * @return a non-zero value if id in in [start, end]
+ * @return true if id in in [start, end]
*/
-static int is_in_interval(int id, int start, int end)
+static bool is_in_interval(int id, int start, int end)
{
int i = id % nb_keys;
int s = start % nb_keys;
try {
comm->wait_for(timeout);
- ChordMessage* answer = static_cast<ChordMessage*>(data);
+ const ChordMessage* answer = static_cast<ChordMessage*>(data);
XBT_DEBUG("Received the answer to my 'Get Predecessor' request: the predecessor of node %d is %d", ask_to,
answer->answer_id);
predecessor_id = answer->answer_id;
int Node::remoteFindSuccessor(int ask_to, int id)
{
int successor = -1;
- void* data = nullptr;
+ ChordMessage* data = nullptr;
simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(ask_to));
simgrid::s4u::Mailbox* return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_succ");
}
// receive the answer
XBT_DEBUG("Sent a 'Find Successor' request to %d for key %d, waiting for the answer", ask_to, id);
- simgrid::s4u::CommPtr comm = return_mailbox->get_async(&data);
+ simgrid::s4u::CommPtr comm = return_mailbox->get_async(reinterpret_cast<void**>(&data));
try {
comm->wait_for(timeout);
- ChordMessage* answer = static_cast<ChordMessage*>(data);
+ const ChordMessage* answer = data;
XBT_DEBUG("Received the answer to my 'Find Successor' request for id %d: the successor of key %d is %d",
answer->request_id, id_, answer->answer_id);
successor = answer->answer_id;
delete answer;
} catch (const simgrid::TimeoutException&) {
XBT_DEBUG("Failed to receive the answer to my 'Find Successor' request");
- delete static_cast<ChordMessage*>(data);
+ delete data;
}
return successor;
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
class ChordMessage {
public:
e_message_type_t type; // type of message
- std::string issuer_host_name; // used for logging
+ std::string issuer_host_name = simgrid::s4u::this_actor::get_host()->get_name(); // used for logging
int request_id = -1; // id (used by some types of messages)
int request_finger = 1; // finger parameter (used by some types of messages)
int answer_id = -1; // answer (used by some types of messages)
simgrid::s4u::Mailbox* answer_to = nullptr; // mailbox to send an answer to (if any)
- explicit ChordMessage(e_message_type_t type)
- : type(type), issuer_host_name(simgrid::s4u::this_actor::get_host()->get_name())
- {
- }
+ explicit ChordMessage(e_message_type_t type) : type(type) {}
static void destroy(void* message);
};
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
namespace kademlia {
-bool sortbydistance(const std::pair<unsigned int, unsigned int>& a, const std::pair<unsigned int, unsigned int>& b)
-{
- return (a.second < b.second);
-}
-
/** @brief Prints a answer_t, for debugging purposes */
void Answer::print()
{
- XBT_INFO("Searching %08x, size %u", destination_id_, size_);
+ XBT_INFO("Searching %08x, size %zu", destination_id_, nodes_.size());
unsigned int i = 0;
- for (auto contact : nodes)
+ for (auto const& contact : nodes_)
XBT_INFO("Node %08x: %08x is at distance %u", i++, contact.first, contact.second);
}
/** @brief Merge two answers together, only keeping the best nodes
* @param source the source of the nodes to add
*/
-unsigned int Answer::merge(Answer* source)
+unsigned int Answer::merge(const Answer* source)
{
if (this == source)
return 0;
unsigned int nb_added = 0;
- for (auto contact : source->nodes) {
- if (std::find(nodes.begin(), nodes.end(), contact) == nodes.end()) {
- nodes.push_back(contact);
- size_++;
+ for (auto const& contact : source->nodes_) {
+ if (std::find(nodes_.begin(), nodes_.end(), contact) == nodes_.end()) {
+ nodes_.push_back(contact);
nb_added++;
}
}
- std::sort(nodes.begin(), nodes.end(), sortbydistance);
trim();
return nb_added;
}
/** @brief Trims an Answer, in order for it to have a size of less or equal to "bucket_size" */
void Answer::trim()
{
- while (size_ > BUCKET_SIZE) {
- nodes.pop_back();
- size_--;
- }
- xbt_assert(nodes.size() == size_, "Wrong size for the answer");
+ // sort by distance
+ std::sort(nodes_.begin(), nodes_.end(),
+ [](const std::pair<unsigned int, unsigned int>& a, const std::pair<unsigned int, unsigned int>& b) {
+ return (a.second < b.second);
+ });
+ if (nodes_.size() > BUCKET_SIZE)
+ nodes_.resize(BUCKET_SIZE);
}
/** @brief Returns if the destination we are trying to find is found
* @return if the destination is found.
*/
-bool Answer::destinationFound()
+bool Answer::destinationFound() const
{
- if (nodes.empty())
- return 0;
-
- return (*nodes.begin()).second == 0;
+ return not nodes_.empty() && nodes_.begin()->second == 0;
}
/** @brief Adds the content of a bucket unsigned into a answer object.
{
xbt_assert((bucket != nullptr), "Provided a NULL bucket");
- for (auto id : bucket->nodes) {
+ for (auto const& id : bucket->nodes) {
unsigned int distance = id ^ destination_id_;
- nodes.push_back(std::pair<unsigned int, unsigned int>(id, distance));
- size_++;
+ nodes_.push_back(std::pair<unsigned int, unsigned int>(id, distance));
}
}
}
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#include <set>
namespace kademlia {
-bool sortbydistance(const std::pair<unsigned int, unsigned int>& a, const std::pair<unsigned int, unsigned int>& b);
-
/* Node query answer. contains the elements closest to the id given. */
class Answer {
unsigned int destination_id_;
- unsigned int size_ = 0;
+ std::vector<std::pair<unsigned int, unsigned int>> nodes_;
public:
- std::vector<std::pair<unsigned int, unsigned int>> nodes;
explicit Answer(unsigned int destination_id) : destination_id_(destination_id) {}
virtual ~Answer() = default;
- unsigned int getDestinationId() { return destination_id_; }
- unsigned int getSize() { return size_; }
+ unsigned int getDestinationId() const { return destination_id_; }
+ size_t getSize() const { return nodes_.size(); }
+ const std::vector<std::pair<unsigned int, unsigned int>>& getNodes() const { return nodes_; }
void print();
- unsigned int merge(Answer* a);
+ unsigned int merge(const Answer* a);
void trim();
- bool destinationFound();
+ bool destinationFound() const;
void addBucket(const kademlia::Bucket* bucket);
};
}
#!/usr/bin/env python
-# Copyright (c) 2012-2019. The SimGrid Team.
+# Copyright (c) 2012-2020. The SimGrid Team.
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
namespace kademlia {
static void destroy(void* message)
{
- Message* msg = static_cast<Message*>(message);
+ const Message* msg = static_cast<Message*>(message);
delete msg->answer_;
delete msg;
}
*/
bool Node::join(unsigned int known_id)
{
- Answer* node_list;
+ const Answer* node_list;
unsigned int i;
bool got_answer = false;
XBT_DEBUG("Received an answer from the node I know.");
got_answer = true;
// retrieve the node list and ping them.
- Message* msg = static_cast<Message*>(received_msg);
+ const Message* msg = static_cast<Message*>(received_msg);
node_list = msg->answer_;
if (node_list) {
- for (auto contact : node_list->nodes)
+ for (auto const& contact : node_list->getNodes())
routingTableUpdate(contact.first);
} else {
handleFindNode(msg);
* Sends to the best "KADEMLIA_ALPHA" nodes in the "node_list" array a "FIND_NODE" request, to ask them for their best
* nodes
*/
-unsigned int Node::sendFindNodeToBest(Answer* node_list)
+unsigned int Node::sendFindNodeToBest(const Answer* node_list)
{
unsigned int i = 0;
unsigned int j = 0;
unsigned int destination = node_list->getDestinationId();
- for (auto node_to_query : node_list->nodes) {
+ for (auto const& node_to_query : node_list->getNodes()) {
/* We need to have at most "KADEMLIA_ALPHA" requests each time, according to the protocol */
/* Gets the node we want to send the query to */
if (node_to_query.first != id_) { /* No need to query ourselves */
}
}
/* We trim the array to have only BUCKET_SIZE or less elements */
- std::sort(answer->nodes.begin(), answer->nodes.end(), sortbydistance);
answer->trim();
return answer;
receive_comm = mailbox->get_async(&received_msg);
if (receive_comm->test()) {
- Message* msg = static_cast<Message*>(received_msg);
+ const Message* msg = static_cast<Message*>(received_msg);
// Check if what we have received is what we are looking for.
if (msg->answer_ && msg->answer_->getDestinationId() == id_to_find) {
routingTableUpdate(msg->sender_id_);
// Handle the answer
- for (auto contact : node_list->nodes)
+ for (auto const& contact : node_list->getNodes())
routingTableUpdate(contact.first);
answers++;
nodes_added = node_list->merge(msg->answer_);
XBT_DEBUG("Received an answer from %s (%s) with %zu nodes on it", msg->answer_to_->get_cname(),
- msg->issuer_host_name_.c_str(), msg->answer_->nodes.size());
+ msg->issuer_host_name_.c_str(), msg->answer_->getSize());
} else {
if (msg->answer_) {
routingTableUpdate(msg->sender_id_);
}
/** @brief Handles the answer to an incoming "find_node" task */
-void Node::handleFindNode(Message* msg)
+void Node::handleFindNode(const Message* msg)
{
routingTableUpdate(msg->sender_id_);
XBT_VERB("Received a FIND_NODE from %s (%s), he's trying to find %08x", msg->answer_to_->get_cname(),
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. 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 _KADEMLIA_NODE_HPP
-#define _KADEMLIA_NODE_HPP
+#ifndef KADEMLIA_NODE_HPP
+#define KADEMLIA_NODE_HPP
#include "answer.hpp"
#include "message.hpp"
#include "routing_table.hpp"
unsigned int id_; // node id - 160 bits
RoutingTable table; // node routing table
public:
- simgrid::s4u::CommPtr receive_comm;
+ simgrid::s4u::CommPtr receive_comm = nullptr;
void* received_msg = nullptr;
unsigned int find_node_success = 0; // Number of find_node which have succeeded.
unsigned int find_node_failed = 0; // Number of find_node which have failed.
- explicit Node(unsigned int node_id) : id_(node_id), table(node_id), receive_comm(nullptr) {}
+ explicit Node(unsigned int node_id) : id_(node_id), table(node_id) {}
Node(const Node&) = delete;
Node& operator=(const Node&) = delete;
unsigned int getId() { return id_; }
bool join(unsigned int known_id);
void sendFindNode(unsigned int id, unsigned int destination);
- unsigned int sendFindNodeToBest(Answer* node_list);
+ unsigned int sendFindNodeToBest(const Answer* node_list);
void routingTableUpdate(unsigned int id);
Answer* findClosest(unsigned int destination_id);
bool findNode(unsigned int id_to_find, bool count_in_stats);
void randomLookup();
- void handleFindNode(Message* msg);
+ void handleFindNode(const Message* msg);
};
}
// identifier functions
unsigned int get_id_in_prefix(unsigned int id, unsigned int prefix);
unsigned int get_node_prefix(unsigned int id, unsigned int nb_bits);
-#endif /* _MSG_EXAMPLES_ROUTING_H */
+#endif /* KADEMLIA_NODE_HPP */
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
if (node->receive_comm->test()) {
// There has been a message, we need to handle it !
- kademlia::Message* msg = static_cast<kademlia::Message*>(node->received_msg);
+ const kademlia::Message* msg = static_cast<kademlia::Message*>(node->received_msg);
if (msg) {
node->handleFindNode(msg);
delete msg->answer_;
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
<zone id="AS0" routing="Full">
<!-- Use the pstate mechanism to encode the boot/shutdown time and energy.
- --
- -- See the C++ file in the same directory for more information.
+ -
+ - See the C++ file in the same directory for more information.
-->
<!-- pstate values:
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
/* Sleep a while before starting the example */
simgrid::s4u::this_actor::sleep_for(10);
-
if (flow_amount == 1) {
/* - Send the task to the @ref worker */
char* payload = bprintf("%f", comm_size);
int main(int argc, char* argv[])
{
-
simgrid::s4u::Engine e(&argc, argv);
XBT_INFO("Activating the SimGrid link energy plugin");
argSender.push_back("1"); // Default value
argReceiver.push_back("1");
}
+
if (argc > 3) {
if (strcmp(argv[3], "random") == 0) { // We're asked to get a random size
/* Initialize the random number generator */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
namespace filter {
/* First example of thing that we can use as a filtering criteria: a simple boolean function */
-static bool filter_speed_more_than_50Mf(simgrid::s4u::Host* host)
+static bool filter_speed_more_than_50Mf(const simgrid::s4u::Host* host)
{
return host->get_speed() > 50E6;
}
*/
class SingleCore {
public:
- bool operator()(simgrid::s4u::Host* host) { return host->get_core_count() == 1; }
+ bool operator()(const simgrid::s4u::Host* host) { return host->get_core_count() == 1; }
};
/* This functor is a bit more complex, as it saves the current state when created.
/* Use a lambda function to filter hosts: We only want multicore hosts */
XBT_INFO("Hosts currently registered with this engine: %zu", e.get_host_count());
std::vector<simgrid::s4u::Host*> list =
- e.get_filtered_hosts([](simgrid::s4u::Host* host) { return host->get_core_count() > 1; });
+ e.get_filtered_hosts([](const simgrid::s4u::Host* host) { return host->get_core_count() > 1; });
for (auto& host : list)
XBT_INFO("The following hosts have more than one core: %s", host->get_cname());
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "simgrid/s4u.hpp"
+#include <vector>
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
-simgrid::s4u::ExecPtr child;
-
static void worker()
{
+ // Define an amount of work that should take 1 second to execute.
double computation_amount = simgrid::s4u::this_actor::get_host()->get_speed();
+ std::vector<simgrid::s4u::ExecPtr> pending_execs;
+ // Create a small DAG
+ // + Two parents and a child
+ // + First parent ends after 1 second and the Second parent after 2 seconds.
simgrid::s4u::ExecPtr first_parent = simgrid::s4u::this_actor::exec_init(computation_amount);
+ pending_execs.push_back(first_parent);
simgrid::s4u::ExecPtr second_parent = simgrid::s4u::this_actor::exec_init(2 * computation_amount);
+ pending_execs.push_back(second_parent);
+ simgrid::s4u::ExecPtr child = simgrid::s4u::this_actor::exec_init(computation_amount);
+ pending_execs.push_back(child);
- child = simgrid::s4u::this_actor::exec_init(computation_amount);
+ // Name the activities (for logging purposes only)
+ first_parent->set_name("parent 1");
+ second_parent->set_name("parent 2");
+ child->set_name("child");
+ // Create the dependencies by declaring 'child' as a successor of first_parent and second_parent
first_parent->add_successor(child.get());
second_parent->add_successor(child.get());
- second_parent->start();
- first_parent->wait();
- second_parent->wait();
-}
-static void vetoed_worker()
-{
+ // Start the activities.
+ first_parent->start();
+ second_parent->start();
+ // child uses a vetoable start to force it to wait for the completion of its predecessors
child->vetoable_start();
- while (not child->test()) {
- if (child->get_state() == simgrid::s4u::Exec::State::STARTING)
- XBT_INFO("child cannot start yet");
- else
- XBT_INFO("child is now in state %d", (int)child->get_state());
- simgrid::s4u::this_actor::sleep_for(0.25);
+
+ // wait for the completion of all activities
+ while (not pending_execs.empty()) {
+ int changed_pos = simgrid::s4u::Exec::wait_any_for(&pending_execs, -1);
+ XBT_INFO("Exec '%s' is complete", pending_execs[changed_pos]->get_cname());
+ pending_execs.erase(pending_execs.begin() + changed_pos);
}
- XBT_INFO("Should be okay now, child is in state %d", (int)child->get_state());
}
int main(int argc, char* argv[])
e.load_platform(argv[1]);
simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Fafard"), worker);
- simgrid::s4u::Actor::create("vetoed_worker", simgrid::s4u::Host::by_name("Fafard"), vetoed_worker);
e.run();
#!/usr/bin/env tesh
-$ ${bindir:=.}/s4u-exec-dependent ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
-> [ 0.000000] (2:vetoed_worker@Fafard) child cannot start yet
-> [ 0.250000] (2:vetoed_worker@Fafard) child cannot start yet
-> [ 0.500000] (2:vetoed_worker@Fafard) child cannot start yet
-> [ 0.750000] (2:vetoed_worker@Fafard) child cannot start yet
-> [ 1.000000] (2:vetoed_worker@Fafard) child cannot start yet
-> [ 1.250000] (2:vetoed_worker@Fafard) child cannot start yet
-> [ 1.500000] (2:vetoed_worker@Fafard) child cannot start yet
-> [ 1.750000] (2:vetoed_worker@Fafard) child cannot start yet
-> [ 2.000000] (2:vetoed_worker@Fafard) child cannot start yet
-> [ 2.250000] (2:vetoed_worker@Fafard) child cannot start yet
-> [ 2.500000] (2:vetoed_worker@Fafard) child cannot start yet
-> [ 2.750000] (2:vetoed_worker@Fafard) child cannot start yet
-> [ 3.000000] (2:vetoed_worker@Fafard) child is now in state 2
-> [ 3.250000] (2:vetoed_worker@Fafard) child is now in state 2
-> [ 3.500000] (2:vetoed_worker@Fafard) child is now in state 2
-> [ 3.750000] (2:vetoed_worker@Fafard) child is now in state 2
-> [ 4.000000] (2:vetoed_worker@Fafard) Should be okay now, child is in state 5
+! output sort
+$ ${bindir:=.}/s4u-exec-dependent ${platfdir}/small_platform.xml --log=s4u_activity.t:debug "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 2.000000] (1:worker@Fafard) Remove a dependency from 'parent 1' on 'child'
+> [ 2.000000] (1:worker@Fafard) Exec 'parent 1' is complete
+> [ 3.000000] (1:worker@Fafard) Remove a dependency from 'parent 2' on 'child'
+> [ 3.000000] (1:worker@Fafard) All dependencies are solved, let's start 'child'
+> [ 3.000000] (1:worker@Fafard) Exec 'parent 2' is complete
+> [ 4.000000] (1:worker@Fafard) Exec 'child' is complete
> [ 4.000000] (0:maestro@) Simulation time 4
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
communication_amounts[i * hosts_count + j] = 1e7; // 10 MB
try {
- simgrid::s4u::this_actor::parallel_execute(hosts, computation_amounts, communication_amounts,
- 10.0 /* timeout (in seconds)*/);
+ simgrid::s4u::this_actor::exec_init(hosts, computation_amounts, communication_amounts)
+ ->wait_for(10.0 /* timeout (in seconds)*/);
xbt_die("Woops, this did not timeout as expected... Please report that bug.");
} catch (const simgrid::TimeoutException&) {
XBT_INFO("Caught the expected timeout exception.");
/* ------[ test 3 ]----------------- */
XBT_INFO("Then, build a parallel task involving only computations (of different amounts) and no communication");
- computation_amounts = {3e8, 6e8, 1e9}; // 300Mflop, 6Mflop, 1Gflop
+ computation_amounts = {3e8, 6e8, 1e9}; // 300Mflop, 600Mflop, 1Gflop
communication_amounts.clear(); // no comm
simgrid::s4u::this_actor::parallel_execute(hosts, computation_amounts, communication_amounts);
communication_amounts.clear();
simgrid::s4u::this_actor::parallel_execute(hosts, computation_amounts, communication_amounts);
+ /* ------[ test 5 ]----------------- */
+ XBT_INFO("Then, Monitor the execution of a parallel task");
+ computation_amounts.assign(hosts_count, 1e6 /*1Mflop*/);
+ communication_amounts = {0, 1e6, 0, 0, 0, 1e6, 1e6, 0, 0};
+ simgrid::s4u::ExecPtr activity =
+ simgrid::s4u::this_actor::exec_init(hosts, computation_amounts, communication_amounts);
+ activity->start();
+
+ while (not activity->test()) {
+ XBT_INFO("Remaining flop ratio: %.0f%%", 100 * activity->get_remaining_ratio());
+ simgrid::s4u::this_actor::sleep_for(5);
+ }
+ activity->wait();
+
XBT_INFO("Goodbye now!");
}
> [320.000000] (0:maestro@) UNCAT HOST [310.000000 - 320.000000] MyHost2 speed_used 60000000.000000
> [320.000000] (0:maestro@) UNCAT HOST [310.000000 - 320.000000] MyHost3 speed_used 100000000.000000
> [320.000000] (1:test@MyHost1) Then, build a parallel task with no computation nor communication (synchro only)
-> [320.000000] (1:test@MyHost1) Goodbye now!
-> [320.000000] (0:maestro@) Simulation done.
+> [320.000000] (1:test@MyHost1) Then, Monitor the execution of a parallel task
+> [320.000000] (1:test@MyHost1) Remaining flop ratio: 100%
+> [325.000000] (1:test@MyHost1) Remaining flop ratio: 83%
+> [330.000000] (1:test@MyHost1) Remaining flop ratio: 67%
+> [335.000000] (1:test@MyHost1) Remaining flop ratio: 50%
+> [340.000000] (1:test@MyHost1) Remaining flop ratio: 33%
+> [345.000000] (1:test@MyHost1) Remaining flop ratio: 17%
+> [350.000000] (0:maestro@) UNCAT HOST [320.000000 - 350.000000] MyHost1 speed_used 33333.333333
+> [350.000000] (0:maestro@) UNCAT HOST [320.000000 - 350.000000] MyHost2 speed_used 33333.333333
+> [350.000000] (0:maestro@) UNCAT HOST [320.000000 - 350.000000] MyHost3 speed_used 33333.333333
+> [350.000000] (0:maestro@) UNCAT LINK [320.000000 - 350.000000] bus bandwidth_used 100000.000000
+> [350.000000] (1:test@MyHost1) Goodbye now!
+> [350.000000] (0:maestro@) Simulation done.
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
static void wizard()
{
- simgrid::s4u::Host* fafard = simgrid::s4u::Host::by_name("Fafard");
+ const simgrid::s4u::Host* fafard = simgrid::s4u::Host::by_name("Fafard");
simgrid::s4u::Host* ginette = simgrid::s4u::Host::by_name("Ginette");
simgrid::s4u::Host* boivin = simgrid::s4u::Host::by_name("Boivin");
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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. */
--- /dev/null
+/* Copyright (c) 2019-2020. 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 "simgrid/s4u.hpp"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_exec_waitfor, "Messages specific for this s4u example");
+
+static void worker()
+{
+ simgrid::s4u::ExecPtr exec;
+ double amount = 5 * simgrid::s4u::this_actor::get_host()->get_speed();
+ XBT_INFO("Create an activity that should run for 5 seconds");
+
+ exec = simgrid::s4u::this_actor::exec_async(amount);
+
+ /* Now that execution is started, wait for 3 seconds. */
+ XBT_INFO("But let it end after 3 seconds");
+ try {
+ exec->wait_for(3);
+ XBT_INFO("Execution complete");
+ } catch (const simgrid::TimeoutException&) {
+ XBT_INFO("Execution Timeout!");
+ }
+
+ /* do it again, but this time with a timeout greater than the duration of the execution */
+ XBT_INFO("Create another activity that should run for 5 seconds and wait for it for 6 seconds");
+ exec = simgrid::s4u::this_actor::exec_async(amount);
+ try {
+ exec->wait_for(6);
+ XBT_INFO("Execution complete");
+ } catch (const simgrid::TimeoutException&) {
+ XBT_INFO("Execution Timeout!");
+ }
+
+ XBT_INFO("Finally test with a parallel execution");
+ auto hosts = simgrid::s4u::Engine::get_instance()->get_all_hosts();
+ size_t hosts_count = hosts.size();
+ std::vector<double> computation_amounts;
+ std::vector<double> communication_amounts;
+
+ computation_amounts.assign(hosts_count, 1e9 /*1Gflop*/);
+ communication_amounts.assign(hosts_count * hosts_count, 0);
+ for (size_t i = 0; i < hosts_count; i++)
+ for (size_t j = i + 1; j < hosts_count; j++)
+ communication_amounts[i * hosts_count + j] = 1e7; // 10 MB
+
+ exec = simgrid::s4u::this_actor::exec_init(hosts, computation_amounts, communication_amounts);
+ try {
+ exec->wait_for(2);
+ XBT_INFO("Parallel Execution complete");
+ } catch (const simgrid::TimeoutException&) {
+ XBT_INFO("Parallel Execution Timeout!");
+ }
+}
+
+int main(int argc, char* argv[])
+{
+ simgrid::s4u::Engine e(&argc, argv);
+ e.load_platform(argv[1]);
+ simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Tremblay"), worker);
+ e.run();
+
+ return 0;
+}
--- /dev/null
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/s4u-exec-waitfor ${platfdir}/multicore_machine.xml "--log=root.fmt:[%10.6r]%e[%14P]%e%m%n"
+> [ 0.000000] [ worker] Create an activity that should run for 5 seconds
+> [ 0.000000] [ worker] But let it end after 3 seconds
+> [ 3.000000] [ worker] Execution Timeout!
+> [ 3.000000] [ worker] Create another activity that should run for 5 seconds and wait for it for 6 seconds
+> [ 8.000000] [ worker] Execution complete
+> [ 8.000000] [ worker] Finally test with a parallel execution
+> [ 10.000000] [ worker] Parallel Execution Timeout!
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
XBT_INFO("Goodbye now!");
}
+static void test_waitfor(sg_size_t size)
+{
+ simgrid::s4u::Disk* disk = simgrid::s4u::Host::current()->get_disks().front();
+ XBT_INFO("Hello! write %llu bytes from %s", size, disk->get_cname());
+
+ simgrid::s4u::IoPtr activity = disk->write_async(size);
+ try {
+ activity->wait_for(0.5);
+ } catch (const simgrid::TimeoutException&) {
+ XBT_INFO("Asynchronous write: Timeout!");
+ }
+
+ XBT_INFO("Goodbye now!");
+}
+
static void test_cancel(sg_size_t size)
{
simgrid::s4u::Disk* disk = simgrid::s4u::Host::current()->get_disks().front();
+ simgrid::s4u::this_actor::sleep_for(0.5);
XBT_INFO("Hello! write %llu bytes from %s", size, disk->get_cname());
simgrid::s4u::IoPtr activity = disk->write_async(size);
XBT_INFO("Goodbye now!");
}
+static void test_monitor(sg_size_t size)
+{
+ simgrid::s4u::Disk* disk = simgrid::s4u::Host::current()->get_disks().front();
+ simgrid::s4u::this_actor::sleep_for(1);
+ simgrid::s4u::IoPtr activity = disk->write_async(size);
+
+ while (not activity->test()) {
+ XBT_INFO("Remaining amount of bytes to write: %g", activity->get_remaining());
+ simgrid::s4u::this_actor::sleep_for(0.2);
+ }
+ activity->wait();
+
+ XBT_INFO("Goodbye now!");
+}
+
int main(int argc, char* argv[])
{
simgrid::s4u::Engine e(&argc, argv);
e.load_platform(argv[1]);
simgrid::s4u::Actor::create("test", simgrid::s4u::Host::by_name("bob"), test, 2e7);
+ simgrid::s4u::Actor::create("test_waitfor", simgrid::s4u::Host::by_name("alice"), test_waitfor, 5e7);
simgrid::s4u::Actor::create("test_cancel", simgrid::s4u::Host::by_name("alice"), test_cancel, 5e7);
+ simgrid::s4u::Actor::create("test_monitor", simgrid::s4u::Host::by_name("alice"), test_monitor, 5e7);
e.run();
$ ${bindir:=.}/s4u-io-async ${platfdir}/hosts_with_disks.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:test@bob) Hello! read 20000000 bytes from Disk1
-> [ 0.000000] (2:test_cancel@alice) Hello! write 50000000 bytes from Disk1
+> [ 0.000000] (2:test_waitfor@alice) Hello! write 50000000 bytes from Disk1
> [ 0.200000] (1:test@bob) Goodbye now!
-> [ 0.500000] (2:test_cancel@alice) I changed my mind, cancel!
-> [ 0.500000] (2:test_cancel@alice) Goodbye now!
-> [ 0.500000] (0:maestro@) Simulation time 0.5
+> [ 0.500000] (2:test_waitfor@alice) Asynchronous write: Timeout!
+> [ 0.500000] (2:test_waitfor@alice) Goodbye now!
+> [ 0.500000] (3:test_cancel@alice) Hello! write 50000000 bytes from Disk1
+> [ 1.000000] (3:test_cancel@alice) I changed my mind, cancel!
+> [ 1.000000] (3:test_cancel@alice) Goodbye now!
+> [ 1.000000] (4:test_monitor@alice) Remaining amount of bytes to write: 5e+07
+> [ 1.200000] (4:test_monitor@alice) Remaining amount of bytes to write: 3.4e+07
+> [ 1.400000] (4:test_monitor@alice) Remaining amount of bytes to write: 1.8e+07
+> [ 1.600000] (4:test_monitor@alice) Remaining amount of bytes to write: 2e+06
+> [ 1.800000] (4:test_monitor@alice) Goodbye now!
+> [ 1.800000] (0:maestro@) Simulation time 1.8
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
std::vector<simgrid::s4u::Disk*> const& disk_list = simgrid::s4u::Host::current()->get_disks();
/* - For each disk mounted on host, display disk name and mount point */
- for (auto disk : disk_list)
+ for (auto const& disk : disk_list)
XBT_INFO("Disk name: %s (read: %.0f B/s -- write: %.0f B/s ", disk->get_cname(), disk->get_read_bandwidth(),
disk->get_write_bandwidth());
/* - Attach some user data to disk1 */
XBT_INFO("*** Get/set data for storage element: Disk1 ***");
- std::string* data = static_cast<std::string*>(disk->get_data());
+ const std::string* data = static_cast<std::string*>(disk->get_data());
XBT_INFO("Get storage data: '%s'", data ? data->c_str() : "No user data");
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
// Test attaching some user data to the file
file->set_data(new std::string("777"));
- std::string* file_data = static_cast<std::string*>(file->get_data());
+ const std::string* file_data = static_cast<std::string*>(file->get_data());
XBT_INFO("User data attached to the file: %s", file_data->c_str());
delete file_data;
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
{
ensure_other_tid();
- std::string* payload = static_cast<std::string*>(simgrid::s4u::Mailbox::by_name("some mailbox")->get());
+ const std::string* payload = static_cast<std::string*>(simgrid::s4u::Mailbox::by_name("some mailbox")->get());
XBT_INFO("Task received");
delete payload;
}
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
int value_got = -1;
simgrid::s4u::Mailbox* mb = simgrid::s4u::Mailbox::by_name("server");
for (int count = 0; count < worker_amount; count++) {
- int* msg = static_cast<int*>(mb->get());
+ const int* msg = static_cast<int*>(mb->get());
value_got = *msg;
delete msg;
}
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
xbt_assert(argc == 2, "Expecting one parameter");
long id = xbt_str_parse_int(argv[1], "Invalid argument %s");
simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::string("worker-") + std::to_string(id));
- double* payload = nullptr;
+ const double* payload = nullptr;
double comp_size = -1;
while (1) {
try {
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
/* Main function of the Yielder process */
static void watcher()
{
- simgrid::s4u::Host* jupiter = simgrid::s4u::Host::by_name("Jupiter");
- simgrid::s4u::Host* fafard = simgrid::s4u::Host::by_name("Fafard");
- simgrid::s4u::Link* link1 = simgrid::s4u::Link::by_name("1");
- simgrid::s4u::Link* link2 = simgrid::s4u::Link::by_name("2");
+ const simgrid::s4u::Host* jupiter = simgrid::s4u::Host::by_name("Jupiter");
+ const simgrid::s4u::Host* fafard = simgrid::s4u::Host::by_name("Fafard");
+ const simgrid::s4u::Link* link1 = simgrid::s4u::Link::by_name("1");
+ const simgrid::s4u::Link* link2 = simgrid::s4u::Link::by_name("2");
for (int i = 0; i < 10; i++) {
XBT_INFO("Fafard: %.0fGflops, Jupiter: % 3.0fGflops, Link1: (%.2fMB/s %.0fms), Link2: (%.2fMB/s %.0fms)",
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
static void bob(std::vector<std::string> /*args*/)
{
/* this host also tests the properties of the AS*/
- simgrid::s4u::NetZone* root = simgrid::s4u::Engine::get_instance()->get_netzone_root();
+ const simgrid::s4u::NetZone* root = simgrid::s4u::Engine::get_instance()->get_netzone_root();
XBT_INFO("== Print the properties of the root zone");
XBT_INFO(" Zone property: filename -> %s", root->get_property("filename"));
XBT_INFO(" Zone property: date -> %s", root->get_property("date"));
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
} else \
((void)0)
-static void log_action(simgrid::xbt::ReplayAction& action, double date)
+static void log_action(const simgrid::xbt::ReplayAction& action, double date)
{
if (XBT_LOG_ISENABLED(replay_comm, xbt_log_priority_verbose)) {
std::string s = boost::algorithm::join(action, " ");
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
} else \
((void)0)
-static void log_action(simgrid::xbt::ReplayAction& action, double date)
+static void log_action(const simgrid::xbt::ReplayAction& action, double date)
{
if (XBT_LOG_ISENABLED(replay_io, xbt_log_priority_verbose)) {
std::string s = boost::algorithm::join(action, " ");
std::string file_name = action[2];
double clock = simgrid::s4u::Engine::get_clock();
- simgrid::s4u::File* file = get_file_descriptor(file_name);
+ const simgrid::s4u::File* file = get_file_descriptor(file_name);
ACT_DEBUG("Entering Close: %s (filename: %s)", NAME.c_str(), file_name.c_str());
delete file;
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
--- /dev/null
+/* Copyright (c) 2006-2020. 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 <mutex> /* std::mutex and std::lock_guard */
+#include <simgrid/s4u.hpp> /* All of S4U */
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "a sample log category");
+
+std::string data;
+bool done = false;
+
+static void worker_fun(simgrid::s4u::ConditionVariablePtr cv, simgrid::s4u::MutexPtr mutex)
+{
+ std::unique_lock<simgrid::s4u::Mutex> lock(*mutex);
+
+ XBT_INFO("Start processing data which is '%s'.", data.c_str());
+ data += std::string(" after processing");
+
+ // Send data back to main()
+ XBT_INFO("Signal to master that the data processing is completed, and exit.");
+
+ done = true;
+ cv->notify_one();
+}
+
+static void master_fun()
+{
+ auto mutex = simgrid::s4u::Mutex::create();
+ auto cv = simgrid::s4u::ConditionVariable::create();
+ data = std::string("Example data");
+ auto worker = simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Jupiter"), worker_fun, cv, mutex);
+
+ // wait for the worker
+ cv->wait(std::unique_lock<simgrid::s4u::Mutex>(*mutex), []() { return done; });
+ XBT_INFO("data is now '%s'.", data.c_str());
+
+ worker->join();
+}
+
+int main(int argc, char** argv)
+{
+ simgrid::s4u::Engine e(&argc, argv);
+ e.load_platform("../../platforms/two_hosts.xml");
+ simgrid::s4u::Actor::create("main", simgrid::s4u::Host::by_name("Tremblay"), master_fun);
+ e.run();
+
+ return 0;
+}
--- /dev/null
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/s4u-synchro-condition-variable
+> [Jupiter:worker:(2) 0.000000] [s4u_test/INFO] Start processing data which is 'Example data'.
+> [Jupiter:worker:(2) 0.000000] [s4u_test/INFO] Signal to master that the data processing is completed, and exit.
+> [Tremblay:main:(1) 0.000000] [s4u_test/INFO] data is now 'Example data after processing'.
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
simgrid::s4u::SemaphorePtr sem_empty = simgrid::s4u::Semaphore::create(1); /* indicates whether the buffer is empty */
simgrid::s4u::SemaphorePtr sem_full = simgrid::s4u::Semaphore::create(0); /* indicates whether the buffer is full */
-
-static void producer(std::vector<std::string>* args)
+static void producer(const std::vector<std::string>* args)
{
for (auto str : *args) {
sem_empty->acquire();
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2016-2019. The SimGrid Team.
+/* Copyright (c) 2016-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2016-2019. The SimGrid Team.
+/* Copyright (c) 2016-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* A simple bugged MPI_ISend and MPI_IRecv test */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#include <stdio.h>
#include <mpi.h>
#include <simgrid/modelchecker.h>
+#include <xbt/dynar.h>
#define GRANT_TAG 0
#define REQUEST_TAG 1
/* A simple bugged MPI_ISend and MPI_IRecv test */
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2014-2019. The SimGrid Team.
+/* Copyright (c) 2014-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#include <stdio.h>
#include <mpi.h>
#include <simgrid/modelchecker.h>
+#include <xbt/dynar.h>
#define GRANT_TAG 0
#define REQUEST_TAG 1
/* ../../../smpi_script/bin/smpirun -hostfile hostfile_send_deterministic -platform ../../platforms/cluster_backbone.xml -np 3 --cfg=smpi/send-is-detached-thresh:0 gdb\ --args\ ./send_deterministic */
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* A simple bugged MPI_Send and MPI_Recv test: it deadlocks when MPI_Send are blocking */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
/* This shows how to extend the trace format by adding a new kind of events.
This function is registered through xbt_replay_action_register() below. */
-static void action_blah(simgrid::xbt::ReplayAction& /*args*/)
+static void action_blah(const simgrid::xbt::ReplayAction& /*args*/)
{
/* Add your answer to the blah event here.
args is a strings array containing the blank-separated parameters found in the trace for this event instance. */
#!/usr/bin/env sh
-# Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2007-2020. 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.
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
}
// Sleeps for a given amount of time
-static int sleeper_process(int* param)
+static int sleeper_process(const int* param)
{
XBT_DEBUG("Sleeping for %d seconds", *param);
simgrid::s4u::this_actor::sleep_for(*param);
}
// Executes a workload of SMPI processes
-static int workload_executor_process(std::vector<Job*>* workload)
+static int workload_executor_process(const std::vector<Job*>* workload)
{
for (Job* job : *workload) {
// Let's wait until the job's waiting time if needed
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
*
* Note that argv is copied over, so you should free your own copy once the actor is started. */
XBT_PUBLIC void sg_actor_start(sg_actor_t actor, xbt_main_func_t code, int argc, char** argv);
-XBT_PUBLIC aid_t sg_actor_get_PID(sg_actor_t actor);
-XBT_PUBLIC aid_t sg_actor_get_PPID(sg_actor_t actor);
+XBT_PUBLIC aid_t sg_actor_get_PID(const_sg_actor_t actor);
+XBT_PUBLIC aid_t sg_actor_get_PPID(const_sg_actor_t actor);
XBT_PUBLIC sg_actor_t sg_actor_by_PID(aid_t pid);
-XBT_PUBLIC const char* sg_actor_get_name(sg_actor_t actor);
-XBT_PUBLIC sg_host_t sg_actor_get_host(sg_actor_t actor);
-XBT_PUBLIC const char* sg_actor_get_property_value(sg_actor_t actor, const char* name);
-XBT_PUBLIC xbt_dict_t sg_actor_get_properties(sg_actor_t actor);
+XBT_PUBLIC const char* sg_actor_get_name(const_sg_actor_t actor);
+XBT_PUBLIC sg_host_t sg_actor_get_host(const_sg_actor_t actor);
+XBT_PUBLIC const char* sg_actor_get_property_value(const_sg_actor_t actor, const char* name);
+XBT_PUBLIC xbt_dict_t sg_actor_get_properties(const_sg_actor_t actor);
XBT_PUBLIC void sg_actor_suspend(sg_actor_t actor);
XBT_PUBLIC void sg_actor_resume(sg_actor_t actor);
XBT_PUBLIC int sg_actor_is_suspended(sg_actor_t actor);
void sg_actor_set_auto_restart(sg_actor_t actor, int auto_restart);
XBT_PUBLIC void sg_actor_daemonize(sg_actor_t actor);
+#ifndef DOXYGEN
XBT_ATTRIB_DEPRECATED_v329("Please use sg_actor_set_host() instead") XBT_PUBLIC
void sg_actor_migrate(sg_actor_t process, sg_host_t host);
+#endif
XBT_PUBLIC void sg_actor_set_host(sg_actor_t actor, sg_host_t host);
XBT_PUBLIC void sg_actor_join(sg_actor_t actor, double timeout);
XBT_PUBLIC void* sg_actor_self_data();
XBT_PUBLIC void sg_actor_self_data_set(void* data);
XBT_PUBLIC void sg_actor_self_execute(double flops);
-XBT_PUBLIC void sg_actor_ref(sg_actor_t actor);
-XBT_PUBLIC void sg_actor_unref(sg_actor_t actor);
+XBT_PUBLIC void sg_actor_ref(const_sg_actor_t actor);
+XBT_PUBLIC void sg_actor_unref(const_sg_actor_t actor);
XBT_PUBLIC void* sg_actor_data(const_sg_actor_t actor);
XBT_PUBLIC void sg_actor_data_set(sg_actor_t actor, void* userdata);
/* Public interface to the Link datatype */
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
SG_BEGIN_DECL
XBT_PUBLIC sg_bar_t sg_barrier_init(unsigned int count);
-XBT_PUBLIC void sg_barrier_destroy(sg_bar_t bar);
+XBT_PUBLIC void sg_barrier_destroy(const_sg_bar_t bar);
XBT_PUBLIC int sg_barrier_wait(sg_bar_t bar);
SG_END_DECL
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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 Blocks onto the given condition variable, but only for the given amount of time.
* @return 0 on success, 1 on timeout */
XBT_PUBLIC int sg_cond_wait_for(sg_cond_t cond, sg_mutex_t mutex, double delay);
-/** @brief Signals the given mutex variable */
+/** @brief Signals the given condition variable */
XBT_PUBLIC void sg_cond_notify_one(sg_cond_t cond);
-/** @brief Broadcasts the given mutex variable */
+/** @brief Broadcasts the given condition variable */
XBT_PUBLIC void sg_cond_notify_all(sg_cond_t cond);
-/** @brief Destroys the given mutex variable */
-XBT_PUBLIC void sg_cond_destroy(sg_cond_t cond);
+/** @brief Destroys the given condition variable */
+XBT_PUBLIC void sg_cond_destroy(const_sg_cond_t cond);
SG_END_DECL
/* simgrid/config.h - Results of the configure made visible to user code. */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
/** Creates a new platform, including hosts, links, and the routing table.
*
- * \rst
+ * \beginrst
* See also: :ref:`platform`.
* \endrst
*/
XBT_PUBLIC void simgrid_load_platform(const char* filename);
/** Load a deployment file and launch the actors that it contains
*
- * \rst
+ * \beginrst
* See also: :ref:`deploy`.
* \endrst
*/
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
class Actor;
/** Smart pointer to a simgrid::s4u::Actor */
typedef boost::intrusive_ptr<Actor> ActorPtr;
-XBT_PUBLIC void intrusive_ptr_release(Actor* actor);
-XBT_PUBLIC void intrusive_ptr_add_ref(Actor* actor);
+XBT_PUBLIC void intrusive_ptr_release(const Actor* actor);
+XBT_PUBLIC void intrusive_ptr_add_ref(const Actor* actor);
class Barrier;
/** Smart pointer to a simgrid::s4u::Barrier */
XBT_PUBLIC void intrusive_ptr_add_ref(Comm* c);
class ConditionVariable;
-/** Smart pointer to a simgrid::s4u::ConditionVariable */
+/** @beginrst
+ * Smart pointer to a :cpp:type:`simgrid::s4u::ConditionVariable`
+ * @endrst
+ */
typedef boost::intrusive_ptr<ConditionVariable> ConditionVariablePtr;
-XBT_PUBLIC void intrusive_ptr_release(ConditionVariable* c);
-XBT_PUBLIC void intrusive_ptr_add_ref(ConditionVariable* c);
+XBT_PUBLIC void intrusive_ptr_release(const ConditionVariable* c);
+XBT_PUBLIC void intrusive_ptr_add_ref(const ConditionVariable* c);
class Engine;
class Mailbox;
class Mutex;
-XBT_PUBLIC void intrusive_ptr_release(Mutex* m);
-XBT_PUBLIC void intrusive_ptr_add_ref(Mutex* m);
-/** Smart pointer to a simgrid::s4u::Mutex */
+XBT_PUBLIC void intrusive_ptr_release(const Mutex* m);
+XBT_PUBLIC void intrusive_ptr_add_ref(const Mutex* m);
+/**
+ * @beginrst
+ * Smart pointer to a :cpp:type:`simgrid::s4u::Mutex`
+ * @endrst
+ */
typedef boost::intrusive_ptr<Mutex> MutexPtr;
class NetZone;
#endif
+/** Pointer to a SimGrid barrier object */
typedef s4u_Barrier* sg_bar_t;
+/** Constant pointer to a SimGrid barrier object */
+typedef const s4u_Barrier* const_sg_bar_t;
typedef s4u_ConditionVariable* sg_cond_t;
+typedef const s4u_ConditionVariable* const_sg_cond_t;
typedef s4u_Mutex* sg_mutex_t;
+typedef const s4u_Mutex* const_sg_mutex_t;
typedef s4u_Semaphore* sg_sem_t;
+typedef const s4u_Semaphore* const_sg_sem_t;
typedef s4u_NetZone* sg_netzone_t;
+typedef const s4u_NetZone* const_sg_netzone_t;
typedef s4u_Host* sg_host_t;
+typedef const s4u_Host* const_sg_host_t;
typedef s4u_Link* sg_link_t;
+typedef const s4u_Link* const_sg_link_t;
typedef s4u_Disk* sg_disk_t;
+typedef const s4u_Disk* const_sg_disk_t;
typedef s4u_Storage* sg_storage_t;
+typedef const s4u_Storage* const_sg_storage_t;
typedef s4u_File* sg_file_t;
+typedef const s4u_File* const_sg_file_t;
typedef s4u_VM* sg_vm_t;
+typedef const s4u_VM* const_sg_vm_t;
typedef s4u_Actor* sg_actor_t;
typedef const s4u_Actor* const_sg_actor_t;
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
XBT_PUBLIC xbt_dynar_t sg_hosts_as_dynar();
XBT_PUBLIC size_t sg_host_extension_create(void (*deleter)(void*));
-XBT_PUBLIC void* sg_host_extension_get(sg_host_t host, size_t rank);
+XBT_PUBLIC void* sg_host_extension_get(const_sg_host_t host, size_t rank);
/** @brief Finds a sg_host_t using its name.
*
XBT_PUBLIC sg_host_t sg_host_by_name(const char* name);
/** @brief Return the name of the #sg_host_t. */
-XBT_PUBLIC const char* sg_host_get_name(sg_host_t host);
+XBT_PUBLIC const char* sg_host_get_name(const_sg_host_t host);
// ========== User Data ==============
/** @brief Return the user data of a #sg_host_t.
*
* This functions returns the user data associated to @a host if any.
*/
-XBT_PUBLIC void* sg_host_data(sg_host_t host);
+XBT_PUBLIC void* sg_host_data(const_sg_host_t host);
XBT_ATTRIB_DEPRECATED_v328("Please use sg_host_data()") XBT_PUBLIC void* sg_host_user(sg_host_t host);
/** @brief Set the user data of a #sg_host_t.
*
* @param host a host
* @return a dynar containing all storages (name) attached to the host
*/
-XBT_PUBLIC xbt_dynar_t sg_host_get_attached_storage_list(sg_host_t host);
+XBT_PUBLIC xbt_dynar_t sg_host_get_attached_storage_list(const_sg_host_t host);
// =========== user-level functions ===============
/** @brief Return the speed of the processor (in flop/s), regardless of the current load on the machine. */
-XBT_PUBLIC double sg_host_speed(sg_host_t host);
-XBT_PUBLIC double sg_host_get_pstate_speed(sg_host_t host, int pstate_index);
+XBT_PUBLIC double sg_host_speed(const_sg_host_t host);
+XBT_PUBLIC double sg_host_get_pstate_speed(const_sg_host_t host, int pstate_index);
-XBT_PUBLIC double sg_host_get_available_speed(sg_host_t host);
+XBT_PUBLIC double sg_host_get_available_speed(const_sg_host_t host);
-XBT_PUBLIC int sg_host_core_count(sg_host_t host);
+XBT_PUBLIC int sg_host_core_count(const_sg_host_t host);
/** @brief Returns the current computation load (in flops per second).
* @param host a host
*/
-XBT_PUBLIC double sg_host_load(sg_host_t host);
+XBT_PUBLIC double sg_host_load(const_sg_host_t host);
/** @brief Return the location on which the current process is running. */
XBT_PUBLIC sg_host_t sg_host_self();
XBT_PUBLIC const char* sg_host_self_get_name();
-/** @brief Return the total count of pstates defined for a host. See also @ref plugin_energy.
+/** @brief Return the total count of pstates defined for a host.
+ *
+ * @beginrst
+ * See also :ref:`plugin_host_energy`.
+ * @endrst
*
* @param host host to test
*/
-XBT_PUBLIC int sg_host_get_nb_pstates(sg_host_t host);
+XBT_PUBLIC int sg_host_get_nb_pstates(const_sg_host_t host);
-XBT_PUBLIC int sg_host_get_pstate(sg_host_t host);
+XBT_PUBLIC int sg_host_get_pstate(const_sg_host_t host);
XBT_PUBLIC void sg_host_set_pstate(sg_host_t host, int pstate);
XBT_PUBLIC void sg_host_turn_on(sg_host_t host);
XBT_PUBLIC void sg_host_turn_off(sg_host_t host);
-XBT_PUBLIC int sg_host_is_on(sg_host_t host);
+XBT_PUBLIC int sg_host_is_on(const_sg_host_t host);
/** @ingroup m_host_management
* @brief Returns a xbt_dict_t consisting of the list of properties assigned to this host
* @param host a host
* @return a dict containing the properties
*/
-XBT_PUBLIC xbt_dict_t sg_host_get_properties(sg_host_t host);
+XBT_PUBLIC xbt_dict_t sg_host_get_properties(const_sg_host_t host);
/** @ingroup m_host_management
* @brief Returns the value of a given host property
* @param name a property name
* @return value of a property (or nullptr if property not set)
*/
-XBT_PUBLIC const char* sg_host_get_property_value(sg_host_t host, const char* name);
+XBT_PUBLIC const char* sg_host_get_property_value(const_sg_host_t host, const char* name);
/** @ingroup m_host_management
* @brief Change the value of a given host property
*/
XBT_PUBLIC void sg_host_set_property_value(sg_host_t host, const char* name, const char* value);
-XBT_PUBLIC void sg_host_route(sg_host_t from, sg_host_t to, xbt_dynar_t links);
-XBT_PUBLIC double sg_host_route_latency(sg_host_t from, sg_host_t to);
-XBT_PUBLIC double sg_host_route_bandwidth(sg_host_t from, sg_host_t to);
+XBT_PUBLIC void sg_host_route(const_sg_host_t from, const_sg_host_t to, xbt_dynar_t links);
+XBT_PUBLIC double sg_host_route_latency(const_sg_host_t from, const_sg_host_t to);
+XBT_PUBLIC double sg_host_route_bandwidth(const_sg_host_t from, const_sg_host_t to);
void sg_host_send_to(sg_host_t from, sg_host_t to, double byte_amount);
-XBT_PUBLIC void sg_host_dump(sg_host_t ws);
+XBT_PUBLIC void sg_host_dump(const_sg_host_t ws);
-XBT_PUBLIC void sg_host_get_actor_list(sg_host_t host, xbt_dynar_t whereto);
+XBT_PUBLIC void sg_host_get_actor_list(const_sg_host_t host, xbt_dynar_t whereto);
SG_END_DECL
#endif /* SIMGRID_HOST_H_ */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
XBT_PUBLIC void TRACE_host_push_state(const char* host, const char* state, const char* value);
XBT_PUBLIC void TRACE_host_pop_state(const char* host, const char* state);
-/* for creating graph configuration files for Viva by hand */
-XBT_PUBLIC xbt_dynar_t TRACE_get_node_types();
-XBT_PUBLIC xbt_dynar_t TRACE_get_edge_types();
-
SG_END_DECL
#endif /* INSTR_H_ */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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 <simgrid/jedule/jedule_events.hpp>
#include <simgrid/jedule/jedule_platform.hpp>
+#include <simgrid/s4u/Engine.hpp>
#include <cstdio>
namespace jedule{
class XBT_PUBLIC Jedule {
-public:
- explicit Jedule(const std::string& name) : root_container_(name) {}
+ std::unordered_map<char*, char*> meta_info_;
std::vector<Event> event_set_;
Container root_container_;
+
+public:
+ explicit Jedule(const std::string& name) : root_container_(name)
+ {
+ root_container_.create_hierarchy(s4u::Engine::get_instance()->get_netzone_root());
+ }
void add_meta_info(char* key, char* value);
+ void add_event(const Event& event);
void cleanup_output();
void write_output(FILE* file);
-
-private:
- std::unordered_map<char*, char*> meta_info_;
};
-}
-}
+} // namespace jedule
+} // namespace simgrid
typedef simgrid::jedule::Jedule *jedule_t;
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
: name_(name), start_time_(start_time), end_time_(end_time), type_(type)
{
}
- void add_characteristic(char* characteristic);
+ void add_characteristic(const char* characteristic);
void add_resources(const std::vector<sg_host_t>& host_selection);
void add_info(char* key, char* value);
void print(FILE* file) const;
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
#define JED_SIMGRID_PLATFORM_H_
#include <simgrid/forward.h>
-#include <xbt/dynar.h>
#include <memory>
#include <string>
namespace simgrid {
namespace jedule{
class XBT_PUBLIC Container {
+ int last_id_ = 0;
+ std::string name;
+ std::unordered_map<const char*, unsigned int> name2id;
+ Container* parent_ = nullptr;
+ std::vector<std::unique_ptr<Container>> children_;
+ std::vector<sg_host_t> resource_list;
+
public:
explicit Container(const std::string& name);
Container(const Container&) = delete;
Container& operator=(const Container&) = delete;
-private:
- int last_id_;
- int is_lowest_ = 0;
+ const char* get_cname() const { return name.c_str(); }
+ void set_parent(Container* parent) { parent_ = parent; }
+ bool has_children() { return not children_.empty(); }
+ int get_child_position(const Container* child) const;
+ unsigned int get_id_by_name(const char* name) { return name2id.at(name); }
-public:
- std::string name;
- std::unordered_map<const char*, unsigned int> name2id;
- Container *parent = nullptr;
- std::vector<std::unique_ptr<Container>> children;
- std::vector<sg_host_t> resource_list;
void add_child(Container* child);
void add_resources(std::vector<sg_host_t> hosts);
- void create_hierarchy(sg_netzone_t from_as);
+ void create_hierarchy(const_sg_netzone_t from_as);
std::vector<int> get_hierarchy();
std::string get_hierarchy_as_string();
void print(FILE *file);
Container *parent;
};
-}
-}
+} // namespace jedule
+} // namespace simgrid
typedef simgrid::jedule::Container * jed_container_t;
void get_resource_selection_by_hosts(std::vector<simgrid::jedule::Subset>& subset_list,
const std::vector<sg_host_t>& host_list);
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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 <simgrid/simdag.h>
SG_BEGIN_DECL
-XBT_PUBLIC void jedule_log_sd_event(SD_task_t task);
+XBT_PUBLIC void jedule_log_sd_event(const_SD_task_t task);
XBT_PUBLIC void jedule_sd_init(void);
XBT_PUBLIC void jedule_sd_exit(void);
XBT_PUBLIC void jedule_sd_dump(const char* filename);
-/* Copyright (c) 2016-2019. The SimGrid Team.
+/* Copyright (c) 2016-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
template<class T>
class FutureState : public FutureStateBase {
public:
-
void set_value(T value)
{
if (this->get_status() != FutureStatus::not_ready)
template<class T>
class Promise {
public:
- Promise() : state_(std::make_shared<FutureState<T>>()) {}
+ Promise() = default;
explicit Promise(std::shared_ptr<FutureState<T>> state) : state_(std::move(state)) {}
// Move type
Promise(Promise const&) = delete;
Promise& operator=(Promise const&) = delete;
- Promise(Promise&& that) :
- state_(std::move(that.state_)), future_get_(that.future_get_)
- {
- that.future_get_ = false;
- }
+ Promise(Promise&& that) : state_(std::move(that.state_)) { std::swap(future_get_, that.future_get_); }
Promise& operator=(Promise&& that)
{
}
private:
- std::shared_ptr<FutureState<T>> state_;
+ std::shared_ptr<FutureState<T>> state_{new FutureState<T>()};
bool future_get_ = false;
};
template<>
class Promise<void> {
public:
- Promise() : state_(std::make_shared<FutureState<void>>()) {}
+ Promise() = default;
explicit Promise(std::shared_ptr<FutureState<void>> state) : state_(std::move(state)) {}
~Promise()
{
// Move type
Promise(Promise const&) = delete;
Promise& operator=(Promise const&) = delete;
- Promise(Promise&& that) :
- state_(std::move(that.state_)), future_get_(that.future_get_)
- {
- that.future_get_ = false;
- }
+ Promise(Promise&& that) : state_(std::move(that.state_)) { std::swap(future_get_, that.future_get_); }
Promise& operator=(Promise&& that)
{
this->state_ = std::move(that.state_);
}
private:
- std::shared_ptr<FutureState<void>> state_;
+ std::shared_ptr<FutureState<void>> state_{new FutureState<void>()};
bool future_get_ = false;
};
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
namespace kernel {
namespace resource {
-typedef std::pair<double, simgrid::kernel::resource::Action*> heap_element_type;
+typedef std::pair<double, 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;
-typedef std::pair<double, simgrid::kernel::resource::Action*> heap_element_type;
+typedef std::pair<double, Action*> heap_element_type;
class XBT_PUBLIC ActionHeap : public heap_type {
friend Action;
/** @brief Get the state set in which the action is */
StateSet* get_state_set() const { return state_set_; };
- simgrid::kernel::resource::Model* get_model() const { return model_; }
+ Model* get_model() const { return model_; }
private:
StateSet* state_set_;
std::string category_; /**< tracing category for categorized resource utilization monitoring */
double cost_;
- simgrid::kernel::resource::Model* model_;
+ Model* model_;
void* data_ = nullptr; /**< for your convenience */
activity::ActivityImpl* activity_ = nullptr;
/* LMM */
- double last_update_ = 0;
- double last_value_ = 0;
- kernel::lmm::Variable* variable_ = nullptr;
+ double last_update_ = 0;
+ double last_value_ = 0;
+ lmm::Variable* variable_ = nullptr;
ActionHeap::Type type_ = ActionHeap::Type::unset;
boost::optional<ActionHeap::handle_type> heap_hook_ = boost::none;
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
virtual ~Model();
+ bool is_update_lazy() { return update_algorithm_ == UpdateAlgo::LAZY; }
+
/** @brief Get the set of [actions](@ref Action) in *inited* state */
Action::StateSet* get_inited_action_set() { return &inited_action_set_; }
void set_maxmin_system(lmm::System* system);
/** @brief Get the update algorithm of the current Model */
- UpdateAlgo get_update_algorithm() const { return update_algorithm_; }
+ XBT_ATTRIB_DEPRECATED_v329("Please use is_update_lazy()") UpdateAlgo get_update_algorithm() const
+ {
+ return update_algorithm_;
+ }
/** @brief Get Action heap */
ActionHeap& get_action_heap() { return action_heap_; }
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
* @details This is the ancestor class of every resources in SimGrid, such as links, CPU or storage
*/
class XBT_PUBLIC Resource {
+ std::string name_;
+ Model* model_;
+ bool is_on_ = true;
+
+ lmm::Constraint* const constraint_;
+
+protected:
+ struct Metric {
+ double peak; /**< The peak of the metric, ie its max value */
+ double scale; /**< Current availability of the metric according to the profiles, in [0,1] */
+ profile::Event* event; /**< The associated profile event associated to the metric */
+ };
+ profile::Event* state_event_ = nullptr;
+
public:
/**
* @brief Constructor of LMM Resources
{
}
- virtual ~Resource();
+ virtual ~Resource() = default;
/** @brief Get the Model of the current Resource */
Model* get_model() const { return model_; }
/** @brief setup the profile file with states events (ON or OFF). The profile must contain boolean values. */
virtual void set_state_profile(profile::Profile* profile);
-private:
- std::string name_;
- Model* model_;
- bool is_on_ = true;
-
-public: /* LMM */
/** @brief Get the lmm constraint associated to this Resource if it is part of a LMM component (or null if none) */
lmm::Constraint* get_constraint() const { return constraint_; }
-
-private:
- kernel::lmm::Constraint* const constraint_;
-
-public:
- profile::Event* state_event_ = nullptr;
-
-protected:
- struct Metric {
- double peak; /**< The peak of the metric, ie its max value */
- double scale; /**< Current availability of the metric according to the profiles, in [0,1] */
- profile::Event* event; /**< The associated profile event associated to the metric */
- };
};
} // namespace resource
} // namespace kernel
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
explicit ClusterZone(NetZoneImpl* father, const std::string& name, resource::NetworkModel* netmodel);
void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override;
- void get_graph(xbt_graph_t graph, std::map<std::string, xbt_node_t>* nodes,
+ void get_graph(const s_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, unsigned int position);
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
* long path resolution times.
*/
class XBT_PRIVATE DijkstraZone : public RoutedZone {
-public:
- DijkstraZone(NetZoneImpl* father, const std::string& name, resource::NetworkModel* netmodel, bool cached);
- DijkstraZone(const DijkstraZone&) = delete;
- DijkstraZone& operator=(const DijkstraZone&) = delete;
+private:
+ static void route_graph_delete(xbt_graph_t);
- ~DijkstraZone() override;
+ std::unique_ptr<s_xbt_graph_t, decltype(&DijkstraZone::route_graph_delete)> route_graph_{
+ xbt_graph_new_graph(1, nullptr), &DijkstraZone::route_graph_delete};
+ std::map<int, xbt_node_t> graph_node_map_;
+ bool cached_;
+ std::map<int, std::vector<int>> route_cache_;
-private:
xbt_node_t route_graph_new_node(int id);
xbt_node_t node_map_search(int id);
void new_edge(int src_id, int dst_id, RouteCreationArgs* e_route);
public:
+ DijkstraZone(NetZoneImpl* father, const std::string& name, resource::NetworkModel* netmodel, bool cached);
+
/* For each vertex (node) already in the graph,
* make sure it also has a loopback link; this loopback
* can potentially already be in the graph, and in that
void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat) override;
void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
std::vector<resource::LinkImpl*>& link_list, bool symmetrical) override;
-
- xbt_graph_t route_graph_ = nullptr; /* xbt_graph */
- std::map<int, xbt_node_t> graph_node_map_; /* map */
- bool cached_; /* cache mode */
- std::map<int, std::vector<int>> route_cache_; /* use in cache mode */
};
} // namespace routing
} // namespace kernel
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
/* There can't be route in an Empty zone */
}
- void get_graph(xbt_graph_t graph, std::map<std::string, xbt_node_t>* /*nodes*/,
+ void get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t>* /*nodes*/,
std::map<std::string, xbt_edge_t>* /*edges*/) override;
};
} // namespace routing
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
* instead of passing by an upper level switch.
*/
resource::LinkImpl* loopback;
- FatTreeNode(ClusterCreationArgs* cluster, int id, int level, int position);
+ FatTreeNode(const ClusterCreationArgs* cluster, int id, int level, int position);
};
/** @brief Link in a fat tree (@ref FatTreeZone).
*/
class FatTreeLink {
public:
- FatTreeLink(ClusterCreationArgs* cluster, FatTreeNode* source, FatTreeNode* destination);
+ FatTreeLink(const ClusterCreationArgs* cluster, FatTreeNode* source, FatTreeNode* destination);
/** Link going up in the tree */
resource::LinkImpl* up_link_;
/** Link going down in the tree */
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
private:
/* vars to compute the Floyd algorithm. */
- int* predecessor_table_;
- double* cost_table_;
- RouteCreationArgs** link_table_;
+ int* predecessor_table_ = nullptr;
+ double* cost_table_ = nullptr;
+ RouteCreationArgs** link_table_ = nullptr;
};
} // namespace routing
} // namespace kernel
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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 <simgrid/kernel/routing/NetZoneImpl.hpp>
namespace simgrid {
+
+extern template class XBT_PUBLIC xbt::Extendable<kernel::routing::NetPoint>;
+
namespace kernel {
namespace routing {
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
namespace simgrid {
namespace kernel {
namespace routing {
-class BypassRoute;
+
+class BypassRoute {
+public:
+ explicit BypassRoute(NetPoint* gwSrc, NetPoint* gwDst) : gw_src(gwSrc), gw_dst(gwDst) {}
+ NetPoint* gw_src;
+ NetPoint* gw_dst;
+ std::vector<resource::LinkImpl*> links;
+};
/** @ingroup ROUTING_API
* @brief Private implementation of the Networking Zones
*/
class XBT_PUBLIC NetZoneImpl : public xbt::PropertyHolder {
friend EngineImpl; // it destroys netRoot_
+ s4u::NetZone piface_;
+
+ // our content, as known to our graph routing algorithm (maps vertex_id -> vertex)
+ std::vector<kernel::routing::NetPoint*> vertices_;
+
+ NetZoneImpl* father_ = nullptr;
+ std::vector<NetZoneImpl*> children_; // sub-netzones
+ std::string name_;
+ bool sealed_ = false; // We cannot add more content when sealed
+
+ std::map<std::pair<NetPoint*, NetPoint*>, BypassRoute*> bypass_routes_; // src x dst -> route
+ routing::NetPoint* netpoint_ = nullptr; // Our representative in the father NetZone
protected:
explicit NetZoneImpl(NetZoneImpl* father, const std::string& name, resource::NetworkModel* network_model);
NetZoneImpl& operator=(const NetZoneImpl&) = delete;
virtual ~NetZoneImpl();
-public:
- s4u::NetZone* get_iface() { return &piface_; }
-
- /** @brief Make a host within that NetZone */
- s4u::Host* create_host(const std::string& name, const std::vector<double>& speed_per_pstate, int core_count,
- const std::map<std::string, std::string>* props);
- /** @brief Creates a new route in this NetZone */
- virtual void add_bypass_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
- std::vector<resource::LinkImpl*>& link_list, bool symmetrical);
-
- /** @brief Seal your netzone once you're done adding content, and before routing stuff through it */
- virtual void seal();
- virtual int add_component(kernel::routing::NetPoint* elm); /* A host, a router or a netzone, whatever */
- virtual void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
- kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
- std::vector<kernel::resource::LinkImpl*>& link_list, bool symmetrical);
-
-protected:
/**
* @brief Probe the routing path between two points that are local to the called NetZone.
*
/* OUT */ std::vector<resource::LinkImpl*>& links, double* latency);
public:
- resource::NetworkModel* network_model_;
-
-private:
- s4u::NetZone piface_;
-
- // our content, as known to our graph routing algorithm (maps vertex_id -> vertex)
- std::vector<kernel::routing::NetPoint*> vertices_;
+ enum class RoutingMode {
+ unset = 0, /**< Undefined type */
+ base, /**< Base case: use simple link lists for routing */
+ recursive /**< Recursive case: also return gateway information */
+ };
- NetZoneImpl* father_ = nullptr;
+ /* FIXME: protect the following fields once the construction madness is sorted out */
+ RoutingMode hierarchy_ = RoutingMode::unset;
- std::vector<NetZoneImpl*> children_; // sub-netzones
+ resource::NetworkModel* network_model_;
-public:
+ s4u::NetZone* get_iface() { return &piface_; }
unsigned int get_table_size() { return vertices_.size(); }
std::vector<kernel::routing::NetPoint*> get_vertices() { return vertices_; }
-
- NetZoneImpl* get_father();
-
- std::vector<NetZoneImpl*>* get_children(); // Sub netzones
-
-private:
- std::string name_;
- bool sealed_ = false; // We cannot add more content when sealed
-
-public:
+ NetZoneImpl* get_father() { return father_; }
+ /** @brief Returns the list of direct children (no grand-children). This returns the internal data, no copy.
+ * Don't mess with it.*/
+ std::vector<NetZoneImpl*>* get_children() { return &children_; }
/** @brief Retrieves the name of that netzone as a C++ string */
const std::string& get_name() const { return name_; }
/** @brief Retrieves the name of that netzone as a C string */
- const char* get_cname() const;
+ const char* get_cname() const { return name_.c_str(); };
std::vector<s4u::Host*> get_all_hosts();
int get_host_count();
+ /** @brief Make a host within that NetZone */
+ s4u::Host* create_host(const std::string& name, const std::vector<double>& speed_per_pstate, int core_count,
+ const std::map<std::string, std::string>* props);
+ /** @brief Creates a new route in this NetZone */
+ virtual void add_bypass_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
+ std::vector<resource::LinkImpl*>& link_list, bool symmetrical);
+
+ /** @brief Seal your netzone once you're done adding content, and before routing stuff through it */
+ virtual void seal() { sealed_ = true; };
+ virtual int add_component(kernel::routing::NetPoint* elm); /* A host, a router or a netzone, whatever */
+ virtual void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
+ kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
+ std::vector<kernel::resource::LinkImpl*>& link_list, bool symmetrical);
+
/* @brief get the route between two nodes in the full platform
*
* @param src where from
static void get_global_route(routing::NetPoint* src, routing::NetPoint* dst,
/* OUT */ std::vector<resource::LinkImpl*>& links, double* latency);
- virtual void get_graph(xbt_graph_t graph, std::map<std::string, xbt_node_t>* nodes,
+ virtual void get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t>* nodes,
std::map<std::string, xbt_edge_t>* edges) = 0;
- enum class RoutingMode {
- unset = 0, /**< Undefined type */
- base, /**< Base case: use simple link lists for routing */
- recursive /**< Recursive case: also return gateway information */
- };
- /* FIXME: protect the following fields once the construction madness is sorted out */
- RoutingMode hierarchy_ = RoutingMode::unset;
-
-private:
- std::map<std::pair<NetPoint*, NetPoint*>, BypassRoute*> bypass_routes_; // src x dst -> route
- routing::NetPoint* netpoint_ = nullptr; // Our representative in the father NetZone
};
} // namespace routing
} // namespace kernel
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
public:
explicit RoutedZone(NetZoneImpl* father, const std::string& name, resource::NetworkModel* netmodel);
- void get_graph(xbt_graph_t graph, std::map<std::string, xbt_node_t>* nodes,
+ void get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t>* nodes,
std::map<std::string, xbt_edge_t>* edges) override;
protected:
bool symmetrical, bool change_order);
void get_route_check_params(NetPoint* src, NetPoint* dst);
void add_route_check_params(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
- std::vector<resource::LinkImpl*>& link_list, bool symmetrical);
+ const std::vector<resource::LinkImpl*>& link_list, bool symmetrical);
};
} // namespace routing
} // namespace kernel
} // namespace simgrid
-XBT_PRIVATE xbt_node_t new_xbt_graph_node(xbt_graph_t graph, const char* name,
+XBT_PRIVATE xbt_node_t new_xbt_graph_node(const s_xbt_graph_t* graph, const char* name,
std::map<std::string, xbt_node_t>* nodes);
-XBT_PRIVATE xbt_edge_t new_xbt_graph_edge(xbt_graph_t graph, xbt_node_t s, xbt_node_t d,
+XBT_PRIVATE xbt_edge_t new_xbt_graph_edge(const s_xbt_graph_t* graph, xbt_node_t s, xbt_node_t d,
std::map<std::string, xbt_edge_t>* edges);
#endif /* SIMGRID_ROUTING_GENERIC_HPP_ */
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
namespace vivaldi {
class XBT_PRIVATE Coords {
public:
- static simgrid::xbt::Extension<NetPoint, Coords> EXTENSION_ID;
+ static xbt::Extension<NetPoint, Coords> EXTENSION_ID;
explicit Coords(NetPoint* host, const std::string& str);
virtual ~Coords() = default;
/* Public interface to the Link datatype */
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
/* C interface */
SG_BEGIN_DECL
-XBT_PUBLIC const char* sg_link_name(sg_link_t link);
+XBT_PUBLIC const char* sg_link_name(const_sg_link_t link);
XBT_PUBLIC sg_link_t sg_link_by_name(const char* name);
-XBT_PUBLIC int sg_link_is_shared(sg_link_t link);
-XBT_PUBLIC double sg_link_bandwidth(sg_link_t link);
-XBT_PUBLIC double sg_link_latency(sg_link_t link);
-XBT_PUBLIC void* sg_link_data(sg_link_t link);
+XBT_PUBLIC int sg_link_is_shared(const_sg_link_t link);
+XBT_PUBLIC double sg_link_bandwidth(const_sg_link_t link);
+XBT_PUBLIC double sg_link_latency(const_sg_link_t link);
+XBT_PUBLIC void* sg_link_data(const_sg_link_t link);
XBT_PUBLIC void sg_link_data_set(sg_link_t link, void* data);
XBT_PUBLIC int sg_link_count();
XBT_PUBLIC sg_link_t* sg_link_list();
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
/* simgrid/modelchecker.h - Formal Verification made possible in SimGrid */
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
}
}
typedef simgrid::msg::Comm sg_msg_Comm;
-/** @brief Task datatype.
- *
- * Since most scheduling algorithms rely on a concept of task that can be either <em>computed</em> locally or
- * <em>transferred</em> on another processor, it seems to be the right level of abstraction for our purposes.
- * A <em>task</em> may then be defined by a <em>computing amount</em>, a <em>message size</em> and
- * some <em>private data</em>.
- */
-typedef simgrid::msg::Task* msg_task_t;
+typedef simgrid::msg::Task sg_msg_Task;
#else
typedef struct msg_Comm sg_msg_Comm;
-typedef struct msg_Task* msg_task_t;
+typedef struct msg_Task sg_msg_Task;
#endif
#ifdef __cplusplus
typedef sg_netzone_t msg_netzone_t;
XBT_PUBLIC msg_netzone_t MSG_zone_get_root();
-XBT_PUBLIC const char* MSG_zone_get_name(msg_netzone_t zone);
+XBT_PUBLIC const char* MSG_zone_get_name(const_sg_netzone_t zone);
XBT_PUBLIC msg_netzone_t MSG_zone_get_by_name(const char* name);
-XBT_PUBLIC void MSG_zone_get_sons(msg_netzone_t zone, xbt_dict_t whereto);
-XBT_PUBLIC const char* MSG_zone_get_property_value(msg_netzone_t zone, const char* name);
-XBT_PUBLIC void MSG_zone_set_property_value(msg_netzone_t zone, const char* name, char* value);
-XBT_PUBLIC void MSG_zone_get_hosts(msg_netzone_t zone, xbt_dynar_t whereto);
+XBT_PUBLIC void MSG_zone_get_sons(const_sg_netzone_t zone, xbt_dict_t whereto);
+XBT_PUBLIC const char* MSG_zone_get_property_value(const_sg_netzone_t zone, const char* name);
+XBT_PUBLIC void MSG_zone_set_property_value(msg_netzone_t zone, const char* name, const char* value);
+XBT_PUBLIC void MSG_zone_get_hosts(const_sg_netzone_t zone, xbt_dynar_t whereto);
/* ******************************** Hosts ************************************ */
/** @brief Host datatype.
XBT_PUBLIC xbt_dynar_t MSG_hosts_as_dynar();
/** @brief Returns the name of this host */
-XBT_PUBLIC const char* MSG_host_get_name(sg_host_t host);
+XBT_PUBLIC const char* MSG_host_get_name(const_sg_host_t host);
/** @brief Returns the user data of this host */
-XBT_PUBLIC void* MSG_host_get_data(sg_host_t host);
+XBT_PUBLIC void* MSG_host_get_data(const_sg_host_t host);
/** @brief Sets the user data of this host */
XBT_PUBLIC void MSG_host_set_data(sg_host_t host, void* data);
XBT_PUBLIC xbt_dict_t MSG_host_get_mounted_storage_list(sg_host_t host);
-XBT_PUBLIC xbt_dynar_t MSG_host_get_attached_storage_lists(sg_host_t host);
-XBT_PUBLIC double MSG_host_get_speed(sg_host_t host);
-XBT_PUBLIC double MSG_host_get_power_peak_at(sg_host_t host, int pstate_index);
-XBT_PUBLIC int MSG_host_get_core_number(sg_host_t host);
-XBT_PUBLIC int MSG_host_get_nb_pstates(sg_host_t host);
-XBT_PUBLIC int MSG_host_get_pstate(sg_host_t host);
+XBT_PUBLIC xbt_dynar_t MSG_host_get_attached_storage_lists(const_sg_host_t host);
+XBT_PUBLIC double MSG_host_get_speed(const_sg_host_t host);
+XBT_PUBLIC double MSG_host_get_power_peak_at(const_sg_host_t host, int pstate_index);
+XBT_PUBLIC int MSG_host_get_core_number(const_sg_host_t host);
+XBT_PUBLIC int MSG_host_get_nb_pstates(const_sg_host_t host);
+XBT_PUBLIC int MSG_host_get_pstate(const_sg_host_t host);
XBT_PUBLIC void MSG_host_set_pstate(sg_host_t host, int pstate);
/** @brief Start the host if it is off
*
- * See also #MSG_host_is_on() to test the current state of the host and @ref SURF_plugin_energy
+ * @beginrst
+ * See also :cpp:func:`MSG_host_is_on()` to test the current state of the host, and :ref:`plugin_host_energy`
* for more info on DVFS.
+ * @endrst
*/
XBT_PUBLIC void MSG_host_on(sg_host_t h);
/** @brief Stop the host if it is on
*
- * See also MSG_host_is_on() to test the current state of the host and @ref SURF_plugin_energy
+ * @beginrst
+ * See also :cpp:func:`MSG_host_is_on()` to test the current state of the host, and :ref:`plugin_host_energy`
* for more info on DVFS.
+ * @endrst
*/
XBT_PUBLIC void MSG_host_off(sg_host_t h);
-XBT_PUBLIC int MSG_host_is_on(sg_host_t h);
-XBT_PUBLIC xbt_dict_t MSG_host_get_properties(sg_host_t host);
-XBT_PUBLIC const char* MSG_host_get_property_value(sg_host_t host, const char* name);
+XBT_PUBLIC int MSG_host_is_on(const_sg_host_t h);
+XBT_PUBLIC xbt_dict_t MSG_host_get_properties(const_sg_host_t host);
+XBT_PUBLIC const char* MSG_host_get_property_value(const_sg_host_t host, const char* name);
XBT_PUBLIC void MSG_host_set_property_value(sg_host_t host, const char* name, const char* value);
-XBT_PUBLIC void MSG_host_get_process_list(sg_host_t host, xbt_dynar_t whereto);
+XBT_PUBLIC void MSG_host_get_process_list(const_sg_host_t host, xbt_dynar_t whereto);
/** @brief Return the location on which the current process is executed */
XBT_PUBLIC sg_host_t MSG_host_self();
-XBT_PUBLIC double MSG_host_get_load(sg_host_t host);
+XBT_PUBLIC double MSG_host_get_load(const_sg_host_t host);
/* ******************************** VMs ************************************* */
typedef sg_vm_t msg_vm_t;
XBT_PUBLIC int MSG_vm_is_running(msg_vm_t vm);
XBT_PUBLIC int MSG_vm_is_suspended(msg_vm_t vm);
-XBT_PUBLIC const char* MSG_vm_get_name(msg_vm_t vm);
+XBT_PUBLIC const char* MSG_vm_get_name(const_sg_vm_t vm);
XBT_PUBLIC void MSG_vm_set_ramsize(msg_vm_t vm, size_t size);
-XBT_PUBLIC size_t MSG_vm_get_ramsize(msg_vm_t vm);
-XBT_PUBLIC msg_host_t MSG_vm_get_pm(msg_vm_t vm);
+XBT_PUBLIC size_t MSG_vm_get_ramsize(const_sg_vm_t vm);
+XBT_PUBLIC msg_host_t MSG_vm_get_pm(const_sg_vm_t vm);
XBT_PUBLIC void MSG_vm_set_bound(msg_vm_t vm, double bound);
XBT_PUBLIC void MSG_vm_start(msg_vm_t vm);
/* ******************************** Storage ********************************* */
typedef sg_storage_t msg_storage_t;
-XBT_PUBLIC const char* MSG_storage_get_name(msg_storage_t storage);
+XBT_PUBLIC const char* MSG_storage_get_name(const_sg_storage_t storage);
XBT_PUBLIC msg_storage_t MSG_storage_get_by_name(const char* name);
-XBT_PUBLIC xbt_dict_t MSG_storage_get_properties(msg_storage_t storage);
+XBT_PUBLIC xbt_dict_t MSG_storage_get_properties(const_sg_storage_t storage);
XBT_PUBLIC void MSG_storage_set_property_value(msg_storage_t storage, const char* name, const char* value);
-XBT_PUBLIC const char* MSG_storage_get_property_value(msg_storage_t storage, const char* name);
+XBT_PUBLIC const char* MSG_storage_get_property_value(const_sg_storage_t storage, const char* name);
XBT_PUBLIC xbt_dynar_t MSG_storages_as_dynar();
XBT_PUBLIC void MSG_storage_set_data(msg_storage_t storage, void* data);
-XBT_PUBLIC void* MSG_storage_get_data(msg_storage_t storage);
-XBT_PUBLIC const char* MSG_storage_get_host(msg_storage_t storage);
+XBT_PUBLIC void* MSG_storage_get_data(const_sg_storage_t storage);
+XBT_PUBLIC const char* MSG_storage_get_host(const_sg_storage_t storage);
XBT_PUBLIC sg_size_t MSG_storage_read(msg_storage_t storage, sg_size_t size);
XBT_PUBLIC sg_size_t MSG_storage_write(msg_storage_t storage, sg_size_t size);
*/
typedef sg_actor_t msg_process_t;
-XBT_PUBLIC int MSG_process_get_PID(msg_process_t process);
-XBT_PUBLIC int MSG_process_get_PPID(msg_process_t process);
+XBT_PUBLIC int MSG_process_get_PID(const_sg_actor_t process);
+XBT_PUBLIC int MSG_process_get_PPID(const_sg_actor_t process);
/** @brief Return a process from its PID (or NULL if not found).
*
* Note that the PID are unique in the whole simulation, not only on a given host.
*/
XBT_PUBLIC sg_actor_t MSG_process_from_PID(int pid);
-XBT_PUBLIC const char* MSG_process_get_name(msg_process_t process);
-XBT_PUBLIC sg_host_t MSG_process_get_host(msg_process_t process);
+XBT_PUBLIC const char* MSG_process_get_name(const_sg_actor_t process);
+XBT_PUBLIC sg_host_t MSG_process_get_host(const_sg_actor_t process);
/*property handlers*/
-XBT_PUBLIC xbt_dict_t MSG_process_get_properties(msg_process_t process);
-XBT_PUBLIC const char* MSG_process_get_property_value(msg_process_t process, const char* name);
+XBT_PUBLIC xbt_dict_t MSG_process_get_properties(const_sg_actor_t process);
+XBT_PUBLIC const char* MSG_process_get_property_value(const_sg_actor_t process, const char* name);
XBT_PUBLIC void MSG_process_suspend(msg_process_t process);
XBT_PUBLIC void MSG_process_resume(msg_process_t process);
XBT_PUBLIC aid_t MSG_process_self_PID();
XBT_PUBLIC aid_t MSG_process_self_PPID();
XBT_PUBLIC const char* MSG_process_self_name();
-XBT_PUBLIC void MSG_process_ref(msg_process_t process);
-XBT_PUBLIC void MSG_process_unref(msg_process_t process);
+XBT_PUBLIC void MSG_process_ref(const_sg_actor_t process);
+XBT_PUBLIC void MSG_process_unref(const_sg_actor_t process);
/** @brief Object representing an ongoing communication between processes.
*
* \endrst
*/
typedef sg_msg_Comm* msg_comm_t;
+typedef const sg_msg_Comm* const_msg_comm_t;
+
+/** @brief Task datatype.
+ *
+ * Since most scheduling algorithms rely on a concept of task that can be either <em>computed</em> locally or
+ * <em>transferred</em> on another processor, it seems to be the right level of abstraction for our purposes.
+ * A <em>task</em> may then be defined by a <em>computing amount</em>, a <em>message size</em> and
+ * some <em>private data</em>.
+ */
+typedef sg_msg_Task* msg_task_t;
+typedef const sg_msg_Task* const_msg_task_t;
/* ******************************** Task ************************************ */
/************************** Global ******************************************/
/** @brief set a configuration variable
*
- * Do --help on any simgrid binary to see the list of currently existing configuration variables, and see Section @ref
- * options.
+ * @beginrst
+ * Do --help on any simgrid binary to see the list of currently existing configuration variables, and see Section
+ * :ref:`options`.
+ * @endrst
*
* Example:
* MSG_config("host/model","ptask_L07");
XBT_PUBLIC xbt_dynar_t MSG_processes_as_dynar();
XBT_PUBLIC int MSG_process_get_number();
-XBT_PUBLIC void* MSG_process_get_data(msg_process_t process);
+XBT_PUBLIC void* MSG_process_get_data(const_sg_actor_t process);
XBT_PUBLIC msg_error_t MSG_process_set_data(msg_process_t process, void* data);
XBT_PUBLIC void MSG_process_on_exit(int_f_int_pvoid_t fun, void* data);
XBT_PUBLIC msg_task_t MSG_task_create(const char* name, double flops_amount, double bytes_amount, void* data);
XBT_PUBLIC msg_task_t MSG_parallel_task_create(const char* name, int host_nb, const msg_host_t* host_list,
double* flops_amount, double* bytes_amount, void* data);
-XBT_PUBLIC void* MSG_task_get_data(msg_task_t task);
+XBT_PUBLIC void* MSG_task_get_data(const_msg_task_t task);
XBT_PUBLIC void MSG_task_set_data(msg_task_t task, void* data);
-XBT_PUBLIC msg_process_t MSG_task_get_sender(msg_task_t task);
-XBT_PUBLIC msg_host_t MSG_task_get_source(msg_task_t task);
-XBT_PUBLIC const char* MSG_task_get_name(msg_task_t task);
+XBT_PUBLIC msg_process_t MSG_task_get_sender(const_msg_task_t task);
+XBT_PUBLIC msg_host_t MSG_task_get_source(const_msg_task_t task);
+XBT_PUBLIC const char* MSG_task_get_name(const_msg_task_t task);
XBT_PUBLIC void MSG_task_set_name(msg_task_t task, const char* name);
XBT_PUBLIC msg_error_t MSG_task_cancel(msg_task_t task);
XBT_PUBLIC msg_error_t MSG_task_destroy(msg_task_t task);
XBT_PUBLIC void MSG_task_set_bound(msg_task_t task, double bound);
XBT_PUBLIC void MSG_task_set_flops_amount(msg_task_t task, double flops_amount);
-XBT_PUBLIC double MSG_task_get_flops_amount(msg_task_t task);
-XBT_PUBLIC double MSG_task_get_remaining_work_ratio(msg_task_t task);
+XBT_PUBLIC double MSG_task_get_flops_amount(const_msg_task_t task);
+XBT_PUBLIC double MSG_task_get_remaining_work_ratio(const_msg_task_t task);
XBT_PUBLIC void MSG_task_set_bytes_amount(msg_task_t task, double bytes_amount);
-XBT_PUBLIC double MSG_task_get_remaining_communication(msg_task_t task);
-XBT_PUBLIC double MSG_task_get_bytes_amount(msg_task_t task);
+XBT_PUBLIC double MSG_task_get_remaining_communication(const_msg_task_t task);
+XBT_PUBLIC double MSG_task_get_bytes_amount(const_msg_task_t task);
XBT_PUBLIC msg_error_t MSG_task_receive_with_timeout(msg_task_t* task, const char* alias, double timeout);
XBT_PUBLIC msg_comm_t MSG_task_irecv(msg_task_t* task, const char* alias);
XBT_PUBLIC msg_comm_t MSG_task_irecv_bounded(msg_task_t* task, const char* alias, double rate);
XBT_PUBLIC int MSG_comm_test(msg_comm_t comm);
-XBT_PUBLIC int MSG_comm_testany(xbt_dynar_t comms);
-XBT_PUBLIC void MSG_comm_destroy(msg_comm_t comm);
+XBT_PUBLIC int MSG_comm_testany(const_xbt_dynar_t comms);
+XBT_PUBLIC void MSG_comm_destroy(const_msg_comm_t comm);
XBT_PUBLIC msg_error_t MSG_comm_wait(msg_comm_t comm, double timeout);
XBT_PUBLIC void MSG_comm_waitall(msg_comm_t* comm, int nb_elem, double timeout);
-XBT_PUBLIC int MSG_comm_waitany(xbt_dynar_t comms);
-XBT_PUBLIC msg_task_t MSG_comm_get_task(msg_comm_t comm);
-XBT_PUBLIC msg_error_t MSG_comm_get_status(msg_comm_t comm);
+XBT_PUBLIC int MSG_comm_waitany(const_xbt_dynar_t comms);
+XBT_PUBLIC msg_task_t MSG_comm_get_task(const_msg_comm_t comm);
+XBT_PUBLIC msg_error_t MSG_comm_get_status(const_msg_comm_t comm);
/** @brief Check if there is a communication going on in a mailbox.
*
XBT_PUBLIC msg_error_t MSG_task_send_bounded(msg_task_t task, const char* alias, double rate);
XBT_PUBLIC int MSG_task_listen_from(const char* alias);
XBT_PUBLIC void MSG_task_set_category(msg_task_t task, const char* category);
-XBT_PUBLIC const char* MSG_task_get_category(msg_task_t task);
+XBT_PUBLIC const char* MSG_task_get_category(const_msg_task_t task);
/************************** Mailbox handling ************************************/
XBT_PUBLIC int MSG_sem_acquire_timeout(msg_sem_t sem, double timeout);
XBT_PUBLIC void MSG_sem_release(msg_sem_t sem);
XBT_PUBLIC int MSG_sem_get_capacity(msg_sem_t sem);
-XBT_PUBLIC void MSG_sem_destroy(msg_sem_t sem);
+XBT_PUBLIC void MSG_sem_destroy(const_sg_sem_t sem);
XBT_PUBLIC int MSG_sem_would_block(msg_sem_t sem);
/** @brief Opaque type representing a barrier identifier */
/** @brief Initializes a barrier, with count elements */
XBT_PUBLIC msg_bar_t MSG_barrier_init(unsigned int count);
/** @brief Destroys barrier */
-XBT_PUBLIC void MSG_barrier_destroy(msg_bar_t bar);
+XBT_PUBLIC void MSG_barrier_destroy(const_sg_bar_t bar);
/** @brief Performs a barrier already initialized */
XBT_PUBLIC int MSG_barrier_wait(msg_bar_t bar);
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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. */
XBT_PUBLIC void sg_mutex_lock(sg_mutex_t mutex);
XBT_PUBLIC void sg_mutex_unlock(sg_mutex_t mutex);
XBT_PUBLIC int sg_mutex_try_lock(sg_mutex_t mutex);
-XBT_PUBLIC void sg_mutex_destroy(sg_mutex_t mutex);
+XBT_PUBLIC void sg_mutex_destroy(const_sg_mutex_t mutex);
SG_END_DECL
-/* Copyright (c) 2017-2019. The SimGrid Team.
+/* Copyright (c) 2017-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
XBT_PUBLIC void sg_host_energy_plugin_init();
XBT_PUBLIC void sg_host_energy_update_all();
-XBT_PUBLIC double sg_host_get_consumed_energy(sg_host_t host);
-XBT_PUBLIC double sg_host_get_idle_consumption(sg_host_t host);
-XBT_PUBLIC double sg_host_get_idle_consumption_at(sg_host_t host, int pstate);
-XBT_PUBLIC double sg_host_get_wattmin_at(sg_host_t host, int pstate);
-XBT_PUBLIC double sg_host_get_wattmax_at(sg_host_t host, int pstate);
-XBT_PUBLIC double sg_host_get_power_range_slope_at(sg_host_t host, int pstate);
-XBT_PUBLIC double sg_host_get_current_consumption(sg_host_t host);
+XBT_PUBLIC double sg_host_get_consumed_energy(const_sg_host_t host);
+XBT_PUBLIC double sg_host_get_idle_consumption(const_sg_host_t host);
+XBT_PUBLIC double sg_host_get_idle_consumption_at(const_sg_host_t host, int pstate);
+XBT_PUBLIC double sg_host_get_wattmin_at(const_sg_host_t host, int pstate);
+XBT_PUBLIC double sg_host_get_wattmax_at(const_sg_host_t host, int pstate);
+XBT_PUBLIC double sg_host_get_power_range_slope_at(const_sg_host_t host, int pstate);
+XBT_PUBLIC double sg_host_get_current_consumption(const_sg_host_t host);
XBT_PUBLIC void sg_link_energy_plugin_init();
-XBT_PUBLIC double sg_link_get_consumed_energy(sg_link_t link);
+XBT_PUBLIC double sg_link_get_consumed_energy(const_sg_link_t link);
XBT_PUBLIC int sg_link_energy_is_inited();
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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 <map>
#include <memory>
#include <string>
-#endif
+#endif /* C++ */
// C interface
////////////////
XBT_PUBLIC sg_file_t sg_file_open(const char* fullpath, void* data);
XBT_PUBLIC sg_size_t sg_file_read(sg_file_t fd, sg_size_t size);
XBT_PUBLIC sg_size_t sg_file_write(sg_file_t fd, sg_size_t size);
-XBT_PUBLIC void sg_file_close(sg_file_t fd);
+XBT_PUBLIC void sg_file_close(const_sg_file_t fd);
XBT_PUBLIC const char* sg_file_get_name(sg_file_t fd);
XBT_PUBLIC sg_size_t sg_file_get_size(sg_file_t fd);
XBT_PUBLIC void sg_file_dump(sg_file_t fd);
-XBT_PUBLIC void* sg_file_get_data(sg_file_t fd);
+XBT_PUBLIC void* sg_file_get_data(const_sg_file_t fd);
XBT_PUBLIC void sg_file_set_data(sg_file_t fd, void* data);
XBT_PUBLIC void sg_file_seek(sg_file_t fd, sg_offset_t offset, int origin);
XBT_PUBLIC sg_size_t sg_file_tell(sg_file_t fd);
XBT_PUBLIC int sg_file_rcopy(sg_file_t file, sg_host_t host, const char* fullpath);
XBT_PUBLIC int sg_file_rmove(sg_file_t file, sg_host_t host, const char* fullpath);
-XBT_PUBLIC sg_size_t sg_disk_get_size_free(sg_disk_t d);
-XBT_PUBLIC sg_size_t sg_disk_get_size_used(sg_disk_t d);
-XBT_PUBLIC sg_size_t sg_disk_get_size(sg_disk_t d);
-XBT_PUBLIC const char* sg_disk_get_mount_point(sg_disk_t d);
+XBT_PUBLIC sg_size_t sg_disk_get_size_free(const_sg_disk_t d);
+XBT_PUBLIC sg_size_t sg_disk_get_size_used(const_sg_disk_t d);
+XBT_PUBLIC sg_size_t sg_disk_get_size(const_sg_disk_t d);
+XBT_PUBLIC const char* sg_disk_get_mount_point(const_sg_disk_t d);
-XBT_PUBLIC sg_size_t sg_storage_get_size_free(sg_storage_t st);
-XBT_PUBLIC sg_size_t sg_storage_get_size_used(sg_storage_t st);
-XBT_PUBLIC sg_size_t sg_storage_get_size(sg_storage_t st);
-XBT_PUBLIC xbt_dict_t sg_storage_get_content(sg_storage_t storage);
+XBT_PUBLIC sg_size_t sg_storage_get_size_free(const_sg_storage_t st);
+XBT_PUBLIC sg_size_t sg_storage_get_size_used(const_sg_storage_t st);
+XBT_PUBLIC sg_size_t sg_storage_get_size(const_sg_storage_t st);
+XBT_PUBLIC xbt_dict_t sg_storage_get_content(const_sg_storage_t storage);
XBT_PUBLIC xbt_dict_t sg_host_get_storage_content(sg_host_t host);
#ifdef __cplusplus
namespace simgrid {
+
+extern template class XBT_PUBLIC xbt::Extendable<s4u::File>;
+
namespace s4u {
/** @brief A simulated file
+ * @addtogroup Plugin_filesystem
*
* Used to simulate the time it takes to access to a file, but does not really store any information.
*
* For now, you cannot change the mountpoints programmatically, and must declare them from your platform file.
*/
class XBT_PUBLIC File : public xbt::Extendable<File> {
+ sg_size_t size_;
+ std::string path_;
+ std::string fullpath_;
+ sg_size_t current_position_ = SEEK_SET;
+ int desc_id = 0;
+ Disk* local_disk_ = nullptr;
+ Storage* local_storage_ = nullptr;
+ std::string mount_point_;
+
+ Storage* find_local_storage_on(Host* host);
+ Disk* find_local_disk_on(const Host* host);
+ sg_size_t write_on_storage(sg_size_t size, bool write_inside);
+ sg_size_t write_on_disk(sg_size_t size, bool write_inside);
+
public:
File(const std::string& fullpath, void* userdata);
File(const std::string& fullpath, sg_host_t host, void* userdata);
sg_size_t read(sg_size_t size);
/** Simulates a write action. Returns the size of data actually written. */
- sg_size_t write(sg_size_t size, int write_inside=0);
+ sg_size_t write(sg_size_t size, bool write_inside = false);
/** Allows to store user data on that host */
XBT_ATTRIB_DEPRECATED_v329("Please use set_data()") void set_userdata(void* data) { set_data(data); }
int unlink(); /** Remove a file from the contents of a disk */
void dump();
-
- int desc_id = 0;
- Disk* local_disk_ = nullptr;
- Storage* local_storage_ = nullptr;
- std::string mount_point_;
-
-private:
- sg_size_t size_;
- std::string path_;
- std::string fullpath_;
- sg_size_t current_position_ = SEEK_SET;
};
class XBT_PUBLIC FileSystemDiskExt {
+ std::unique_ptr<std::map<std::string, sg_size_t>> content_;
+ std::map<Host*, std::string> remote_mount_points_;
+ std::string mount_point_;
+ sg_size_t used_size_ = 0;
+ sg_size_t size_ = static_cast<sg_size_t>(500 * 1024) * 1024 * 1024;
+
public:
static simgrid::xbt::Extension<Disk, FileSystemDiskExt> EXTENSION_ID;
- explicit FileSystemDiskExt(Disk* ptr);
+ explicit FileSystemDiskExt(const Disk* ptr);
FileSystemDiskExt(const FileSystemDiskExt&) = delete;
FileSystemDiskExt& operator=(const FileSystemDiskExt&) = delete;
std::map<std::string, sg_size_t>* parse_content(const std::string& filename);
sg_size_t get_used_size() const { return used_size_; }
void decr_used_size(sg_size_t size) { used_size_ -= size; }
void incr_used_size(sg_size_t size) { used_size_ += size; }
+};
-private:
+class XBT_PUBLIC FileSystemStorageExt {
std::unique_ptr<std::map<std::string, sg_size_t>> content_;
- std::map<Host*, std::string> remote_mount_points_;
- std::string mount_point_;
sg_size_t used_size_ = 0;
- sg_size_t size_ = static_cast<sg_size_t>(500 * 1024) * 1024 * 1024;
-};
+ sg_size_t size_ = 0;
-class XBT_PUBLIC FileSystemStorageExt {
public:
static simgrid::xbt::Extension<Storage, FileSystemStorageExt> EXTENSION_ID;
- explicit FileSystemStorageExt(Storage* ptr);
+ explicit FileSystemStorageExt(const Storage* ptr);
FileSystemStorageExt(const FileSystemStorageExt&) = delete;
FileSystemStorageExt& operator=(const FileSystemStorageExt&) = delete;
std::map<std::string, sg_size_t>* parse_content(const std::string& filename);
sg_size_t get_used_size() { return used_size_; }
void decr_used_size(sg_size_t size) { used_size_ -= size; }
void incr_used_size(sg_size_t size) { used_size_ += size; }
-
-private:
- std::unique_ptr<std::map<std::string, sg_size_t>> content_;
- sg_size_t used_size_ = 0;
- sg_size_t size_ = 0;
};
class XBT_PUBLIC FileDescriptorHostExt {
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
XBT_PUBLIC void sg_vm_live_migration_plugin_init();
XBT_PRIVATE void sg_vm_dirty_page_tracking_init();
-XBT_PUBLIC void sg_vm_start_dirty_page_tracking(sg_vm_t vm);
-XBT_PUBLIC void sg_vm_stop_dirty_page_tracking(sg_vm_t vm);
-XBT_PUBLIC double sg_vm_lookup_computed_flops(sg_vm_t vm);
+XBT_PUBLIC void sg_vm_start_dirty_page_tracking(const_sg_vm_t vm);
+XBT_PUBLIC void sg_vm_stop_dirty_page_tracking(const_sg_vm_t vm);
+XBT_PUBLIC double sg_vm_lookup_computed_flops(const_sg_vm_t vm);
XBT_PUBLIC void sg_vm_migrate(sg_vm_t vm, sg_host_t dst_pm);
-XBT_PUBLIC void sg_vm_set_dirty_page_intensity(sg_vm_t vm, double intensity);
-XBT_PUBLIC double sg_vm_get_dirty_page_intensity(sg_vm_t vm);
-XBT_PUBLIC void sg_vm_set_working_set_memory(sg_vm_t vm, sg_size_t size);
-XBT_PUBLIC sg_size_t sg_vm_get_working_set_memory(sg_vm_t vm);
-XBT_PUBLIC void sg_vm_set_migration_speed(sg_vm_t vm, double speed);
-XBT_PUBLIC double sg_vm_get_migration_speed(sg_vm_t vm);
-XBT_PUBLIC double sg_vm_get_max_downtime(sg_vm_t vm);
-XBT_PUBLIC int sg_vm_is_migrating(sg_vm_t vm);
+XBT_PUBLIC void sg_vm_set_dirty_page_intensity(const_sg_vm_t vm, double intensity);
+XBT_PUBLIC double sg_vm_get_dirty_page_intensity(const_sg_vm_t vm);
+XBT_PUBLIC void sg_vm_set_working_set_memory(const_sg_vm_t vm, sg_size_t size);
+XBT_PUBLIC sg_size_t sg_vm_get_working_set_memory(const_sg_vm_t vm);
+XBT_PUBLIC void sg_vm_set_migration_speed(const_sg_vm_t vm, double speed);
+XBT_PUBLIC double sg_vm_get_migration_speed(const_sg_vm_t vm);
+XBT_PUBLIC double sg_vm_get_max_downtime(const_sg_vm_t vm);
+XBT_PUBLIC int sg_vm_is_migrating(const_sg_vm_t vm);
XBT_PUBLIC sg_vm_t sg_vm_create_migratable(sg_host_t pm, const char* name, int coreAmount, int ramsize,
int mig_netspeed, int dp_intensity);
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
SG_BEGIN_DECL
XBT_PUBLIC void sg_host_load_plugin_init();
-XBT_PUBLIC double sg_host_get_current_load(sg_host_t host);
-XBT_PUBLIC double sg_host_get_avg_load(sg_host_t host);
-XBT_PUBLIC double sg_host_get_idle_time(sg_host_t host);
-XBT_PUBLIC double sg_host_get_total_idle_time(sg_host_t host);
-XBT_PUBLIC double sg_host_get_computed_flops(sg_host_t host);
-XBT_PUBLIC void sg_host_load_reset(sg_host_t host);
+XBT_PUBLIC double sg_host_get_current_load(const_sg_host_t host);
+XBT_PUBLIC double sg_host_get_avg_load(const_sg_host_t host);
+XBT_PUBLIC double sg_host_get_idle_time(const_sg_host_t host);
+XBT_PUBLIC double sg_host_get_total_idle_time(const_sg_host_t host);
+XBT_PUBLIC double sg_host_get_computed_flops(const_sg_host_t host);
+XBT_PUBLIC void sg_host_load_reset(const_sg_host_t host);
#define MSG_host_load_plugin_init() sg_host_load_plugin_init()
/** @brief Returns the current load of that host, as a ratio = achieved_flops / (core_current_speed * core_amount)
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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 <vector>
#include <xbt/signal.hpp>
+XBT_LOG_EXTERNAL_CATEGORY(s4u_activity);
+
namespace simgrid {
namespace s4u {
template <class AnyActivity> class Activity_T : public Activity {
private:
- std::string name_ = "";
+ std::string name_ = "unnamed";
std::string tracing_category_ = "";
void* user_data_ = nullptr;
std::atomic_int_fast32_t refcount_{0};
{
while (has_successors()) {
AnyActivity* b = get_successor();
+ XBT_CDEBUG(s4u_activity, "Remove a dependency from '%s' on '%s'", get_cname(), b->get_cname());
b->remove_dependency_on(static_cast<AnyActivity*>(this));
if (not b->has_dependencies()) {
b->vetoable_start();
if (has_dependencies())
return static_cast<AnyActivity*>(this);
set_state(State::STARTED);
+ XBT_CDEBUG(s4u_activity, "All dependencies are solved, let's start '%s'", get_cname());
static_cast<AnyActivity*>(this)->start();
return static_cast<AnyActivity*>(this);
}
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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 <unordered_map>
namespace simgrid {
+
+extern template class XBT_PUBLIC xbt::Extendable<s4u::Actor>;
+
namespace s4u {
-/** \beginrst An actor is an independent stream of execution in your distributed application.
+/** An actor is an independent stream of execution in your distributed application.
+ *
+ * \beginrst
* It is located on a (simulated) :cpp:class:`host <simgrid::s4u::Host>`, but can interact
* with the whole simulated platform.
*
Actor& operator=(Actor const&) = delete;
// ***** Reference count *****
- friend XBT_PUBLIC void intrusive_ptr_add_ref(Actor * actor);
- friend XBT_PUBLIC void intrusive_ptr_release(Actor * actor);
+ friend XBT_PUBLIC void intrusive_ptr_add_ref(const Actor* actor);
+ friend XBT_PUBLIC void intrusive_ptr_release(const Actor* actor);
#endif
/** Retrieve the amount of references on that object. Useful to debug the automatic refcounting */
int get_refcount();
#endif
/** Signal indicating that an actor terminated its code.
+ * @beginrst
* The actor may continue to exist if it is still referenced in the simulation, but it's not active anymore.
- * If you want to free extra data when the actor's destructor is called, use Actor::on_destruction.
- * If you want to register to the termination of a given actor, use this_actor::on_exit() instead.*/
+ * If you want to free extra data when the actor's destructor is called, use :cpp:var:`Actor::on_destruction`.
+ * If you want to register to the termination of a given actor, use :cpp:func:`this_actor::on_exit()` instead.
+ * @endrst
+ */
static xbt::signal<void(Actor const&)> on_termination;
/** Signal indicating that an actor is about to disappear (its destructor was called).
* This signal is fired for any destructed actor, which is mostly useful when designing plugins and extensions.
* vector means that `host0` should compute 1000 flops while `host1` will compute 2000 flops. A matrix of
* communications' sizes of ``[0, 1, 2, 3]`` specifies the following data exchanges:
*
- * +-----------+-------+------+
- * |from \\ to | host0 | host1|
- * +===========+=======+======+
- * |host0 | 0 | 1 |
- * +-----------+-------+------+
- * |host1 | 2 | 3 |
- * +-----------+-------+------+
+ * - from host0: [ to host0: 0 bytes; to host1: 1 byte ]
+ *
+ * - from host1: [ to host0: 2 bytes; to host1: 3 bytes ]
+ *
+ * Or, in other words:
*
* - From host0 to host0: 0 bytes are exchanged
+ *
* - From host0 to host1: 1 byte is exchanged
+ *
* - From host1 to host0: 2 bytes are exchanged
+ *
* - From host1 to host1: 3 bytes are exchanged
*
* In a parallel execution, all parts (all executions on each hosts, all communications) progress exactly at the
*
* \endrst
*/
+/** Block the current actor until the built parallel execution completes */
XBT_PUBLIC void parallel_execute(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
const std::vector<double>& bytes_amounts);
-/** Block the current actor until the built parallel execution completes, or until the timeout. */
-XBT_PUBLIC void parallel_execute(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
- const std::vector<double>& bytes_amounts, double timeout);
+XBT_ATTRIB_DEPRECATED_v329("Please use exec_init(...)->wait_for(timeout)") XBT_PUBLIC
+ void parallel_execute(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
+ const std::vector<double>& bytes_amounts, double timeout);
/** Initialize a sequential execution that must then be started manually */
XBT_PUBLIC ExecPtr exec_init(double flops_amounts);
/** @brief Yield the current actor. */
XBT_PUBLIC void yield();
-/** @brief Resume the current actor, that was suspend()ed previously. */
-XBT_PUBLIC void resume();
-
/** @brief kill the current actor. */
XBT_PUBLIC void exit();
#ifndef DOXYGEN
XBT_ATTRIB_DEPRECATED_v329("Please use set_host() instead") XBT_PUBLIC void migrate(Host* new_host);
#endif
-
-/** @} */
}
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
class XBT_PUBLIC Barrier {
private:
- MutexPtr mutex_;
- ConditionVariablePtr cond_;
+ MutexPtr mutex_ = Mutex::create();
+ ConditionVariablePtr cond_ = ConditionVariable::create();
unsigned int expected_actors_;
unsigned int arrived_actors_ = 0;
public:
/** Creates a barrier for the given amount of actors */
- explicit Barrier(unsigned int count);
+ explicit Barrier(unsigned int expected_actors) : expected_actors_(expected_actors) {}
#ifndef DOXYGEN
~Barrier() = default;
Barrier(Barrier const&) = delete;
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
std::string tracing_category_ = "";
/* FIXME: expose these elements in the API */
bool detached_ = false;
- int (*match_fun_)(void*, void*, kernel::activity::CommImpl*) = nullptr;
+ bool (*match_fun_)(void*, void*, kernel::activity::CommImpl*) = nullptr;
void (*clean_fun_)(void*) = nullptr;
void (*copy_data_function_)(kernel::activity::CommImpl*, void*, size_t) = nullptr;
/*! take a vector s4u::CommPtr and return when one of them is finished.
* The return value is the rank of the first finished CommPtr. */
- static int wait_any(std::vector<CommPtr> * comms) { return wait_any_for(comms, -1); }
+ static int wait_any(const std::vector<CommPtr>* comms) { return wait_any_for(comms, -1); }
/*! Same as wait_any, but with a timeout. If the timeout occurs, parameter last is returned.*/
- static int wait_any_for(std::vector<CommPtr>* comms_in, double timeout);
+ static int wait_any_for(const std::vector<CommPtr>* comms_in, double timeout);
/*! take a vector s4u::CommPtr and return when all of them is finished. */
- static void wait_all(std::vector<CommPtr>* comms);
+ static void wait_all(const std::vector<CommPtr>* comms);
/*! take a vector s4u::CommPtr and return the rank of the first finished one (or -1 if none is done). */
- static int test_any(std::vector<CommPtr> * comms);
+ static int test_any(const std::vector<CommPtr>* comms);
Comm* start() override;
Comm* wait() override;
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
namespace simgrid {
namespace s4u {
-/** @brief A condition variable
- * @ingroup s4u_api
- *
- * This is a drop-in replacement of `std::condition_variable` and should respect the same
- * semantic. But we currently use (only) double for both durations and
- * timestamp timeouts.
+/**
+ * @rst
+ * SimGrid's condition variables are meant to be drop-in replacements of ``std::condition_variable``.
+ * Please refer to the `documentation of standard C++ <https://en.cppreference.com/w/cpp/thread/condition_variable>`_
+ * for more information on condition variables. A SimGrid example is available in Section :ref:`s4u_ex_IPC`.
+ * @endrst
*/
class XBT_PUBLIC ConditionVariable {
private:
kernel::activity::ConditionVariableImpl* const cond_;
public:
+#ifndef DOXYGEN
explicit ConditionVariable(kernel::activity::ConditionVariableImpl* cond) : cond_(cond) {}
-#ifndef DOXYGEN
ConditionVariable(ConditionVariable const&) = delete;
ConditionVariable& operator=(ConditionVariable const&) = delete;
- friend XBT_PUBLIC void intrusive_ptr_add_ref(ConditionVariable * cond);
- friend XBT_PUBLIC void intrusive_ptr_release(ConditionVariable * cond);
+ friend XBT_PUBLIC void intrusive_ptr_add_ref(const ConditionVariable* cond);
+ friend XBT_PUBLIC void intrusive_ptr_release(const ConditionVariable* cond);
#endif
+ /** Create a new condition variable and return a smart pointer
+ *
+ * @rst
+ * You should only manipulate :cpp:type:`simgrid::s4u::ConditionVariablePtr`, as created by this function (see also :ref:`s4u_raii`).
+ * @endrst
+ */
static ConditionVariablePtr create();
- // Wait functions without time:
-
- void wait(MutexPtr lock);
- void wait(std::unique_lock<Mutex> & lock);
- template <class P> void wait(std::unique_lock<Mutex> & lock, P pred)
+ /// Wait until notification, with no timeout
+ void wait(s4u::MutexPtr lock);
+ /// Wait until notification, with no timeout
+ void wait(const std::unique_lock<s4u::Mutex>& lock);
+ template <class P> void wait(const std::unique_lock<Mutex>& lock, P pred)
{
while (not pred())
wait(lock);
}
- // Wait function taking a plain double as time:
-
- std::cv_status wait_until(std::unique_lock<Mutex> & lock, double timeout_time);
- std::cv_status wait_for(std::unique_lock<Mutex> & lock, double duration);
- template <class P> bool wait_until(std::unique_lock<Mutex> & lock, double timeout_time, P pred)
+ /// Wait until the given instant (specified as a plain double)
+ std::cv_status wait_until(const std::unique_lock<s4u::Mutex>& lock, double timeout_time);
+ /// Wait for the given amount of seconds (specified as a plain double)
+ std::cv_status wait_for(const std::unique_lock<s4u::Mutex>& lock, double duration);
+ /// Wait until predicate is true, or the given instant (specified as a plain double)
+ template <class P> bool wait_until(const std::unique_lock<s4u::Mutex>& lock, double timeout_time, P pred)
{
while (not pred())
if (this->wait_until(lock, timeout_time) == std::cv_status::timeout)
return pred();
return true;
}
- template <class P> bool wait_for(std::unique_lock<Mutex> & lock, double duration, P pred)
+ /// As long as the predicate is false, wait for the given amount of seconds (specified as a plain double)
+ template <class P> bool wait_for(const std::unique_lock<s4u::Mutex>& lock, double duration, P pred)
{
return this->wait_until(lock, SIMIX_get_clock() + duration, std::move(pred));
}
// Wait function taking a C++ style time:
+ /// As long as the predicate is false, wait for the given amount of seconds (specified in C++ style)
template <class Rep, class Period, class P>
- bool wait_for(std::unique_lock<Mutex> & lock, std::chrono::duration<Rep, Period> duration, P pred)
+ bool wait_for(const std::unique_lock<s4u::Mutex>& lock, std::chrono::duration<Rep, Period> duration, P pred)
{
auto seconds = std::chrono::duration_cast<SimulationClockDuration>(duration);
return this->wait_for(lock, seconds.count(), pred);
}
+ /// Wait for the given amount of seconds (specified in C++ style)
template <class Rep, class Period>
- std::cv_status wait_for(std::unique_lock<Mutex> & lock, std::chrono::duration<Rep, Period> duration)
+ std::cv_status wait_for(const std::unique_lock<s4u::Mutex>& lock, std::chrono::duration<Rep, Period> duration)
{
auto seconds = std::chrono::duration_cast<SimulationClockDuration>(duration);
return this->wait_for(lock, seconds.count());
}
+ /** Wait until the given instant (specified in C++ style) */
template <class Duration>
- std::cv_status wait_until(std::unique_lock<Mutex> & lock, const SimulationTimePoint<Duration>& timeout_time)
+ std::cv_status wait_until(const std::unique_lock<s4u::Mutex>& lock, const SimulationTimePoint<Duration>& timeout_time)
{
auto timeout_native = std::chrono::time_point_cast<SimulationClockDuration>(timeout_time);
return this->wait_until(lock, timeout_native.time_since_epoch().count());
}
+ /** Wait until predicate is true, or the given instant (specified in C++ style) */
template <class Duration, class P>
- bool wait_until(std::unique_lock<Mutex> & lock, const SimulationTimePoint<Duration>& timeout_time, P pred)
+ bool wait_until(const std::unique_lock<s4u::Mutex>& lock, const SimulationTimePoint<Duration>& timeout_time, P pred)
{
auto timeout_native = std::chrono::time_point_cast<SimulationClockDuration>(timeout_time);
return this->wait_until(lock, timeout_native.time_since_epoch().count(), std::move(pred));
}
- // Notify functions
-
+ /** Unblock one actor blocked on that condition variable. If none was blocked, nothing happens. */
void notify_one();
+ /** Unblock all actors blocked on that condition variable. If none was blocked, nothing happens. */
void notify_all();
};
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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 <unordered_map>
namespace simgrid {
+
+extern template class XBT_PUBLIC xbt::Extendable<s4u::Disk>;
+
namespace s4u {
/** Disk represent the disk resources associated to a host
/** @brief Retrieves the name of that disk as a C string */
const char* get_cname() const { return name_.c_str(); }
double get_read_bandwidth() const;
- double get_write_bandwidth();
+ double get_write_bandwidth() const;
const std::unordered_map<std::string, std::string>* get_properties() const;
const char* get_property(const std::string& key) const;
void set_property(const std::string&, const std::string& value);
- Host* get_host();
+ Host* get_host() const;
IoPtr io_init(sg_size_t size, s4u::Io::OpType type);
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
namespace s4u {
/** @brief Simulation engine
*
- * This class is an interface to the simulation engine.
+ * This is a singleton containing all the main functions of the simulation.
*/
class XBT_PUBLIC Engine {
public:
/** Constructor, taking the command line parameters of your main function */
explicit Engine(int* argc, char** argv);
- /** Currently, only one instance is allowed to exist. This is why you can't copy or move it */
+ /* Currently, only one instance is allowed to exist. This is why you can't copy or move it */
+#ifndef DOXYGEN
Engine(const Engine&) = delete;
Engine(Engine&&) = delete;
-
~Engine();
+#endif
+
/** Finalize the default engine and all its dependencies */
static void shutdown();
- /** @brief Run the simulation after initialization */
+ /** Run the simulation after initialization */
void run();
/** @brief Retrieve the simulation time (in seconds) */
friend kernel::resource::LinkImpl;
void host_register(const std::string& name, Host* host);
void host_unregister(const std::string& name);
- void link_register(const std::string& name, Link* link);
+ void link_register(const std::string& name, const Link* link);
void link_unregister(const std::string& name);
- void storage_register(const std::string& name, Storage* storage);
+ void storage_register(const std::string& name, const Storage* storage);
void storage_unregister(const std::string& name);
void netpoint_register(simgrid::kernel::routing::NetPoint* card);
void netpoint_unregister(simgrid::kernel::routing::NetPoint* card);
std::vector<ActorPtr> get_all_actors();
std::vector<ActorPtr> get_filtered_actors(const std::function<bool(ActorPtr)>& filter);
+#ifndef DOXYGEN
size_t get_storage_count();
std::vector<Storage*> get_all_storages();
Storage* storage_by_name(const std::string& name);
Storage* storage_by_name_or_null(const std::string& name);
+#endif
std::vector<kernel::routing::NetPoint*> get_all_netpoints();
kernel::routing::NetPoint* netpoint_by_name_or_null(const std::string& name);
NetZone* get_netzone_root();
- void set_netzone_root(NetZone* netzone);
+ void set_netzone_root(const NetZone* netzone);
NetZone* netzone_by_name_or_null(const std::string& name);
static bool is_initialized();
/** @brief set a configuration variable
*
- * Do --help on any simgrid binary to see the list of currently existing configuration variables (see also @ref
- * options).
+ * @beginrst
+ * Do --help on any simgrid binary to see the list of currently existing configuration variables
+ * (see also :ref:`options`).
+ * @endrst
*
* Example:
* e->set_config("host/model:ptask_L07");
};
#ifndef DOXYGEN /* Internal use only, no need to expose it */
-template <class T> XBT_PRIVATE void get_filtered_netzones_recursive(s4u::NetZone* current, std::vector<T*>* whereto)
+template <class T>
+XBT_PRIVATE void get_filtered_netzones_recursive(const s4u::NetZone* current, std::vector<T*>* whereto)
{
static_assert(std::is_base_of<kernel::routing::NetZoneImpl, T>::value,
"Filtering netzones is only possible for subclasses of kernel::routing::NetZoneImpl");
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
ExecPtr set_bound(double bound);
ExecPtr set_priority(double priority);
- ExecPtr set_timeout(double timeout);
+ XBT_ATTRIB_DEPRECATED_v329("Please use exec_init(...)->wait_for(timeout)") ExecPtr set_timeout(double timeout);
Exec* cancel() override;
Host* get_host() const;
unsigned int get_host_number() const;
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
namespace simgrid {
-namespace xbt {
-extern template class XBT_PUBLIC Extendable<s4u::Host>;
-} // namespace xbt
+extern template class XBT_PUBLIC xbt::Extendable<s4u::Host>;
namespace s4u {
/** @ingroup s4u_api
*
* Some physical resource with computing and networking capabilities on which Actors execute.
*
+ * @beginrst
* All hosts are automatically created during the call of the method
- * @ref simgrid::s4u::Engine::load_platform().
+ * :cpp:func:`simgrid::s4u::Engine::load_platform()`.
* You cannot create a host yourself.
*
- * You can retrieve a particular host using @ref simgrid::s4u::Host::by_name()
- * and actors can retrieve the host on which they run using @ref simgrid::s4u::Host::current() or
- * @ref simgrid::s4u::this_actor::get_host().
+ * You can retrieve a particular host using :cpp:func:`simgrid::s4u::Host::by_name()`
+ * and actors can retrieve the host on which they run using :cpp:func:`simgrid::s4u::Host::current()` or
+ * :cpp:func:`simgrid::s4u::this_actor::get_host()`
+ * @endrst
*/
class XBT_PUBLIC Host : public xbt::Extendable<Host> {
friend vm::VMModel; // Use the pimpl_cpu to compute the VM sharing
kernel::routing::NetPoint* get_netpoint() const { return pimpl_netpoint_; }
- int get_actor_count();
- std::vector<ActorPtr> get_all_actors();
+ int get_actor_count() const;
+ std::vector<ActorPtr> get_all_actors() const;
/** Turns that host on if it was previously off
*
*/
std::unordered_map<std::string, Storage*> const& get_mounted_storages();
- void route_to(Host* dest, std::vector<Link*>& links, double* latency);
- void route_to(Host* dest, std::vector<kernel::resource::LinkImpl*>& links, double* latency);
+ void route_to(const Host* dest, std::vector<Link*>& links, double* latency) const;
+ void route_to(const Host* dest, std::vector<kernel::resource::LinkImpl*>& links, double* latency) const;
void send_to(Host* dest, double byte_amount);
NetZone* get_englobing_zone();
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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 S4U_LINK_HPP_
-#define S4U_LINK_HPP_
+#ifndef S4U_LINK_HPP
+#define S4U_LINK_HPP
#include <simgrid/forward.h>
#include <simgrid/kernel/resource/Action.hpp>
***********/
namespace simgrid {
+
+extern template class XBT_PUBLIC xbt::Extendable<s4u::Link>;
+
namespace s4u {
/** @brief A Link represents the network facilities between [hosts](@ref simgrid::s4u::Host) */
class XBT_PUBLIC Link : public xbt::Extendable<Link> {
double get_latency() const;
/** @brief Describes how the link is shared between flows */
- SharingPolicy get_sharing_policy();
+ SharingPolicy get_sharing_policy() const;
/** @brief Returns the current load (in flops per second) */
- double get_usage();
+ double get_usage() const;
/** @brief Check if the Link is used (at least one flow uses the link) */
- bool is_used();
+ bool is_used() const;
void turn_on();
bool is_on() const;
} // namespace s4u
} // namespace simgrid
-#endif /* SURF_NETWORK_INTERFACE_HPP_ */
+#endif /* S4U_LINK_HPP */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
#define SIMGRID_S4U_MAILBOX_HPP
#include <simgrid/forward.h>
-
#include <simgrid/s4u/Actor.hpp>
+#include <smpi/forward.hpp>
#include <xbt/string.hpp>
#include <string>
/** @brief Mailboxes: Network rendez-vous points. */
class XBT_PUBLIC Mailbox {
friend Comm;
+ friend smpi::Request;
friend kernel::activity::MailboxImpl;
kernel::activity::MailboxImpl* const pimpl_;
explicit Mailbox(kernel::activity::MailboxImpl * mbox) : pimpl_(mbox) {}
~Mailbox() = default;
-public:
- /** private function, do not use. FIXME: make me protected */
+protected:
kernel::activity::MailboxImpl* get_impl() const { return pimpl_; }
+public:
/** @brief Retrieves the name of that mailbox as a C++ string */
const xbt::string& get_name() const;
/** @brief Retrieves the name of that mailbox as a C string */
const char* get_cname() const;
- /** Retrieve the mailbox associated to the given name */
+ /** Retrieve the mailbox associated to the given name. Mailboxes are created on demand. */
static Mailbox* by_name(const std::string& name);
/** Returns whether the mailbox contains queued communications */
/** Creates and start a data transmission to that mailbox */
CommPtr put_async(void* data, uint64_t simulated_size_in_bytes);
- smx_activity_t iprobe(int type, int (*match_fun)(void*, void*, kernel::activity::CommImpl*), void* data);
+ smx_activity_t iprobe(int type, bool (*match_fun)(void*, void*, kernel::activity::CommImpl*), void* data);
/** Blocking data transmission */
void put(void* payload, uint64_t simulated_size_in_bytes);
/** Blocking data transmission with timeout */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
namespace simgrid {
namespace s4u {
-/** @brief A classical mutex, but blocking in the simulation world
- * @ingroup s4u_api
+/** @brief A classical mutex, but blocking in the simulation world.
*
+ * @rst
* It is strictly impossible to use a real mutex, such as
- * <a href="http://en.cppreference.com/w/cpp/thread/mutex">std::mutex</a>
- * or <a href="http://pubs.opengroup.org/onlinepubs/007908775/xsh/pthread_mutex_lock.html">pthread_mutex_t</a>,
+ * `std::mutex <http://en.cppreference.com/w/cpp/thread/mutex>`_
+ * or `pthread_mutex_t <http://pubs.opengroup.org/onlinepubs/007908775/xsh/pthread_mutex_lock.html>`_,
* because it would block the whole simulation.
- * Instead, you should use the present class, that is a drop-in replacement of
- * <a href="http://en.cppreference.com/w/cpp/thread/mutex">std::mutex</a>.
+ * Instead, you should use the present class, that is a drop-in replacement of these mechanisms.
*
- * As for any S4U object, Mutexes are using the @ref s4u_raii "RAII idiom" for memory management.
- * Use create() to get a simgrid::s4u::MutexPtr to a newly created mutex and only manipulate simgrid::s4u::MutexPtr.
+ * An example is available in Section :ref:`s4u_ex_IPC`.
*
+ * As for any S4U object, you can use the :ref:`RAII idiom <s4u_raii>` for memory management of Mutexes.
+ * Use :cpp:func:`create() <simgrid::s4u::Mutex::create()>` to get a :cpp:type:`simgrid::s4u::MutexPtr` to a newly
+ * created mutex, and only manipulate :cpp:type:`simgrid::s4u::MutexPtr`.
+ * @endrst
*/
class XBT_PUBLIC Mutex {
friend ConditionVariable;
kernel::activity::MutexImpl* const pimpl_;
/* refcounting */
- friend XBT_PUBLIC void intrusive_ptr_add_ref(Mutex* mutex);
- friend XBT_PUBLIC void intrusive_ptr_release(Mutex* mutex);
+ friend XBT_PUBLIC void intrusive_ptr_add_ref(const Mutex* mutex);
+ friend XBT_PUBLIC void intrusive_ptr_release(const Mutex* mutex);
public:
explicit Mutex(kernel::activity::MutexImpl* mutex) : pimpl_(mutex) {}
~Mutex();
- // No copy:
- /** You cannot create a new mutex by copying an existing one. Use MutexPtr instead */
- Mutex(Mutex const&) = delete;
- /** You cannot create a new mutex by value assignment either. Use MutexPtr instead */
- Mutex& operator=(Mutex const&) = delete;
+#ifndef DOXYGEN
+ Mutex(Mutex const&) = delete; // No copy constructor; Use MutexPtr instead
+ Mutex& operator=(Mutex const&) = delete; // No direct assignment either. Use MutexPtr instead
+#endif
/** Constructs a new mutex */
static MutexPtr create();
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
NetZone* get_father();
- std::vector<Host*> get_all_hosts();
+ std::vector<Host*> get_all_hosts() const;
int get_host_count();
kernel::routing::NetZoneImpl* get_impl() const { return pimpl_; }
const char* get_property(const std::string& key) const;
void set_property(const std::string& key, const std::string& value);
- std::vector<NetZone*> get_children();
+ std::vector<NetZone*> get_children() const;
/* Add content to the netzone, at parsing time. It should be sealed afterward. */
int add_component(kernel::routing::NetPoint* elm); /* A host, a router or a netzone, whatever */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
namespace s4u {
/** @brief A classical semaphore, but blocking in the simulation world
- * @ingroup s4u_api
*
+ * @rst
* It is strictly impossible to use a real semaphore, such as
- * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_init.html">sem_init</a>,
+ * `sem_init <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_init.html>`_,
* because it would block the whole simulation.
* Instead, you should use the present class, that offers a very similar interface.
*
- * As for any S4U object, Semaphores are using the @ref s4u_raii "RAII idiom" for memory management.
- * Use #create() to get a simgrid::s4u::SemaphorePtr to a newly created semaphore
- * and only manipulate simgrid::s4u::SemaphorePtr.
+ * An example is available in Section :ref:`s4u_ex_IPC`.
+ *
+ * As for any S4U object, you can use the :ref:`RAII idiom <s4u_raii>` for memory management of semaphores.
+ * Use :cpp:func:`create() <simgrid::s4u::Mutex::create()>` to get a :cpp:type:`simgrid::s4u::SemaphorePtr` to a newly
+ * created semaphore, that will get automatically freed when the variable goes out of scope.
+ * @endrst
*
*/
class XBT_PUBLIC Semaphore {
explicit Semaphore(unsigned int initial_capacity);
~Semaphore();
- // No copy:
- /** You cannot create a new semaphore by copying an existing one. Use SemaphorePtr instead */
- Semaphore(Semaphore const&) = delete;
- /** You cannot create a new semaphore by value assignment either. Use SemaphorePtr instead */
- Semaphore& operator=(Semaphore const&) = delete;
+#ifndef DOXYGEN
+ Semaphore(Semaphore const&) = delete; // No copy constructor. Use SemaphorePtr instead
+ Semaphore& operator=(Semaphore const&) = delete; // No direct assignment either. Use SemaphorePtr instead
+#endif
/** Constructs a new semaphore */
static SemaphorePtr create(unsigned int initial_capacity);
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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 <unordered_map>
namespace simgrid {
+
+extern template class XBT_PUBLIC xbt::Extendable<s4u::Storage>;
+
namespace s4u {
/** Storage represent the disk resources, usually associated to a given host
/** @brief Retrieves the name of that storage as a C string */
const char* get_cname() const { return name_.c_str(); }
- const char* get_type();
- Host* get_host() { return attached_to_; };
+ const char* get_type() const;
+ Host* get_host() const { return attached_to_; };
void set_host(Host* host) { attached_to_ = host; }
const std::unordered_map<std::string, std::string>* get_properties() const;
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
void shutdown();
void destroy() override;
- Host* get_pm();
+ Host* get_pm() const;
void set_pm(Host* pm);
- size_t get_ramsize();
+ size_t get_ramsize() const;
void set_ramsize(size_t ramsize);
void set_bound(double bound);
/* Public interface to the Link datatype */
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
XBT_PUBLIC int sg_sem_acquire_timeout(sg_sem_t sem, double timeout);
XBT_PUBLIC void sg_sem_release(sg_sem_t sem);
XBT_PUBLIC int sg_sem_get_capacity(sg_sem_t sem);
-XBT_PUBLIC void sg_sem_destroy(sg_sem_t sem);
+XBT_PUBLIC void sg_sem_destroy(const_sg_sem_t sem);
XBT_PUBLIC int sg_sem_would_block(sg_sem_t sem);
SG_END_DECL
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
*/
typedef struct s_SD_task_t* SD_task_t;
+typedef const struct s_SD_task_t* const_SD_task_t;
/** @brief Task states
@ingroup SD_task_api */
* @{
*/
XBT_PUBLIC SD_task_t SD_task_create(const char* name, void* data, double amount);
-XBT_PUBLIC void* SD_task_get_data(SD_task_t task);
+XBT_PUBLIC void* SD_task_get_data(const_SD_task_t task);
XBT_PUBLIC void SD_task_set_data(SD_task_t task, void* data);
-XBT_PUBLIC e_SD_task_state_t SD_task_get_state(SD_task_t task);
-XBT_PUBLIC const char* SD_task_get_name(SD_task_t task);
+XBT_PUBLIC e_SD_task_state_t SD_task_get_state(const_SD_task_t task);
+XBT_PUBLIC const char* SD_task_get_name(const_SD_task_t task);
XBT_PUBLIC void SD_task_set_name(SD_task_t task, const char* name);
XBT_PUBLIC void SD_task_set_rate(SD_task_t task, double rate);
XBT_PUBLIC void SD_task_watch(SD_task_t task, e_SD_task_state_t state);
XBT_PUBLIC void SD_task_unwatch(SD_task_t task, e_SD_task_state_t state);
-XBT_PUBLIC double SD_task_get_amount(SD_task_t task);
+XBT_PUBLIC double SD_task_get_amount(const_SD_task_t task);
XBT_PUBLIC void SD_task_set_amount(SD_task_t task, double amount);
-XBT_PUBLIC double SD_task_get_alpha(SD_task_t task);
-XBT_PUBLIC double SD_task_get_remaining_amount(SD_task_t task);
-XBT_PUBLIC double SD_task_get_execution_time(SD_task_t task, int host_count, const sg_host_t* host_list,
+XBT_PUBLIC double SD_task_get_alpha(const_SD_task_t task);
+XBT_PUBLIC double SD_task_get_remaining_amount(const_SD_task_t task);
+XBT_PUBLIC double SD_task_get_execution_time(const_SD_task_t task, int host_count, const sg_host_t* host_list,
const double* flops_amount, const double* bytes_amount);
-XBT_PUBLIC e_SD_task_kind_t SD_task_get_kind(SD_task_t task);
+XBT_PUBLIC e_SD_task_kind_t SD_task_get_kind(const_SD_task_t task);
XBT_PUBLIC void SD_task_schedule(SD_task_t task, int host_count, const sg_host_t* host_list, const double* flops_amount,
const double* bytes_amount, double rate);
XBT_PUBLIC void SD_task_unschedule(SD_task_t task);
-XBT_PUBLIC double SD_task_get_start_time(SD_task_t task);
-XBT_PUBLIC double SD_task_get_finish_time(SD_task_t task);
-XBT_PUBLIC xbt_dynar_t SD_task_get_parents(SD_task_t task);
-XBT_PUBLIC xbt_dynar_t SD_task_get_children(SD_task_t task);
-XBT_PUBLIC int SD_task_get_workstation_count(SD_task_t task);
-XBT_PUBLIC sg_host_t* SD_task_get_workstation_list(SD_task_t task);
+XBT_PUBLIC double SD_task_get_start_time(const_SD_task_t task);
+XBT_PUBLIC double SD_task_get_finish_time(const_SD_task_t task);
+XBT_PUBLIC xbt_dynar_t SD_task_get_parents(const_SD_task_t task);
+XBT_PUBLIC xbt_dynar_t SD_task_get_children(const_SD_task_t task);
+XBT_PUBLIC int SD_task_get_workstation_count(const_SD_task_t task);
+XBT_PUBLIC sg_host_t* SD_task_get_workstation_list(const_SD_task_t task);
XBT_PUBLIC void SD_task_destroy(SD_task_t task);
-XBT_PUBLIC void SD_task_dump(SD_task_t task);
-XBT_PUBLIC void SD_task_dotty(SD_task_t task, void* out_FILE);
+XBT_PUBLIC void SD_task_dump(const_SD_task_t task);
+XBT_PUBLIC void SD_task_dotty(const_SD_task_t task, void* out_FILE);
XBT_PUBLIC SD_task_t SD_task_create_comp_seq(const char* name, void* data, double amount);
XBT_PUBLIC SD_task_t SD_task_create_comp_par_amdahl(const char* name, void* data, double amount, double alpha);
*/
XBT_PUBLIC void SD_task_dependency_add(SD_task_t src, SD_task_t dst);
XBT_PUBLIC void SD_task_dependency_remove(SD_task_t src, SD_task_t dst);
-XBT_PUBLIC int SD_task_dependency_exists(SD_task_t src, SD_task_t dst);
+XBT_PUBLIC int SD_task_dependency_exists(const_SD_task_t src, SD_task_t dst);
/** @} */
/************************** Global *******************************************/
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
/******************************* Host simcalls ********************************/
#ifdef __cplusplus
-XBT_PUBLIC e_smx_state_t simcall_execution_wait(const smx_activity_t& execution);
+XBT_PUBLIC e_smx_state_t simcall_execution_wait(const smx_activity_t& execution, double timeout);
XBT_PUBLIC unsigned int simcall_execution_waitany_for(simgrid::kernel::activity::ExecImpl* execs[], size_t count,
double timeout);
XBT_PUBLIC bool simcall_execution_test(const smx_activity_t& execution);
#ifdef __cplusplus
XBT_PUBLIC void simcall_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff,
size_t src_buff_size,
- int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+ bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
void* data, double timeout);
XBT_PUBLIC smx_activity_t simcall_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate,
void* src_buff, size_t src_buff_size,
- int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+ bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
void (*clean_fun)(void*),
void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
void* data, bool detached);
XBT_PUBLIC void simcall_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size,
- int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+ bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
void* data, double timeout, double rate);
XBT_PUBLIC smx_activity_t simcall_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff,
size_t* dst_buff_size,
- int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+ bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
void* data, double rate);
XBT_PUBLIC smx_activity_t simcall_comm_iprobe(smx_mailbox_t mbox, int type,
- int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+ bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
void* data);
/* FIXME: waitany is going to be a vararg function, and should take a timeout */
/***************************** Io **************************************/
#ifdef __cplusplus
-XBT_PUBLIC e_smx_state_t simcall_io_wait(const smx_activity_t& io);
+XBT_PUBLIC e_smx_state_t simcall_io_wait(const smx_activity_t& io, double timeout);
+XBT_PUBLIC bool simcall_io_test(const smx_activity_t& io);
#endif
/************************** MC simcalls **********************************/
SG_BEGIN_DECL
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
try {
auto future = code();
future.then_([&result, self](std::shared_ptr<simgrid::kernel::FutureState<T>>&& value) {
- simgrid::xbt::set_promise(result, simgrid::kernel::Future<T>(value));
+ simgrid::xbt::set_promise(result, simgrid::kernel::Future<T>(std::move(value)));
simgrid::simix::unblock(self);
});
} catch (...) {
// When the kernel future is ready...
this->future_.then_([&result, self](std::shared_ptr<simgrid::kernel::FutureState<T>>&& value) {
// ... wake up the process with the result of the kernel future.
- simgrid::xbt::set_promise(result, simgrid::kernel::Future<T>(value));
+ simgrid::xbt::set_promise(result, simgrid::kernel::Future<T>(std::move(value)));
simgrid::simix::unblock(self);
});
} catch (...) {
// When the kernel future is ready...
this->future_.then_([this, self](std::shared_ptr<simgrid::kernel::FutureState<T>>&& value) {
// ...store it the simix kernel and wake up.
- this->future_ = std::move(simgrid::kernel::Future<T>(value));
+ this->future_ = simgrid::kernel::Future<T>(std::move(value));
simgrid::simix::unblock(self);
});
} catch (...) {
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
XBT_PRIVATE unsigned char* smpi_get_tmp_sendbuffer(size_t size);
XBT_PRIVATE unsigned char* smpi_get_tmp_recvbuffer(size_t size);
-XBT_PRIVATE void log_timed_action(simgrid::xbt::ReplayAction& action, double clock);
+XBT_PRIVATE void log_timed_action(const simgrid::xbt::ReplayAction& action, double clock);
namespace simgrid {
namespace smpi {
* In other words: The logic goes here, the setup is done by the ActionArgParser.
*/
template <class T> class ReplayAction {
+ const std::string name_;
+ const aid_t my_proc_id_ = s4u::this_actor::get_pid();
+ T args_;
+
protected:
- const std::string name;
- const aid_t my_proc_id;
- T args;
+ const std::string& get_name() const { return name_; }
+ aid_t get_pid() const { return my_proc_id_; }
+ const T& get_args() const { return args_; }
public:
- explicit ReplayAction(const std::string& name) : name(name), my_proc_id(s4u::this_actor::get_pid()) {}
+ explicit ReplayAction(const std::string& name) : name_(name) {}
virtual ~ReplayAction() = default;
void execute(xbt::ReplayAction& action)
{
// Needs to be re-initialized for every action, hence here
double start_time = smpi_process()->simulated_elapsed();
- args.parse(action, name);
+ args_.parse(action, name_);
kernel(action);
- if (name != "Init")
+ if (name_ != "Init")
log_timed_action(action, start_time);
}
/* Public interface to the Link datatype */
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
/* C interface */
SG_BEGIN_DECL
-XBT_PUBLIC const char* sg_storage_get_name(sg_storage_t storage);
+XBT_PUBLIC const char* sg_storage_get_name(const_sg_storage_t storage);
XBT_PUBLIC sg_storage_t sg_storage_get_by_name(const char* name);
-XBT_PUBLIC xbt_dict_t sg_storage_get_properties(sg_storage_t storage);
+XBT_PUBLIC xbt_dict_t sg_storage_get_properties(const_sg_storage_t storage);
XBT_PUBLIC void sg_storage_set_property_value(sg_storage_t storage, const char* name, const char* value);
-XBT_PUBLIC const char* sg_storage_get_property_value(sg_storage_t storage, const char* name);
+XBT_PUBLIC const char* sg_storage_get_property_value(const_sg_storage_t storage, const char* name);
XBT_PUBLIC xbt_dynar_t sg_storages_as_dynar();
XBT_PUBLIC void sg_storage_set_data(sg_storage_t host, void* data);
-XBT_PUBLIC void* sg_storage_get_data(sg_storage_t storage);
-XBT_PUBLIC const char* sg_storage_get_host(sg_storage_t storage);
+XBT_PUBLIC void* sg_storage_get_data(const_sg_storage_t storage);
+XBT_PUBLIC const char* sg_storage_get_host(const_sg_storage_t storage);
XBT_PUBLIC sg_size_t sg_storage_read(sg_storage_t storage, sg_size_t size);
XBT_PUBLIC sg_size_t sg_storage_write(sg_storage_t storage, sg_size_t size);
/* src/simgrid/version.h - internal versioning info */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
#define SIMGRID_VERSION_STRING "@SIMGRID_VERSION_STRING@"
-#endif /* SIMGRID_PUBLIC_CONFIG_H */
+#endif /* SIMGRID_VERSION_H */
/* Public interface to the Link datatype */
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
XBT_PUBLIC int sg_vm_is_running(sg_vm_t vm);
XBT_PUBLIC int sg_vm_is_suspended(sg_vm_t vm);
-XBT_PUBLIC const char* sg_vm_get_name(sg_vm_t vm);
+XBT_PUBLIC const char* sg_vm_get_name(const_sg_vm_t vm);
XBT_PUBLIC void sg_vm_set_ramsize(sg_vm_t vm, size_t size);
-XBT_PUBLIC size_t sg_vm_get_ramsize(sg_vm_t vm);
+XBT_PUBLIC size_t sg_vm_get_ramsize(const_sg_vm_t vm);
XBT_PUBLIC void sg_vm_set_bound(sg_vm_t vm, double bound);
-XBT_PUBLIC sg_host_t sg_vm_get_pm(sg_vm_t vm);
+XBT_PUBLIC sg_host_t sg_vm_get_pm(const_sg_vm_t vm);
XBT_PUBLIC void sg_vm_start(sg_vm_t vm);
XBT_PUBLIC void sg_vm_suspend(sg_vm_t vm);
/* Public interface to the Link datatype */
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
SG_BEGIN_DECL
XBT_PUBLIC sg_netzone_t sg_zone_get_root();
-XBT_PUBLIC const char* sg_zone_get_name(sg_netzone_t zone);
+XBT_PUBLIC const char* sg_zone_get_name(const_sg_netzone_t zone);
XBT_PUBLIC sg_netzone_t sg_zone_get_by_name(const char* name);
-XBT_PUBLIC void sg_zone_get_sons(sg_netzone_t zone, xbt_dict_t whereto);
-XBT_PUBLIC const char* sg_zone_get_property_value(sg_netzone_t as, const char* name);
-XBT_PUBLIC void sg_zone_set_property_value(sg_netzone_t netzone, const char* name, char* value);
-XBT_PUBLIC void sg_zone_get_hosts(sg_netzone_t zone, xbt_dynar_t whereto);
+XBT_PUBLIC void sg_zone_get_sons(const_sg_netzone_t zone, xbt_dict_t whereto);
+XBT_PUBLIC const char* sg_zone_get_property_value(const_sg_netzone_t as, const char* name);
+XBT_PUBLIC void sg_zone_set_property_value(sg_netzone_t netzone, const char* name, const char* value);
+XBT_PUBLIC void sg_zone_get_hosts(const_sg_netzone_t zone, xbt_dynar_t whereto);
SG_END_DECL
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#if SIMGRID_HAVE_MC
#undef assert
-#define assert(x) MC_assert((int)(x))
+#define assert(x) MC_assert(!!(x))
#endif
#ifdef TRACE_CALL_LOCATION /* Defined by smpicc on the command line */
! -*- fortran -*-
-! Copyright (c) 2010-2019. The SimGrid Team.
+! Copyright (c) 2010-2020. The SimGrid Team.
! All rights reserved.
! This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
*/
XBT_PUBLIC void smpi_trace_set_call_location(const char* file, int line);
/** Fortran binding **/
-XBT_PUBLIC void smpi_trace_set_call_location_(const char* file, int* line);
+XBT_PUBLIC void smpi_trace_set_call_location_(const char* file, const int* line);
/** Fortran binding + -fsecond-underscore **/
-XBT_PUBLIC void smpi_trace_set_call_location__(const char* file, int* line);
+XBT_PUBLIC void smpi_trace_set_call_location__(const char* file, const int* line);
#define SMPI_ITER_NAME1(line) _XBT_CONCAT(iter_count, line)
#define SMPI_ITER_NAME(line) SMPI_ITER_NAME1(line)
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* xbt.h - Public interface to the xbt (SimGrid's toolbox) */
-/* Copyright (c) 2004-2019. The SimGrid Team.
+/* Copyright (c) 2004-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2015-2019. The SimGrid Team.
+/* Copyright (c) 2015-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
template<class T, class U>
class Extension {
- static const std::size_t INVALID_ID = std::numeric_limits<std::size_t>::max();
- std::size_t id_;
+ static constexpr std::size_t INVALID_ID = std::numeric_limits<std::size_t>::max();
+ std::size_t id_ = INVALID_ID;
friend class Extendable<T>;
explicit constexpr Extension(std::size_t id) : id_(id) {}
public:
- explicit constexpr Extension() : id_(INVALID_ID) {}
+ explicit constexpr Extension() {}
std::size_t id() const { return id_; }
bool valid() const { return id_ != INVALID_ID; }
};
class Extendable {
private:
static std::vector<void(*)(void*)> deleters_;
- std::vector<void*> extensions_;
+ std::vector<void*> extensions_{(deleters_.size() > 0 ? deleters_.size() : 1), nullptr};
+
public:
static size_t extension_create(void (*deleter)(void*))
{
{
return Extension<T, U>(extension_create([](void* p) { delete static_cast<U*>(p); }));
}
- Extendable() : extensions_((deleters_.size() > 0 ? deleters_.size() : 1), nullptr) {}
+ Extendable() {}
Extendable(const Extendable&) = delete;
Extendable& operator=(const Extendable&) = delete;
~Extendable()
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
/* xbt/asserts.h -- assertion mechanism */
-/* Copyright (c) 2005-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2005-2020. 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. */
-/* Copyright (c) 2011-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2011-2020. 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. */
} s_xbt_automaton_state;
typedef struct xbt_automaton_state* xbt_automaton_state_t;
+typedef const struct xbt_automaton_state* const_xbt_automaton_state_t;
typedef struct xbt_automaton {
xbt_dynar_t propositional_symbols;
} s_xbt_automaton;
typedef struct xbt_automaton* xbt_automaton_t;
+typedef const struct xbt_automaton* const_xbt_automaton_t;
typedef struct xbt_automaton_exp_label{
enum{AUT_OR=0, AUT_AND=1, AUT_NOT=2, AUT_PREDICAT=3, AUT_ONE=4} type;
} s_xbt_automaton_exp_label;
typedef struct xbt_automaton_exp_label* xbt_automaton_exp_label_t;
+typedef const struct xbt_automaton_exp_label* const_xbt_automaton_exp_label_t;
typedef struct xbt_automaton_transition {
xbt_automaton_state_t src;
} s_xbt_automaton_transition;
typedef struct xbt_automaton_transition* xbt_automaton_transition_t;
+typedef const struct xbt_automaton_transition* const_xbt_automaton_transition_t;
typedef struct xbt_automaton_propositional_symbol* xbt_automaton_propositional_symbol_t;
+typedef const struct xbt_automaton_propositional_symbol* const_xbt_automaton_propositional_symbol_t;
typedef int (*xbt_automaton_propositional_symbol_callback_type)(void*);
typedef void (*xbt_automaton_propositional_symbol_free_function_type)(void*);
XBT_PUBLIC xbt_automaton_t xbt_automaton_new(void);
XBT_PUBLIC void xbt_automaton_load(xbt_automaton_t automaton, const char* file);
-XBT_PUBLIC xbt_automaton_state_t xbt_automaton_state_new(xbt_automaton_t a, int type, char* id);
-XBT_PUBLIC xbt_automaton_transition_t xbt_automaton_transition_new(xbt_automaton_t a, xbt_automaton_state_t src,
+XBT_PUBLIC xbt_automaton_state_t xbt_automaton_state_new(const_xbt_automaton_t a, int type, const char* id);
+XBT_PUBLIC xbt_automaton_transition_t xbt_automaton_transition_new(const_xbt_automaton_t a, xbt_automaton_state_t src,
xbt_automaton_state_t dst,
xbt_automaton_exp_label_t label);
XBT_PUBLIC xbt_automaton_exp_label_t xbt_automaton_exp_label_new_or(xbt_automaton_exp_label_t left,
XBT_PUBLIC xbt_automaton_exp_label_t xbt_automaton_exp_label_new_and(xbt_automaton_exp_label_t left,
xbt_automaton_exp_label_t right);
XBT_PUBLIC xbt_automaton_exp_label_t xbt_automaton_exp_label_new_not(xbt_automaton_exp_label_t exp_not);
-XBT_PUBLIC xbt_automaton_exp_label_t xbt_automaton_exp_label_new_predicat(char* p);
+XBT_PUBLIC xbt_automaton_exp_label_t xbt_automaton_exp_label_new_predicat(const char* p);
XBT_PUBLIC xbt_automaton_exp_label_t xbt_automaton_exp_label_new_one(void);
-XBT_PUBLIC xbt_dynar_t xbt_automaton_get_states(xbt_automaton_t a);
-XBT_PUBLIC xbt_dynar_t xbt_automaton_get_transitions(xbt_automaton_t a);
-XBT_PUBLIC xbt_automaton_transition_t xbt_automaton_get_transition(xbt_automaton_t a, xbt_automaton_state_t src,
- xbt_automaton_state_t dst);
-XBT_PUBLIC xbt_automaton_state_t xbt_automaton_transition_get_source(xbt_automaton_transition_t t);
-XBT_PUBLIC xbt_automaton_state_t xbt_automaton_transition_get_destination(xbt_automaton_transition_t t);
+XBT_PUBLIC xbt_dynar_t xbt_automaton_get_states(const_xbt_automaton_t a);
+XBT_PUBLIC xbt_dynar_t xbt_automaton_get_transitions(const_xbt_automaton_t a);
+XBT_PUBLIC xbt_automaton_transition_t xbt_automaton_get_transition(const_xbt_automaton_t a,
+ const_xbt_automaton_state_t src,
+ const_xbt_automaton_state_t dst);
+XBT_PUBLIC xbt_automaton_state_t xbt_automaton_transition_get_source(const_xbt_automaton_transition_t t);
+XBT_PUBLIC xbt_automaton_state_t xbt_automaton_transition_get_destination(const_xbt_automaton_transition_t t);
XBT_PUBLIC void xbt_automaton_transition_set_source(xbt_automaton_transition_t t, xbt_automaton_state_t src);
XBT_PUBLIC void xbt_automaton_transition_set_destination(xbt_automaton_transition_t t, xbt_automaton_state_t dst);
-XBT_PUBLIC xbt_dynar_t xbt_automaton_state_get_out_transitions(xbt_automaton_state_t s);
-XBT_PUBLIC xbt_dynar_t xbt_automaton_state_get_in_transitions(xbt_automaton_state_t s);
-XBT_PUBLIC xbt_automaton_state_t xbt_automaton_state_exists(xbt_automaton_t a, char* id);
-XBT_PUBLIC void xbt_automaton_display(xbt_automaton_t a);
-XBT_PUBLIC void xbt_automaton_exp_label_display(xbt_automaton_exp_label_t l);
+XBT_PUBLIC xbt_dynar_t xbt_automaton_state_get_out_transitions(const_xbt_automaton_state_t s);
+XBT_PUBLIC xbt_dynar_t xbt_automaton_state_get_in_transitions(const_xbt_automaton_state_t s);
+XBT_PUBLIC xbt_automaton_state_t xbt_automaton_state_exists(const_xbt_automaton_t a, const char* id);
+XBT_PUBLIC void xbt_automaton_display(const_xbt_automaton_t a);
+XBT_PUBLIC void xbt_automaton_exp_label_display(const_xbt_automaton_exp_label_t l);
// xbt_automaton_propositional_symbol constructors:
-XBT_PUBLIC xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new(xbt_automaton_t a,
+XBT_PUBLIC xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new(const_xbt_automaton_t a,
const char* id,
int (*fct)(void));
-XBT_PUBLIC xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new_pointer(xbt_automaton_t a,
+XBT_PUBLIC xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new_pointer(const_xbt_automaton_t a,
const char* id,
int* value);
XBT_PUBLIC xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new_callback(
- xbt_automaton_t a, const char* id, xbt_automaton_propositional_symbol_callback_type callback, void* data,
+ const_xbt_automaton_t a, const char* id, xbt_automaton_propositional_symbol_callback_type callback, void* data,
xbt_automaton_propositional_symbol_free_function_type free_function);
// xbt_automaton_propositional_symbol accessors:
XBT_PUBLIC xbt_automaton_propositional_symbol_callback_type
-xbt_automaton_propositional_symbol_get_callback(xbt_automaton_propositional_symbol_t symbol);
-XBT_PUBLIC void* xbt_automaton_propositional_symbol_get_data(xbt_automaton_propositional_symbol_t symbol);
-XBT_PUBLIC const char* xbt_automaton_propositional_symbol_get_name(xbt_automaton_propositional_symbol_t symbol);
+xbt_automaton_propositional_symbol_get_callback(const_xbt_automaton_propositional_symbol_t symbol);
+XBT_PUBLIC void* xbt_automaton_propositional_symbol_get_data(const_xbt_automaton_propositional_symbol_t symbol);
+XBT_PUBLIC const char* xbt_automaton_propositional_symbol_get_name(const_xbt_automaton_propositional_symbol_t symbol);
// xbt_automaton_propositional_symbol methods!
-XBT_PUBLIC int xbt_automaton_propositional_symbol_evaluate(xbt_automaton_propositional_symbol_t symbol);
-
-XBT_PUBLIC xbt_automaton_state_t xbt_automaton_get_current_state(xbt_automaton_t a);
-XBT_PUBLIC int xbt_automaton_state_compare(xbt_automaton_state_t s1, xbt_automaton_state_t s2);
-XBT_PUBLIC int xbt_automaton_propositional_symbols_compare_value(xbt_dynar_t s1, xbt_dynar_t s2);
-XBT_PUBLIC int xbt_automaton_transition_compare(const void* t1, const void* t2);
-XBT_PUBLIC int xbt_automaton_exp_label_compare(xbt_automaton_exp_label_t l1, xbt_automaton_exp_label_t l2);
+XBT_PUBLIC int xbt_automaton_propositional_symbol_evaluate(const_xbt_automaton_propositional_symbol_t symbol);
+
+XBT_PUBLIC xbt_automaton_state_t xbt_automaton_get_current_state(const_xbt_automaton_t a);
+XBT_PUBLIC int xbt_automaton_state_compare(const_xbt_automaton_state_t s1, const_xbt_automaton_state_t s2);
+XBT_PUBLIC int xbt_automaton_propositional_symbols_compare_value(const_xbt_dynar_t s1, const_xbt_dynar_t s2);
+XBT_PUBLIC int xbt_automaton_transition_compare(const_xbt_automaton_transition_t t1,
+ const_xbt_automaton_transition_t t2);
+XBT_PUBLIC int xbt_automaton_exp_label_compare(const_xbt_automaton_exp_label_t l1, const_xbt_automaton_exp_label_t l2);
XBT_PUBLIC void xbt_automaton_state_free_voidp(void* s);
XBT_PUBLIC void xbt_automaton_state_free(xbt_automaton_state_t s);
XBT_PUBLIC void xbt_automaton_transition_free_voidp(void* t);
-/* Copyright (c) 2015-2019. The SimGrid Team.
+/* Copyright (c) 2015-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* This API hides all the callback and dynamic allocation hell from
* the used which can use C++ style functors and lambda expressions.
*/
-template<class F>
-xbt_automaton_propositional_symbol_t add_proposition(
- xbt_automaton_t a, const char* id, F f)
+template <class F> xbt_automaton_propositional_symbol_t add_proposition(const_xbt_automaton_t a, const char* id, F f)
{
F* callback = new F(std::move(f));
return xbt_automaton_propositional_symbol_new_callback(
-/* Copyright (c) 2005-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2005-2020. 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/base.h>
-#include <cstddef>
#include <functional>
#include <memory>
#include <string>
-#include <vector>
SG_BEGIN_DECL
/** @brief Shows a backtrace of the current location */
*/
class Backtrace {
public:
- BacktraceImpl* impl_ = nullptr;
+ std::shared_ptr<BacktraceImpl> impl_;
Backtrace();
- Backtrace(const Backtrace& bt);
- Backtrace(Backtrace&& bt);
- Backtrace& operator=(const Backtrace& rhs);
- Backtrace& operator=(Backtrace&& rhs);
- ~Backtrace();
/** @brief Translate the backtrace in a human friendly form, unmangled with source code locations. */
- std::string const resolve() const;
+ std::string resolve() const;
/** @brief Display the resolved backtrace on stderr */
void display() const;
};
/* xbt.h - Public interface to the xbt (simgrid's toolbox) */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
# define _GNU_SOURCE
#endif
-// Teach the compiler that some code path is unreachable:
-#if defined(__has_builtin)
-# if __has_builtin(__builtin_unreachable)
-# define XBT_UNREACHABLE() __builtin_unreachable()
-# else
-# include <stdlib.h>
-# define XBT_UNREACHABLE() abort()
-# endif
-#elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
-# define XBT_UNREACHABLE() __builtin_unreachable()
-#else
-# include <stdlib.h>
-# define XBT_UNREACHABLE() abort()
-#endif
-
/* On MinGW, stdio.h defines __MINGW_PRINTF_FORMAT and __MINGW_SCANF_FORMAT
which are the suitable format style (either gnu_printf or ms_printf)
depending on which version is available (__USE_MINGW_ANSI_STDIO): */
/* Concatenate arguments. _XBT_CONCAT2 adds a level of indirection over _XBT_CONCAT. */
#define _XBT_CONCAT(a, b) a##b
#define _XBT_CONCAT2(a, b) _XBT_CONCAT(a, b)
-#define _XBT_CONCAT3(a, b, c) _XBT_CONCAT2(_XBT_CONCAT(a, b), c)
+#define _XBT_CONCAT3(a, b, c) _XBT_CONCAT2(_XBT_CONCAT2(a, b), c)
#define _XBT_CONCAT4(a, b, c, d) _XBT_CONCAT2(_XBT_CONCAT3(a, b, c), d)
/*
/* config - Dictionary where the type of each cell is provided. */
/* This is useful to build named structs, like option or property sets. */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
XBT_PUBLIC void sg_cfg_set_string(const char* name, const char* val);
/* @} */
-/** @defgroup XBT_cfg_decl Configuration type declaration and memory management
- * @ingroup XBT_config
- *
- * @{
- */
-
-/** @brief Callback types. They get the name of the modified entry, and the position of the changed value */
-typedef void (*xbt_cfg_cb_t)(const char* name);
-
-/** @} */
-
/** @defgroup XBT_cfg_get Getting the stored values
* @ingroup XBT_config
*
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
std::string name_;
public:
-
/** Constructor
*
* @param name Flag name
template<class U>
Flag& operator=(U const& that) { value_ = that; return *this; }
template<class U>
- Flag& operator=(U && that) { value_ = that; return *this; }
+ Flag& operator=(U&& that) { value_ = std::forward<U>(that); return *this; }
template<class U>
bool operator==(U const& that) const { return value_ == that; }
template<class U>
XBT_PUBLIC void finalize();
XBT_PUBLIC void show_aliases();
XBT_PUBLIC void help();
-}
-}
+} // namespace config
+} // namespace simgrid
#endif
/* xbt/dict.h -- api to a generic dictionary */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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 Dictionary data type (opaque structure) */
typedef struct s_xbt_dict *xbt_dict_t;
+typedef const struct s_xbt_dict* const_xbt_dict_t;
typedef struct s_xbt_dictelm *xbt_dictelm_t;
typedef struct s_xbt_dictelm {
char *key;
XBT_PUBLIC xbt_dict_t xbt_dict_new_homogeneous(void_f_pvoid_t free_ctn);
XBT_PUBLIC void xbt_dict_free(xbt_dict_t* dict);
-XBT_PUBLIC unsigned int xbt_dict_size(xbt_dict_t dict);
+XBT_PUBLIC unsigned int xbt_dict_size(const_xbt_dict_t dict);
/** @} */
/** @defgroup XBT_dict_basic Dictionaries basic usage
*/
XBT_PUBLIC void xbt_dict_set(xbt_dict_t dict, const char* key, void* data);
-XBT_PUBLIC void* xbt_dict_get(xbt_dict_t dict, const char* key);
-XBT_PUBLIC void* xbt_dict_get_or_null(xbt_dict_t dict, const char* key);
-XBT_PUBLIC char* xbt_dict_get_key(xbt_dict_t dict, const void* data);
-XBT_PUBLIC xbt_dictelm_t xbt_dict_get_elm(xbt_dict_t dict, const char* key);
-XBT_PUBLIC xbt_dictelm_t xbt_dict_get_elm_or_null(xbt_dict_t dict, const char* key);
+XBT_PUBLIC void* xbt_dict_get_or_null(const_xbt_dict_t dict, const char* key);
+XBT_PUBLIC xbt_dictelm_t xbt_dict_get_elm_or_null(const_xbt_dict_t dict, const char* key);
-XBT_PUBLIC void xbt_dict_remove(xbt_dict_t dict, const char* key);
-XBT_PUBLIC void xbt_dict_reset(xbt_dict_t dict);
-XBT_PUBLIC int xbt_dict_length(xbt_dict_t dict);
-XBT_PUBLIC int xbt_dict_is_empty(xbt_dict_t dict);
+XBT_PUBLIC int xbt_dict_length(const_xbt_dict_t dict);
+XBT_PUBLIC int xbt_dict_is_empty(const_xbt_dict_t dict);
/** @} */
/** @defgroup XBT_dict_nnul Dictionaries with non-nul terminated keys
* @{
*/
XBT_PUBLIC void xbt_dict_set_ext(xbt_dict_t dict, const char* key, int key_len, void* data);
-XBT_PUBLIC void* xbt_dict_get_ext(xbt_dict_t dict, const char* key, int key_len);
-XBT_PUBLIC void* xbt_dict_get_or_null_ext(xbt_dict_t dict, const char* key, int key_len);
+XBT_PUBLIC void* xbt_dict_get_or_null_ext(const_xbt_dict_t dict, const char* key, int key_len);
XBT_PUBLIC void xbt_dict_remove_ext(xbt_dict_t dict, const char* key, int key_len);
struct s_xbt_dict_cursor {
xbt_dictelm_t current;
int line;
- xbt_dict_t dict;
+ const_xbt_dict_t dict;
};
/** @} */
/** @brief Cursor on dictionaries (opaque type) */
typedef struct s_xbt_dict_cursor *xbt_dict_cursor_t;
+typedef const struct s_xbt_dict_cursor* const_xbt_dict_cursor_t;
-static inline xbt_dictelm_t xbt_dict_cursor_get_elm(xbt_dict_cursor_t cursor) {
- return cursor->current;
-}
-
-XBT_PUBLIC xbt_dict_cursor_t xbt_dict_cursor_new(const xbt_dict_t dict);
+XBT_PUBLIC xbt_dict_cursor_t xbt_dict_cursor_new(const_xbt_dict_t dict);
XBT_PUBLIC void xbt_dict_cursor_free(xbt_dict_cursor_t* cursor);
XBT_PUBLIC void xbt_dict_cursor_rewind(xbt_dict_cursor_t cursor);
-XBT_PUBLIC char* xbt_dict_cursor_get_key(xbt_dict_cursor_t cursor);
-XBT_PUBLIC void* xbt_dict_cursor_get_data(xbt_dict_cursor_t cursor);
+XBT_PUBLIC char* xbt_dict_cursor_get_key(const_xbt_dict_cursor_t cursor);
+XBT_PUBLIC void* xbt_dict_cursor_get_data(const_xbt_dict_cursor_t cursor);
-XBT_PUBLIC void xbt_dict_cursor_first(const xbt_dict_t dict, xbt_dict_cursor_t* cursor);
+XBT_PUBLIC void xbt_dict_cursor_first(const_xbt_dict_t dict, xbt_dict_cursor_t* cursor);
XBT_PUBLIC void xbt_dict_cursor_step(xbt_dict_cursor_t cursor);
XBT_PUBLIC int xbt_dict_cursor_get_or_free(xbt_dict_cursor_t* cursor, char** key, void** data);
/** @def xbt_dict_foreach
/* dynar - a generic dynamic array */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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 Dynar data type (opaque type) */
typedef struct xbt_dynar_s *xbt_dynar_t;
+typedef const struct xbt_dynar_s* const_xbt_dynar_t;
-XBT_PUBLIC xbt_dynar_t xbt_dynar_new(const unsigned long elm_size, void_f_pvoid_t const free_f);
-XBT_PUBLIC void xbt_dynar_init(xbt_dynar_t dynar, const unsigned long elmsize, void_f_pvoid_t const free_f);
+XBT_PUBLIC xbt_dynar_t xbt_dynar_new(const unsigned long elm_size, void_f_pvoid_t free_f);
XBT_PUBLIC void xbt_dynar_free(xbt_dynar_t* dynar);
-XBT_PUBLIC void xbt_dynar_free_voidp(void* dynar);
XBT_PUBLIC void xbt_dynar_free_container(xbt_dynar_t* dynar);
-XBT_PUBLIC void xbt_dynar_free_data(xbt_dynar_t dynar);
XBT_PUBLIC void xbt_dynar_shrink(xbt_dynar_t dynar, int empty_slots);
-XBT_PUBLIC void xbt_dynar_dump(xbt_dynar_t dynar);
/** @} */
/** @defgroup XBT_dynar_array Dynar as a regular array
* @{
*/
-XBT_PUBLIC void xbt_dynar_get_cpy(const xbt_dynar_t dynar, const unsigned long idx, void* const dst);
-XBT_PUBLIC void xbt_dynar_set(xbt_dynar_t dynar, const int idx, const void* src);
-XBT_PUBLIC void xbt_dynar_replace(xbt_dynar_t dynar, const unsigned long idx, const void* object);
+XBT_PUBLIC void xbt_dynar_get_cpy(const_xbt_dynar_t dynar, unsigned long idx, void* dst);
-XBT_PUBLIC void xbt_dynar_insert_at(xbt_dynar_t const dynar, const int idx, const void* src);
-XBT_PUBLIC void xbt_dynar_remove_at(xbt_dynar_t const dynar, const int idx, void* const dst);
-XBT_PUBLIC void xbt_dynar_remove_n_at(xbt_dynar_t const dynar, const unsigned int n, const int idx);
+XBT_PUBLIC void xbt_dynar_insert_at(xbt_dynar_t dynar, int idx, const void* src);
+XBT_PUBLIC void xbt_dynar_remove_at(xbt_dynar_t dynar, int idx, void* dst);
-XBT_PUBLIC unsigned int xbt_dynar_search(xbt_dynar_t const dynar, void* elem);
-XBT_PUBLIC signed int xbt_dynar_search_or_negative(xbt_dynar_t const dynar, void* const elem);
-XBT_PUBLIC int xbt_dynar_member(xbt_dynar_t const dynar, void* elem);
-XBT_PUBLIC void xbt_dynar_sort(xbt_dynar_t const dynar, int_f_cpvoid_cpvoid_t compar_fn);
-XBT_PUBLIC int xbt_dynar_compare(xbt_dynar_t d1, xbt_dynar_t d2, int (*compar)(const void*, const void*));
+XBT_PUBLIC signed int xbt_dynar_search_or_negative(const_xbt_dynar_t dynar, const void* elem);
+XBT_PUBLIC int xbt_dynar_member(const_xbt_dynar_t dynar, const void* elem);
+XBT_PUBLIC void xbt_dynar_sort(const_xbt_dynar_t dynar, int_f_cpvoid_cpvoid_t compar_fn);
XBT_PUBLIC void* xbt_dynar_to_array(xbt_dynar_t dynar);
/** @} */
* @{
*/
-XBT_PUBLIC unsigned long xbt_dynar_length(const xbt_dynar_t dynar);
-XBT_PUBLIC int xbt_dynar_is_empty(const xbt_dynar_t dynar);
-XBT_PUBLIC void xbt_dynar_reset(xbt_dynar_t const dynar);
-XBT_PUBLIC void xbt_dynar_merge(xbt_dynar_t* d1, xbt_dynar_t* d2);
+XBT_PUBLIC unsigned long xbt_dynar_length(const_xbt_dynar_t dynar);
+XBT_PUBLIC int xbt_dynar_is_empty(const_xbt_dynar_t dynar);
+XBT_PUBLIC void xbt_dynar_reset(xbt_dynar_t dynar);
/** @} */
/** @defgroup XBT_dynar_perl Perl-like use of dynars
* @{
*/
-XBT_PUBLIC void xbt_dynar_push(xbt_dynar_t const dynar, const void* src);
-XBT_PUBLIC void xbt_dynar_pop(xbt_dynar_t const dynar, void* const dst);
-XBT_PUBLIC void xbt_dynar_unshift(xbt_dynar_t const dynar, const void* src);
-XBT_PUBLIC void xbt_dynar_shift(xbt_dynar_t const dynar, void* const dst);
-XBT_PUBLIC void xbt_dynar_map(const xbt_dynar_t dynar, void_f_pvoid_t const op);
+XBT_PUBLIC void xbt_dynar_push(xbt_dynar_t dynar, const void* src);
+XBT_PUBLIC void xbt_dynar_pop(xbt_dynar_t dynar, void* dst);
+XBT_PUBLIC void xbt_dynar_unshift(xbt_dynar_t dynar, const void* src);
+XBT_PUBLIC void xbt_dynar_shift(xbt_dynar_t dynar, void* dst);
+XBT_PUBLIC void xbt_dynar_map(const_xbt_dynar_t dynar, void_f_pvoid_t op);
/** @} */
/** @defgroup XBT_dynar_ctn Direct manipulation to the dynars content
* @{
*/
-XBT_PUBLIC void* xbt_dynar_set_at_ptr(const xbt_dynar_t dynar, const unsigned long idx);
-XBT_PUBLIC void* xbt_dynar_get_ptr(const xbt_dynar_t dynar, const unsigned long idx);
-XBT_PUBLIC void* xbt_dynar_insert_at_ptr(xbt_dynar_t const dynar, const int idx);
-XBT_PUBLIC void* xbt_dynar_push_ptr(xbt_dynar_t const dynar);
-XBT_PUBLIC void* xbt_dynar_pop_ptr(xbt_dynar_t const dynar);
+XBT_PUBLIC void* xbt_dynar_set_at_ptr(const xbt_dynar_t dynar, unsigned long idx);
+XBT_PUBLIC void* xbt_dynar_get_ptr(const_xbt_dynar_t dynar, unsigned long idx);
+XBT_PUBLIC void* xbt_dynar_insert_at_ptr(xbt_dynar_t dynar, int idx);
+XBT_PUBLIC void* xbt_dynar_push_ptr(xbt_dynar_t dynar);
+XBT_PUBLIC void* xbt_dynar_pop_ptr(xbt_dynar_t dynar);
/** @} */
/** @defgroup XBT_dynar_speed Speed optimized access to dynars of scalars
* @hideinitializer */
# define xbt_dynar_getfirst_as(dynar,type) \
(*(type*)xbt_dynar_get_ptr((dynar),0))
-/** @brief Quick insertion of scalar content
- * @hideinitializer */
-#define xbt_dynar_insert_at_as(dynar, idx, type, value) *(type*)xbt_dynar_insert_at_ptr((dynar), (idx)) = (value)
/** @brief Quick insertion of scalar content
* @hideinitializer */
#define xbt_dynar_push_as(dynar, type, value) *(type*)xbt_dynar_push_ptr(dynar) = (value)
* @{
*/
-XBT_PUBLIC void xbt_dynar_cursor_rm(xbt_dynar_t dynar, unsigned int* const cursor);
+XBT_PUBLIC void xbt_dynar_cursor_rm(xbt_dynar_t dynar, unsigned int* cursor);
/*
* @warning DO NOT USE THIS STRUCTURE DIRECTLY! Instead, use the public interface:
void_f_pvoid_t free_f;
} s_xbt_dynar_t;
-static inline int _xbt_dynar_cursor_get(const xbt_dynar_t dynar, unsigned int idx, void* const dst)
+static inline int _xbt_dynar_cursor_get(const_xbt_dynar_t dynar, unsigned int idx, void* dst)
{
if (!dynar) /* iterating over a NULL dynar is a no-op */
return 0;
#define xbt_dynar_foreach(_dynar, _cursor, _data) \
for ((_cursor) = 0; _xbt_dynar_cursor_get((_dynar), (_cursor), &(_data)); (_cursor)++)
-#ifndef __cplusplus
-#define xbt_dynar_foreach_ptr(_dynar, _cursor, _ptr) \
- for ((_cursor) = 0; ((_ptr) = (_cursor) < (_dynar)->used ? xbt_dynar_get_ptr((_dynar), (_cursor)) : NULL); \
- (_cursor)++)
-#else
-#define xbt_dynar_foreach_ptr(_dynar, _cursor, _ptr) \
- for ((_cursor) = 0; \
- ((_ptr) = (_cursor) < (_dynar)->used ? (decltype(_ptr))xbt_dynar_get_ptr((_dynar), (_cursor)) : NULL); \
- (_cursor)++)
-#endif
/** @} */
SG_END_DECL
-/* Copyright (c) 2005-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2005-2020. 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. */
SG_END_DECL
/** @} */
-#endif /* __XBT_EX_H__ */
+#endif /* XBT_EX_H */
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
/* function_type.h - classical types for pointer to function */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
namespace xbt {
template <class F> class MainFunction {
-private:
F code_;
std::shared_ptr<const std::vector<std::string>> args_;
*/
template<class R, class... Args>
class Task<R(Args...)> {
-private:
-
// Placeholder for some class type:
struct whatever {};
that.vtable_->move(buffer_, that.buffer_);
else
std::memcpy(static_cast<void*>(&buffer_), static_cast<void*>(&that.buffer_), sizeof(buffer_));
-
- vtable_ = that.vtable_;
+ vtable_ = std::move(that.vtable_);
that.vtable_ = nullptr;
}
Task& operator=(Task const& that) = delete;
that.vtable_->move(buffer_, that.buffer_);
else
std::memcpy(static_cast<void*>(&buffer_), static_cast<void*>(&that.buffer_), sizeof(buffer_));
- vtable_ = that.vtable_;
+ vtable_ = std::move(that.vtable_);
that.vtable_ = nullptr;
return *this;
}
private:
-
template<class F>
typename std::enable_if<canSBO<F>()>::type
init(F code)
F* src = reinterpret_cast<F*>(&buffer);
F code = std::move(*src);
src->~F();
+ // NOTE: std::forward<Args>(args)... is correct.
return code(std::forward<Args>(args)...);
},
// Destroy:
[](TaskUnion& buffer, Args... args) {
// Delete F when we go out of scope:
std::unique_ptr<F> code(*reinterpret_cast<F**>(&buffer));
+ // NOTE: std::forward<Args>(args)... is correct.
return (*code)(std::forward<Args>(args)...);
},
// Destroy:
throw std::bad_function_call();
const TaskVtable* vtable = vtable_;
vtable_ = nullptr;
+ // NOTE: std::forward<Args>(args)... is correct.
+ // see C++ [func.wrap.func.inv] for an example
return vtable->call(buffer_, std::forward<Args>(args)...);
}
};
template<class F, class... Args>
class TaskImpl {
-private:
F code_;
std::tuple<Args...> args_;
typedef decltype(simgrid::xbt::apply(std::move(code_), std::move(args_))) result_type;
-/* Copyright (c) 2015-2019. The SimGrid Team.
+/* Copyright (c) 2015-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
/* API */
XBT_PUBLIC xbt_graph_t xbt_graph_new_graph(unsigned short int directed, void* data);
-XBT_PUBLIC xbt_node_t xbt_graph_new_node(xbt_graph_t g, void* data);
-XBT_PUBLIC xbt_edge_t xbt_graph_new_edge(xbt_graph_t g, xbt_node_t src, xbt_node_t dst, void* data);
-XBT_PUBLIC void* xbt_graph_node_get_data(xbt_node_t node);
+XBT_PUBLIC xbt_node_t xbt_graph_new_node(const s_xbt_graph_t* g, void* data);
+XBT_PUBLIC xbt_edge_t xbt_graph_new_edge(const s_xbt_graph_t* g, xbt_node_t src, xbt_node_t dst, void* data);
+XBT_PUBLIC void* xbt_graph_node_get_data(const s_xbt_node_t* node);
XBT_PUBLIC void xbt_graph_node_set_data(xbt_node_t node, void* data);
-XBT_PUBLIC void* xbt_graph_edge_get_data(xbt_edge_t edge);
+XBT_PUBLIC void* xbt_graph_edge_get_data(const s_xbt_edge_t* edge);
XBT_PUBLIC void xbt_graph_edge_set_data(xbt_edge_t edge, void* data);
-XBT_PUBLIC xbt_edge_t xbt_graph_get_edge(xbt_graph_t g, xbt_node_t src, xbt_node_t dst);
+XBT_PUBLIC xbt_edge_t xbt_graph_get_edge(const s_xbt_graph_t* g, const s_xbt_node_t* src, const s_xbt_node_t* dst);
XBT_PUBLIC void xbt_graph_free_graph(xbt_graph_t g, void_f_pvoid_t node_free_function,
void_f_pvoid_t edge_free_function, void_f_pvoid_t graph_free_function);
-XBT_PUBLIC xbt_dynar_t xbt_graph_get_nodes(xbt_graph_t g);
-XBT_PUBLIC xbt_dynar_t xbt_graph_get_edges(xbt_graph_t g);
-XBT_PUBLIC xbt_dynar_t xbt_graph_node_get_outedges(xbt_node_t n);
-XBT_PUBLIC xbt_node_t xbt_graph_edge_get_source(xbt_edge_t e);
-XBT_PUBLIC xbt_node_t xbt_graph_edge_get_target(xbt_edge_t e);
+XBT_PUBLIC xbt_dynar_t xbt_graph_get_nodes(const s_xbt_graph_t* g);
+XBT_PUBLIC xbt_dynar_t xbt_graph_get_edges(const s_xbt_graph_t* g);
+XBT_PUBLIC xbt_dynar_t xbt_graph_node_get_outedges(const s_xbt_node_t* n);
+XBT_PUBLIC xbt_node_t xbt_graph_edge_get_source(const s_xbt_edge_t* e);
+XBT_PUBLIC xbt_node_t xbt_graph_edge_get_target(const s_xbt_edge_t* e);
SG_END_DECL
#endif /* XBT_GRAPH_H */
/* log - a generic logging facility in the spirit of log4j */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
#define XBT_HELP(...) XBT_CINFO(xbt_help, __VA_ARGS__)
SG_END_DECL
-#endif /* ! _XBT_LOG_H_ */
+#endif /* XBT_LOG_H */
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
XBT_PUBLIC void log_exception(e_xbt_log_priority_t priority, const char* context, std::exception const& exception);
XBT_PUBLIC void install_exception_handler();
-}
-}
+
+} // namespace xbt
+} // namespace simgrid
/* xbt/mallocator.h -- api to recycle allocated objects */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
/** @} */
SG_END_DECL
-#endif /* _XBT_MALLOCATOR_H */
+#endif /* XBT_MALLOCATOR_H */
/* xbt.h - Public interface to the xbt (simgrid's toolbox) */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
/* module - modularize the code */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
/* A thread pool. */
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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. */
-/* Copyright (c) 2016-2019. The SimGrid Team.
+/* Copyright (c) 2016-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* xbt/replay_reader.h -- Tools to parse a replay file */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
/* str.h - XBT string related functions. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
string() : string(&NUL, 0) {}
explicit string(const char* s) : string(s, strlen(s)) {}
string(string const& s) : string(s.c_str(), s.size()) {}
- string(string&& s)
+ string(string&& s) : str(std::move(s.str))
{
- str.len = s.str.len;
- str.data = s.str.data;
s.str.len = 0;
s.str.data = &NUL;
}
/* xbt/synchro.h -- Simulated synchronization */
-/* Copyright (c) 2009-2019. The SimGrid Team. */
+/* Copyright (c) 2009-2020. The SimGrid Team. */
/* 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. */
/* no system header should be loaded out of this file so that we have only */
/* one file to check when porting to another OS */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
-/* Copyright (c) 2016-2019. The SimGrid Team.
+/* Copyright (c) 2016-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2016-2019. The SimGrid Team.
+/* Copyright (c) 2016-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* virtu - virtualization layer for the logging to know about the actors */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
#define XBT_VIRTU_H
#include <xbt/base.h>
-#include <xbt/dynar.h>
-#include <xbt/function_types.h>
-#include <xbt/misc.h>
+
+#ifdef __cplusplus
+#include <string>
+#include <vector>
+
+namespace simgrid {
+namespace xbt {
+
+/* Get the name of the UNIX process englobing the world */
+XBT_PUBLIC_DATA std::string binary_name;
+/** Contains all the parameters we got from the command line (including argv[0]) */
+XBT_PUBLIC_DATA std::vector<std::string> cmdline;
+
+} // namespace xbt
+} // namespace simgrid
+#endif
SG_BEGIN_DECL
XBT_PUBLIC int xbt_getpid(void);
-/* Get the name of the UNIX process englobing the world */
-XBT_PUBLIC_DATA char* xbt_binary_name;
-
-/** Contains all the parameters we got from the command line (including argv[0]) */
-XBT_PUBLIC_DATA xbt_dynar_t xbt_cmdline;
-
SG_END_DECL
+
#endif /* XBT_VIRTU_H */
/* xbt/xbt_os_timer.h -- system dependency on time functions */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
XBT_PUBLIC void xbt_os_sleep(double sec);
typedef struct s_xbt_os_timer *xbt_os_timer_t;
+typedef const struct s_xbt_os_timer* const_xbt_os_timer_t;
XBT_PUBLIC xbt_os_timer_t xbt_os_timer_new(void);
XBT_PUBLIC void xbt_os_timer_free(xbt_os_timer_t timer);
-XBT_PUBLIC double xbt_os_timer_elapsed(xbt_os_timer_t timer);
+XBT_PUBLIC double xbt_os_timer_elapsed(const_xbt_os_timer_t timer);
XBT_PUBLIC size_t xbt_os_timer_size(void);
XBT_PUBLIC void xbt_os_walltimer_start(xbt_os_timer_t timer);
# Disable some rules on some files
-sonar.issue.ignore.multicriteria=j1,j2,j3,j4,j5,jni1,jni2,c1,c2a,c2b,c3,c4a,c4b,c5a,c5b,c6a,c6b,c7,c8,c9,c10,f1,p1,s1,s2,s3,s4
+sonar.issue.ignore.multicriteria=j1,j2,j3,j4,j5,jni1,jni2,c1,c2a,c2b,c3,c4a,c4b,c5a,c5b,c6a,c6b,c7,c8,c9,c10,f1,p1,s1,s2,s3,s4,s5
# The Object.finalize() method should not be overridden
# But we need to clean the native memory with JNI
-sonar.issue.ignore.multicriteria.j1.ruleKey=squid:ObjectFinalizeOverridenCheck
+sonar.issue.ignore.multicriteria.j1.ruleKey=java:S1113
sonar.issue.ignore.multicriteria.j1.resourceKey=**/*.java
# Throwable.printStackTrace(...) should not be called
# But we don't have no better mechanism, and our Java apps are not rocket science
-sonar.issue.ignore.multicriteria.j2.ruleKey=squid:S1148
+sonar.issue.ignore.multicriteria.j2.ruleKey=java:S1148
sonar.issue.ignore.multicriteria.j2.resourceKey=**/*.java
# Using command line arguments is security-sensitive
# But the authors of the applications using our library will be their only users, so there is no security concern
-sonar.issue.ignore.multicriteria.j3.ruleKey=squid:S4823
+sonar.issue.ignore.multicriteria.j3.ruleKey=java:S4823
sonar.issue.ignore.multicriteria.j3.resourceKey=**/*.java
# Standard outputs should not be used directly to log anything
# But this file is used before SimGrid is initialized
-sonar.issue.ignore.multicriteria.j4.ruleKey=squid:S106
+sonar.issue.ignore.multicriteria.j4.ruleKey=java:S106
sonar.issue.ignore.multicriteria.j4.resourceKey=src/bindings/java/org/simgrid/NativeLib.java
# Deprecated code should be removed
# We do have a process to remove deprecated code
-sonar.issue.ignore.multicriteria.j5.ruleKey=squid:S1133
+sonar.issue.ignore.multicriteria.j5.ruleKey=java:S1133
sonar.issue.ignore.multicriteria.j5.resourceKey=**/*.java
# "reinterpret_cast" should not be used
sonar.issue.ignore.multicriteria.s4.ruleKey=cpp:S859
sonar.issue.ignore.multicriteria.s4.resourceKey=src/smpi/**/*.cpp
+# Pointer and reference parameters should be "const" if the corresponding object is not modified
+# AFAICT, the "constness" is required by the MPI standard and cannot be fixed.
+sonar.issue.ignore.multicriteria.s5.ruleKey=cpp:S995
+sonar.issue.ignore.multicriteria.s5.resourceKey=src/smpi/bindings/*.cpp
+
# Exclude some files from the analysis:
# - our unit tests
# - the tests that we borrowed elsewhere (MPICH and ISP)
sonar.sourceEncoding=UTF-8
# Version of the used prog languages
-sonar.java.source=7
+sonar.java.source=8
sonar.java.binaries=CMakeFiles/simgrid-java_jar.dir,examples/deprecated/java
# Don't talk to me: travis don't like your verbosity
#sonar.python.coverage.reportPaths
#sonar.coverage.jacoco.xmlReportPaths
#sonar.cfamily.threads
+#sonar.cfamily.cache.enabled
+#sonar.cfamily.cache.path
/* Context switching within the JVM. */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
JavaContextFactory::JavaContextFactory() : ContextFactory()
{
- xbt_assert(xbt_binary_name && strcmp(xbt_binary_name, "java") == 0); // Set by Java_org_simgrid_msg_Msg_init
+ xbt_assert(xbt::binary_name == "java");
}
JavaContextFactory::~JavaContextFactory()=default;
/* Context switching within the JVM. */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
}}} // namespace simgrid::kernel::context
-#endif /* !_XBT_CONTEXT_JAVA_H */
+#endif /* SIMGRID_JAVA_JAVA_CONTEXT_HPP */
/* Java Wrappers to the MSG API. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
JNIEnv *get_current_thread_env()
{
using simgrid::kernel::context::JavaContext;
- JavaContext* ctx = static_cast<JavaContext*>(simgrid::kernel::context::Context::self());
+ const JavaContext* ctx = static_cast<JavaContext*>(simgrid::kernel::context::Context::self());
if (ctx)
return ctx->jenv_;
else
env->GetJavaVM(&__java_vm);
simgrid::kernel::context::factory_initializer = &simgrid::kernel::context::java_factory;
- jthrowable exc = env->ExceptionOccurred();
+ const _jthrowable* exc = env->ExceptionOccurred();
if (exc) {
env->ExceptionClear();
}
argc += static_cast<int>(env->GetArrayLength(jargs));
xbt_assert(argc > 0);
- // Need a static storage because the XBT layer saves the arguments in xbt_binary_name and xbt_cmdline.
+ // Need a static storage because the XBT layer saves the arguments in xbt::binary_name and xbt::cmdline.
static std::vector<std::string> args;
args.reserve(argc);
/* Cleanup java hosts */
xbt_dynar_t hosts = MSG_hosts_as_dynar();
for (unsigned long index = 0; index < xbt_dynar_length(hosts) - 1; index++) {
- msg_host_t msg_host = xbt_dynar_get_as(hosts,index,msg_host_t);
+ auto const* msg_host = xbt_dynar_get_as(hosts, index, msg_host_t);
jobject jhost = (jobject) msg_host->extension(JAVA_HOST_LEVEL);
if (jhost)
jhost_unref(env, jhost);
xbt_assert((jprocess != nullptr), "Process allocation failed.");
jprocess = env->NewGlobalRef(jprocess);
//bind the process to the context
- msg_process_t process = MSG_process_self();
+ const_sg_actor_t process = MSG_process_self();
context->jprocess_ = jprocess;
/* sets the PID and the PPID of the process */
/* Java Wrappers to the MSG API. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
/* Java bindings of the NetZones. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
}
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_As_getName(JNIEnv * env, jobject jas) {
- simgrid::s4u::NetZone* as = jnetzone_get_native(env, jas);
+ const simgrid::s4u::NetZone* as = jnetzone_get_native(env, jas);
return env->NewStringUTF(as->get_cname());
}
JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getSons(JNIEnv * env, jobject jas) {
int index = 0;
jobjectArray jtable;
- sg_netzone_t self_as = jnetzone_get_native(env, jas);
+ const simgrid::s4u::NetZone* self_as = jnetzone_get_native(env, jas);
jclass cls = env->FindClass("org/simgrid/msg/As");
}
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_As_getProperty(JNIEnv *env, jobject jas, jobject jname) {
- simgrid::s4u::NetZone* as = jnetzone_get_native(env, jas);
+ const simgrid::s4u::NetZone* as = jnetzone_get_native(env, jas);
if (not as) {
jxbt_throw_notbound(env, "as", jas);
jobjectArray jtable;
jobject jhost;
jstring jname;
- simgrid::s4u::NetZone* as = jnetzone_get_native(env, jas);
+ const simgrid::s4u::NetZone* as = jnetzone_get_native(env, jas);
jclass cls = jxbt_get_class(env, "org/simgrid/msg/Host");
if (not cls)
/* Functions related to the java As instances. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
/* Java bindings to the Comm API */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
static jfieldID jcomm_field_Comm_taskBind;
void jcomm_bind_task(JNIEnv *env, jobject jcomm) {
- msg_comm_t comm = (msg_comm_t) (uintptr_t) env->GetLongField(jcomm, jcomm_field_Comm_bind);
+ const_msg_comm_t comm = (msg_comm_t)(uintptr_t)env->GetLongField(jcomm, jcomm_field_Comm_bind);
//test if we are receiving or sending a task.
jboolean jreceiving = env->GetBooleanField(jcomm, jcomm_field_Comm_receiving);
if (jreceiving == JNI_TRUE) {
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Comm_nativeFinalize(JNIEnv *env, jobject jcomm) {
- msg_comm_t comm;
msg_task_t *task_received;
task_received = (msg_task_t*) (uintptr_t) env->GetLongField(jcomm, jcomm_field_Comm_taskBind);
delete task_received;
- comm = (msg_comm_t) (uintptr_t) env->GetLongField(jcomm, jcomm_field_Comm_bind);
+ const_msg_comm_t comm = (msg_comm_t)(uintptr_t)env->GetLongField(jcomm, jcomm_field_Comm_bind);
MSG_comm_destroy(comm);
}
/* Java bindings to the Comm API */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
/* Java bindings of the file API. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_File_close(JNIEnv *env, jobject jfile) {
- msg_file_t file = jfile_get_native(env, jfile);
+ const_sg_file_t file = jfile_get_native(env, jfile);
MSG_file_close(file);
jfile_bind(env, jfile, nullptr);
/* Java bindings of the file API. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
/* Functions related to the java host instances. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
"Native initialization of msg/Host failed. Please report that bug");
}
-JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jclass cls, jstring jname) {
-
+JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName(JNIEnv* env, jclass cls, jstring jname)
+{
/* get the C string from the java string */
if (jname == nullptr) {
jxbt_throw_null(env, "No host can have a null name");
}
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getSpeed(JNIEnv * env, jobject jhost) {
- msg_host_t host = jhost_get_native(env, jhost);
+ const_sg_host_t host = jhost_get_native(env, jhost);
if (not host) {
jxbt_throw_notbound(env, "host", jhost);
}
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCoreNumber(JNIEnv * env, jobject jhost) {
- msg_host_t host = jhost_get_native(env, jhost);
+ const_sg_host_t host = jhost_get_native(env, jhost);
if (not host) {
jxbt_throw_notbound(env, "host", jhost);
}
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getProperty(JNIEnv *env, jobject jhost, jobject jname) {
- msg_host_t host = jhost_get_native(env, jhost);
+ const_sg_host_t host = jhost_get_native(env, jhost);
if (not host) {
jxbt_throw_notbound(env, "host", jhost);
}
const char *name = env->GetStringUTFChars((jstring) jname, 0);
const char *value_java = env->GetStringUTFChars((jstring) jvalue, 0);
- char *value = xbt_strdup(value_java);
+ const char* value = xbt_strdup(value_java);
MSG_host_set_property_value(host, name, value);
JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Host_isOn(JNIEnv * env, jobject jhost)
{
- msg_host_t host = jhost_get_native(env, jhost);
+ const_sg_host_t host = jhost_get_native(env, jhost);
if (not host) {
jxbt_throw_notbound(env, "host", jhost);
JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getAttachedStorage(JNIEnv * env, jobject jhost)
{
- msg_host_t host = jhost_get_native(env, jhost);
+ const_sg_host_t host = jhost_get_native(env, jhost);
if (not host) {
jxbt_throw_notbound(env, "host", jhost);
JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_all(JNIEnv * env, jclass cls_arg)
{
-
xbt_dynar_t table = MSG_hosts_as_dynar();
int count = xbt_dynar_length(table);
}
for (int index = 0; index < count; index++) {
- msg_host_t host = xbt_dynar_get_as(table, index, msg_host_t);
+ auto const* host = xbt_dynar_get_as(table, index, msg_host_t);
jobject jhost = static_cast<jobject>(host->extension(JAVA_HOST_LEVEL));
if (not jhost) {
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getConsumedEnergy (JNIEnv *env, jobject jhost)
{
- msg_host_t host = jhost_get_native(env, jhost);
+ const_sg_host_t host = jhost_get_native(env, jhost);
if (not host) {
jxbt_throw_notbound(env, "host", jhost);
}
JNIEXPORT jint JNICALL Java_org_simgrid_msg_Host_getPstate(JNIEnv* env, jobject jhost)
{
- msg_host_t host = jhost_get_native(env, jhost);
+ const_sg_host_t host = jhost_get_native(env, jhost);
return MSG_host_get_pstate(host);
}
JNIEXPORT jint JNICALL Java_org_simgrid_msg_Host_getPstatesCount(JNIEnv* env, jobject jhost)
{
- msg_host_t host = jhost_get_native(env, jhost);
+ const_sg_host_t host = jhost_get_native(env, jhost);
return MSG_host_get_nb_pstates(host);
}
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCurrentPowerPeak(JNIEnv* env, jobject jhost)
{
- msg_host_t host = jhost_get_native(env, jhost);
+ const_sg_host_t host = jhost_get_native(env, jhost);
return MSG_host_get_speed(host);
}
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getPowerPeakAt(JNIEnv* env, jobject jhost, jint pstate)
{
- msg_host_t host = jhost_get_native(env, jhost);
+ const_sg_host_t host = jhost_get_native(env, jhost);
return MSG_host_get_power_peak_at(host, pstate);
}
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getLoad(JNIEnv* env, jobject jhost)
{
- msg_host_t host = jhost_get_native(env, jhost);
+ const_sg_host_t host = jhost_get_native(env, jhost);
return MSG_host_get_load(host);
}
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCurrentLoad (JNIEnv *env, jobject jhost)
{
- msg_host_t host = jhost_get_native(env, jhost);
+ const_sg_host_t host = jhost_get_native(env, jhost);
if (not host) {
jxbt_throw_notbound(env, "host", jhost);
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getComputedFlops (JNIEnv *env, jobject jhost)
{
- msg_host_t host = jhost_get_native(env, jhost);
+ const_sg_host_t host = jhost_get_native(env, jhost);
if (not host) {
jxbt_throw_notbound(env, "host", jhost);
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getAvgLoad (JNIEnv *env, jobject jhost)
{
- msg_host_t host = jhost_get_native(env, jhost);
+ const_sg_host_t host = jhost_get_native(env, jhost);
if (not host) {
jxbt_throw_notbound(env, "host", jhost);
/* Functions related to the java host instances. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
/* Functions related to the java process instances. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
jfieldID jprocess_field_Process_pid;
jfieldID jprocess_field_Process_ppid;
-jobject jprocess_from_native(msg_process_t process)
+jobject jprocess_from_native(const_sg_actor_t process)
{
- simgrid::kernel::context::JavaContext* context =
+ const simgrid::kernel::context::JavaContext* context =
static_cast<simgrid::kernel::context::JavaContext*>(process->get_impl()->context_.get());
return context->jprocess_;
}
return (msg_process_t)(intptr_t)env->GetLongField(jprocess, jprocess_field_Process_bind);
}
-void jprocess_bind(jobject jprocess, msg_process_t process, JNIEnv * env)
+void jprocess_bind(jobject jprocess, const_sg_actor_t process, JNIEnv* env)
{
env->SetLongField(jprocess, jprocess_field_Process_bind, (intptr_t)process);
}
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID(JNIEnv * env, jclass cls, jint pid)
{
- msg_process_t process = MSG_process_from_PID(pid);
+ auto const* process = MSG_process_from_PID(pid);
if (not process) {
jxbt_throw_process_not_found(env, std::string("PID = ") + std::to_string(static_cast<int>(pid)));
JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_nativeGetPID(JNIEnv* env, jobject jprocess)
{
- msg_process_t process = jprocess_to_native(jprocess, env);
+ const_sg_actor_t process = jprocess_to_native(jprocess, env);
return MSG_process_get_PID(process);
}
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, jobject jprocess, jobject jname) {
- msg_process_t process = jprocess_to_native(jprocess, env);
+ const_sg_actor_t process = jprocess_to_native(jprocess, env);
if (not process) {
jxbt_throw_notbound(env, "process", jprocess);
process->resume();
}
-JNIEXPORT void
-JNICALL Java_org_simgrid_msg_Process_setAutoRestart (JNIEnv *env, jobject jprocess, jboolean jauto_restart) {
-
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setAutoRestart(JNIEnv* env, jobject jprocess,
+ jboolean jauto_restart)
+{
msg_process_t process = jprocess_to_native(jprocess, env);
if (not process) {
jxbt_throw_notbound(env, "process", jprocess);
/* Functions related to the java process instances. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
void jprocess_unref(jobject jprocess, JNIEnv* env);
/** Binds a native instance to a java instance. */
-void jprocess_bind(jobject jprocess, msg_process_t process, JNIEnv* env);
+void jprocess_bind(jobject jprocess, const_sg_actor_t process, JNIEnv* env);
/** Extract the java instance from the native one */
-jobject jprocess_from_native(msg_process_t process);
+jobject jprocess_from_native(const_sg_actor_t process);
/** Extract the native instance from the java one */
msg_process_t jprocess_to_native(jobject jprocess, JNIEnv* env);
/* Java bindings of the Storage API. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
}
JNIEXPORT jlong JNICALL Java_org_simgrid_msg_Storage_getSize(JNIEnv * env,jobject jstorage) {
- msg_storage_t storage = jstorage_get_native(env, jstorage);
+ const_sg_storage_t storage = jstorage_get_native(env, jstorage);
if (not storage) {
jxbt_throw_notbound(env, "storage", jstorage);
}
JNIEXPORT jlong JNICALL Java_org_simgrid_msg_Storage_getFreeSize(JNIEnv * env,jobject jstorage) {
- msg_storage_t storage = jstorage_get_native(env, jstorage);
+ const_sg_storage_t storage = jstorage_get_native(env, jstorage);
if (not storage) {
jxbt_throw_notbound(env, "storage", jstorage);
}
JNIEXPORT jlong JNICALL Java_org_simgrid_msg_Storage_getUsedSize(JNIEnv * env,jobject jstorage) {
- msg_storage_t storage = jstorage_get_native(env, jstorage);
+ const_sg_storage_t storage = jstorage_get_native(env, jstorage);
if (not storage) {
jxbt_throw_notbound(env, "storage", jstorage);
}
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getProperty(JNIEnv *env, jobject jstorage, jobject jname) {
- msg_storage_t storage = jstorage_get_native(env, jstorage);
+ const_sg_storage_t storage = jstorage_get_native(env, jstorage);
if (not storage) {
jxbt_throw_notbound(env, "storage", jstorage);
env->ReleaseStringUTFChars((jstring) jvalue, value_java);
env->ReleaseStringUTFChars((jstring) jname, name);
-
}
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getHost(JNIEnv * env,jobject jstorage) {
- msg_storage_t storage = jstorage_get_native(env, jstorage);
+ const_sg_storage_t storage = jstorage_get_native(env, jstorage);
if (not storage) {
jxbt_throw_notbound(env, "storage", jstorage);
/* Java bindings of the Storage API. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
/* Java bindings of the Synchronization API. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Mutex_nativeFinalize(JNIEnv * env, jobject obj) {
- sg_mutex_t mutex = (sg_mutex_t)(uintptr_t)env->GetLongField(obj, jsynchro_field_Mutex_bind);
+ const_sg_mutex_t mutex = (sg_mutex_t)(uintptr_t)env->GetLongField(obj, jsynchro_field_Mutex_bind);
sg_mutex_destroy(mutex);
}
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Semaphore_nativeFinalize(JNIEnv * env, jobject obj) {
- sg_sem_t sem;
+ const_sg_sem_t sem;
sem = (sg_sem_t)(uintptr_t)env->GetLongField(obj, jsynchro_field_Semaphore_bind);
sg_sem_destroy(sem);
/* Java bindings of the Synchronization API. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
/* Functions related to the java task instances. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
}
JNIEXPORT jstring JNICALL Java_org_simgrid_msg_Task_getName(JNIEnv * env, jobject jtask) {
- msg_task_t task = jtask_to_native(jtask, env);
+ const_msg_task_t task = jtask_to_native(jtask, env);
if (not task) {
jxbt_throw_notbound(env, "task", jtask);
}
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_getSender(JNIEnv * env, jobject jtask) {
- msg_process_t process;
-
- msg_task_t task = jtask_to_native(jtask, env);
+ const_msg_task_t task = jtask_to_native(jtask, env);
if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return nullptr;
}
- process = MSG_task_get_sender(task);
+ auto const* process = MSG_task_get_sender(task);
if (process == nullptr) {
return nullptr;
}
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_getSource(JNIEnv * env, jobject jtask)
{
- msg_host_t host;
- msg_task_t task = jtask_to_native(jtask, env);
+ const_msg_task_t task = jtask_to_native(jtask, env);
if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return nullptr;
}
- host = MSG_task_get_source(task);
+ auto const* host = MSG_task_get_source(task);
if (host == nullptr) {
return nullptr;
}
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Task_getFlopsAmount(JNIEnv * env, jobject jtask)
{
- msg_task_t ptask = jtask_to_native(jtask, env);
+ const_msg_task_t ptask = jtask_to_native(jtask, env);
if (not ptask) {
jxbt_throw_notbound(env, "task", jtask);
/* Functions related to the java task instances. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
/* Functions related to the Virtual Machines. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
xbt_assert(jvm_field_bind, "Native initialization of msg/VM failed. Please report that bug");
}
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isCreated(JNIEnv * env, jobject jvm)
+JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isCreated(JNIEnv* env, jobject jvm)
{
msg_vm_t vm = jvm_get_native(env,jvm);
return MSG_vm_is_created(vm);
}
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isRunning(JNIEnv * env, jobject jvm)
+JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isRunning(JNIEnv* env, jobject jvm)
{
msg_vm_t vm = jvm_get_native(env,jvm);
- return (jint) MSG_vm_is_running(vm);
+ return MSG_vm_is_running(vm);
}
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isMigrating(JNIEnv * env, jobject jvm)
+JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isMigrating(JNIEnv* env, jobject jvm)
{
- msg_vm_t vm = jvm_get_native(env,jvm);
- return (jint) MSG_vm_is_migrating(vm);
+ const_sg_vm_t vm = jvm_get_native(env, jvm);
+ return MSG_vm_is_migrating(vm);
}
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isSuspended(JNIEnv * env, jobject jvm)
+JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isSuspended(JNIEnv* env, jobject jvm)
{
msg_vm_t vm = jvm_get_native(env,jvm);
- return (jint) MSG_vm_is_suspended(vm);
+ return MSG_vm_is_suspended(vm);
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_setBound(JNIEnv *env, jobject jvm, jdouble bound)
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_VM_getVMByName(JNIEnv* env, jclass cls, jstring jname)
{
-
/* get the C string from the java string */
if (jname == nullptr) {
jxbt_throw_null(env, "No VM can have a null name");
}
const char* name = env->GetStringUTFChars(jname, 0);
/* get the VM by name (VMs are just special hosts, unfortunately) */
- msg_host_t host = MSG_host_by_name(name);
+ auto const* host = MSG_host_by_name(name);
if (not host) { /* invalid name */
jxbt_throw_host_not_found(env, name);
/* Functions related to the Virtual Machines. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_VM_all(JNIEnv* env, jclass cls_arg);
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isCreated(JNIEnv* env, jobject jvm);
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isRunning(JNIEnv* env, jobject jvm);
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isMigrating(JNIEnv* env, jobject jvm);
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isSuspended(JNIEnv* env, jobject jvm);
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isResuming(JNIEnv* env, jobject jvm);
+JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isCreated(JNIEnv* env, jobject jvm);
+JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isRunning(JNIEnv* env, jobject jvm);
+JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isMigrating(JNIEnv* env, jobject jvm);
+JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isSuspended(JNIEnv* env, jobject jvm);
JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_setBound(JNIEnv* env, jobject jvm, jdouble bound);
/* Java bindings of the Trace API. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
/* Java bindings of the Trace API. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
/* Various JNI helper functions */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
id = env->GetMethodID(cls, name, signature);
if (not id) {
-
jmethodID tostr_id = env->GetMethodID(cls, "getName", "()Ljava/lang/String;");
jstring jclassname = (jstring) env->CallObjectMethod(cls, tostr_id, nullptr);
const char *classname = env->GetStringUTFChars(jclassname, 0);
/* Various JNI helper functions */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* Bindings to the MSG hosts */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
/* This exception is raised when there is a problem within the bindings (in JNI). */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
/* JNI interface to C code for MSG. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
/* This exception is an abstract class grouping all MSG-related exceptions */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* Bindings to the MSG storage */
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
/* Java bindings of the s4u::VirtualMachine */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
private native void nativeFinalize();
/** Returns whether the given VM is currently suspended */
- public native int isCreated();
+ public native boolean isCreated();
/** Returns whether the given VM is currently running */
- public native int isRunning();
+ public native boolean isRunning();
/** Returns whether the given VM is currently running */
- public native int isMigrating();
+ public native boolean isMigrating();
/** Returns whether the given VM is currently suspended */
- public native int isSuspended();
+ public native boolean isSuspended();
/** Returns the amount of virtual CPUs provided */
public int getCoreAmount() {
/* JNI interface to C code for the TRACES part of SimGrid. */
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
*/
static int l_host_get_name(lua_State * L)
{
- sg_host_t ht = sglua_check_host(L, 1);
+ auto const* ht = sglua_check_host(L, 1);
lua_pushstring(L, ht->get_cname());
return 1;
}
*/
static int l_host_get_property_value(lua_State * L)
{
- sg_host_t ht = sglua_check_host(L, 1);
+ const_sg_host_t ht = sglua_check_host(L, 1);
const char *prop = luaL_checkstring(L, 2);
lua_pushstring(L, sg_host_get_property_value(ht,prop));
return 1;
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
*
* - Argument 1 (string): the text to print
*/
-static int info(lua_State* L) {
-
+static int info(lua_State* L)
+{
const char* str = luaL_checkstring(L, 1);
XBT_INFO("%s", str);
return 0;
}
-static int error(lua_State* L) {
-
+static int error(lua_State* L)
+{
const char* str = luaL_checkstring(L, 1);
XBT_ERROR("%s", str);
return 0;
}
-static int critical(lua_State* L) {
-
+static int critical(lua_State* L)
+{
const char* str = luaL_checkstring(L, 1);
XBT_CRITICAL("%s", str);
return 0;
* This function can be called from within lua via "simgrid.dump(table)". It will
* then dump the table via XBT_DEBUG
*/
-static int dump(lua_State* L) {
+static int dump(lua_State* L)
+{
int argc = lua_gettop(L);
for (int i = 1; i <= argc; i++) {
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
XBT_LOG_NEW_DEFAULT_CATEGORY(python, "python");
-PYBIND11_DECLARE_HOLDER_TYPE(T, boost::intrusive_ptr<T>)
-
namespace {
static std::string get_simgrid_version()
return simgrid::xbt::string_printf("%i.%i.%i", major, minor, patch);
}
-static std::string simgrid_version = get_simgrid_version();
-
} // namespace
+PYBIND11_DECLARE_HOLDER_TYPE(T, boost::intrusive_ptr<T>)
+
PYBIND11_MODULE(simgrid, m)
{
m.doc() = "SimGrid userspace API";
- m.attr("simgrid_version") = simgrid_version;
+ m.attr("simgrid_version") = get_simgrid_version();
// Internal exception used to kill actors and sweep the RAII chimney (free objects living on the stack)
static py::object pyForcefulKillEx(py::register_exception<simgrid::ForcefulKillException>(m, "ActorKilled"));
/* this_actor namespace */
- void (*sleep_for_fun)(double) = &simgrid::s4u::this_actor::sleep_for; // pick the right overload
- void (*sleep_until_fun)(double) = &simgrid::s4u::this_actor::sleep_until;
-
- py::module m2 = m.def_submodule("this_actor", "Bindings of the s4u::this_actor namespace.");
- m2.def("info", [](char* s) { XBT_INFO("%s", s); }, "Display a logging message of default priority.");
- m2.def("error", [](char* s) { XBT_ERROR("%s", s); }, "Display a logging message of 'error' priority.");
- m2.def("execute", py::overload_cast<double, double>(&simgrid::s4u::this_actor::execute),
- "Block the current actor, computing the given amount of flops at the given priority, see :cpp:func:`void "
- "simgrid::s4u::this_actor::execute(double, double)`",
- py::arg("flops"), py::arg("priority") = 1);
- m2.def("exec_init", [](double flops){return simgrid::s4u::this_actor::exec_init(flops);});
- m2.def("get_host", &simgrid::s4u::this_actor::get_host, "Retrieves host on which the current actor is located");
- m2.def("set_host", &simgrid::s4u::this_actor::set_host,
- "Moves the current actor to another host, see :cpp:func:`void simgrid::s4u::this_actor::set_host()`",
- py::arg("dest"));
- m2.def("sleep_for", sleep_for_fun,
- "Block the actor sleeping for that amount of seconds, see :cpp:func:`void simgrid::s4u::this_actor::sleep_for`", py::arg("duration"));
- m2.def("sleep_until", sleep_until_fun,
- "Block the actor sleeping until the specified timestamp, see :cpp:func:`void simgrid::s4u::this_actor::sleep_until`", py::arg("duration"));
- m2.def("suspend", &simgrid::s4u::this_actor::suspend, "Suspend the current actor, that is blocked until resume()ed by another actor. see :cpp:func:`void simgrid::s4u::this_actor::suspend`");
- m2.def("yield_", &simgrid::s4u::this_actor::yield,
- "Yield the actor, see :cpp:func:`void simgrid::s4u::this_actor::yield()`");
- m2.def("exit", &simgrid::s4u::this_actor::exit, "kill the current actor");
- m2.def("on_exit",
- [](py::object fun) {
- ActorPtr act = Actor::self();
- simgrid::s4u::this_actor::on_exit([act, fun](bool /*failed*/) {
- try {
- fun();
- } catch (py::error_already_set& e) {
- xbt_die("Error while executing the on_exit lambda: %s", e.what());
- }
- });
- },
- "");
+ m.def_submodule("this_actor", "Bindings of the s4u::this_actor namespace.")
+ .def("info", [](const char* s) { XBT_INFO("%s", s); }, "Display a logging message of 'info' priority.")
+ .def("error", [](const char* s) { XBT_ERROR("%s", s); }, "Display a logging message of 'error' priority.")
+ .def("execute", py::overload_cast<double, double>(&simgrid::s4u::this_actor::execute),
+ "Block the current actor, computing the given amount of flops at the given priority, "
+ "see :cpp:func:`void simgrid::s4u::this_actor::execute(double, double)`",
+ py::arg("flops"), py::arg("priority") = 1)
+ .def("exec_init", py::overload_cast<double>(&simgrid::s4u::this_actor::exec_init))
+ .def("get_host", &simgrid::s4u::this_actor::get_host, "Retrieves host on which the current actor is located")
+ .def("set_host", &simgrid::s4u::this_actor::set_host,
+ "Moves the current actor to another host, see :cpp:func:`void simgrid::s4u::this_actor::set_host()`",
+ py::arg("dest"))
+ .def("sleep_for", static_cast<void (*)(double)>(&simgrid::s4u::this_actor::sleep_for),
+ "Block the actor sleeping for that amount of seconds, "
+ "see :cpp:func:`void simgrid::s4u::this_actor::sleep_for`",
+ py::arg("duration"))
+ .def("sleep_until", static_cast<void (*)(double)>(&simgrid::s4u::this_actor::sleep_until),
+ "Block the actor sleeping until the specified timestamp, "
+ "see :cpp:func:`void simgrid::s4u::this_actor::sleep_until`",
+ py::arg("duration"))
+ .def("suspend", &simgrid::s4u::this_actor::suspend,
+ "Suspend the current actor, that is blocked until resume()ed by another actor. "
+ "see :cpp:func:`void simgrid::s4u::this_actor::suspend`")
+ .def("yield_", &simgrid::s4u::this_actor::yield,
+ "Yield the actor, see :cpp:func:`void simgrid::s4u::this_actor::yield()`")
+ .def("exit", &simgrid::s4u::this_actor::exit, "kill the current actor")
+ .def("on_exit",
+ [](py::object fun) {
+ simgrid::s4u::this_actor::on_exit([fun](bool /*failed*/) {
+ try {
+ fun();
+ } catch (const py::error_already_set& e) {
+ xbt_die("Error while executing the on_exit lambda: %s", e.what());
+ }
+ });
+ },
+ "");
/* Class Engine */
py::class_<Engine>(m, "Engine", "Simulation Engine, see :ref:`class s4u::Engine <API_s4u_Engine>`")
- .def(py::init([](std::vector<std::string> args) -> simgrid::s4u::Engine* {
+ .def(py::init([](std::vector<std::string> args) {
static char noarg[] = {'\0'};
int argc = args.size();
std::unique_ptr<char* []> argv(new char*[argc + 1]);
// Currently this can be dangling, we should wrap this somehow.
return new simgrid::s4u::Engine(&argc, argv.get());
}))
- .def_static("get_clock", &Engine::get_clock, "The simulation time, ie the amount of simulated seconds since the simulation start.")
+ .def_static("get_clock", &Engine::get_clock,
+ "The simulation time, ie the amount of simulated seconds since the simulation start.")
.def("get_all_hosts", &Engine::get_all_hosts, "Returns the list of all hosts found in the platform")
.def("load_platform", &Engine::load_platform,
"Load a platform file describing the environment, see :cpp:func:`simgrid::s4u::Engine::load_platform()`")
/* If I was passed a class, I just built an instance, so I need to call it now */
if (py::isinstance<py::function>(res))
res();
- } catch (py::error_already_set& ex) {
+ } catch (const py::error_already_set& ex) {
if (ex.matches(pyForcefulKillEx)) {
XBT_VERB("Actor killed");
/* Stop here that ForcefulKill exception which was meant to free the RAII stuff on the stack */
"Registers the main function of an actor, see :cpp:func:`simgrid::s4u::Engine::register_actor()`");
/* Class Host */
- py::class_<simgrid::s4u::Host, std::unique_ptr<Host, py::nodelete>>(m, "Host", "Simulation Engine, see :ref:`class s4u::Host <API_s4u_Host>`")
+ py::class_<simgrid::s4u::Host, std::unique_ptr<Host, py::nodelete>>(
+ m, "Host", "Simulation Engine, see :ref:`class s4u::Host <API_s4u_Host>`")
.def("by_name", &Host::by_name, "Retrieves a host from its name, or die")
- .def("get_pstate_count", &Host::get_pstate_count, "Retrieve the cound of defined pstate levels, see :cpp:func:`simgrid::s4u::Host::get_pstate_count`")
- .def("get_pstate_speed", &Host::get_pstate_speed, "Retrieve the maximal speed at the given pstate, see :cpp:func:`simgrid::s4u::Host::get_pstate_speed`")
+ .def("get_pstate_count", &Host::get_pstate_count,
+ "Retrieve the cound of defined pstate levels, see :cpp:func:`simgrid::s4u::Host::get_pstate_count`")
+ .def("get_pstate_speed", &Host::get_pstate_speed,
+ "Retrieve the maximal speed at the given pstate, see :cpp:func:`simgrid::s4u::Host::get_pstate_speed`")
.def_property("pstate", &Host::get_pstate, &Host::set_pstate, "The current pstate")
- .def("current", &Host::current, "Retrieves the host on which the running actor is located, see :cpp:func:`simgrid::s4u::Host::current()`")
- .def_property_readonly("name", [](Host* self) -> const std::string {
- return std::string(self->get_name().c_str()); // Convert from xbt::string because of MC
- }, "The name of this host")
- .def_property_readonly("load", &Host::get_load,
- "Returns the current computation load (in flops per second). This is the currently achieved speed. See :cpp:func:`simgrid::s4u::Host::get_load()`")
- .def_property_readonly("speed", &Host::get_speed,
- "The peak computing speed in flops/s at the current pstate, taking the external load into account. This is the max potential speed. See :cpp:func:`simgrid::s4u::Host::get_speed()`");
+ .def("current", &Host::current,
+ "Retrieves the host on which the running actor is located, see :cpp:func:`simgrid::s4u::Host::current()`")
+ .def_property_readonly("name",
+ [](const Host* self) {
+ return std::string(self->get_name().c_str()); // Convert from xbt::string because of MC
+ },
+ "The name of this host")
+ .def_property_readonly(
+ "load", &Host::get_load,
+ "Returns the current computation load (in flops per second). This is the currently achieved speed. "
+ "See :cpp:func:`simgrid::s4u::Host::get_load()`")
+ .def_property_readonly(
+ "speed", &Host::get_speed,
+ "The peak computing speed in flops/s at the current pstate, taking the external load into account. "
+ "This is the max potential speed. See :cpp:func:`simgrid::s4u::Host::get_speed()`");
/* Class Mailbox */
- py::class_<simgrid::s4u::Mailbox, std::unique_ptr<Mailbox, py::nodelete>>(m, "Mailbox", "Mailbox, see :ref:`class s4u::Mailbox <API_s4u_Mailbox>`")
- .def("__str__", [](Mailbox* self) -> const std::string {
- return std::string("Mailbox(") + self->get_cname() + ")";
- }, "Textual representation of the Mailbox`")
- .def("by_name", &Mailbox::by_name, "Retrieve a Mailbox from its name, see :cpp:func:`simgrid::s4u::Mailbox::by_name()`")
- .def_property_readonly("name", [](Mailbox* self) -> const std::string {
- return std::string(self->get_name().c_str()); // Convert from xbt::string because of MC
- }, "The name of that mailbox, see :cpp:func:`simgrid::s4u::Mailbox::get_name()`")
- .def("put", [](Mailbox* self, py::object data, int size) {
- data.inc_ref();
- self->put(data.ptr(), size);
- }, "Blocking data transmission, see :cpp:func:`void simgrid::s4u::Mailbox::put(void*, uint64_t)`")
- .def("put_async", [](Mailbox* self, py::object data, int size) -> simgrid::s4u::CommPtr {
- data.inc_ref();
- return self->put_async(data.ptr(), size);
- }, "Non-blocking data transmission, see :cpp:func:`void simgrid::s4u::Mailbox::put_async(void*, uint64_t)`")
- .def("get", [](Mailbox* self) -> py::object {
- py::object data = pybind11::reinterpret_steal<py::object>(static_cast<PyObject*>(self->get()));
- data.dec_ref();
- return data;
- }, "Blocking data reception, see :cpp:func:`void* simgrid::s4u::Mailbox::get()`");
+ py::class_<simgrid::s4u::Mailbox, std::unique_ptr<Mailbox, py::nodelete>>(
+ m, "Mailbox", "Mailbox, see :ref:`class s4u::Mailbox <API_s4u_Mailbox>`")
+ .def("__str__", [](const Mailbox* self) { return std::string("Mailbox(") + self->get_cname() + ")"; },
+ "Textual representation of the Mailbox`")
+ .def("by_name", &Mailbox::by_name,
+ "Retrieve a Mailbox from its name, see :cpp:func:`simgrid::s4u::Mailbox::by_name()`")
+ .def_property_readonly("name",
+ [](const Mailbox* self) {
+ return std::string(self->get_name().c_str()); // Convert from xbt::string because of MC
+ },
+ "The name of that mailbox, see :cpp:func:`simgrid::s4u::Mailbox::get_name()`")
+ .def("put",
+ [](Mailbox* self, py::object data, int size) {
+ data.inc_ref();
+ self->put(data.ptr(), size);
+ },
+ "Blocking data transmission, see :cpp:func:`void simgrid::s4u::Mailbox::put(void*, uint64_t)`")
+ .def("put_async",
+ [](Mailbox* self, py::object data, int size) {
+ data.inc_ref();
+ return self->put_async(data.ptr(), size);
+ },
+ "Non-blocking data transmission, see :cpp:func:`void simgrid::s4u::Mailbox::put_async(void*, uint64_t)`")
+ .def("get",
+ [](Mailbox* self) {
+ py::object data = pybind11::reinterpret_steal<py::object>(static_cast<PyObject*>(self->get()));
+ data.dec_ref();
+ return data;
+ },
+ "Blocking data reception, see :cpp:func:`void* simgrid::s4u::Mailbox::get()`");
/* Class Comm */
py::class_<simgrid::s4u::Comm, simgrid::s4u::CommPtr>(m, "Comm",
"Communication, see :ref:`class s4u::Comm <API_s4u_Comm>`")
- .def("test", [](simgrid::s4u::CommPtr self) { return self->test(); },
+ .def("test", &simgrid::s4u::Comm::test,
"Test whether the communication is terminated, see :cpp:func:`simgrid::s4u::Comm::test()`")
- .def("wait", [](simgrid::s4u::CommPtr self) { self->wait(); },
+ .def("wait", &simgrid::s4u::Comm::wait,
"Block until the completion of that communication, see :cpp:func:`simgrid::s4u::Comm::wait()`")
- .def("wait_all", [](std::vector<simgrid::s4u::CommPtr>* comms) { simgrid::s4u::Comm::wait_all(comms); },
+ .def("wait_all", &simgrid::s4u::Comm::wait_all,
"Block until the completion of all communications in the list, see "
":cpp:func:`simgrid::s4u::Comm::wait_all()`")
- .def(
- "wait_any", [](std::vector<simgrid::s4u::CommPtr>* comms) { return simgrid::s4u::Comm::wait_any(comms); },
- "Block until the completion of any communication in the list and return the index of the terminated one, see "
- ":cpp:func:`simgrid::s4u::Comm::wait_any()`");
- py::class_<simgrid::s4u::Exec, simgrid::s4u::ExecPtr>(m, "Exec", "Execution, see :ref:`class s4u::Exec <API_s4u_Exec>`")
- .def_property_readonly("remaining", [](simgrid::s4u::ExecPtr self) { return self->get_remaining(); },
- "Amount of flops that remain to be computed until completion, see :cpp:func:`simgrid::s4u::Exec::get_remaining()`")
- .def_property_readonly("remaining_ratio", [](simgrid::s4u::ExecPtr self) { return self->get_remaining_ratio(); },
- "Amount of work remaining until completion from 0 (completely done) to 1 (nothing done yet). See :cpp:func:`simgrid::s4u::Exec::get_remaining_ratio()`")
+ .def("wait_any", &simgrid::s4u::Comm::wait_any,
+ "Block until the completion of any communication in the list and return the index of the terminated one, "
+ "see :cpp:func:`simgrid::s4u::Comm::wait_any()`");
+
+ /* Class Exec */
+ py::class_<simgrid::s4u::Exec, simgrid::s4u::ExecPtr>(m, "Exec",
+ "Execution, see :ref:`class s4u::Exec <API_s4u_Exec>`")
+ .def_property_readonly("remaining", &simgrid::s4u::Exec::get_remaining,
+ "Amount of flops that remain to be computed until completion, see "
+ ":cpp:func:`simgrid::s4u::Exec::get_remaining()`")
+ .def_property_readonly("remaining_ratio", &simgrid::s4u::Exec::get_remaining_ratio,
+ "Amount of work remaining until completion from 0 (completely done) to 1 (nothing done "
+ "yet). See :cpp:func:`simgrid::s4u::Exec::get_remaining_ratio()`")
.def_property("host",
[](simgrid::s4u::ExecPtr self) {
- simgrid::s4u::ExecSeqPtr seq = boost::dynamic_pointer_cast<simgrid::s4u::ExecSeq>(self);
- if (seq != nullptr)
- return seq->get_host();
- xbt_throw_unimplemented(__FILE__, __LINE__, "host of parallel executions is not implemented in python yet.");
+ simgrid::s4u::ExecSeqPtr seq = boost::dynamic_pointer_cast<simgrid::s4u::ExecSeq>(self);
+ if (seq != nullptr)
+ return seq->get_host();
+ xbt_throw_unimplemented(__FILE__, __LINE__,
+ "host of parallel executions is not implemented in python yet.");
},
- [](simgrid::s4u::ExecPtr self, simgrid::s4u::Host* host) { self->set_host(host); },
- "Host on which this execution runs. See :cpp:func:`simgrid::s4u::ExecSeq::get_host()`")
- .def("test", [](simgrid::s4u::ExecPtr self) { return self->test(); },
- "Test whether the execution is terminated, see :cpp:func:`simgrid::s4u::Exec::test()`")
- .def("cancel", [](simgrid::s4u::ExecPtr self) { self->cancel(); },
- "Cancel that execution, see :cpp:func:`simgrid::s4u::Exec::cancel()`")
- .def("start", [](simgrid::s4u::ExecPtr self) { return self->start(); },
- "Start that execution, see :cpp:func:`simgrid::s4u::Exec::start()`")
- .def("wait", [](simgrid::s4u::ExecPtr self) { return self->wait(); },
- "Block until the completion of that execution, see :cpp:func:`simgrid::s4u::Exec::wait()`");
+ &simgrid::s4u::Exec::set_host,
+ "Host on which this execution runs. See :cpp:func:`simgrid::s4u::ExecSeq::get_host()`")
+ .def("test", &simgrid::s4u::Exec::test,
+ "Test whether the execution is terminated, see :cpp:func:`simgrid::s4u::Exec::test()`")
+ .def("cancel", &simgrid::s4u::Exec::cancel, "Cancel that execution, see :cpp:func:`simgrid::s4u::Exec::cancel()`")
+ .def("start", &simgrid::s4u::Exec::start, "Start that execution, see :cpp:func:`simgrid::s4u::Exec::start()`")
+ .def("wait", &simgrid::s4u::Exec::wait,
+ "Block until the completion of that execution, see :cpp:func:`simgrid::s4u::Exec::wait()`");
/* Class Actor */
py::class_<simgrid::s4u::Actor, ActorPtr>(m, "Actor",
"An actor is an independent stream of execution in your distributed "
"application, see :ref:`class s4u::Actor <API_s4u_Actor>`")
.def("create",
- [](py::str name, py::object host, py::object fun, py::args args) {
- return simgrid::s4u::Actor::create(name, host.cast<Host*>(), [fun, args]() {
+ [](py::str name, Host* host, py::object fun, py::args args) {
+ return simgrid::s4u::Actor::create(name, host, [fun, args]() {
try {
fun(*args);
- } catch (py::error_already_set& ex) {
+ } catch (const py::error_already_set& ex) {
if (ex.matches(pyForcefulKillEx)) {
XBT_VERB("Actor killed");
/* Stop here that ForcefulKill exception which was meant to free the RAII stuff on the stack */
"terminates.")
.def("join", py::overload_cast<double>(&Actor::join),
"Wait for the actor to finish (more info in the C++ documentation).", py::arg("timeout"))
- .def("kill", [](ActorPtr act) { act->kill(); }, "Kill that actor")
+ .def("kill", &Actor::kill, "Kill that actor")
.def("kill_all", &Actor::kill_all, "Kill all actors but the caller.")
.def("self", &Actor::self, "Retrieves the current actor.")
.def("is_suspended", &Actor::is_suspended, "Returns True if that actor is currently suspended.")
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
/********************************* Global *************************************/
XBT_ATTRIB_NORETURN XBT_PUBLIC void MC_run();
-XBT_PUBLIC void MC_process_clock_add(smx_actor_t, double);
-XBT_PUBLIC double MC_process_clock_get(smx_actor_t);
XBT_PRIVATE void MC_automaton_load(const char *file);
/********************************* Memory *************************************/
SG_END_DECL
+#ifdef __cplusplus
+XBT_PUBLIC void MC_process_clock_add(const simgrid::kernel::actor::ActorImpl*, double);
+XBT_PUBLIC double MC_process_clock_get(const simgrid::kernel::actor::ActorImpl*);
+#endif
+
#endif
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
/* A thread pool (C++ version). */
-/* Copyright (c) 2004-2019 The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020 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. */
Synchro* new_synchro(e_xbt_parmap_mode_t mode);
void work();
- bool destroying; /**< is the parmap being destroyed? */
- std::atomic_uint work_round; /**< index of the current round */
+ bool destroying = false; /**< is the parmap being destroyed? */
+ std::atomic_uint work_round{0}; /**< index of the current round */
std::vector<std::thread*> workers; /**< worker thread handlers */
unsigned num_workers; /**< total number of worker threads including the controller */
Synchro* synchro; /**< synchronization object */
std::atomic_uint thread_counter{0}; /**< number of workers that have done the work */
std::function<void(T)> fun; /**< function to run in parallel on each element of data */
const std::vector<T>* data = nullptr; /**< parameters to pass to fun in parallel */
- std::atomic_uint index; /**< index of the next element of data to pick */
+ std::atomic_uint index{0}; /**< index of the next element of data to pick */
};
/**
XBT_CDEBUG(xbt_parmap, "Create new parmap (%u workers)", num_workers);
/* Initialize the thread pool data structure */
- this->destroying = false;
- this->work_round = 0;
this->workers.resize(num_workers);
this->num_workers = num_workers;
this->synchro = new_synchro(mode);
/* Create the pool of worker threads (the caller of apply() will be worker[0]) */
this->workers[0] = nullptr;
- XBT_ATTRIB_UNUSED unsigned int core_bind = 0;
for (unsigned i = 1; i < num_workers; i++) {
- this->workers[i] = new std::thread(worker_main, new ThreadData(*this, i));
+ ThreadData* data = new ThreadData(*this, i);
+ this->workers[i] = new std::thread(worker_main, data);
/* Bind the worker to a core if possible */
#if HAVE_PTHREAD_SETAFFINITY
size_t size = sizeof(cpu_set_t);
#endif
pthread_t pthread = this->workers[i]->native_handle();
+ int core_bind = (i - 1) % std::thread::hardware_concurrency();
CPU_ZERO(&cpuset);
CPU_SET(core_bind, &cpuset);
pthread_setaffinity_np(pthread, size, &cpuset);
- if (core_bind != std::thread::hardware_concurrency() - 1)
- core_bind++;
- else
- core_bind = 0;
#endif
}
}
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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 "simgrid/version.h"
#include "src/instr/instr_private.hpp"
#include "surf/surf.hpp"
-#include "xbt/virtu.h" /* xbt_cmdline */
+#include "xbt/virtu.h" /* xbt::cmdline */
#include <fstream>
#include <string>
tracing_file << "#This file was generated using SimGrid-" << SIMGRID_VERSION_MAJOR << "." << SIMGRID_VERSION_MINOR
<< "." << SIMGRID_VERSION_PATCH << std::endl;
tracing_file << "#[";
- unsigned int cpt;
- char* str;
- xbt_dynar_foreach (xbt_cmdline, cpt, str) {
+ for (auto str : simgrid::xbt::cmdline) {
tracing_file << str << " ";
}
tracing_file << "]" << std::endl;
TRACE_last_timestamp_to_dump = surf_get_clock();
TRACE_paje_dump_buffer(true);
- simgrid::instr::Type* root_type = simgrid::instr::Container::get_root()->type_;
+ const simgrid::instr::Type* root_type = simgrid::instr::Container::get_root()->type_;
/* destroy all data structures of tracing (and free) */
delete simgrid::instr::Container::get_root();
delete root_type;
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
std::set<std::string> user_host_variables;
std::set<std::string> user_vm_variables;
std::set<std::string> user_link_variables;
-extern std::set<std::string> trivaNodeTypes;
-extern std::set<std::string> trivaEdgeTypes;
-static xbt_dynar_t instr_set_to_dynar(std::set<std::string>* filter)
+static xbt_dynar_t instr_set_to_dynar(const std::set<std::string>& filter)
{
if (not TRACE_is_enabled() || not TRACE_needs_platform())
return nullptr;
xbt_dynar_t ret = xbt_dynar_new (sizeof(char*), &xbt_free_ref);
- for (auto const& name : *filter)
+ for (auto const& name : filter)
xbt_dynar_push_as(ret, char*, xbt_strdup(name.c_str()));
return ret;
{
if (not TRACE_is_enabled() || not TRACE_categorized())
return nullptr;
- return instr_set_to_dynar(&created_categories);
+ return instr_set_to_dynar(created_categories);
}
/** @ingroup TRACE_mark
if (not TRACE_is_enabled())
return nullptr;
- return instr_set_to_dynar(&declared_marks);
+ return instr_set_to_dynar(declared_marks);
}
static void instr_user_variable(double time, const char* resource, const char* variable_name, const char* father_type,
*/
xbt_dynar_t TRACE_get_host_variables ()
{
- return instr_set_to_dynar(&user_host_variables);
+ return instr_set_to_dynar(user_host_variables);
}
/* for link variables */
*/
xbt_dynar_t TRACE_get_link_variables ()
{
- return instr_set_to_dynar(&user_link_variables);
+ return instr_set_to_dynar(user_link_variables);
}
/** @ingroup TRACE_user_variables
{
simgrid::instr::Container::by_name(host)->get_state(state_name)->pop_event();
}
-
-/** @ingroup TRACE_API
- * @brief Get Paje container types that can be mapped to the nodes of a graph.
- *
- * This function can be used to create a user made graph configuration file for Triva. Normally, it is used with the
- * functions defined in @ref TRACE_user_variables.
- *
- * @return A dynar with the types, must be freed with xbt_dynar_free.
- */
-xbt_dynar_t TRACE_get_node_types ()
-{
- return instr_set_to_dynar(&trivaNodeTypes);
-}
-
-/** @ingroup TRACE_API
- * @brief Get Paje container types that can be mapped to the edges of a graph.
- *
- * This function can be used to create a user made graph configuration file for Triva. Normally, it is used with the
- * functions defined in @ref TRACE_user_variables.
- *
- * @return A dynar with the types, must be freed with xbt_dynar_free.
- */
-xbt_dynar_t TRACE_get_edge_types ()
-{
- return instr_set_to_dynar(&trivaEdgeTypes);
-}
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
static container_t rootContainer = nullptr; /* the root container */
static std::map<std::string, container_t> allContainers; /* all created containers indexed by name */
-std::set<std::string> trivaNodeTypes; /* all host types defined */
-std::set<std::string> trivaEdgeTypes; /* all link types defined */
long long int instr_new_paje_id ()
{
netpoint_ = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(get_name());
xbt_assert(netpoint_, "Element '%s' not found", get_cname());
-
- trivaNodeTypes.insert(type_->get_name());
}
HostContainer::HostContainer(simgrid::s4u::Host const& host, NetZoneContainer* father)
netpoint_ = host.get_netpoint();
xbt_assert(netpoint_, "Element '%s' not found", host.get_cname());
-
- trivaNodeTypes.insert(type_->get_name());
}
Container::Container(const std::string& name, const std::string& type_name, Container* father)
simgrid::xbt::string_printf("container %s already present in allContainers data structure", get_cname()));
XBT_DEBUG("Add container name '%s'", get_cname());
-
- //register NODE types for triva configuration
- if (type_name == "LINK")
- trivaNodeTypes.insert(type_->get_name());
}
Container::~Container()
ret->set_calling_container(this);
return ret;
}
-}
-}
+} // namespace instr
+} // namespace simgrid
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
: container_(container), type_(type), timestamp_(timestamp), eventType_(eventType)
{
XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, eventType_, TRACE_precision(), timestamp_);
- if (trace_format == simgrid::instr::TraceFormat::Paje) {
+ if (trace_format == TraceFormat::Paje) {
stream_ << std::fixed << std::setprecision(TRACE_precision());
stream_ << eventType_ << " " << timestamp_ << " " << type_->get_id() << " " << container_->get_id();
}
void PajeEvent::print()
{
- if (trace_format != simgrid::instr::TraceFormat::Paje)
+ if (trace_format != TraceFormat::Paje)
return;
XBT_DEBUG("Dump %s", stream_.str().c_str());
{
#if HAVE_SMPI
if (simgrid::config::get_value<bool>("smpi/trace-call-location")) {
- smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
+ const smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
filename = loc->filename;
linenumber = loc->linenumber;
}
void NewEvent::print()
{
- if (trace_format != simgrid::instr::TraceFormat::Paje)
+ if (trace_format != TraceFormat::Paje)
return;
stream_ << " " << value->get_id();
void LinkEvent::print()
{
- if (trace_format != simgrid::instr::TraceFormat::Paje)
+ if (trace_format != TraceFormat::Paje)
return;
stream_ << " " << value_ << " " << endpoint_->get_id() << " " << key_;
void VariableEvent::print()
{
- if (trace_format != simgrid::instr::TraceFormat::Paje)
+ if (trace_format != TraceFormat::Paje)
return;
stream_ << " " << value_;
void StateEvent::print()
{
- if (trace_format == simgrid::instr::TraceFormat::Paje) {
-
+ if (trace_format == TraceFormat::Paje) {
if (value != nullptr) // PAJE_PopState Event does not need to have a value
stream_ << " " << value->get_id();
#endif
XBT_DEBUG("Dump %s", stream_.str().c_str());
tracing_file << stream_.str() << std::endl;
- } else if (trace_format == simgrid::instr::TraceFormat::Ti) {
+ } else if (trace_format == TraceFormat::Ti) {
if (extra_ == nullptr)
return;
container_name=std::to_string(stoi(container_name.erase(0, 5)) - 1);
}
#if HAVE_SMPI
- if (simgrid::config::get_value<bool>("smpi/trace-call-location")) {
+ if (config::get_value<bool>("smpi/trace-call-location")) {
stream_ << container_name << " location " << filename << " " << linenumber << std::endl ;
}
#endif
} else {
THROW_IMPOSSIBLE;
}
-
-}
-}
}
+} // namespace instr
+} // namespace simgrid
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
static std::vector<simgrid::instr::NetZoneContainer*> currentContainer; /* push and pop, used only in creation */
-static const char* instr_node_name(xbt_node_t node)
+static const char* instr_node_name(const s_xbt_node_t* node)
{
return static_cast<char*>(xbt_graph_node_get_data(node));
}
-static container_t lowestCommonAncestor(container_t a1, container_t a2)
+static container_t lowestCommonAncestor(const simgrid::instr::Container* a1, const simgrid::instr::Container* a2)
{
// this is only an optimization (since most of a1 and a2 share the same parent)
if (a1->father_ == a2->father_)
int j = ancestors_a2.size() - 1;
while (i >= 0 && j >= 0) {
container_t a1p = ancestors_a1.at(i);
- container_t a2p = ancestors_a2.at(j);
+ const simgrid::instr::Container* a2p = ancestors_a2.at(j);
if (a1p == a2p) {
p = a1p;
} else {
simgrid::instr::LinkType* link = father->type_->by_name_or_create(link_typename, src->type_, dst->type_);
link->set_calling_container(father);
- // register EDGE types for triva configuration
- trivaEdgeTypes.insert(link->get_name());
-
// create the link
static long long counter = 0;
XBT_DEBUG(" linkContainers %s <-> %s", src->get_cname(), dst->get_cname());
}
-static void recursiveGraphExtraction(simgrid::s4u::NetZone* netzone, container_t container,
+static void recursiveGraphExtraction(const simgrid::s4u::NetZone* netzone, container_t container,
std::set<std::string>* filter)
{
if (not TRACE_platform_topology()) {
}
xbt_graph_t graph = xbt_graph_new_graph(0, nullptr);
- std::map<std::string, xbt_node_t>* nodes = new std::map<std::string, xbt_node_t>;
- std::map<std::string, xbt_edge_t>* edges = new std::map<std::string, xbt_edge_t>;
+ std::map<std::string, xbt_node_t>* nodes = new std::map<std::string, xbt_node_t>();
+ std::map<std::string, xbt_edge_t>* edges = new std::map<std::string, xbt_edge_t>();
netzone->get_impl()->get_graph(graph, nodes, edges);
for (auto elm : *edges) {
- xbt_edge_t edge = elm.second;
+ const xbt_edge* edge = elm.second;
linkContainers(simgrid::instr::Container::by_name(static_cast<const char*>(edge->src->data)),
simgrid::instr::Container::by_name(static_cast<const char*>(edge->dst->data)), filter);
}
static void instr_host_on_creation(simgrid::s4u::Host const& host)
{
- container_t container = new simgrid::instr::HostContainer(host, currentContainer.back());
- container_t root = simgrid::instr::Container::get_root();
+ simgrid::instr::Container* container = new simgrid::instr::HostContainer(host, currentContainer.back());
+ const simgrid::instr::Container* root = simgrid::instr::Container::get_root();
if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_speed())) {
simgrid::instr::VariableType* speed = container->type_->by_name_or_create("speed", "");
double value = action.get_variable()->get_value() * action.get_variable()->get_constraint_weight(i);
/* Beware of composite actions: ptasks put links and cpus together. Extra pb: we cannot dynamic_cast from void* */
simgrid::kernel::resource::Resource* resource = action.get_variable()->get_constraint(i)->get_id();
- simgrid::kernel::resource::Cpu* cpu = dynamic_cast<simgrid::kernel::resource::Cpu*>(resource);
+ const simgrid::kernel::resource::Cpu* cpu = dynamic_cast<simgrid::kernel::resource::Cpu*>(resource);
if (cpu != nullptr)
TRACE_surf_resource_set_utilization("HOST", "speed_used", cpu->get_cname(), action.get_category(), value,
action.get_last_update(), SIMIX_get_clock() - action.get_last_update());
- simgrid::kernel::resource::LinkImpl* link = dynamic_cast<simgrid::kernel::resource::LinkImpl*>(resource);
+ const simgrid::kernel::resource::LinkImpl* link = dynamic_cast<simgrid::kernel::resource::LinkImpl*>(resource);
if (link != nullptr)
TRACE_surf_resource_set_utilization("LINK", "bandwidth_used", link->get_cname(), action.get_category(), value,
static void instr_on_platform_created()
{
currentContainer.clear();
- std::set<std::string>* filter = new std::set<std::string>;
+ std::set<std::string>* filter = new std::set<std::string>();
XBT_DEBUG("Starting graph extraction.");
recursiveGraphExtraction(simgrid::s4u::Engine::get_instance()->get_netzone_root(),
simgrid::instr::Container::get_root(), filter);
static void instr_actor_on_creation(simgrid::s4u::Actor const& actor)
{
- container_t root = simgrid::instr::Container::get_root();
- container_t container = simgrid::instr::Container::by_name(actor.get_host()->get_name());
+ const simgrid::instr::Container* root = simgrid::instr::Container::get_root();
+ simgrid::instr::Container* container = simgrid::instr::Container::by_name(actor.get_host()->get_name());
container->create_child(instr_pid(actor), "ACTOR");
simgrid::instr::ContainerType* actor_type =
static void instr_vm_on_creation(simgrid::s4u::Host const& host)
{
- container_t container = new simgrid::instr::HostContainer(host, currentContainer.back());
- container_t root = simgrid::instr::Container::get_root();
+ const simgrid::instr::Container* container = new simgrid::instr::HostContainer(host, currentContainer.back());
+ const simgrid::instr::Container* root = simgrid::instr::Container::get_root();
simgrid::instr::ContainerType* vm = container->type_->by_name_or_create<simgrid::instr::ContainerType>("VM");
simgrid::instr::StateType* state = vm->by_name_or_create<simgrid::instr::StateType>("VM_STATE");
state->add_entity_value("suspend", "1 0 1");
#define GRAPHICATOR_SUPPORT_FUNCTIONS
-static void recursiveXBTGraphExtraction(xbt_graph_t graph, std::map<std::string, xbt_node_t>* nodes,
- std::map<std::string, xbt_edge_t>* edges, sg_netzone_t netzone,
+static void recursiveXBTGraphExtraction(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t>* nodes,
+ std::map<std::string, xbt_edge_t>* edges, const_sg_netzone_t netzone,
container_t container)
{
if (not netzone->get_children().empty()) {
xbt_graph_t instr_routing_platform_graph()
{
xbt_graph_t ret = xbt_graph_new_graph(0, nullptr);
- std::map<std::string, xbt_node_t>* nodes = new std::map<std::string, xbt_node_t>;
- std::map<std::string, xbt_edge_t>* edges = new std::map<std::string, xbt_edge_t>;
+ std::map<std::string, xbt_node_t>* nodes = new std::map<std::string, xbt_node_t>();
+ std::map<std::string, xbt_edge_t>* edges = new std::map<std::string, xbt_edge_t>();
recursiveXBTGraphExtraction(ret, nodes, edges, simgrid::s4u::Engine::get_instance()->get_netzone_root(),
simgrid::instr::Container::get_root());
delete nodes;
return ret;
}
-void instr_routing_platform_graph_export_graphviz(xbt_graph_t g, const char* filename)
+void instr_routing_platform_graph_export_graphviz(const s_xbt_graph_t* g, const char* filename)
{
unsigned int cursor = 0;
xbt_node_t node = nullptr;
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
};
class Pt2PtTIData : public TIData {
- int tag;
+ int tag = 0;
+
public:
explicit Pt2PtTIData(const std::string& name, int endpoint, int size, int tag, const std::string& datatype)
: TIData(name, endpoint, size, datatype), tag(tag){};
explicit Pt2PtTIData(const std::string& name, int endpoint, int size, const std::string& datatype)
- : TIData(name, endpoint, size, datatype), tag(0){};
+ : TIData(name, endpoint, size, datatype){};
std::string print() override
{
std::stringstream stream;
double delta);
/* instr_paje.c */
-extern XBT_PRIVATE std::set<std::string> trivaNodeTypes;
-extern XBT_PRIVATE std::set<std::string> trivaEdgeTypes;
XBT_PRIVATE long long int instr_new_paje_id();
XBT_PRIVATE void instr_define_callbacks();
void instr_new_variable_type(const std::string& new_typename, const std::string& color);
/* instr_platform */
xbt_graph_t instr_routing_platform_graph();
-void instr_routing_platform_graph_export_graphviz(xbt_graph_t g, const char* filename);
+void instr_routing_platform_graph_export_graphviz(const s_xbt_graph_t* g, const char* filename);
#endif
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
/* Helper functions */
XBT_PRIVATE container_t smpi_container(int rank);
-XBT_PRIVATE void TRACE_smpi_setup_container(int rank, sg_host_t host);
+XBT_PRIVATE void TRACE_smpi_setup_container(int rank, const_sg_host_t host);
XBT_PRIVATE void TRACE_smpi_computing_init(int rank);
XBT_PRIVATE void TRACE_smpi_computing_out(int rank);
XBT_PRIVATE void TRACE_smpi_recv(int src, int dst, int tag);
XBT_PRIVATE void TRACE_smpi_init(int rank);
/* SMPI + LB (load balancer) */
-XBT_PRIVATE void TRACE_smpi_process_change_host(int rank, sg_host_t new_host);
+XBT_PRIVATE void TRACE_smpi_process_change_host(int rank, const_sg_host_t new_host);
class smpi_trace_call_location_t {
public:
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
this->meta_info_.insert({key, value});
}
+void Jedule::add_event(const Event& event)
+{
+ event_set_.emplace_back(event);
+}
+
void Jedule::write_output(FILE* file)
{
if (not this->event_set_.empty()) {
}
}
-}
-}
+} // namespace jedule
+} // namespace simgrid
#endif
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
get_resource_selection_by_hosts(this->resource_subsets_, host_selection);
}
-void Event::add_characteristic(char* characteristic)
+void Event::add_characteristic(const char* characteristic)
{
xbt_assert( characteristic != nullptr );
this->characteristics_list_.push_back(characteristic);
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
namespace simgrid {
namespace jedule {
Subset::Subset(int start_idx, int end_idx, Container* parent)
-: start_idx(start_idx), parent(parent)
+ : start_idx(start_idx), nres(end_idx - start_idx + 1), parent(parent)
{
- nres=end_idx-start_idx+1;
}
Container::Container(const std::string& name) : name(name)
void Container::add_child(jed_container_t child)
{
xbt_assert(child != nullptr);
- this->children.emplace_back(child);
- child->parent = this;
+ children_.emplace_back(child);
+ child->set_parent(this);
}
void Container::add_resources(std::vector<sg_host_t> hosts)
{
- this->is_lowest_ = 1;
- this->children.clear();
- this->last_id_ = 0;
+ children_.clear();
+ last_id_ = 0;
for (auto const& host : hosts) {
const char *host_name = sg_host_get_name(host);
}
}
-void Container::create_hierarchy(sg_netzone_t from_as)
+void Container::create_hierarchy(const_sg_netzone_t from_as)
{
-
if (from_as->get_children().empty()) {
// I am no AS
// add hosts to jedule platform
}
}
-std::vector<int> Container::get_hierarchy()
+int Container::get_child_position(const Container* child) const
{
- if(this->parent != nullptr ) {
-
- if (not this->parent->children.empty()) {
- // we are in the last level
- return this->parent->get_hierarchy();
- } else {
- unsigned int i =0;
- int child_nb = -1;
-
- for (auto const& child : this->parent->children) {
- if (child.get() == this) {
- child_nb = i;
- break;
- }
- i++;
- }
+ auto it = std::find_if(begin(children_), end(children_),
+ [&child](const std::unique_ptr<Container>& c) { return c.get() == child; });
+ return it == end(children_) ? -1 : std::distance(begin(children_), it);
+}
- xbt_assert( child_nb > - 1);
- std::vector<int> heir_list = this->parent->get_hierarchy();
- heir_list.insert(heir_list.begin(), child_nb);
- return heir_list;
- }
- } else {
+std::vector<int> Container::get_hierarchy()
+{
+ if (parent_ == nullptr) {
int top_level = 0;
std::vector<int> heir_list = {top_level};
return heir_list;
+ } else if (parent_->has_children()) {
+ int child_nb = parent_->get_child_position(this);
+ xbt_assert(child_nb > -1);
+ std::vector<int> heir_list = parent_->get_hierarchy();
+ heir_list.insert(heir_list.begin(), child_nb);
+ return heir_list;
+ } else {
+ // we are in the last level
+ return parent_->get_hierarchy();
}
}
void Container::print(FILE* jed_file)
{
fprintf(jed_file, " <res name=\"%s\">\n", this->name.c_str());
- if (not this->children.empty()) {
- for (auto const& child : this->children) {
+ if (not children_.empty()) {
+ for (auto const& child : children_) {
child->print(jed_file);
}
} else {
fprintf(jed_file, " </res>\n");
}
-}
-}
+} // namespace jedule
+} // namespace simgrid
static void add_subsets_to(std::vector<simgrid::jedule::Subset>& subset_list, std::vector<const char*> hostgroup,
jed_container_t parent)
for (auto const& host_name : hostgroup) {
xbt_assert( host_name != nullptr );
jed_container_t parent_cont = host2_simgrid_parent_container.at(host_name);
- unsigned int id = parent_cont->name2id.at(host_name);
+ unsigned int id = parent_cont->get_id_by_name(host_name);
id_list.push_back(id);
}
unsigned int nb_ids = id_list.size();
pos = i;
}
}
-
}
void get_resource_selection_by_hosts(std::vector<simgrid::jedule::Subset>& subset_list,
std::unordered_map<const char*, std::vector<const char*>> parent2hostgroup;
for (auto const& host : host_list) {
const char *host_name = sg_host_get_name(host);
- jed_container_t parent = host2_simgrid_parent_container.at(host_name);
+ const simgrid::jedule::Container* parent = host2_simgrid_parent_container.at(host_name);
xbt_assert( parent != nullptr );
- auto host_group = parent2hostgroup.find(parent->name.c_str());
+ auto host_group = parent2hostgroup.find(parent->get_cname());
if (host_group == parent2hostgroup.end())
- parent2hostgroup.insert({parent->name.c_str(), std::vector<const char*>(1,host_name)});
+ parent2hostgroup.insert({parent->get_cname(), std::vector<const char*>(1, host_name)});
else
host_group->second.push_back(host_name);
}
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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 "simgrid/jedule/jedule.hpp"
-#include "src/simdag/simdag_private.hpp"
-
#include "simgrid/s4u/Engine.hpp"
#include "simgrid/s4u/NetZone.hpp"
+#include "src/simdag/simdag_private.hpp"
#if SIMGRID_HAVE_JEDULE
jedule_t my_jedule;
-void jedule_log_sd_event(SD_task_t task)
+void jedule_log_sd_event(const_SD_task_t task)
{
xbt_assert(task != nullptr);
simgrid::jedule::Event event(std::string(SD_task_get_name(task)), SD_task_get_start_time(task),
SD_task_get_finish_time(task), "SD");
event.add_resources(*task->allocation);
- my_jedule->event_set_.emplace_back(std::move(event));
+ my_jedule->add_event(std::move(event));
}
void jedule_sd_init()
{
- sg_netzone_t root_comp = simgrid::s4u::Engine::get_instance()->get_netzone_root();
+ const_sg_netzone_t root_comp = simgrid::s4u::Engine::get_instance()->get_netzone_root();
XBT_DEBUG("root name %s\n", root_comp->get_cname());
my_jedule = new simgrid::jedule::Jedule(root_comp->get_name());
- my_jedule->root_container_.create_hierarchy(root_comp);
}
void jedule_sd_exit()
void jedule_sd_dump(const char * filename)
{
if (my_jedule) {
- char *fname;
+ std::string fname;
if (not filename) {
- fname = bprintf("%s.jed", xbt_binary_name);
+ fname = simgrid::xbt::binary_name + ".jed";
} else {
- fname = xbt_strdup(filename);
+ fname = filename;
}
- FILE *fh = fopen(fname, "w");
+ FILE* fh = fopen(fname.c_str(), "w");
my_jedule->write_output(fh);
fclose(fh);
- xbt_free(fname);
}
}
#endif
/* Warning: The file internal_config.h is AUTOMATICALLY GENERATED by Cmake.
* Edit the template instead: src/internal_config.h.in */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
/* Address Sanitizer */
#cmakedefine01 HAVE_SANITIZER_THREAD
+#cmakedefine01 HAVE_SANITIZER_THREAD_FIBER_SUPPORT
#cmakedefine01 HAVE_SANITIZER_ADDRESS
#cmakedefine01 HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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 SIMGRID_KERNEL_ACTIVITY_ACTIVITY_HPP
-#define SIMGRID_KERNEL_ACTIVITY_ACTIVITY_HPP
+#ifndef SIMGRID_KERNEL_ACTIVITY_ACTIVITYIMPL_HPP
+#define SIMGRID_KERNEL_ACTIVITY_ACTIVITYIMPL_HPP
#include <string>
#include <list>
class XBT_PUBLIC ActivityImpl {
std::atomic_int_fast32_t refcount_{0};
+
public:
virtual ~ActivityImpl();
ActivityImpl() = default;
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
XBT_PRIVATE void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_actor_t src, smx_mailbox_t mbox, double task_size,
double rate, unsigned char* src_buff, size_t src_buff_size,
- int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+ bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
void* data, double timeout)
{
XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend(
smx_simcall_t /*simcall*/, smx_actor_t src_proc, smx_mailbox_t mbox, double task_size, double rate,
- unsigned char* src_buff, size_t src_buff_size, int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+ unsigned char* src_buff, size_t src_buff_size,
+ bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
void (*clean_fun)(void*), // used to free the synchro in case of problem after a detached send
void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), // used to copy data if not default one
void* data, bool detached)
XBT_PRIVATE void simcall_HANDLER_comm_recv(smx_simcall_t simcall, smx_actor_t receiver, smx_mailbox_t mbox,
unsigned char* dst_buff, size_t* dst_buff_size,
- int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+ bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
void* data, double timeout, double rate)
{
XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_irecv(
smx_simcall_t /*simcall*/, smx_actor_t receiver, smx_mailbox_t mbox, unsigned char* dst_buff, size_t* dst_buff_size,
- simix_match_func_t match_fun, void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
- void* data, double rate)
+ bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+ void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data, double rate)
{
simgrid::kernel::activity::CommImplPtr this_synchro =
simgrid::kernel::activity::CommImplPtr(new simgrid::kernel::activity::CommImpl());
/* Check out for errors */
if (not simcall->issuer_->get_host()->is_on()) {
- simcall->issuer_->context_->iwannadie = true;
+ simcall->issuer_->context_->set_wannadie();
} else {
switch (state_) {
case State::DONE:
case State::SRC_HOST_FAILURE:
if (simcall->issuer_ == src_actor_)
- simcall->issuer_->context_->iwannadie = true;
+ simcall->issuer_->context_->set_wannadie();
else
simcall->issuer_->exception_ =
std::make_exception_ptr(simgrid::NetworkFailureException(XBT_THROW_POINT, "Remote peer failed"));
case State::DST_HOST_FAILURE:
if (simcall->issuer_ == dst_actor_)
- simcall->issuer_->context_->iwannadie = true;
+ simcall->issuer_->context_->set_wannadie();
else
simcall->issuer_->exception_ =
std::make_exception_ptr(simgrid::NetworkFailureException(XBT_THROW_POINT, "Remote peer failed"));
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
#endif
void (*clean_fun)(void*) = nullptr; /* Function to clean the detached src_buf if something goes wrong */
- int (*match_fun)(void*, void*, CommImpl*) = nullptr; /* Filter function used by the other side. It is used when
+ bool (*match_fun)(void*, void*, CommImpl*) = nullptr; /* Filter function used by the other side. It is used when
looking if a given communication matches my needs. For that, myself must match the
expectations of the other side, too. See */
void (*copy_data_fun)(CommImpl*, void*, size_t) = nullptr;
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
namespace kernel {
namespace activity {
-ConditionVariableImpl::ConditionVariableImpl() : cond_(this) {}
-ConditionVariableImpl::~ConditionVariableImpl() = default;
-
/**
* @brief Signalizes a condition.
*
/* If there is a mutex unlock it */
if (mutex != nullptr) {
- xbt_assert(mutex->owner_ == issuer,
+ xbt_assert(mutex->get_owner() == issuer,
"Actor %s cannot wait on ConditionVariable %p since it does not own the provided mutex %p",
issuer->get_cname(), this, mutex);
mutex_ = mutex;
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
namespace activity {
class XBT_PUBLIC ConditionVariableImpl {
-public:
- ConditionVariableImpl();
- ~ConditionVariableImpl();
-
- actor::SynchroList sleeping_; /* list of sleeping processes */
MutexImpl* mutex_ = nullptr;
- s4u::ConditionVariable cond_;
-
- void broadcast();
- void signal();
- void wait(MutexImpl* mutex, double timeout, actor::ActorImpl* issuer);
+ s4u::ConditionVariable piface_;
+ actor::SynchroList sleeping_; /* list of sleeping actors*/
-private:
std::atomic_int_fast32_t refcount_{1};
friend void intrusive_ptr_add_ref(ConditionVariableImpl* cond);
friend void intrusive_ptr_release(ConditionVariableImpl* cond);
+
+public:
+ ConditionVariableImpl() : piface_(this){};
+ ~ConditionVariableImpl() = default;
+
+ void remove_sleeping_actor(actor::ActorImpl& actor) { xbt::intrusive_erase(sleeping_, actor); }
+ s4u::ConditionVariable* get_iface() { return &piface_; }
+ void broadcast();
+ void signal();
+ void wait(MutexImpl* mutex, double timeout, actor::ActorImpl* issuer);
};
} // namespace activity
} // namespace kernel
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_process);
-void simcall_HANDLER_execution_wait(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* synchro)
+void simcall_HANDLER_execution_wait(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* synchro, double timeout)
{
XBT_DEBUG("Wait for execution of synchro %p, state %d", synchro, (int)synchro->state_);
+ xbt_assert(std::isfinite(timeout), "timeout is not finite!");
/* Associate this simcall to the synchro */
synchro->register_simcall(simcall);
/* set surf's synchro */
if (MC_is_active() || MC_record_replay_is_active()) {
- synchro->state_ = simgrid::kernel::activity::State::DONE;
+ int idx = SIMCALL_GET_MC_VALUE(*simcall);
+ if (idx == 0) {
+ synchro->state_ = simgrid::kernel::activity::State::DONE;
+ } else {
+ /* If we reached this point, the wait simcall must have a timeout */
+ /* Otherwise it shouldn't be enabled and executed by the MC */
+ if (timeout < 0.0)
+ THROW_IMPOSSIBLE;
+ synchro->state_ = simgrid::kernel::activity::State::TIMEOUT;
+ }
synchro->finish();
return;
}
/* If the synchro is already finished then perform the error handling */
- if (synchro->state_ != simgrid::kernel::activity::State::RUNNING)
+ if (synchro->state_ != simgrid::kernel::activity::State::RUNNING) {
synchro->finish();
+ } else { /* we need a sleep action (even when there is no timeout) to be notified of host failures */
+ synchro->set_timeout(timeout);
+ }
}
void simcall_HANDLER_execution_test(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* synchro)
namespace kernel {
namespace activity {
-ExecImpl::~ExecImpl()
-{
- if (timeout_detector_)
- timeout_detector_->unref();
- XBT_DEBUG("Destroy exec %p", this);
-}
-
ExecImpl& ExecImpl::set_host(s4u::Host* host)
{
if (not hosts_.empty())
ExecImpl& ExecImpl::set_timeout(double timeout)
{
if (timeout > 0 && not MC_is_active() && not MC_record_replay_is_active()) {
- timeout_detector_ = hosts_.front()->pimpl_cpu->sleep(timeout);
+ timeout_detector_.reset(hosts_.front()->pimpl_cpu->sleep(timeout));
timeout_detector_->set_activity(this);
}
return *this;
}
clean_action();
-
- if (timeout_detector_) {
- timeout_detector_->unref();
- timeout_detector_ = nullptr;
- }
-
+ timeout_detector_.reset();
/* Answer all simcalls associated with the synchro */
finish();
}
}
switch (state_) {
-
case State::DONE:
/* do nothing, synchro done */
XBT_DEBUG("ExecImpl::finish(): execution successful");
case State::FAILED:
XBT_DEBUG("ExecImpl::finish(): host '%s' failed", simcall->issuer_->get_host()->get_cname());
- simcall->issuer_->context_->iwannadie = true;
+ simcall->issuer_->context_->set_wannadie();
if (simcall->issuer_->get_host()->is_on())
simcall->issuer_->exception_ =
std::make_exception_ptr(simgrid::HostFailureException(XBT_THROW_POINT, "Host failed"));
if (simcall->issuer_->get_host()->is_on())
simcall->issuer_->simcall_answer();
else
- simcall->issuer_->context_->iwannadie = true;
+ simcall->issuer_->context_->set_wannadie();
}
}
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
namespace activity {
class XBT_PUBLIC ExecImpl : public ActivityImpl_T<ExecImpl> {
- resource::Action* timeout_detector_ = nullptr;
+ std::unique_ptr<resource::Action, std::function<void(resource::Action*)>> timeout_detector_{
+ nullptr, [](resource::Action* a) { a->unref(); }};
double sharing_penalty_ = 1.0;
double bound_ = 0.0;
std::vector<s4u::Host*> hosts_;
std::vector<double> flops_amounts_;
std::vector<double> bytes_amounts_;
- ~ExecImpl();
public:
ExecImpl& set_timeout(double timeout);
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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 "src/mc/mc_replay.hpp"
#include "src/simix/smx_private.hpp"
#include "src/surf/StorageImpl.hpp"
+#include "src/surf/cpu_interface.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_io, simix, "Logging specific to SIMIX (io)");
-void simcall_HANDLER_io_wait(smx_simcall_t simcall, simgrid::kernel::activity::IoImpl* synchro)
+void simcall_HANDLER_io_wait(smx_simcall_t simcall, simgrid::kernel::activity::IoImpl* synchro, double timeout)
{
XBT_DEBUG("Wait for execution of synchro %p, state %d", synchro, (int)synchro->state_);
/* Associate this simcall to the synchro */
synchro->register_simcall(simcall);
- if (MC_is_active() || MC_record_replay_is_active())
- synchro->state_ = simgrid::kernel::activity::State::DONE;
+ if (MC_is_active() || MC_record_replay_is_active()) {
+ int idx = SIMCALL_GET_MC_VALUE(*simcall);
+ if (idx == 0) {
+ synchro->state_ = simgrid::kernel::activity::State::DONE;
+ } else {
+ /* If we reached this point, the wait simcall must have a timeout */
+ /* Otherwise it shouldn't be enabled and executed by the MC */
+ if (timeout < 0.0)
+ THROW_IMPOSSIBLE;
+ synchro->state_ = simgrid::kernel::activity::State::TIMEOUT;
+ }
+ synchro->finish();
+ }
/* If the synchro is already finished then perform the error handling */
if (synchro->state_ != simgrid::kernel::activity::State::RUNNING)
synchro->finish();
+ else {
+ /* we need a sleep action (even when there is no timeout) to be notified of host failures */
+ if (synchro->get_disk() != nullptr)
+ synchro->set_timeout_detector(synchro->get_disk()->get_host()->pimpl_cpu->sleep(timeout));
+ else
+ synchro->set_timeout_detector(
+ simgrid::s4u::Host::by_name(synchro->get_storage()->get_host())->pimpl_cpu->sleep(timeout));
+ }
+}
+
+void simcall_HANDLER_io_test(smx_simcall_t simcall, simgrid::kernel::activity::IoImpl* synchro)
+{
+ bool res = (synchro->state_ != simgrid::kernel::activity::State::WAITING &&
+ synchro->state_ != simgrid::kernel::activity::State::RUNNING);
+ if (res) {
+ synchro->simcalls_.push_back(simcall);
+ synchro->finish();
+ } else {
+ simcall->issuer_->simcall_answer();
+ }
+ simcall_io_test__set__result(simcall, res);
}
namespace simgrid {
state_ = State::CANCELED;
} else if (surf_action_->get_state() == resource::Action::State::FINISHED) {
state_ = State::DONE;
+ } else if (timeout_detector_ && timeout_detector_->get_state() == resource::Action::State::FINISHED) {
+ state_ = State::TIMEOUT;
}
+
+ if (timeout_detector_) {
+ timeout_detector_->unref();
+ timeout_detector_ = nullptr;
+ }
+
on_completion(*this);
/* Answer all simcalls associated with the synchro */
void IoImpl::finish()
{
while (not simcalls_.empty()) {
- smx_simcall_t simcall = simcalls_.front();
+ const s_smx_simcall* simcall = simcalls_.front();
simcalls_.pop_front();
switch (state_) {
case State::DONE:
/* do nothing, synchro done */
break;
case State::FAILED:
- simcall->issuer_->context_->iwannadie = true;
+ simcall->issuer_->context_->set_wannadie();
simcall->issuer_->exception_ =
std::make_exception_ptr(StorageFailureException(XBT_THROW_POINT, "Storage failed"));
break;
case State::CANCELED:
simcall->issuer_->exception_ = std::make_exception_ptr(CancelException(XBT_THROW_POINT, "I/O Canceled"));
break;
+ case State::TIMEOUT:
+ XBT_DEBUG("IoImpl::finish(): execution timeouted");
+ simcall->issuer_->exception_ = std::make_exception_ptr(simgrid::TimeoutException(XBT_THROW_POINT, "Timeouted"));
+ break;
default:
xbt_die("Internal error in IoImpl::finish(): unexpected synchro state %d", static_cast<int>(state_));
}
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
sg_size_t size_ = 0;
s4u::Io::OpType type_ = s4u::Io::OpType::READ;
sg_size_t performed_ioops_ = 0;
+ resource::Action* timeout_detector_ = nullptr;
public:
IoImpl& set_size(sg_size_t size);
IoImpl& set_storage(resource::StorageImpl* storage);
IoImpl& set_disk(resource::DiskImpl* disk);
+ void set_timeout_detector(resource::Action* action)
+ {
+ timeout_detector_ = action;
+ timeout_detector_->set_activity(this);
+ }
+
sg_size_t get_performed_ioops() { return performed_ioops_; }
+ resource::DiskImpl* get_disk() { return disk_; }
+ resource::StorageImpl* get_storage() { return storage_; }
IoImpl* start();
void post() override;
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
xbt_die("Comm %p not found in mailbox %s", comm.get(), this->get_cname());
}
-CommImplPtr MailboxImpl::iprobe(int type, int (*match_fun)(void*, void*, CommImpl*), void* data)
+CommImplPtr MailboxImpl::iprobe(int type, bool (*match_fun)(void*, void*, CommImpl*), void* data)
{
XBT_DEBUG("iprobe from %p %p", this, &comm_queue_);
* @param remove_matching whether or not to clean the found object from the queue
* @return The communication activity if found, nullptr otherwise
*/
-CommImplPtr MailboxImpl::find_matching_comm(CommImpl::Type type, int (*match_fun)(void*, void*, CommImpl*),
+CommImplPtr MailboxImpl::find_matching_comm(CommImpl::Type type, bool (*match_fun)(void*, void*, CommImpl*),
void* this_user_data, const CommImplPtr& my_synchro, bool done,
bool remove_matching)
{
auto& comm_queue = done ? done_comm_queue_ : comm_queue_;
for (auto it = comm_queue.begin(); it != comm_queue.end(); it++) {
- CommImplPtr& comm = *it;
+ const CommImplPtr& comm = *it;
if (comm->type_ == CommImpl::Type::SEND) {
other_user_data = comm->src_data_;
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
friend s4u::Mailbox* s4u::Mailbox::by_name(const std::string& name);
friend mc::CommunicationDeterminismChecker;
- explicit MailboxImpl(const std::string& name)
- : piface_(this), name_(name), comm_queue_(MAX_MAILBOX_SIZE), done_comm_queue_(MAX_MAILBOX_SIZE)
- {
- }
+ explicit MailboxImpl(const std::string& name) : piface_(this), name_(name) {}
public:
const xbt::string& get_name() const { return name_; }
void set_receiver(s4u::ActorPtr actor);
void push(CommImplPtr comm);
void remove(const CommImplPtr& comm);
- CommImplPtr iprobe(int type, int (*match_fun)(void*, void*, CommImpl*), void* data);
- CommImplPtr find_matching_comm(CommImpl::Type type, int (*match_fun)(void*, void*, CommImpl*), void* this_user_data,
+ CommImplPtr iprobe(int type, bool (*match_fun)(void*, void*, CommImpl*), void* data);
+ CommImplPtr find_matching_comm(CommImpl::Type type, bool (*match_fun)(void*, void*, CommImpl*), void* this_user_data,
const CommImplPtr& my_synchro, bool done, bool remove_matching);
actor::ActorImplPtr permanent_receiver_; // actor to which the mailbox is attached
- boost::circular_buffer_space_optimized<CommImplPtr> comm_queue_;
- boost::circular_buffer_space_optimized<CommImplPtr> done_comm_queue_; // messages already received in the permanent
- // receive mode
+ boost::circular_buffer_space_optimized<CommImplPtr> comm_queue_{MAX_MAILBOX_SIZE};
+ // messages already received in the permanent receive mode
+ boost::circular_buffer_space_optimized<CommImplPtr> done_comm_queue_{MAX_MAILBOX_SIZE};
};
} // namespace activity
} // namespace kernel
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
std::atomic_int_fast32_t refcount_{1};
s4u::Mutex piface_;
bool locked_ = false;
+ actor::ActorImpl* owner_ = nullptr;
+ // List of sleeping actors:
+ actor::SynchroList sleeping_;
public:
MutexImpl() : piface_(this) {}
MutexImpl* ref();
void unref();
- actor::ActorImpl* owner_ = nullptr;
- // List of sleeping actors:
- actor::SynchroList sleeping_;
+ void remove_sleeping_actor(actor::ActorImpl& actor) { xbt::intrusive_erase(sleeping_, actor); }
+ actor::ActorImpl* get_owner() const { return owner_; }
// boost::intrusive_ptr<Mutex> support:
friend void intrusive_ptr_add_ref(MutexImpl* mutex)
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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. */
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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 SIMGRID_KERNEL_ACTIVITY_SEMAPHORE_HPP
-#define SIMGRID_KERNEL_ACTIVITY_SEMAPHORE_HPP
+#ifndef SIMGRID_KERNEL_ACTIVITY_SEMAPHOREIMPL_HPP
+#define SIMGRID_KERNEL_ACTIVITY_SEMAPHOREIMPL_HPP
#include <atomic>
#include <boost/intrusive/list.hpp>
class XBT_PUBLIC SemaphoreImpl {
std::atomic_int_fast32_t refcount_{1};
unsigned int value_;
-
-public:
actor::SynchroList sleeping_; /* list of sleeping actors*/
+public:
explicit SemaphoreImpl(unsigned int value) : value_(value){};
~SemaphoreImpl() = default;
void acquire(actor::ActorImpl* issuer, double timeout);
void release();
bool would_block() { return (value_ == 0); }
+ void remove_sleeping_actor(actor::ActorImpl& actor) { xbt::intrusive_erase(sleeping_, actor); }
unsigned int get_capacity() { return value_; }
+ bool is_used() { return not sleeping_.empty(); }
friend void intrusive_ptr_add_ref(SemaphoreImpl* sem)
{
} // namespace kernel
} // namespace simgrid
-#endif /* SIMGRID_KERNEL_ACTIVITY_SEMAPHOREIMPL_HPP_ */
+#endif /* SIMGRID_KERNEL_ACTIVITY_SEMAPHOREIMPL_HPP */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
void SleepImpl::finish()
{
while (not simcalls_.empty()) {
- smx_simcall_t simcall = simcalls_.front();
+ const s_smx_simcall* simcall = simcalls_.front();
simcalls_.pop_front();
simcall->issuer_->waiting_synchro = nullptr;
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
if (state_ == State::FAILED) {
XBT_DEBUG("RawImpl::finish(): host '%s' failed", simcall->issuer_->get_host()->get_cname());
- simcall->issuer_->context_->iwannadie = true;
+ simcall->issuer_->context_->set_wannadie();
simcall->issuer_->exception_ = std::make_exception_ptr(HostFailureException(XBT_THROW_POINT, "Host failed"));
} else if (state_ != State::SRC_TIMEOUT) {
xbt_die("Internal error in RawImpl::finish() unexpected synchro state %d", static_cast<int>(state_));
}
switch (simcall->call_) {
-
case SIMCALL_MUTEX_LOCK:
- simgrid::xbt::intrusive_erase(simcall_mutex_lock__get__mutex(simcall)->sleeping_, *simcall->issuer_);
+ simcall_mutex_lock__get__mutex(simcall)->remove_sleeping_actor(*simcall->issuer_);
break;
case SIMCALL_COND_WAIT:
- simgrid::xbt::intrusive_erase(simcall_cond_wait__get__cond(simcall)->sleeping_, *simcall->issuer_);
+ simcall_cond_wait_timeout__get__cond(simcall)->remove_sleeping_actor(*simcall->issuer_);
break;
case SIMCALL_COND_WAIT_TIMEOUT:
- simgrid::xbt::intrusive_erase(simcall_cond_wait_timeout__get__cond(simcall)->sleeping_, *simcall->issuer_);
+ simcall_cond_wait_timeout__get__cond(simcall)->remove_sleeping_actor(*simcall->issuer_);
simcall_cond_wait_timeout__set__result(simcall, 1); // signal a timeout
break;
case SIMCALL_SEM_ACQUIRE:
- simgrid::xbt::intrusive_erase(simcall_sem_acquire__get__sem(simcall)->sleeping_, *simcall->issuer_);
+ simcall_sem_acquire_timeout__get__sem(simcall)->remove_sleeping_actor(*simcall->issuer_);
break;
case SIMCALL_SEM_ACQUIRE_TIMEOUT:
- simgrid::xbt::intrusive_erase(simcall_sem_acquire_timeout__get__sem(simcall)->sleeping_, *simcall->issuer_);
+ simcall_sem_acquire_timeout__get__sem(simcall)->remove_sleeping_actor(*simcall->issuer_);
simcall_sem_acquire_timeout__set__result(simcall, 1); // signal a timeout
break;
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
ActorImpl::~ActorImpl()
{
- if (simix_global != nullptr && this != simix_global->maestro_) {
- if (context_.get() != nullptr) /* the actor was not start()ed yet. This happens if its host was initially off */
- context_->iwannadie = false; // don't let the simcall's yield() do a Context::stop(), to avoid infinite loops
- actor::simcall([this] { s4u::Actor::on_destruction(*ciface()); });
- if (context_.get() != nullptr)
- context_->iwannadie = true;
- }
+ if (simix_global != nullptr && this != simix_global->maestro_)
+ s4u::Actor::on_destruction(*ciface());
}
/* Become an actor in the simulation
context->attach_stop();
}
+void ActorImpl::cleanup_from_simix()
+{
+ const std::lock_guard<std::mutex> lock(simix_global->mutex);
+ simix_global->process_list.erase(pid_);
+ if (host_ && host_actor_list_hook.is_linked())
+ host_->pimpl_->remove_actor(this);
+ if (not smx_destroy_list_hook.is_linked()) {
+#if SIMGRID_HAVE_MC
+ xbt_dynar_push_as(simix_global->dead_actors_vector, ActorImpl*, this);
+#endif
+ simix_global->actors_to_destroy.push_back(*this);
+ }
+}
+
void ActorImpl::cleanup()
{
finished_ = true;
if (on_exit) {
// Execute the termination callbacks
- bool failed = context_->iwannadie;
+ bool failed = context_->wannadie();
for (auto exit_fun = on_exit->crbegin(); exit_fun != on_exit->crend(); ++exit_fun)
(*exit_fun)(failed);
on_exit.reset();
kill_timer->remove();
kill_timer = nullptr;
}
+ cleanup_from_simix();
- simix_global->mutex.lock();
-
- simix_global->process_list.erase(pid_);
- if (host_ && host_actor_list_hook.is_linked())
- host_->pimpl_->remove_actor(this);
- if (not smx_destroy_list_hook.is_linked()) {
-#if SIMGRID_HAVE_MC
- xbt_dynar_push_as(simix_global->dead_actors_vector, ActorImpl*, this);
-#endif
- simix_global->actors_to_destroy.push_back(*this);
- }
-
- simix_global->mutex.unlock();
-
- context_->iwannadie = false; // don't let the simcall's yield() do a Context::stop(), to avoid infinite loops
+ context_->set_wannadie(false); // don't let the simcall's yield() do a Context::stop(), to avoid infinite loops
actor::simcall([this] { s4u::Actor::on_termination(*ciface()); });
- context_->iwannadie = true;
+ context_->set_wannadie();
}
void ActorImpl::exit()
{
- context_->iwannadie = true;
+ context_->set_wannadie();
suspended_ = false;
exception_ = nullptr;
/* Ok, maestro returned control to us */
XBT_DEBUG("Control returned to me: '%s'", get_cname());
- if (context_->iwannadie) {
+ if (context_->wannadie()) {
XBT_DEBUG("Actor %s@%s is dead", get_cname(), host_->get_cname());
context_->stop();
THROW_IMPOSSIBLE;
{
XBT_IN("actor = %p", this);
- if (context_->iwannadie) {
+ if (context_->wannadie()) {
XBT_VERB("Ignoring request to suspend an actor that is currently dying.");
return;
}
XBT_OUT();
}
-activity::ActivityImplPtr ActorImpl::join(ActorImpl* actor, double timeout)
+activity::ActivityImplPtr ActorImpl::join(const ActorImpl* actor, double timeout)
{
activity::ActivityImplPtr sleep = this->sleep(timeout);
actor->on_exit->emplace_back([sleep](bool) {
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
private:
s4u::Actor piface_; // Our interface is part of ourselves
+ void cleanup_from_simix();
void undaemonize();
public:
s4u::Actor* restart();
void suspend();
void resume();
- activity::ActivityImplPtr join(ActorImpl* actor, double timeout);
+ activity::ActivityImplPtr join(const ActorImpl* actor, double timeout);
activity::ActivityImplPtr sleep(double duration);
/** Ask the actor to throw an exception right away */
void throw_exception(std::exception_ptr e);
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
std::function<void()> code_;
actor::ActorImpl* actor_ = nullptr;
+ bool iwannadie_ = false;
void declare_context(std::size_t size);
public:
- bool iwannadie = false;
-
Context(std::function<void()>&& code, actor::ActorImpl* actor);
Context(const Context&) = delete;
Context& operator=(const Context&) = delete;
virtual ~Context();
+ bool wannadie() const { return iwannadie_; }
+ void set_wannadie(bool value = true) { iwannadie_ = value; }
void operator()() { code_(); }
bool has_code() const { return static_cast<bool>(code_); }
actor::ActorImpl* get_actor() { return this->actor_; }
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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 "ContextBoost.hpp"
-#include "context_private.hpp"
#include "simgrid/Exception.hpp"
#include "src/simix/smx_private.hpp"
/* if the user provided a function for the process then use it, otherwise it is the context for maestro */
if (has_code()) {
- /* We need to pass the bottom of the stack to make_fcontext,
- depending on the stack direction it may be the lower or higher address: */
-#if PTH_STACKGROWTH == -1
- unsigned char* stack = get_stack() + smx_context_stack_size;
-#else
- unsigned char* stack = get_stack();
-#endif
#if BOOST_VERSION < 106100
- this->fc_ = boost::context::make_fcontext(stack, smx_context_stack_size, BoostContext::wrapper);
+ this->fc_ = boost::context::make_fcontext(get_stack_bottom(), smx_context_stack_size, BoostContext::wrapper);
#else
- this->fc_ = boost::context::detail::make_fcontext(stack, smx_context_stack_size, BoostContext::wrapper);
-#endif
-
- } else {
-#if BOOST_VERSION < 105600
- this->fc_ = new boost::context::fcontext_t();
+ this->fc_ =
+ boost::context::detail::make_fcontext(get_stack_bottom(), smx_context_stack_size, BoostContext::wrapper);
#endif
}
}
-BoostContext::~BoostContext()
-{
-#if BOOST_VERSION < 105600
- if (not get_stack())
- delete this->fc_;
-#endif
-}
-
void BoostContext::wrapper(BoostContext::arg_type arg)
{
#if BOOST_VERSION < 106100
BoostContext* context = reinterpret_cast<BoostContext*>(arg);
#else
BoostContext* context = static_cast<BoostContext**>(arg.data)[1];
- ASAN_ONLY(xbt_assert(context->asan_ctx_ == static_cast<BoostContext**>(arg.data)[0]));
- ASAN_FINISH_SWITCH(nullptr, &context->asan_ctx_->asan_stack_, &context->asan_ctx_->asan_stack_size_);
+ context->verify_previous_context(static_cast<BoostContext**>(arg.data)[0]);
static_cast<BoostContext**>(arg.data)[0]->fc_ = arg.fctx;
#endif
- try {
- (*context)();
- context->Context::stop();
- } catch (ForcefulKillException const&) {
- XBT_DEBUG("Caught a ForcefulKillException");
- } catch (simgrid::Exception const& e) {
- XBT_INFO("Actor killed by an uncaught exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
- throw;
- }
- ASAN_ONLY(context->asan_stop_ = true);
- context->suspend();
+ smx_ctx_wrapper(context);
}
-void BoostContext::swap_into(SwappedContext* to_)
+void BoostContext::swap_into_for_real(SwappedContext* to_)
{
BoostContext* to = static_cast<BoostContext*>(to_);
-#if BOOST_VERSION < 105600
- boost::context::jump_fcontext(this->fc_, to->fc_, reinterpret_cast<intptr_t>(to));
-#elif BOOST_VERSION < 106100
+#if BOOST_VERSION < 106100
boost::context::jump_fcontext(&this->fc_, to->fc_, reinterpret_cast<intptr_t>(to));
#else
BoostContext* ctx[2] = {this, to};
- ASAN_ONLY(void* fake_stack = nullptr);
- ASAN_ONLY(to->asan_ctx_ = this);
- ASAN_START_SWITCH(this->asan_stop_ ? nullptr : &fake_stack, to->asan_stack_, to->asan_stack_size_);
boost::context::detail::transfer_t arg = boost::context::detail::jump_fcontext(to->fc_, ctx);
- ASAN_ONLY(xbt_assert(this->asan_ctx_ == static_cast<BoostContext**>(arg.data)[0]));
- ASAN_FINISH_SWITCH(fake_stack, &this->asan_ctx_->asan_stack_, &this->asan_ctx_->asan_stack_size_);
+ this->verify_previous_context(static_cast<BoostContext**>(arg.data)[0]);
static_cast<BoostContext**>(arg.data)[0]->fc_ = arg.fctx;
#endif
}
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
class BoostContext : public SwappedContext {
public:
BoostContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory);
- ~BoostContext() override;
-
- void swap_into(SwappedContext* to) override;
private:
-#if BOOST_VERSION < 105600
- boost::context::fcontext_t* fc_ = nullptr;
- typedef intptr_t arg_type;
-#elif BOOST_VERSION < 106100
+#if BOOST_VERSION < 106100
boost::context::fcontext_t fc_;
typedef intptr_t arg_type;
#else
typedef boost::context::detail::transfer_t arg_type;
#endif
- static void wrapper(arg_type arg);
+ XBT_ATTRIB_NORETURN static void wrapper(arg_type arg);
+
+ void swap_into_for_real(SwappedContext* to) override;
};
class BoostContextFactory : public SwappedContextFactory {
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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 "ContextRaw.hpp"
-#include "context_private.hpp"
#include "mc/mc.h"
#include "simgrid/Exception.hpp"
#include "src/simix/smx_private.hpp"
// Raw context routines
-typedef void (*rawctx_entry_point_t)(simgrid::kernel::context::RawContext*);
+typedef void (*rawctx_entry_point_t)(simgrid::kernel::context::SwappedContext*);
typedef void* raw_stack_t;
extern "C" raw_stack_t raw_makecontext(void* malloced_stack, int stack_size, rawctx_entry_point_t entry_point,
- simgrid::kernel::context::RawContext* arg);
+ simgrid::kernel::context::SwappedContext* arg);
extern "C" void raw_swapcontext(raw_stack_t* old, raw_stack_t new_context);
// TODO, we should handle FP, MMX and the x87 control-word (for x86 and x86_64)
update the definition of HAVE_RAW_CONTEXTS in tools/cmake/CompleteInFiles.cmake */
raw_stack_t raw_makecontext(void* malloced_stack, int stack_size, rawctx_entry_point_t entry_point,
- simgrid::kernel::context::RawContext* arg)
+ simgrid::kernel::context::SwappedContext* arg)
{
THROW_UNIMPLEMENTED;
}
: SwappedContext(std::move(code), actor, factory)
{
if (has_code()) {
- this->stack_top_ = raw_makecontext(get_stack(), smx_context_stack_size, RawContext::wrapper, this);
+ this->stack_top_ = raw_makecontext(get_stack(), smx_context_stack_size, smx_ctx_wrapper, this);
} else {
if (MC_is_active())
MC_ignore_heap(&stack_top_, sizeof(stack_top_));
}
}
-void RawContext::wrapper(RawContext* context)
+void RawContext::swap_into_for_real(SwappedContext* to_)
{
- ASAN_FINISH_SWITCH(nullptr, &context->asan_ctx_->asan_stack_, &context->asan_ctx_->asan_stack_size_);
- try {
- (*context)();
- context->Context::stop();
- } catch (ForcefulKillException const&) {
- XBT_DEBUG("Caught a ForcefulKillException");
- } catch (simgrid::Exception const& e) {
- XBT_INFO("Actor killed by an uncaught exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
- throw;
- }
- ASAN_ONLY(context->asan_stop_ = true);
- context->suspend();
-}
-
-void RawContext::swap_into(SwappedContext* to_)
-{
- RawContext* to = static_cast<RawContext*>(to_);
- ASAN_ONLY(void* fake_stack = nullptr);
- ASAN_ONLY(to->asan_ctx_ = this);
- ASAN_START_SWITCH(this->asan_stop_ ? nullptr : &fake_stack, to->asan_stack_, to->asan_stack_size_);
+ const RawContext* to = static_cast<RawContext*>(to_);
raw_swapcontext(&this->stack_top_, to->stack_top_);
- ASAN_FINISH_SWITCH(fake_stack, &this->asan_ctx_->asan_stack_, &this->asan_ctx_->asan_stack_size_);
}
ContextFactory* raw_factory()
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
public:
RawContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory);
- void swap_into(SwappedContext* to) override;
-
private:
/** pointer to top the stack stack */
void* stack_top_ = nullptr;
- static void wrapper(RawContext* context);
+ void swap_into_for_real(SwappedContext* to) override;
};
class RawContextFactory : public SwappedContextFactory {
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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 "simgrid/modelchecker.h"
#include "src/internal_config.h"
#include "src/kernel/actor/ActorImpl.hpp"
-#include "src/kernel/context/context_private.hpp"
#include "src/simix/smx_private.hpp"
#include "xbt/parmap.hpp"
#if HAVE_VALGRIND_H
#include <valgrind/valgrind.h>
#endif
+#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
+#include <sanitizer/asan_interface.h>
+#endif
+#if HAVE_SANITIZER_THREAD_FIBER_SUPPORT
+#include <sanitizer/tsan_interface.h>
+#endif
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_context);
+// The name of this function is currently hardcoded in MC (as string).
+// Do not change it without fixing those references as well.
+void smx_ctx_wrapper(simgrid::kernel::context::SwappedContext* context)
+{
+#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
+ __sanitizer_finish_switch_fiber(nullptr, &context->asan_ctx_->asan_stack_, &context->asan_ctx_->asan_stack_size_);
+#endif
+ try {
+ (*context)();
+ context->Context::stop();
+ } catch (simgrid::ForcefulKillException const&) {
+ XBT_DEBUG("Caught a ForcefulKillException");
+ } catch (simgrid::Exception const& e) {
+ XBT_INFO("Actor killed by an uncaught exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
+ throw;
+ }
+#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
+ context->asan_stop_ = true;
+#endif
+ context->suspend();
+ THROW_IMPOSSIBLE;
+}
+
namespace simgrid {
namespace kernel {
namespace context {
/* thread-specific storage for the worker's context */
thread_local SwappedContext* SwappedContext::worker_context_ = nullptr;
-SwappedContextFactory::SwappedContextFactory() : ContextFactory(), parallel_(SIMIX_context_is_parallel())
-{
- parmap_ = nullptr; // will be created lazily with the right parameters if needed (ie, in parallel)
-}
-
SwappedContext::SwappedContext(std::function<void()>&& code, smx_actor_t actor, SwappedContextFactory* factory)
- : Context(std::move(code), actor), factory_(factory)
+ : Context(std::move(code), actor), factory_(*factory)
{
// Save maestro (=context created first) in preparation for run_all
- if (not factory->parallel_ && factory->maestro_context_ == nullptr)
- factory->maestro_context_ = this;
+ if (not SIMIX_context_is_parallel() && factory_.maestro_context_ == nullptr)
+ factory_.maestro_context_ = this;
if (has_code()) {
xbt_assert((smx_context_stack_size & 0xf) == 0, "smx_context_stack_size should be multiple of 16");
if (smx_context_guard_size > 0 && not MC_is_active()) {
-
-#if !defined(PTH_STACKGROWTH) || (PTH_STACKGROWTH != -1)
+#if PTH_STACKGROWTH != -1
xbt_die(
"Stack overflow protection is known to be broken on your system: you stacks grow upwards (or detection is "
"broken). "
this->stack_ = static_cast<unsigned char*>(xbt_malloc0(smx_context_stack_size));
}
-#if PTH_STACKGROWTH == -1
- ASAN_ONLY(this->asan_stack_ = this->stack_ + smx_context_stack_size);
-#else
- ASAN_ONLY(this->asan_stack_ = this->stack_);
-#endif
#if HAVE_VALGRIND_H
if (RUNNING_ON_VALGRIND)
this->valgrind_stack_id_ = VALGRIND_STACK_REGISTER(this->stack_, this->stack_ + smx_context_stack_size);
+#endif
+#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
+ this->asan_stack_ = get_stack_bottom();
+#endif
+#if HAVE_SANITIZER_THREAD_FIBER_SUPPORT
+ this->tsan_fiber_ = __tsan_create_fiber(0);
+#endif
+ } else {
+ // not has_code(): in maestro context
+#if HAVE_SANITIZER_THREAD_FIBER_SUPPORT
+ this->tsan_fiber_ = __tsan_get_current_fiber();
#endif
}
}
if (stack_ == nullptr) // maestro has no extra stack
return;
+#if HAVE_SANITIZER_THREAD_FIBER_SUPPORT
+ __tsan_destroy_fiber(tsan_fiber_);
+#endif
#if HAVE_VALGRIND_H
if (RUNNING_ON_VALGRIND)
VALGRIND_STACK_DEREGISTER(valgrind_stack_id_);
xbt_free(stack_);
}
-unsigned char* SwappedContext::get_stack()
-{
- return stack_;
-}
-
void SwappedContext::stop()
{
Context::stop();
throw ForcefulKillException();
}
+void SwappedContext::swap_into(SwappedContext* to)
+{
+#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
+ void* fake_stack = nullptr;
+ to->asan_ctx_ = this;
+ __sanitizer_start_switch_fiber(this->asan_stop_ ? nullptr : &fake_stack, to->asan_stack_, to->asan_stack_size_);
+#endif
+#if HAVE_SANITIZER_THREAD_FIBER_SUPPORT
+ __tsan_switch_to_fiber(to->tsan_fiber_, 0);
+#endif
+
+ swap_into_for_real(to);
+
+#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
+ __sanitizer_finish_switch_fiber(fake_stack, &this->asan_ctx_->asan_stack_, &this->asan_ctx_->asan_stack_size_);
+#endif
+}
+
/** Maestro wants to run all ready actors */
void SwappedContextFactory::run_all()
{
* stuff It is much easier to understand what happens if you see the working threads as bodies that swap their soul
* for the ones of the simulated processes that must run.
*/
- if (parallel_) {
+ if (SIMIX_context_is_parallel()) {
// We lazily create the parmap so that all options are actually processed when doing so.
if (parmap_ == nullptr)
parmap_.reset(
// It only yields back to worker_context when the work array is exhausted.
// - So, resume() is only launched from the parmap for the first job of each minion.
parmap_->apply(
- [](smx_actor_t process) {
+ [](const actor::ActorImpl* process) {
SwappedContext* context = static_cast<SwappedContext*>(process->context_.get());
context->resume();
},
return;
/* maestro is already saved in the first slot of workers_context_ */
- smx_actor_t first_actor = simix_global->actors_to_run.front();
+ const actor::ActorImpl* first_actor = simix_global->actors_to_run.front();
process_index_ = 1;
/* execute the first actor; it will chain to the others when using suspend() */
static_cast<SwappedContext*>(first_actor->context_.get())->resume();
*/
void SwappedContext::resume()
{
- if (factory_->parallel_) {
+ SwappedContext* old = static_cast<SwappedContext*>(self());
+ if (SIMIX_context_is_parallel()) {
// Save my current soul (either maestro, or one of the minions) in a thread-specific area
- worker_context_ = static_cast<SwappedContext*>(self());
- // Switch my soul and the actor's one
- Context::set_current(this);
- worker_context_->swap_into(this);
- // No body runs that soul anymore at this point, but it is stored in a safe place.
- // When the executed actor will do a blocking action, ActorImpl::yield() will call suspend(), below.
- } else { // sequential execution
- SwappedContext* old = static_cast<SwappedContext*>(self());
- Context::set_current(this);
- old->swap_into(this);
+ worker_context_ = old;
}
+ // Switch my soul and the actor's one
+ Context::set_current(this);
+ old->swap_into(this);
+ // No body runs that soul anymore at this point, but it is stored in a safe place.
+ // When the executed actor will do a blocking action, ActorImpl::yield() will call suspend(), below.
}
/** The actor wants to yield back to maestro, because it is blocked in a simcall (i.e., in ActorImpl::yield())
*
* Actually, it does not really yield back to maestro, but directly into the next executable actor.
*
- * This makes the parmap::apply awkward (see ParallelUContext::run_all()) because it only apply regularly
+ * This makes the parmap::apply awkward (see SwappedContextFactory::run_all()) because it only apply regularly
* on the few first elements of the array, but it saves a lot of context switches back to maestro,
* and directly forth to the next executable actor.
*/
void SwappedContext::suspend()
{
- if (factory_->parallel_) {
+ SwappedContext* next_context;
+ if (SIMIX_context_is_parallel()) {
// Get some more work to directly swap into the next executable actor instead of yielding back to the parmap
- boost::optional<smx_actor_t> next_work = factory_->parmap_->next();
- SwappedContext* next_context;
+ boost::optional<smx_actor_t> next_work = factory_.parmap_->next();
if (next_work) {
// There is a next soul to embody (ie, another executable actor)
XBT_DEBUG("Run next process");
next_context = worker_context_;
// When given that soul, the body will wait for the next scheduling round
}
-
- // Get the next soul to run, either from another actor or the initial minion's one
- Context::set_current(next_context);
- this->swap_into(next_context);
-
} else { // sequential execution
/* determine the next context */
- SwappedContext* next_context;
- unsigned long int i = factory_->process_index_;
- factory_->process_index_++;
+ unsigned long int i = factory_.process_index_;
+ factory_.process_index_++;
if (i < simix_global->actors_to_run.size()) {
/* Actually swap into the next actor directly without transiting to maestro */
} else {
/* all processes were run, actually return to maestro */
XBT_DEBUG("No more actors to run");
- next_context = factory_->maestro_context_;
+ next_context = factory_.maestro_context_;
}
- Context::set_current(next_context);
- this->swap_into(next_context);
}
+ Context::set_current(next_context);
+ this->swap_into(next_context);
}
} // namespace context
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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 SIMGRID_KERNEL_CONTEXT_SWAPPED_CONTEXT_HPP
#define SIMGRID_KERNEL_CONTEXT_SWAPPED_CONTEXT_HPP
+#include "src/internal_config.h" // HAVE_SANITIZER_*
#include "src/kernel/context/Context.hpp"
#include <memory>
namespace kernel {
namespace context {
class SwappedContext;
+} // namespace context
+} // namespace kernel
+} // namespace simgrid
+
+/* Use extern "C" to make sure that this symbol is easy to recognize by name, even on exotic platforms */
+extern "C" XBT_ATTRIB_NORETURN void smx_ctx_wrapper(simgrid::kernel::context::SwappedContext* context);
+
+namespace simgrid {
+namespace kernel {
+namespace context {
class SwappedContextFactory : public ContextFactory {
friend SwappedContext; // Reads whether we are in parallel mode
public:
- SwappedContextFactory();
+ SwappedContextFactory() = default;
SwappedContextFactory(const SwappedContextFactory&) = delete;
SwappedContextFactory& operator=(const SwappedContextFactory&) = delete;
void run_all() override;
private:
- bool parallel_;
-
/* For the sequential execution */
unsigned long process_index_ = 0; // next actor to execute
SwappedContext* maestro_context_ = nullptr; // save maestro's context
- /* For the parallel execution */
- std::unique_ptr<simgrid::xbt::Parmap<smx_actor_t>> parmap_;
+ /* For the parallel execution, will be created lazily with the right parameters if needed (ie, in parallel) */
+ std::unique_ptr<simgrid::xbt::Parmap<smx_actor_t>> parmap_{nullptr};
};
class SwappedContext : public Context {
+ friend void ::smx_ctx_wrapper(simgrid::kernel::context::SwappedContext*);
+
public:
SwappedContext(std::function<void()>&& code, smx_actor_t get_actor, SwappedContextFactory* factory);
SwappedContext(const SwappedContext&) = delete;
void suspend() override;
virtual void resume();
- void stop() override;
+ XBT_ATTRIB_NORETURN void stop() override;
+
+ void swap_into(SwappedContext* to);
- virtual void swap_into(SwappedContext* to) = 0; // Defined in Raw, Boost and UContext subclasses
+ unsigned char* get_stack() const { return stack_; }
+ // Return the address for the bottom of the stack. Depending on the stack direction it may be the lower or higher
+ // address
+ unsigned char* get_stack_bottom() const { return PTH_STACKGROWTH == -1 ? stack_ + smx_context_stack_size : stack_; }
- unsigned char* get_stack();
+protected:
+ // With ASan, after a context switch, check that the originating context is the expected one (see BoostContext)
+ void verify_previous_context(const SwappedContext* context) const;
+private:
static thread_local SwappedContext* worker_context_;
+ unsigned char* stack_ = nullptr; // the thread stack
+ SwappedContextFactory& factory_; // for sequential and parallel run_all()
+
+#if HAVE_VALGRIND_H
+ unsigned int valgrind_stack_id_;
+#endif
#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
const void* asan_stack_ = nullptr;
size_t asan_stack_size_ = 0;
SwappedContext* asan_ctx_ = nullptr;
bool asan_stop_ = false;
#endif
+#if HAVE_SANITIZER_THREAD_FIBER_SUPPORT
+ void* tsan_fiber_;
+#endif
-private:
- unsigned char* stack_ = nullptr; /* the thread stack */
- SwappedContextFactory* const factory_; // for sequential and parallel run_all()
+ virtual void swap_into_for_real(SwappedContext* to) = 0; // Defined in Raw, Boost and UContext subclasses
+};
-#if HAVE_VALGRIND_H
- unsigned int valgrind_stack_id_;
+inline void SwappedContext::verify_previous_context(XBT_ATTRIB_UNUSED const SwappedContext* context) const
+{
+#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
+ xbt_assert(this->asan_ctx_ == context);
#endif
-};
+}
} // namespace context
} // namespace kernel
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
// ThreadContextFactory
-ThreadContextFactory::ThreadContextFactory() : ContextFactory(), parallel_(SIMIX_context_is_parallel())
+ThreadContextFactory::ThreadContextFactory() : ContextFactory()
{
- if (parallel_)
+ if (SIMIX_context_is_parallel())
ParallelThreadContext::initialize();
}
ThreadContextFactory::~ThreadContextFactory()
{
- if (parallel_)
+ if (SIMIX_context_is_parallel())
ParallelThreadContext::finalize();
}
ThreadContext* ThreadContextFactory::create_context(std::function<void()>&& code, actor::ActorImpl* actor, bool maestro)
{
- if (parallel_)
+ if (SIMIX_context_is_parallel())
return this->new_context<ParallelThreadContext>(std::move(code), actor, maestro);
else
return this->new_context<SerialThreadContext>(std::move(code), actor, maestro);
void ThreadContextFactory::run_all()
{
- if (parallel_) {
+ if (SIMIX_context_is_parallel()) {
// Parallel execution
ParallelThreadContext::run_all();
} else {
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
ThreadContext(const ThreadContext&) = delete;
ThreadContext& operator=(const ThreadContext&) = delete;
~ThreadContext() override;
- void stop() override;
+ XBT_ATTRIB_NORETURN void stop() override;
void suspend() override;
void attach_start() override;
void attach_stop() override;
}
private:
- bool parallel_;
-
ThreadContext* create_context(std::function<void()>&& code, actor::ActorImpl* actor, bool maestro);
};
} // namespace context
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
/* \file UContext.cpp Context switching with ucontexts from System V */
-#include "context_private.hpp"
-
#include "mc/mc.h"
#include "simgrid/Exception.hpp"
#include "src/kernel/actor/ActorImpl.hpp"
static_assert(sizeof(simgrid::kernel::context::UContext*) <= CTX_ADDR_LEN * sizeof(int),
"Ucontexts are not supported on this arch yet. Please increase CTX_ADDR_LEN.");
-/* Make sure that this symbol is easy to recognize by name, even on exotic platforms */
+// This function is called by makecontext(3): use extern "C" to have C language linkage for its type
extern "C" {
-static void smx_ctx_wrapper(int i1, int i2);
-}
-
-// The name of this function is currently hardcoded in MC (as string).
-// Do not change it without fixing those references as well.
-static void smx_ctx_wrapper(int i1, int i2)
+XBT_ATTRIB_NORETURN static void sysv_ctx_wrapper(int i1, int i2)
{
// Rebuild the Context* pointer from the integers:
int ctx_addr[CTX_ADDR_LEN] = {i1, i2};
simgrid::kernel::context::UContext* context;
memcpy(&context, ctx_addr, sizeof context);
-
- ASAN_FINISH_SWITCH(nullptr, &context->asan_ctx_->asan_stack_, &context->asan_ctx_->asan_stack_size_);
- try {
- (*context)();
- context->Context::stop();
- } catch (simgrid::ForcefulKillException const&) {
- XBT_DEBUG("Caught a ForcefulKillException");
- } catch (simgrid::Exception const& e) {
- XBT_INFO("Actor killed by an uncaught exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
- throw;
- }
- ASAN_ONLY(context->asan_stop_ = true);
- context->suspend();
+ smx_ctx_wrapper(context);
+}
}
namespace simgrid {
int ctx_addr[CTX_ADDR_LEN]{};
UContext* arg = this;
memcpy(ctx_addr, &arg, sizeof this);
- makecontext(&this->uc_, (void (*)())smx_ctx_wrapper, 2, ctx_addr[0], ctx_addr[1]);
+ makecontext(&this->uc_, (void (*)())sysv_ctx_wrapper, 2, ctx_addr[0], ctx_addr[1]);
#if SIMGRID_HAVE_MC
if (MC_is_active()) {
}
}
-void UContext::swap_into(SwappedContext* to_)
+void UContext::swap_into_for_real(SwappedContext* to_)
{
- UContext* to = static_cast<UContext*>(to_);
- ASAN_ONLY(void* fake_stack = nullptr);
- ASAN_ONLY(to->asan_ctx_ = this);
- ASAN_START_SWITCH(this->asan_stop_ ? nullptr : &fake_stack, to->asan_stack_, to->asan_stack_size_);
+ const UContext* to = static_cast<UContext*>(to_);
swapcontext(&this->uc_, &to->uc_);
- ASAN_FINISH_SWITCH(fake_stack, &this->asan_ctx_->asan_stack_, &this->asan_ctx_->asan_stack_size_);
}
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
public:
UContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory);
- void swap_into(SwappedContext* to) override;
-
private:
ucontext_t uc_; /* the ucontext that executes the code */
+
+ void swap_into_for_real(SwappedContext* to) override;
};
class UContextFactory : public SwappedContextFactory {
+++ /dev/null
-/* Copyright (c) 2017-2019. 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 SIMGRID_KERNEL_CONTEXT_PRIVATE_HPP
-#define SIMGRID_KERNEL_CONTEXT_PRIVATE_HPP
-
-#include "src/internal_config.h"
-
-#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
-#include <sanitizer/asan_interface.h>
-#define ASAN_ONLY(expr) expr
-#define ASAN_START_SWITCH(fake_stack_save, bottom, size) __sanitizer_start_switch_fiber(fake_stack_save, bottom, size)
-#define ASAN_FINISH_SWITCH(fake_stack_save, bottom_old, size_old) \
- __sanitizer_finish_switch_fiber(fake_stack_save, bottom_old, size_old)
-#else
-#define ASAN_ONLY(expr) (void)0
-#define ASAN_START_SWITCH(fake_stack_save, bottom, size) (void)0
-#define ASAN_FINISH_SWITCH(fake_stack_save, bottom_old, size_old) (void)0
-#endif
-
-#endif
-/* Copyright (c) 2016-2019. The SimGrid Team.
+/* Copyright (c) 2016-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
int nb = 0;
XBT_DEBUG("Processing cnst %p ", &cnst);
cnst.usage_ = 0.0;
- for (Element& elem : cnst.enabled_element_set_) {
+ for (const Element& elem : cnst.enabled_element_set_) {
xbt_assert(elem.variable->sharing_penalty_ > 0);
if (elem.consumption_weight > 0 && elem.variable->saturated_variable_set_hook_.is_linked())
nb++;
Constraint& cnst = *iter;
XBT_DEBUG("Updating cnst %p ", &cnst);
if (cnst.sharing_policy_ != s4u::Link::SharingPolicy::FATPIPE) {
- for (Element& elem : cnst.enabled_element_set_) {
+ for (const Element& elem : cnst.enabled_element_set_) {
xbt_assert(elem.variable->sharing_penalty_ > 0);
XBT_DEBUG("\tUpdate constraint %p (%g) with variable %p by %g", &cnst, cnst.remaining_, elem.variable,
elem.variable->mu_);
double_update(&cnst.remaining_, elem.consumption_weight * elem.variable->mu_, sg_maxmin_precision);
}
} else {
- for (Element& elem : cnst.enabled_element_set_) {
+ for (const Element& elem : cnst.enabled_element_set_) {
xbt_assert(elem.variable->sharing_penalty_ > 0);
XBT_DEBUG("\tNon-Shared variable. Update constraint usage of %p (%g) with variable %p by %g", &cnst,
cnst.usage_, elem.variable, elem.variable->mu_);
XBT_DEBUG("\tGet rid of constraint %p", &cnst);
iter = cnst_list.erase(iter);
- for (Element& elem : cnst.enabled_element_set_) {
+ for (const Element& elem : cnst.enabled_element_set_) {
if (elem.variable->sharing_penalty_ <= 0)
break;
if (elem.consumption_weight > 0 && elem.variable->saturated_variable_set_hook_.is_linked()) {
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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 "src/kernel/lmm/maxmin.hpp"
-#include "src/surf/surf_interface.hpp"
#include "xbt/backtrace.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_maxmin, surf, "Logging specific to SURF (maxmin)");
continue;
const Element& elem = var.cnsts_[0];
- int belong_to_enabled = elem.enabled_element_set_hook.is_linked();
- int belong_to_disabled = elem.disabled_element_set_hook.is_linked();
- int belong_to_active = elem.active_element_set_hook.is_linked();
+ bool belong_to_enabled = elem.enabled_element_set_hook.is_linked();
+ bool belong_to_disabled = elem.disabled_element_set_hook.is_linked();
+ bool belong_to_active = elem.active_element_set_hook.is_linked();
for (Element const& elem2 : var.cnsts_) {
xbt_assert(belong_to_enabled == elem2.enabled_element_set_hook.is_linked(),
Constraint::Constraint(resource::Resource* id_value, double bound_value) : bound_(bound_value), id_(id_value)
{
rank_ = next_rank_++;
-
- remaining_ = 0.0;
- usage_ = 0.0;
- concurrency_limit_ = sg_concurrency_limit;
- concurrency_current_ = 0;
- concurrency_maximum_ = 0;
- sharing_policy_ = s4u::Link::SharingPolicy::SHARED;
-
- lambda_ = 0.0;
- new_lambda_ = 0.0;
- cnst_light_ = nullptr;
}
Constraint* System::constraint_new(resource::Resource* id, double bound_value)
// If it does, subtract it from the required slack
int current_share = 0;
if (var->concurrency_share_ > 1) {
- for (Element& elem : var->cnsts_) {
+ for (const Element& elem : var->cnsts_) {
if (elem.constraint == cnst && elem.enabled_element_set_hook.is_linked())
current_share += elem.get_concurrency();
}
}
}
-static inline void saturated_variable_set_update(ConstraintLight* cnst_light_tab,
+static inline void saturated_variable_set_update(const ConstraintLight* cnst_light_tab,
const dyn_light_t& saturated_constraints, System* sys)
{
/* Add active variables (i.e. variables that need to be set) from the set of constraints to saturate
* (cnst_light_tab)*/
for (int const& saturated_cnst : saturated_constraints) {
- ConstraintLight& cnst = cnst_light_tab[saturated_cnst];
+ const ConstraintLight& cnst = cnst_light_tab[saturated_cnst];
for (Element const& elem : cnst.cnst->active_element_set_) {
xbt_assert(elem.variable->sharing_penalty_ > 0); // All elements of active_element_set should be active
if (elem.consumption_weight > 0 && not elem.variable->saturated_variable_set_hook_.is_linked())
// Remember: non-shared constraints only require that max(elem.value * var.value) < cnst->bound
cnst->usage_ = 0.0;
elem.make_inactive();
- for (Element& elem2 : cnst->enabled_element_set_) {
+ for (const Element& elem2 : cnst->enabled_element_set_) {
xbt_assert(elem2.variable->sharing_penalty_ > 0);
if (elem2.variable->value_ > 0)
continue;
if (penalty == var->sharing_penalty_)
return;
- int enabling_var = (penalty > 0 && var->sharing_penalty_ <= 0);
- int disabling_var = (penalty <= 0 && var->sharing_penalty_ > 0);
+ bool enabling_var = (penalty > 0 && var->sharing_penalty_ <= 0);
+ bool disabling_var = (penalty <= 0 && var->sharing_penalty_ > 0);
XBT_IN("(sys=%p, var=%p, penalty=%f)", this, var, penalty);
* A recursive algorithm to optimize the system recalculation selecting only constraints that have changed. Each
* constraint change is propagated to the list of constraints for each variable.
*/
-void System::update_modified_set_rec(Constraint* cnst)
+void System::update_modified_set_rec(const Constraint* cnst)
{
for (Element const& elem : cnst->enabled_element_set_) {
Variable* var = elem.variable;
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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 "simgrid/kernel/resource/Action.hpp"
#include "simgrid/s4u/Link.hpp"
+#include "src/surf/surf_interface.hpp"
#include "xbt/asserts.h"
#include "xbt/mallocator.h"
boost::intrusive::list<Element, boost::intrusive::member_hook<Element, boost::intrusive::list_member_hook<>,
&Element::active_element_set_hook>>
active_element_set_;
- double remaining_;
- double usage_;
+ double remaining_ = 0.0;
+ double usage_ = 0.0;
double bound_;
// TODO MARTIN Check maximum value across resources at the end of simulation and give a warning is more than e.g. 500
- int concurrency_current_; /* The current concurrency */
- int concurrency_maximum_; /* The maximum number of (enabled and disabled) variables associated to the constraint at
- * any given time (essentially for tracing)*/
+ int concurrency_current_ = 0; /* The current concurrency */
+ int concurrency_maximum_ = 0; /* The maximum number of (enabled and disabled) variables associated to the constraint
+ * at any given time (essentially for tracing)*/
- s4u::Link::SharingPolicy sharing_policy_;
+ s4u::Link::SharingPolicy sharing_policy_ = s4u::Link::SharingPolicy::SHARED;
int rank_; // Only used in debug messages to identify the constraint
- double lambda_;
- double new_lambda_;
- ConstraintLight* cnst_light_;
+ double lambda_ = 0.0;
+ double new_lambda_ = 0.0;
+ ConstraintLight* cnst_light_ = nullptr;
private:
static int next_rank_; // To give a separate rank_ to each constraint
- int concurrency_limit_; /* The maximum number of variables that may be enabled at any time (stage variables if
- * necessary) */
+ int concurrency_limit_ = sg_concurrency_limit; /* The maximum number of variables that may be enabled at any time
+ * (stage variables if necessary) */
resource::Resource* id_;
};
/** @brief Check if a variable can be enabled
* Make sure to set staged_penalty before, if your intent is only to check concurrency
*/
- int can_enable() const { return staged_penalty_ > 0 && get_min_concurrency_slack() >= concurrency_share_; }
+ bool can_enable() const { return staged_penalty_ > 0 && get_min_concurrency_slack() >= concurrency_share_; }
/* hookup to system */
boost::intrusive::list_member_hook<> variable_set_hook_;
/** @brief Update a constraint bound */
void update_constraint_bound(Constraint * cnst, double bound);
- int constraint_used(Constraint* cnst) { return cnst->active_constraint_set_hook_.is_linked(); }
+ int constraint_used(const Constraint* cnst) const { return cnst->active_constraint_set_hook_.is_linked(); }
/** @brief Print the lmm system */
void print() const;
*/
void update(Constraint * cnst, Variable * var, double value);
- void update_modified_set(Constraint * cnst);
- void update_modified_set_rec(Constraint * cnst);
+ void update_modified_set(Constraint* cnst);
+ void update_modified_set_rec(const Constraint* cnst);
/** @brief Remove all constraints of the modified_constraint_set. */
void remove_all_modified_set();
resource::Action::ModifiedSet* modified_set_ = nullptr;
private:
-
typedef std::vector<int> dyn_light_t;
//Data used in lmm::solve
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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. */
SECTION("Consumption weight + variable penalty")
{
-
/*
* Resource proportionality between variable is kept while
* varying consumption weight
SECTION("Multiple constraints systems")
{
-
/*
* Multiple constraint systems can be solved with shared variables
*
SECTION("Variable penalty")
{
-
/*
* A variable with a penalty of two get half of the max_share
*
SECTION("Consumption weight")
{
-
/*
* In a given constraint with all variable penalty to 1,
* the max_share is affected only by the maximum consumption weight
SECTION("Consumption weight + variable penalty")
{
-
/*
* Resource proportionality between variable is kept but
* constraint bound can be violated
SECTION("Multiple constraints systems")
{
-
/*
* Multiple constraint systems can be solved with shared variables
* on unshared constraints.
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
: remains_(cost), start_time_(surf_get_clock()), cost_(cost), model_(model), variable_(var)
{
if (failed)
- state_set_ = get_model()->get_failed_action_set();
+ state_set_ = model_->get_failed_action_set();
else
- state_set_ = get_model()->get_started_action_set();
+ state_set_ = model_->get_started_action_set();
state_set_->push_back(*this);
}
if (state_set_hook_.is_linked())
simgrid::xbt::intrusive_erase(*state_set_, *this);
if (get_variable())
- get_model()->get_maxmin_system()->variable_free(get_variable());
+ model_->get_maxmin_system()->variable_free(get_variable());
/* remove from heap on need (ie, if selective update) */
- get_model()->get_action_heap().remove(this);
+ model_->get_action_heap().remove(this);
if (modified_set_hook_.is_linked())
- simgrid::xbt::intrusive_erase(*get_model()->get_modified_set(), *this);
+ simgrid::xbt::intrusive_erase(*model_->get_modified_set(), *this);
}
void Action::finish(Action::State state)
{
XBT_IN("(%p,%g)", this, bound);
if (variable_)
- get_model()->get_maxmin_system()->update_variable_bound(variable_, bound);
+ model_->get_maxmin_system()->update_variable_bound(variable_, bound);
- if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY && get_last_update() != surf_get_clock())
- get_model()->get_action_heap().remove(this);
+ if (model_->is_update_lazy() && get_last_update() != surf_get_clock())
+ model_->get_action_heap().remove(this);
XBT_OUT();
}
void Action::set_max_duration(double duration)
{
max_duration_ = duration;
- if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) // remove action from the heap
- get_model()->get_action_heap().remove(this);
+ if (model_->is_update_lazy()) // remove action from the heap
+ model_->get_action_heap().remove(this);
}
void Action::set_sharing_penalty(double sharing_penalty)
{
XBT_IN("(%p,%g)", this, sharing_penalty);
sharing_penalty_ = sharing_penalty;
- get_model()->get_maxmin_system()->update_variable_penalty(get_variable(), sharing_penalty);
+ model_->get_maxmin_system()->update_variable_penalty(get_variable(), sharing_penalty);
- if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY)
- get_model()->get_action_heap().remove(this);
+ if (model_->is_update_lazy())
+ model_->get_action_heap().remove(this);
XBT_OUT();
}
void Action::cancel()
{
set_state(Action::State::FAILED);
- if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) {
+ if (model_->is_update_lazy()) {
if (modified_set_hook_.is_linked())
- simgrid::xbt::intrusive_erase(*get_model()->get_modified_set(), *this);
- get_model()->get_action_heap().remove(this);
+ xbt::intrusive_erase(*model_->get_modified_set(), *this);
+ model_->get_action_heap().remove(this);
}
}
{
XBT_IN("(%p)", this);
if (suspended_ != SuspendStates::SLEEPING) {
- get_model()->get_maxmin_system()->update_variable_penalty(get_variable(), 0.0);
- if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) {
- get_model()->get_action_heap().remove(this);
- if (state_set_ == get_model()->get_started_action_set() && sharing_penalty_ > 0) {
+ model_->get_maxmin_system()->update_variable_penalty(get_variable(), 0.0);
+ if (model_->is_update_lazy()) {
+ model_->get_action_heap().remove(this);
+ if (state_set_ == model_->get_started_action_set() && sharing_penalty_ > 0) {
// If we have a lazy model, we need to update the remaining value accordingly
update_remains_lazy(surf_get_clock());
}
{
XBT_IN("(%p)", this);
if (suspended_ != SuspendStates::SLEEPING) {
- get_model()->get_maxmin_system()->update_variable_penalty(get_variable(), get_sharing_penalty());
+ model_->get_maxmin_system()->update_variable_penalty(get_variable(), get_sharing_penalty());
suspended_ = SuspendStates::RUNNING;
- if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY)
- get_model()->get_action_heap().remove(this);
+ if (model_->is_update_lazy())
+ model_->get_action_heap().remove(this);
}
XBT_OUT();
}
{
XBT_IN("(%p)", this);
/* update remains before returning it */
- if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) /* update remains before return it */
+ if (model_->is_update_lazy()) /* update remains before return it */
update_remains_lazy(surf_get_clock());
XBT_OUT();
return remains_;
if (max_duration_ != NO_MAX_DURATION)
double_update(&max_duration_, delta, sg_surf_precision);
}
+
void Action::update_remains(double delta)
{
double_update(&remains_, delta, sg_maxmin_precision * sg_surf_precision);
{
return top().first;
}
+
void ActionHeap::insert(Action* action, double date, ActionHeap::Type type)
{
action->type_ = type;
action->heap_hook_ = emplace(std::make_pair(date, action));
}
+
void ActionHeap::remove(Action* action)
{
action->type_ = ActionHeap::Type::unset;
action->heap_hook_ = boost::none;
}
}
+
void ActionHeap::update(Action* action, double date, ActionHeap::Type type)
{
action->type_ = type;
action->heap_hook_ = emplace(std::make_pair(date, action));
}
}
+
Action* ActionHeap::pop()
{
Action* action = top().second;
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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. */
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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. */
/*********
* Model *
*********/
-class DiskModel : public kernel::resource::Model {
+class DiskModel : public Model {
public:
DiskModel();
DiskModel(const DiskModel&) = delete;
void turn_on() override;
void turn_off() override;
- s4u::Host* get_host() { return host_; }
+ s4u::Host* get_host() const { return host_; }
void set_host(s4u::Host* host) { host_ = host; }
void destroy(); // Must be called instead of the destructor
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
namespace resource {
Model::Model(Model::UpdateAlgo algo) : update_algorithm_(algo) {}
-Model::~Model() = default;
+Model::~Model() = default; // Don't move this declaration to the header, or it will break external projects such as SimGrid-FMI
Action::ModifiedSet* Model::get_modified_set() const
{
while (not maxmin_system_->modified_set_->empty()) {
Action* action = &(maxmin_system_->modified_set_->front());
maxmin_system_->modified_set_->pop_front();
- bool max_duration_flag = false;
+ ActionHeap::Type action_type = ActionHeap::Type::normal;
if (action->get_state_set() != &started_action_set_)
continue;
(min <= -1 || action->get_start_time() + action->get_max_duration() < min)) {
// when the task will complete anyway because of the deadline if any
min = action->get_start_time() + action->get_max_duration();
- max_duration_flag = true;
+ action_type = ActionHeap::Type::max_duration;
}
XBT_DEBUG("Action(%p) corresponds to variable %d", action, action->get_variable()->rank_);
action->get_start_time(), min, share, action->get_max_duration());
if (min > -1) {
- action_heap_.update(action, min, max_duration_flag ? ActionHeap::Type::max_duration : ActionHeap::Type::normal);
+ action_heap_.update(action, min, action_type);
XBT_DEBUG("Insert at heap action(%p) min %f now %f", action, min, now);
} else
DIE_IMPOSSIBLE;
{
if (list->empty())
return nullptr;
- simgrid::kernel::resource::Action* res = &list->front();
+ Action* res = &list->front();
list->pop_front();
return res;
}
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
namespace kernel {
namespace resource {
-Resource::~Resource() = default;
-
double Resource::get_load() const
{
return constraint_->get_usage();
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
xbt_assert(not path.empty(), "Cannot parse a trace from an empty filename");
xbt_assert(trace_list.find(path) == trace_list.end(), "Refusing to define trace %s twice", path.c_str());
- std::ifstream* f = surf_ifsopen(path);
+ const std::ifstream* f = surf_ifsopen(path);
xbt_assert(not f->fail(), "Cannot open file '%s' (path=%s)", path.c_str(), (boost::join(surf_path, ":")).c_str());
std::stringstream buffer;
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
}
}
-void ClusterZone::get_graph(xbt_graph_t graph, std::map<std::string, xbt_node_t>* nodes,
+void ClusterZone::get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t>* nodes,
std::map<std::string, xbt_edge_t>* edges)
{
xbt_assert(router_,
link.policy = cluster->sharing_policy;
sg_platf_new_link(&link);
- s4u::Link* linkUp;
- s4u::Link* linkDown;
+ const s4u::Link* linkUp;
+ const s4u::Link* linkDown;
if (link.policy == simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX) {
linkUp = s4u::Link::by_name(link_id + "_UP");
linkDown = s4u::Link::by_name(link_id + "_DOWN");
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
{
}
-static void graph_node_data_free(void* n)
+void DijkstraZone::route_graph_delete(xbt_graph_t g)
{
- delete static_cast<simgrid::kernel::routing::GraphNodeData*>(n);
-}
-
-static void graph_edge_data_free(void* e)
-{
- delete static_cast<simgrid::kernel::routing::RouteCreationArgs*>(e);
-}
-
-DijkstraZone::~DijkstraZone()
-{
- xbt_graph_free_graph(route_graph_, &graph_node_data_free, &graph_edge_data_free, nullptr);
+ xbt_graph_free_graph(g, [](void* n) { delete static_cast<simgrid::kernel::routing::GraphNodeData*>(n); },
+ [](void* e) { delete static_cast<simgrid::kernel::routing::RouteCreationArgs*>(e); }, nullptr);
}
void DijkstraZone::seal()
unsigned int cursor;
xbt_node_t node = nullptr;
- if (not route_graph_)
- route_graph_ = xbt_graph_new_graph(1, nullptr);
-
/* Add the loopback if needed */
if (network_model_->loopback_ && hierarchy_ == RoutingMode::base) {
-
- xbt_dynar_foreach (xbt_graph_get_nodes(route_graph_), cursor, node) {
+ xbt_dynar_foreach (xbt_graph_get_nodes(route_graph_.get()), cursor, node) {
bool found = false;
xbt_edge_t edge = nullptr;
unsigned int cursor2;
if (not found) {
RouteCreationArgs* route = new simgrid::kernel::routing::RouteCreationArgs();
route->link_list.push_back(network_model_->loopback_);
- xbt_graph_new_edge(route_graph_, node, node, route);
+ xbt_graph_new_edge(route_graph_.get(), node, node, route);
}
}
}
/* initialize graph indexes in nodes after graph has been built */
- xbt_dynar_t nodes = xbt_graph_get_nodes(route_graph_);
+ const_xbt_dynar_t nodes = xbt_graph_get_nodes(route_graph_.get());
xbt_dynar_foreach (nodes, cursor, node) {
GraphNodeData* data = static_cast<GraphNodeData*>(xbt_graph_node_get_data(node));
xbt_node_t DijkstraZone::route_graph_new_node(int id)
{
- xbt_node_t node = xbt_graph_new_node(route_graph_, new GraphNodeData(id));
+ xbt_node_t node = xbt_graph_new_node(route_graph_.get(), new GraphNodeData(id));
graph_node_map_.emplace(id, node);
return node;
int src_id = src->id();
int dst_id = dst->id();
- xbt_dynar_t nodes = xbt_graph_get_nodes(route_graph_);
+ const_xbt_dynar_t nodes = xbt_graph_get_nodes(route_graph_.get());
/* Use the graph_node id mapping set to quickly find the nodes */
- xbt_node_t src_elm = node_map_search(src_id);
- xbt_node_t dst_elm = node_map_search(dst_id);
+ const s_xbt_node_t* src_elm = node_map_search(src_id);
+ const s_xbt_node_t* dst_elm = node_map_search(dst_id);
int src_node_id = static_cast<GraphNodeData*>(xbt_graph_node_get_data(src_elm))->graph_id_;
int dst_node_id = static_cast<GraphNodeData*>(xbt_graph_node_get_data(dst_elm))->graph_id_;
/* if the src and dst are the same */
if (src_node_id == dst_node_id) {
-
- xbt_node_t node_s_v = xbt_dynar_get_as(nodes, src_node_id, xbt_node_t);
- xbt_node_t node_e_v = xbt_dynar_get_as(nodes, dst_node_id, xbt_node_t);
- xbt_edge_t edge = xbt_graph_get_edge(route_graph_, node_s_v, node_e_v);
+ const s_xbt_node_t* node_s_v = xbt_dynar_get_as(nodes, src_node_id, xbt_node_t);
+ const s_xbt_node_t* node_e_v = xbt_dynar_get_as(nodes, dst_node_id, xbt_node_t);
+ const s_xbt_edge_t* edge = xbt_graph_get_edge(route_graph_.get(), node_s_v, node_e_v);
if (edge == nullptr)
throw std::invalid_argument(xbt::string_printf("No route from '%s' to '%s'", src->get_cname(), dst->get_cname()));
- RouteCreationArgs* e_route = static_cast<RouteCreationArgs*>(xbt_graph_edge_get_data(edge));
+ const RouteCreationArgs* e_route = static_cast<RouteCreationArgs*>(xbt_graph_edge_get_data(edge));
for (auto const& link : e_route->link_list) {
route->link_list.insert(route->link_list.begin(), link);
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);
+ const s_xbt_node_t* v_node = xbt_dynar_get_as(nodes, v_id, xbt_node_t);
xbt_edge_t edge = nullptr;
unsigned int cursor;
xbt_dynar_foreach (xbt_graph_node_get_outedges(v_node), cursor, edge) {
- xbt_node_t u_node = xbt_graph_edge_get_target(edge);
- GraphNodeData* data = static_cast<GraphNodeData*>(xbt_graph_node_get_data(u_node));
+ const s_xbt_node_t* u_node = xbt_graph_edge_get_target(edge);
+ const GraphNodeData* data = static_cast<GraphNodeData*>(xbt_graph_node_get_data(u_node));
int u_id = data->graph_id_;
- RouteCreationArgs* tmp_e_route = static_cast<RouteCreationArgs*>(xbt_graph_edge_get_data(edge));
+ const RouteCreationArgs* tmp_e_route = static_cast<RouteCreationArgs*>(xbt_graph_edge_get_data(edge));
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]) {
NetPoint* first_gw = nullptr;
for (int v = dst_node_id; v != src_node_id; v = pred_arr[v]) {
- xbt_node_t node_pred_v = xbt_dynar_get_as(nodes, pred_arr[v], xbt_node_t);
- xbt_node_t node_v = xbt_dynar_get_as(nodes, v, xbt_node_t);
- xbt_edge_t edge = xbt_graph_get_edge(route_graph_, node_pred_v, node_v);
+ const s_xbt_node_t* node_pred_v = xbt_dynar_get_as(nodes, pred_arr[v], xbt_node_t);
+ const s_xbt_node_t* node_v = xbt_dynar_get_as(nodes, v, xbt_node_t);
+ const s_xbt_edge_t* edge = xbt_graph_get_edge(route_graph_.get(), node_pred_v, node_v);
if (edge == nullptr)
throw std::invalid_argument(xbt::string_printf("No route from '%s' to '%s'", src->get_cname(), dst->get_cname()));
- RouteCreationArgs* e_route = static_cast<RouteCreationArgs*>(xbt_graph_edge_get_data(edge));
+ const RouteCreationArgs* e_route = static_cast<RouteCreationArgs*>(xbt_graph_edge_get_data(edge));
- NetPoint* prev_gw_src = gw_src;
+ const NetPoint* prev_gw_src = gw_src;
gw_src = e_route->gw_src;
NetPoint* gw_dst = e_route->gw_dst;
{
add_route_check_params(src, dst, gw_src, gw_dst, link_list, symmetrical);
- if (not route_graph_)
- route_graph_ = xbt_graph_new_graph(1, nullptr);
-
new_edge(src->id(), dst->id(), new_extended_route(hierarchy_, src, dst, gw_src, gw_dst, link_list, symmetrical, 1));
if (symmetrical == true)
new_edge(dst->id(), src->id(), new_extended_route(hierarchy_, dst, src, gw_dst, gw_src, link_list, symmetrical, 0));
}
-void DijkstraZone::new_edge(int src_id, int dst_id, simgrid::kernel::routing::RouteCreationArgs* route)
+void DijkstraZone::new_edge(int src_id, int dst_id, RouteCreationArgs* route)
{
XBT_DEBUG("Create Route from '%d' to '%d'", src_id, dst_id);
dst = route_graph_new_node(dst_id);
// Make sure that this graph edge was not already added to the graph
- if (xbt_graph_get_edge(route_graph_, src, dst) != nullptr) {
+ if (xbt_graph_get_edge(route_graph_.get(), src, dst) != nullptr) {
if (route->gw_dst == nullptr || route->gw_src == nullptr)
throw std::invalid_argument(
xbt::string_printf("Route from %s to %s already exists", route->src->get_cname(), route->dst->get_cname()));
}
// Finally add it
- xbt_graph_new_edge(route_graph_, src, dst, route);
-}
-}
+ xbt_graph_new_edge(route_graph_.get(), src, dst, route);
}
-} // namespace
+} // namespace routing
+} // namespace kernel
+} // namespace simgrid
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
}
if (targetRouter != myRouter) {
-
// are we on a different group ?
if (targetRouter->group_ != currentRouter->group_) {
// go to the router of our group connected to this one.
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
EmptyZone::~EmptyZone() = default;
-void EmptyZone::get_graph(xbt_graph_t /*graph*/, std::map<std::string, xbt_node_t>* /*nodes*/,
+void EmptyZone::get_graph(const s_xbt_graph_t* /*graph*/, std::map<std::string, xbt_node_t>* /*nodes*/,
std::map<std::string, xbt_edge_t>* /*edges*/)
{
XBT_ERROR("No routing no graph");
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
void FatTreeZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency)
{
-
if (dst->is_router() || src->is_router())
return;
file.close();
}
-FatTreeNode::FatTreeNode(ClusterCreationArgs* cluster, int id, int level, int position)
+FatTreeNode::FatTreeNode(const ClusterCreationArgs* cluster, int id, int level, int position)
: id(id), level(level), position(position)
{
LinkCreationArgs linkTemplate;
}
}
-FatTreeLink::FatTreeLink(ClusterCreationArgs* cluster, FatTreeNode* downNode, FatTreeNode* upNode)
+FatTreeLink::FatTreeLink(const ClusterCreationArgs* cluster, FatTreeNode* downNode, FatTreeNode* upNode)
: up_node_(upNode), down_node_(downNode)
{
static int uniqueId = 0;
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
FloydZone::FloydZone(NetZoneImpl* father, const std::string& name, resource::NetworkModel* netmodel)
: RoutedZone(father, name, netmodel)
{
- predecessor_table_ = nullptr;
- cost_table_ = nullptr;
- link_table_ = nullptr;
}
FloydZone::~FloydZone()
NetPoint* prev_dst_gw = nullptr;
while (not route_stack.empty()) {
- RouteCreationArgs* e_route = route_stack.back();
+ const RouteCreationArgs* e_route = route_stack.back();
route_stack.pop_back();
if (hierarchy_ == RoutingMode::recursive && prev_dst_gw != nullptr &&
prev_dst_gw->get_cname() != e_route->gw_src->get_cname()) {
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
XBT_DEBUG("full getLocalRoute from %s[%u] to %s[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
unsigned int table_size = get_table_size();
- RouteCreationArgs* e_route = TO_ROUTE_FULL(src->id(), dst->id());
+ const RouteCreationArgs* e_route = TO_ROUTE_FULL(src->id(), dst->id());
if (e_route != nullptr) {
res->gw_src = e_route->gw_src;
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route, surf, "Routing part of surf");
namespace simgrid {
+
+template class xbt::Extendable<kernel::routing::NetPoint>;
+
namespace kernel {
namespace routing {
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
namespace kernel {
namespace routing {
-class BypassRoute {
-public:
- explicit BypassRoute(NetPoint* gwSrc, NetPoint* gwDst) : gw_src(gwSrc), gw_dst(gwDst) {}
- NetPoint* gw_src;
- NetPoint* gw_dst;
- std::vector<resource::LinkImpl*> links;
-};
-
NetZoneImpl::NetZoneImpl(NetZoneImpl* father, const std::string& name, resource::NetworkModel* network_model)
- : network_model_(network_model), piface_(this), father_(father), name_(name)
+ : piface_(this), father_(father), name_(name), network_model_(network_model)
{
- xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(get_name()),
+ xbt_assert(nullptr == s4u::Engine::get_instance()->netpoint_by_name_or_null(get_name()),
"Refusing to create a second NetZone called '%s'.", get_cname());
netpoint_ = new NetPoint(name_, NetPoint::Type::NetZone, father);
for (auto const& kv : bypass_routes_)
delete kv.second;
- simgrid::s4u::Engine::get_instance()->netpoint_unregister(netpoint_);
-}
-const char* NetZoneImpl::get_cname() const
-{
- return name_.c_str();
-}
-NetZoneImpl* NetZoneImpl::get_father()
-{
- return father_;
-}
-void NetZoneImpl::seal()
-{
- sealed_ = true;
-}
-/** @brief Returns the list of direct children (no grand-children)
- *
- * This returns the internal data, no copy. Don't mess with it.
- */
-std::vector<NetZoneImpl*>* NetZoneImpl::get_children()
-{
- return &children_;
+ s4u::Engine::get_instance()->netpoint_unregister(netpoint_);
}
+
/** @brief Returns the list of the hosts found in this NetZone (not recursively)
*
* Only the hosts that are directly contained in this NetZone are retrieved,
{
std::vector<s4u::Host*> res;
for (auto const& card : get_vertices()) {
- s4u::Host* host = simgrid::s4u::Host::by_name_or_null(card->get_name());
+ s4u::Host* host = s4u::Host::by_name_or_null(card->get_name());
if (host != nullptr)
res.push_back(host);
}
{
int count = 0;
for (auto const& card : get_vertices()) {
- s4u::Host* host = simgrid::s4u::Host::by_name_or_null(card->get_name());
+ const s4u::Host* host = s4u::Host::by_name_or_null(card->get_name());
if (host != nullptr)
count++;
}
return count;
}
-simgrid::s4u::Host* NetZoneImpl::create_host(const std::string& name, const std::vector<double>& speed_per_pstate,
- int coreAmount, const std::map<std::string, std::string>* props)
+s4u::Host* NetZoneImpl::create_host(const std::string& name, const std::vector<double>& speed_per_pstate,
+ int coreAmount, const std::map<std::string, std::string>* props)
{
- simgrid::s4u::Host* res = new simgrid::s4u::Host(name);
+ s4u::Host* res = new s4u::Host(name);
if (hierarchy_ == RoutingMode::unset)
hierarchy_ = RoutingMode::base;
if (props != nullptr)
res->set_properties(*props);
- simgrid::s4u::Host::on_creation(*res); // notify the signal
+ s4u::Host::on_creation(*res); // notify the signal
return res;
}
-int NetZoneImpl::add_component(kernel::routing::NetPoint* elm)
+int NetZoneImpl::add_component(NetPoint* elm)
{
vertices_.push_back(elm);
return vertices_.size() - 1; // The rank of the newly created object
}
-void NetZoneImpl::add_route(kernel::routing::NetPoint* /*src*/, kernel::routing::NetPoint* /*dst*/,
- kernel::routing::NetPoint* /*gw_src*/, kernel::routing::NetPoint* /*gw_dst*/,
- std::vector<kernel::resource::LinkImpl*>& /*link_list*/, bool /*symmetrical*/)
+
+void NetZoneImpl::add_route(NetPoint* /*src*/, NetPoint* /*dst*/, NetPoint* /*gw_src*/, NetPoint* /*gw_dst*/,
+ std::vector<resource::LinkImpl*>& /*link_list*/, bool /*symmetrical*/)
{
xbt_die("NetZone '%s' does not accept new routes (wrong class).", get_cname());
}
}
/* Build a copy that will be stored in the dict */
- kernel::routing::BypassRoute* newRoute = new kernel::routing::BypassRoute(gw_src, gw_dst);
+ BypassRoute* newRoute = new BypassRoute(gw_src, gw_dst);
for (auto const& link : link_list)
newRoute->links.push_back(link);
/* engage the full recursive search */
/* (1) find the path to root of src and dst*/
- NetZoneImpl* src_as = src->get_englobing_zone();
- NetZoneImpl* dst_as = dst->get_englobing_zone();
+ const NetZoneImpl* src_as = src->get_englobing_zone();
+ const NetZoneImpl* dst_as = dst->get_englobing_zone();
xbt_assert(src_as, "Host %s must be in a netzone", src->get_cname());
xbt_assert(dst_as, "Host %s must be in a netzone", dst->get_cname());
}
/* PRECONDITION: this is the common ancestor of src and dst */
-bool NetZoneImpl::get_bypass_route(routing::NetPoint* src, routing::NetPoint* dst,
+bool NetZoneImpl::get_bypass_route(NetPoint* src, NetPoint* dst,
/* OUT */ std::vector<resource::LinkImpl*>& links, double* latency)
{
// If never set a bypass route return nullptr without any further computations
/* Base case, no recursion is needed */
if (dst->get_englobing_zone() == this && src->get_englobing_zone() == this) {
if (bypass_routes_.find({src, dst}) != bypass_routes_.end()) {
- BypassRoute* bypassedRoute = bypass_routes_.at({src, dst});
+ const BypassRoute* bypassedRoute = bypass_routes_.at({src, dst});
for (resource::LinkImpl* const& link : bypassedRoute->links) {
links.push_back(link);
if (latency)
int max_index = std::max(max_index_src, max_index_dst);
/* (3) Search for a bypass making the path up to the ancestor useless */
- BypassRoute* bypassedRoute = nullptr;
+ const BypassRoute* bypassedRoute = nullptr;
std::pair<kernel::routing::NetPoint*, kernel::routing::NetPoint*> key;
for (int max = 0; max <= max_index; max++) {
for (int i = 0; i < max; i++) {
if (route.gw_dst != dst)
get_global_route(route.gw_dst, dst, links, latency);
}
-}
-}
-} // namespace
+} // namespace routing
+} // namespace kernel
+} // namespace simgrid
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
/* ***************************************************************** */
/* *********************** GENERIC METHODS ************************* */
-static const char* instr_node_name(xbt_node_t node)
+static const char* instr_node_name(const s_xbt_node_t* node)
{
- void* data = xbt_graph_node_get_data(node);
+ const void* data = xbt_graph_node_get_data(node);
return static_cast<const char*>(data);
}
-xbt_node_t new_xbt_graph_node(xbt_graph_t graph, const char* name, std::map<std::string, xbt_node_t>* nodes)
+xbt_node_t new_xbt_graph_node(const s_xbt_graph_t* graph, const char* name, std::map<std::string, xbt_node_t>* nodes)
{
-
auto elm = nodes->find(name);
if (elm == nodes->end()) {
xbt_node_t ret = xbt_graph_new_node(graph, xbt_strdup(name));
return elm->second;
}
-xbt_edge_t new_xbt_graph_edge(xbt_graph_t graph, xbt_node_t s, xbt_node_t d, std::map<std::string, xbt_edge_t>* edges)
+xbt_edge_t new_xbt_graph_edge(const s_xbt_graph_t* graph, xbt_node_t s, xbt_node_t d,
+ std::map<std::string, xbt_edge_t>* edges)
{
const char* sn = instr_node_name(s);
const char* dn = instr_node_name(d);
{
}
-void RoutedZone::get_graph(xbt_graph_t graph, std::map<std::string, xbt_node_t>* nodes,
+void RoutedZone::get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t>* nodes,
std::map<std::string, xbt_edge_t>* edges)
{
- std::vector<kernel::routing::NetPoint*> vertices = get_vertices();
+ std::vector<NetPoint*> vertices = get_vertices();
for (auto const& my_src : vertices) {
for (auto const& my_dst : vertices) {
xbt_assert(src, "Cannot find a route from nullptr to %s", dst->get_cname());
xbt_assert(dst, "Cannot find a route from %s to nullptr", src->get_cname());
- NetZoneImpl* src_as = src->get_englobing_zone();
- NetZoneImpl* dst_as = dst->get_englobing_zone();
+ const NetZoneImpl* src_as = src->get_englobing_zone();
+ const NetZoneImpl* dst_as = dst->get_englobing_zone();
xbt_assert(src_as == dst_as,
"Internal error: %s@%s and %s@%s are not in the same netzone as expected. Please report that bug.",
src->get_cname(), dst->get_cname(), src_as->get_cname(), dst_as->get_cname(), get_cname());
}
void RoutedZone::add_route_check_params(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
- std::vector<resource::LinkImpl*>& link_list, bool symmetrical)
+ const std::vector<resource::LinkImpl*>& link_list, bool symmetrical)
{
const char* srcName = src->get_cname();
const char* dstName = dst->get_cname();
dstName, gw_dst->get_cname());
}
- simgrid::s4u::NetZone::on_route_creation(symmetrical, src, dst, gw_src, gw_dst, link_list);
-}
-}
-}
+ s4u::NetZone::on_route_creation(symmetrical, src, dst, gw_src, gw_dst, link_list);
}
+} // namespace routing
+} // namespace kernel
+} // namespace simgrid
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
void TorusZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat)
{
-
XBT_VERB("torus getLocalRoute from '%s'[%u] to '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
if (dst->is_router() || src->is_router())
const unsigned cur_dim = dimensions_[j];
// current_node/dim_product = position in current dimension
if ((current_node / dim_product) % cur_dim != (dst->id() / dim_product) % cur_dim) {
-
if ((targetCoords[j] > myCoords[j] &&
targetCoords[j] <= myCoords[j] + cur_dim / 2) // Is the target node on the right, without the wrap-around?
|| (myCoords[j] > cur_dim / 2 &&
delete[] myCoords;
delete[] targetCoords;
}
-}
-}
-} // namespace
+} // namespace routing
+} // namespace kernel
+} // namespace simgrid
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
namespace simgrid {
namespace kernel {
namespace routing {
+
namespace vivaldi {
-simgrid::xbt::Extension<NetPoint, Coords> Coords::EXTENSION_ID;
+
+xbt::Extension<NetPoint, Coords> Coords::EXTENSION_ID;
Coords::Coords(NetPoint* netpoint, const std::string& coordStr)
{
static std::vector<double>* netpoint_get_coords(NetPoint* np)
{
- simgrid::kernel::routing::vivaldi::Coords* coords = np->extension<simgrid::kernel::routing::vivaldi::Coords>();
+ vivaldi::Coords* coords = np->extension<vivaldi::Coords>();
xbt_assert(coords, "Please specify the Vivaldi coordinates of %s %s (%p)",
(np->is_netzone() ? "Netzone" : (np->is_host() ? "Host" : "Router")), np->get_cname(), np);
return &coords->coords;
xbt_assert(netpoint->get_englobing_zone() == this,
"Cannot add a peer link to a netpoint that is not in this netzone");
- new simgrid::kernel::routing::vivaldi::Coords(netpoint, coord);
+ new vivaldi::Coords(netpoint, coord);
std::string link_up = "link_" + netpoint->get_name() + "_UP";
std::string link_down = "link_" + netpoint->get_name() + "_DOWN";
if (src->is_netzone()) {
std::string srcName = "router_" + src->get_name();
std::string dstName = "router_" + dst->get_name();
- route->gw_src = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(srcName);
- route->gw_dst = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(dstName);
+ route->gw_src = s4u::Engine::get_instance()->netpoint_by_name_or_null(srcName);
+ route->gw_dst = s4u::Engine::get_instance()->netpoint_by_name_or_null(dstName);
}
/* Retrieve the private links */
*lat += euclidean_dist / 1000.0; // From .ms to .s
}
}
-}
-}
-}
+} // namespace routing
+} // namespace kernel
+} // namespace simgrid
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
* integers are not allowed.
*/
class ReadOptions {
- std::uint32_t value_;
+ std::uint32_t value_ = 0;
constexpr explicit ReadOptions(std::uint32_t value) : value_(value) {}
public:
- constexpr ReadOptions() : value_(0) {}
+ constexpr ReadOptions() {}
explicit constexpr operator bool() const { return value_ != 0; }
constexpr bool operator!() const { return value_ == 0; }
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
namespace simgrid {
namespace mc {
-ModelChecker::ModelChecker(std::unique_ptr<RemoteClient> process)
- : base_(nullptr)
- , socket_event_(nullptr)
- , signal_event_(nullptr)
- , page_store_(500)
- , process_(std::move(process))
-{
-
-}
+ModelChecker::ModelChecker(std::unique_ptr<RemoteClient> process) : process_(std::move(process)) {}
-ModelChecker::~ModelChecker() {
+ModelChecker::~ModelChecker()
+{
if (socket_event_ != nullptr)
event_free(socket_event_);
if (signal_event_ != nullptr)
{
XBT_DEBUG("Shuting down model-checker");
- simgrid::mc::RemoteClient* process = &this->process();
+ RemoteClient* process = &this->process();
if (process->running()) {
XBT_DEBUG("Killing process");
kill(process->pid(), SIGKILL);
}
}
-void ModelChecker::resume(simgrid::mc::RemoteClient& process)
+void ModelChecker::resume(RemoteClient& process)
{
int res = process.get_channel().send(MC_MESSAGE_CONTINUE);
if (res)
- throw simgrid::xbt::errno_error();
+ throw xbt::errno_error();
process.clear_cache();
}
XBT_INFO("Counter-example execution trace:");
for (auto const& s : mc_model_checker->getChecker()->get_textual_trace())
XBT_INFO(" %s", s.c_str());
- simgrid::mc::dumpRecordPath();
- simgrid::mc::session->log_state();
+ dumpRecordPath();
+ session->log_state();
if (xbt_log_no_loc) {
XBT_INFO("Stack trace not displayed because you passed --log=no_loc");
} else {
XBT_INFO("Counter-example execution trace:");
for (auto const& s : mc_model_checker->getChecker()->get_textual_trace())
XBT_INFO(" %s", s.c_str());
- simgrid::mc::dumpRecordPath();
- simgrid::mc::session->log_state();
+ dumpRecordPath();
+ session->log_state();
}
-bool ModelChecker::handle_message(char* buffer, ssize_t size)
+bool ModelChecker::handle_message(const char* buffer, ssize_t size)
{
s_mc_message_t base_message;
xbt_assert(size >= (ssize_t)sizeof(base_message), "Broken message");
memcpy(&base_message, buffer, sizeof(base_message));
switch(base_message.type) {
-
case MC_MESSAGE_IGNORE_HEAP:
{
s_mc_message_ignore_heap_t message;
xbt_assert(not message.callback, "Support for client-side function proposition is not implemented.");
XBT_DEBUG("Received symbol: %s", message.name);
- if (simgrid::mc::property_automaton == nullptr)
- simgrid::mc::property_automaton = xbt_automaton_new();
+ if (property_automaton == nullptr)
+ property_automaton = xbt_automaton_new();
- simgrid::mc::RemoteClient* process = &this->process();
- simgrid::mc::RemotePtr<int> address = simgrid::mc::remote((int*)message.data);
- simgrid::xbt::add_proposition(simgrid::mc::property_automaton, message.name,
- [process, address]() { return process->read(address); });
+ RemoteClient* process = &this->process();
+ RemotePtr<int> address = remote((int*)message.data);
+ xbt::add_proposition(property_automaton, message.name, [process, address]() { return process->read(address); });
break;
}
default:
xbt_die("Unexpected message from model-checked application");
-
}
return true;
}
}
if (pid == this->process().pid()) {
-
// From PTRACE_O_TRACEEXIT:
#ifdef __linux__
if (status>>8 == (SIGTRAP | (PTRACE_EVENT_EXIT<<8))) {
return message.value != 0;
}
-}
-}
+} // namespace mc
+} // namespace simgrid
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
/** State of the model-checker (global variables for the model checker)
*/
class ModelChecker {
- struct event_base *base_;
- struct event* socket_event_;
- struct event* signal_event_;
+ struct event_base* base_ = nullptr;
+ struct event* socket_event_ = nullptr;
+ struct event* signal_event_ = nullptr;
/** String pool for host names */
// TODO, use std::set with heterogeneous comparison lookup (C++14)?
std::set<std::string> hostnames_;
// This is the parent snapshot of the current state:
- PageStore page_store_;
+ PageStore page_store_{500};
std::unique_ptr<RemoteClient> process_;
Checker* checker_ = nullptr;
public:
private:
void setup_ignore();
- bool handle_message(char* buffer, ssize_t size);
+ bool handle_message(const char* buffer, ssize_t size);
void handle_waitpid();
void on_signal(int signo);
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
-/* Copyright (c) 2015-2019. The SimGrid Team.
+/* Copyright (c) 2015-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2011-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2011-2020. 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. */
this->actors_count = mc_model_checker->process().actors().size();
this->system_state = std::make_shared<simgrid::mc::Snapshot>(state_number);
- this->original_num = -1;
}
void VisitedStates::prune()
{
while (states_.size() > (std::size_t)_sg_mc_max_visited_states) {
XBT_DEBUG("Try to remove visited state (maximum number of stored states reached)");
- auto min_element = boost::range::min_element(states_,
- [](std::unique_ptr<simgrid::mc::VisitedState>& a, std::unique_ptr<simgrid::mc::VisitedState>& b) {
- return a->num < b->num;
- });
+ auto min_element = boost::range::min_element(
+ states_, [](const std::unique_ptr<simgrid::mc::VisitedState>& a,
+ const std::unique_ptr<simgrid::mc::VisitedState>& b) { return a->num < b->num; });
xbt_assert(min_element != states_.end());
// and drop it:
states_.erase(min_element);
{
std::unique_ptr<simgrid::mc::VisitedState> new_state =
std::unique_ptr<simgrid::mc::VisitedState>(new VisitedState(state_number));
- graph_state->system_state = new_state->system_state;
+ graph_state->system_state_ = new_state->system_state;
XBT_DEBUG("Snapshot %p of visited state %d (exploration stack state %d)", new_state->system_state.get(),
new_state->num, graph_state->num_);
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
std::size_t heap_bytes_used = 0;
int actors_count = 0;
int num = 0; // unique id of that state in the storage of all stored IDs
- int original_num = 0; // num field of the VisitedState to which I was declared equal to (used for dot_output)
+ int original_num = -1; // num field of the VisitedState to which I was declared equal to (used for dot_output)
explicit VisitedState(unsigned long state_number);
~VisitedState() = default;
-/* Copyright (c) 2016-2019. The SimGrid Team.
+/* Copyright (c) 2016-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
mc_model_checker->setChecker(this);
}
-}
-}
+} // namespace mc
+} // namespace simgrid
-/* Copyright (c) 2016-2019. The SimGrid Team.
+/* Copyright (c) 2016-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
/********** Static functions ***********/
-static e_mc_comm_pattern_difference_t compare_comm_pattern(simgrid::mc::PatternCommunication* comm1,
- simgrid::mc::PatternCommunication* comm2)
+static e_mc_comm_pattern_difference_t compare_comm_pattern(const simgrid::mc::PatternCommunication* comm1,
+ const simgrid::mc::PatternCommunication* comm2)
{
if(comm1->type != comm2->type)
return TYPE_DIFF;
}
static char* print_determinism_result(e_mc_comm_pattern_difference_t diff, int process,
- simgrid::mc::PatternCommunication* comm, unsigned int cursor)
+ const simgrid::mc::PatternCommunication* comm, unsigned int cursor)
{
char* type;
char* res;
// HACK, type punning
simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
mc_model_checker->process().read(temp_comm, comm_addr);
- simgrid::kernel::activity::CommImpl* comm = temp_comm.get_buffer();
+ const simgrid::kernel::activity::CommImpl* comm = temp_comm.get_buffer();
smx_actor_t src_proc = mc_model_checker->process().resolve_actor(simgrid::mc::remote(comm->src_actor_.get()));
smx_actor_t dst_proc = mc_model_checker->process().resolve_actor(simgrid::mc::remote(comm->dst_actor_.get()));
namespace simgrid {
namespace mc {
-void CommunicationDeterminismChecker::deterministic_comm_pattern(int process, simgrid::mc::PatternCommunication* comm,
+void CommunicationDeterminismChecker::deterministic_comm_pattern(int process, const PatternCommunication* comm,
int backtracking)
{
if (not backtracking) {
- simgrid::mc::PatternCommunicationList& list = initial_communications_pattern[process];
+ PatternCommunicationList& list = initial_communications_pattern[process];
e_mc_comm_pattern_difference_t diff = compare_comm_pattern(list.list[list.index_comm].get(), comm);
if (diff != NONE_DIFF) {
- if (comm->type == simgrid::mc::PatternCommunicationType::send) {
+ if (comm->type == PatternCommunicationType::send) {
this->send_deterministic = 0;
if (this->send_diff != nullptr)
xbt_free(this->send_diff);
XBT_INFO("%s", this->send_diff);
xbt_free(this->send_diff);
this->send_diff = nullptr;
- simgrid::mc::session->log_state();
+ mc::session->log_state();
mc_model_checker->exit(SIMGRID_MC_EXIT_NON_DETERMINISM);
} else if (_sg_mc_comms_determinism && (not this->send_deterministic && not this->recv_deterministic)) {
XBT_INFO("****************************************************");
xbt_free(this->recv_diff);
this->recv_diff = nullptr;
}
- simgrid::mc::session->log_state();
+ mc::session->log_state();
mc_model_checker->exit(SIMGRID_MC_EXIT_NON_DETERMINISM);
}
}
int backtracking)
{
const smx_actor_t issuer = MC_smx_simcall_get_issuer(request);
- const simgrid::mc::PatternCommunicationList& initial_pattern = initial_communications_pattern[issuer->get_pid()];
- const std::vector<simgrid::mc::PatternCommunication*>& incomplete_pattern =
- incomplete_communications_pattern[issuer->get_pid()];
+ const mc::PatternCommunicationList& initial_pattern = initial_communications_pattern[issuer->get_pid()];
+ const std::vector<PatternCommunication*>& incomplete_pattern = incomplete_communications_pattern[issuer->get_pid()];
- std::unique_ptr<simgrid::mc::PatternCommunication> pattern(new simgrid::mc::PatternCommunication());
+ std::unique_ptr<PatternCommunication> pattern(new PatternCommunication());
pattern->index = initial_pattern.index_comm + incomplete_pattern.size();
if (call_type == MC_CALL_TYPE_SEND) {
/* Create comm pattern */
- pattern->type = simgrid::mc::PatternCommunicationType::send;
- pattern->comm_addr = static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_isend__getraw__result(request));
+ pattern->type = PatternCommunicationType::send;
+ pattern->comm_addr = static_cast<kernel::activity::CommImpl*>(simcall_comm_isend__getraw__result(request));
- simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_synchro;
+ Remote<kernel::activity::CommImpl> temp_synchro;
mc_model_checker->process().read(temp_synchro,
- remote(static_cast<simgrid::kernel::activity::CommImpl*>(pattern->comm_addr)));
- simgrid::kernel::activity::CommImpl* synchro =
- static_cast<simgrid::kernel::activity::CommImpl*>(temp_synchro.get_buffer());
+ remote(static_cast<kernel::activity::CommImpl*>(pattern->comm_addr)));
+ const kernel::activity::CommImpl* synchro = static_cast<kernel::activity::CommImpl*>(temp_synchro.get_buffer());
char* remote_name = mc_model_checker->process().read<char*>(RemotePtr<char*>(
(uint64_t)(synchro->get_mailbox() ? &synchro->get_mailbox()->name_ : &synchro->mbox_cpy->name_)));
pattern->rdv = mc_model_checker->process().read_string(RemotePtr<char>(remote_name));
- pattern->src_proc =
- mc_model_checker->process().resolve_actor(simgrid::mc::remote(synchro->src_actor_.get()))->get_pid();
+ pattern->src_proc = mc_model_checker->process().resolve_actor(mc::remote(synchro->src_actor_.get()))->get_pid();
pattern->src_host = MC_smx_actor_get_host_name(issuer);
#if HAVE_SMPI
simgrid::smpi::Request mpi_request;
- mc_model_checker->process().read(
- &mpi_request, remote(static_cast<simgrid::smpi::Request*>(simcall_comm_isend__get__data(request))));
+ mc_model_checker->process().read(&mpi_request,
+ remote(static_cast<smpi::Request*>(simcall_comm_isend__get__data(request))));
pattern->tag = mpi_request.tag();
#endif
}
#endif
} else if (call_type == MC_CALL_TYPE_RECV) {
- pattern->type = simgrid::mc::PatternCommunicationType::receive;
- pattern->comm_addr = static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_irecv__getraw__result(request));
+ pattern->type = PatternCommunicationType::receive;
+ pattern->comm_addr = static_cast<kernel::activity::CommImpl*>(simcall_comm_irecv__getraw__result(request));
#if HAVE_SMPI
- simgrid::smpi::Request mpi_request;
- mc_model_checker->process().read(
- &mpi_request, remote(static_cast<simgrid::smpi::Request*>(simcall_comm_irecv__get__data(request))));
+ smpi::Request mpi_request;
+ mc_model_checker->process().read(&mpi_request,
+ remote(static_cast<smpi::Request*>(simcall_comm_irecv__get__data(request))));
pattern->tag = mpi_request.tag();
#endif
- simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
- mc_model_checker->process().read(temp_comm,
- remote(static_cast<simgrid::kernel::activity::CommImpl*>(pattern->comm_addr)));
- simgrid::kernel::activity::CommImpl* comm = temp_comm.get_buffer();
+ Remote<kernel::activity::CommImpl> temp_comm;
+ mc_model_checker->process().read(temp_comm, remote(static_cast<kernel::activity::CommImpl*>(pattern->comm_addr)));
+ const kernel::activity::CommImpl* comm = temp_comm.get_buffer();
char* remote_name;
- mc_model_checker->process().read(&remote_name,
- remote(comm->get_mailbox()
- ? &simgrid::xbt::string::to_string_data(comm->get_mailbox()->name_).data
- : &simgrid::xbt::string::to_string_data(comm->mbox_cpy->name_).data));
+ mc_model_checker->process().read(
+ &remote_name, remote(comm->get_mailbox() ? &xbt::string::to_string_data(comm->get_mailbox()->name_).data
+ : &xbt::string::to_string_data(comm->mbox_cpy->name_).data));
pattern->rdv = mc_model_checker->process().read_string(RemotePtr<char>(remote_name));
- pattern->dst_proc =
- mc_model_checker->process().resolve_actor(simgrid::mc::remote(comm->dst_actor_.get()))->get_pid();
+ pattern->dst_proc = mc_model_checker->process().resolve_actor(mc::remote(comm->dst_actor_.get()))->get_pid();
pattern->dst_host = MC_smx_actor_get_host_name(issuer);
} else
xbt_die("Unexpected call_type %i", (int) call_type);
incomplete_communications_pattern[issuer->get_pid()].push_back(pattern.release());
}
-void CommunicationDeterminismChecker::complete_comm_pattern(
- simgrid::mc::RemotePtr<simgrid::kernel::activity::CommImpl> comm_addr, unsigned int issuer, int backtracking)
+void CommunicationDeterminismChecker::complete_comm_pattern(RemotePtr<kernel::activity::CommImpl> comm_addr,
+ unsigned int issuer, int backtracking)
{
/* Complete comm pattern */
- std::vector<simgrid::mc::PatternCommunication*>& incomplete_pattern = incomplete_communications_pattern[issuer];
- auto current_comm_pattern = std::find_if(
- begin(incomplete_pattern), end(incomplete_pattern),
- [&comm_addr](simgrid::mc::PatternCommunication* comm) { return remote(comm->comm_addr) == comm_addr; });
+ std::vector<PatternCommunication*>& incomplete_pattern = incomplete_communications_pattern[issuer];
+ auto current_comm_pattern =
+ std::find_if(begin(incomplete_pattern), end(incomplete_pattern),
+ [&comm_addr](const PatternCommunication* comm) { return remote(comm->comm_addr) == comm_addr; });
if (current_comm_pattern == std::end(incomplete_pattern))
xbt_die("Corresponding communication not found!");
update_comm_pattern(*current_comm_pattern, comm_addr);
- std::unique_ptr<simgrid::mc::PatternCommunication> comm_pattern(*current_comm_pattern);
+ std::unique_ptr<PatternCommunication> comm_pattern(*current_comm_pattern);
XBT_DEBUG("Remove incomplete comm pattern for process %u at cursor %zd", issuer,
std::distance(begin(incomplete_pattern), current_comm_pattern));
incomplete_pattern.erase(current_comm_pattern);
for (auto const& state : stack_) {
smx_simcall_t req = &state->executed_req_;
if (req)
- trace.push_back(
- simgrid::mc::request_to_string(req, state->transition_.argument_, simgrid::mc::RequestType::executed));
+ trace.push_back(request_to_string(req, state->transition_.argument_, RequestType::executed));
}
return trace;
}
initial_communications_pattern.resize(maxpid);
incomplete_communications_pattern.resize(maxpid);
- std::unique_ptr<simgrid::mc::State> initial_state(new simgrid::mc::State(++expanded_states_count_));
+ std::unique_ptr<State> initial_state(new State(++expanded_states_count_));
XBT_DEBUG("********* Start communication determinism verification *********");
/* Get an enabled actor and insert it in the interleave set of the initial state */
for (auto& actor : mc_model_checker->process().actors())
- if (simgrid::mc::actor_is_enabled(actor.copy.get_buffer()))
+ if (mc::actor_is_enabled(actor.copy.get_buffer()))
initial_state->add_interleaving_set(actor.copy.get_buffer());
stack_.push_back(std::move(initial_state));
void CommunicationDeterminismChecker::restoreState()
{
/* Intermediate backtracking */
- simgrid::mc::State* last_state = stack_.back().get();
- if (last_state->system_state) {
- last_state->system_state->restore(&mc_model_checker->process());
+ State* last_state = stack_.back().get();
+ if (last_state->system_state_) {
+ last_state->system_state_->restore(&mc_model_checker->process());
MC_restore_communications_pattern(last_state);
return;
}
/* Restore the initial state */
- simgrid::mc::session->restore_initial_state();
+ mc::session->restore_initial_state();
unsigned n = MC_smx_get_maxpid();
assert(n == incomplete_communications_pattern.size());
break;
int req_num = state->transition_.argument_;
- smx_simcall_t saved_req = &state->executed_req_;
+ const s_smx_simcall* saved_req = &state->executed_req_;
xbt_assert(saved_req);
/* because we got a copy of the executed request, we have to fetch the
void CommunicationDeterminismChecker::real_run()
{
- std::unique_ptr<simgrid::mc::VisitedState> visited_state = nullptr;
+ std::unique_ptr<VisitedState> visited_state = nullptr;
smx_simcall_t req = nullptr;
while (not stack_.empty()) {
/* Get current state */
- simgrid::mc::State* cur_state = stack_.back().get();
+ State* cur_state = stack_.back().get();
XBT_DEBUG("**************************************************");
XBT_DEBUG("Exploration depth = %zu (state = %d, interleaved processes = %zu)", stack_.size(), cur_state->num_,
req = nullptr;
if (req != nullptr && visited_state == nullptr) {
-
int req_num = cur_state->transition_.argument_;
- XBT_DEBUG("Execute: %s", simgrid::mc::request_to_string(req, req_num, simgrid::mc::RequestType::simix).c_str());
+ XBT_DEBUG("Execute: %s", request_to_string(req, req_num, RequestType::simix).c_str());
std::string req_str;
if (dot_output != nullptr)
- req_str = simgrid::mc::request_get_dot_output(req, req_num);
+ req_str = request_get_dot_output(req, req_num);
mc_model_checker->executed_transitions++;
mc_model_checker->wait_for_requests();
/* Create the new expanded state */
- std::unique_ptr<simgrid::mc::State> next_state(new simgrid::mc::State(++expanded_states_count_));
+ std::unique_ptr<State> next_state(new State(++expanded_states_count_));
/* If comm determinism verification, we cannot stop the exploration if some communications are not finished (at
* least, data are transferred). These communications are incomplete and they cannot be analyzed and compared
visited_state = nullptr;
if (visited_state == nullptr) {
-
/* Get enabled actors and insert them in the interleave set of the next state */
for (auto& actor : mc_model_checker->process().actors())
if (simgrid::mc::actor_is_enabled(actor.copy.get_buffer()))
visited_state->original_num == -1 ? visited_state->num : visited_state->original_num, req_str.c_str());
stack_.push_back(std::move(next_state));
-
} else {
-
if (stack_.size() > (std::size_t) _sg_mc_max_depth)
XBT_WARN("/!\\ Max depth reached! /!\\ ");
else if (visited_state != nullptr)
}
while (not stack_.empty()) {
- std::unique_ptr<simgrid::mc::State> state(std::move(stack_.back()));
+ std::unique_ptr<State> state(std::move(stack_.back()));
stack_.pop_back();
if (state->interleave_size() && stack_.size() < (std::size_t)_sg_mc_max_depth) {
/* We found a back-tracking point, let's loop */
}
}
- simgrid::mc::session->log_state();
+ mc::session->log_state();
}
void CommunicationDeterminismChecker::run()
{
XBT_INFO("Check communication determinism");
- simgrid::mc::session->initialize();
+ mc::session->initialize();
this->prepare();
return new CommunicationDeterminismChecker(s);
}
-}
-}
+} // namespace mc
+} // namespace simgrid
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
void prepare();
void real_run();
void log_state() override;
- void deterministic_comm_pattern(int process, simgrid::mc::PatternCommunication* comm, int backtracking);
+ void deterministic_comm_pattern(int process, const simgrid::mc::PatternCommunication* comm, int backtracking);
void restoreState();
public:
// These are used by functions which should be moved in CommunicationDeterminismChecker:
-/* Copyright (c) 2011-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2011-2020. 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. */
VisitedPair::VisitedPair(int pair_num, xbt_automaton_state_t automaton_state,
std::shared_ptr<const std::vector<int>> atomic_propositions,
- std::shared_ptr<simgrid::mc::State> graph_state)
+ std::shared_ptr<State> graph_state)
: num(pair_num), automaton_state(automaton_state)
{
- simgrid::mc::RemoteClient* process = &(mc_model_checker->process());
+ RemoteClient* process = &(mc_model_checker->process());
this->graph_state = std::move(graph_state);
- if(this->graph_state->system_state == nullptr)
- this->graph_state->system_state = std::make_shared<simgrid::mc::Snapshot>(pair_num);
+ if (this->graph_state->system_state_ == nullptr)
+ this->graph_state->system_state_ = std::make_shared<Snapshot>(pair_num);
this->heap_bytes_used = mmalloc_get_bytes_used_remote(process->get_heap()->heaplimit, process->get_malloc_info());
this->actors_count = mc_model_checker->process().actors().size();
this->atomic_propositions = std::move(atomic_propositions);
}
-static bool evaluate_label(xbt_automaton_exp_label_t l, std::vector<int> const& values)
+static bool evaluate_label(const xbt_automaton_exp_label* l, std::vector<int> const& values)
{
switch (l->type) {
case xbt_automaton_exp_label::AUT_OR:
std::vector<int> values;
unsigned int cursor = 0;
xbt_automaton_propositional_symbol_t ps = nullptr;
- xbt_dynar_foreach(simgrid::mc::property_automaton->propositional_symbols, cursor, ps)
+ xbt_dynar_foreach (mc::property_automaton->propositional_symbols, cursor, ps)
values.push_back(xbt_automaton_propositional_symbol_evaluate(ps));
return std::make_shared<const std::vector<int>>(std::move(values));
}
pair->num, pair->automaton_state, pair->atomic_propositions,
pair->graph_state);
- auto res = boost::range::equal_range(acceptance_pairs_, new_pair.get(),
- simgrid::mc::DerefAndCompareByActorsCountAndUsedHeap());
+ auto res = boost::range::equal_range(acceptance_pairs_, new_pair.get(), DerefAndCompareByActorsCountAndUsedHeap());
if (pair->search_cycle) for (auto i = res.first; i != res.second; ++i) {
std::shared_ptr<simgrid::mc::VisitedPair> const& pair_test = *i;
if (xbt_automaton_state_compare(pair_test->automaton_state, new_pair->automaton_state) != 0 ||
*(pair_test->atomic_propositions) != *(new_pair->atomic_propositions) ||
- not snapshot_equal(pair_test->graph_state->system_state.get(), new_pair->graph_state->system_state.get()))
+ not snapshot_equal(pair_test->graph_state->system_state_.get(), new_pair->graph_state->system_state_.get()))
continue;
XBT_INFO("Pair %d already reached (equal to pair %d) !", new_pair->num, pair_test->num);
exploration_stack_.pop_back();
/* Intermediate backtracking */
if(_sg_mc_checkpoint > 0) {
- simgrid::mc::Pair* pair = exploration_stack_.back().get();
- if(pair->graph_state->system_state){
- pair->graph_state->system_state->restore(&mc_model_checker->process());
+ const Pair* pair = exploration_stack_.back().get();
+ if (pair->graph_state->system_state_) {
+ pair->graph_state->system_state_->restore(&mc_model_checker->process());
return;
}
}
/* Restore the initial state */
- simgrid::mc::session->restore_initial_state();
+ mc::session->restore_initial_state();
/* Traverse the stack from the initial state and re-execute the transitions */
int depth = 1;
std::shared_ptr<State> state = pair->graph_state;
if (pair->exploration_started) {
-
int req_num = state->transition_.argument_;
- smx_simcall_t saved_req = &state->executed_req_;
+ const s_smx_simcall* saved_req = &state->executed_req_;
smx_simcall_t req = nullptr;
req = &issuer->simcall;
/* Debug information */
- XBT_DEBUG("Replay (depth = %d) : %s (%p)",
- depth,
- simgrid::mc::request_to_string(
- req, req_num, simgrid::mc::RequestType::simix).c_str(),
- state.get());
+ XBT_DEBUG("Replay (depth = %d) : %s (%p)", depth,
+ request_to_string(req, req_num, simgrid::mc::RequestType::simix).c_str(), state.get());
}
this->get_session().execute(state->transition_);
mc_model_checker->executed_transitions++;
depth++;
-
}
-
XBT_DEBUG("**** End Replay ****");
}
visited_pair =
std::make_shared<VisitedPair>(pair->num, pair->automaton_state, pair->atomic_propositions, pair->graph_state);
- auto range = boost::range::equal_range(visited_pairs_, visited_pair.get(),
- simgrid::mc::DerefAndCompareByActorsCountAndUsedHeap());
+ auto range = boost::range::equal_range(visited_pairs_, visited_pair.get(), DerefAndCompareByActorsCountAndUsedHeap());
for (auto i = range.first; i != range.second; ++i) {
- VisitedPair* pair_test = i->get();
+ const VisitedPair* pair_test = i->get();
if (xbt_automaton_state_compare(pair_test->automaton_state, visited_pair->automaton_state) != 0 ||
*(pair_test->atomic_propositions) != *(visited_pair->atomic_propositions) ||
- not snapshot_equal(pair_test->graph_state->system_state.get(), visited_pair->graph_state->system_state.get()))
+ not snapshot_equal(pair_test->graph_state->system_state_.get(), visited_pair->graph_state->system_state_.get()))
continue;
if (pair_test->other_num == -1)
visited_pair->other_num = pair_test->num;
XBT_INFO("Counter-example that violates formula:");
for (auto const& s : this->get_textual_trace())
XBT_INFO(" %s", s.c_str());
- simgrid::mc::dumpRecordPath();
- simgrid::mc::session->log_state();
+ mc::dumpRecordPath();
+ mc::session->log_state();
XBT_INFO("Counter-example depth: %zu", depth);
}
int req_num = pair->graph_state->transition_.argument_;
smx_simcall_t req = &pair->graph_state->executed_req_;
if (req && req->call_ != SIMCALL_NONE)
- trace.push_back(simgrid::mc::request_to_string(
- req, req_num, simgrid::mc::RequestType::executed));
+ trace.push_back(request_to_string(req, req_num, RequestType::executed));
}
return trace;
}
-std::shared_ptr<Pair> LivenessChecker::create_pair(Pair* current_pair, xbt_automaton_state_t state,
+std::shared_ptr<Pair> LivenessChecker::create_pair(const Pair* current_pair, xbt_automaton_state_t state,
std::shared_ptr<const std::vector<int>> propositions)
{
expanded_pairs_count_++;
std::shared_ptr<Pair> next_pair = std::make_shared<Pair>(expanded_pairs_count_);
next_pair->automaton_state = state;
- next_pair->graph_state = std::shared_ptr<simgrid::mc::State>(new simgrid::mc::State(++expanded_states_count_));
+ next_pair->graph_state = std::shared_ptr<State>(new State(++expanded_states_count_));
next_pair->atomic_propositions = std::move(propositions);
if (current_pair)
next_pair->depth = current_pair->depth + 1;
next_pair->depth = 1;
/* Get enabled actors and insert them in the interleave set of the next graph_state */
for (auto& actor : mc_model_checker->process().actors())
- if (simgrid::mc::actor_is_enabled(actor.copy.get_buffer()))
+ if (mc::actor_is_enabled(actor.copy.get_buffer()))
next_pair->graph_state->add_interleaving_set(actor.copy.get_buffer());
next_pair->requests = next_pair->graph_state->interleave_size();
/* FIXME : get search_cycle value for each accepting state */
MC_automaton_load(_sg_mc_property_file.get().c_str());
XBT_DEBUG("Starting the liveness algorithm");
- simgrid::mc::session->initialize();
+ mc::session->initialize();
/* Initialize */
this->previous_pair_ = 0;
// (application_state, automaton_state) pair to the exploration stack:
unsigned int cursor = 0;
xbt_automaton_state_t automaton_state;
- xbt_dynar_foreach (simgrid::mc::property_automaton->states, cursor, automaton_state)
+ xbt_dynar_foreach (mc::property_automaton->states, cursor, automaton_state)
if (automaton_state->type == -1)
exploration_stack_.push_back(this->create_pair(nullptr, automaton_state, propos));
std::shared_ptr<Pair> current_pair = exploration_stack_.back();
/* Update current state in buchi automaton */
- simgrid::mc::property_automaton->current_state = current_pair->automaton_state;
+ mc::property_automaton->current_state = current_pair->automaton_state;
XBT_DEBUG(
"********************* ( Depth = %d, search_cycle = %d, interleave size = %zu, pair_num = %d, requests = %d)",
reached_pair = this->insert_acceptance_pair(current_pair.get());
if (reached_pair == nullptr) {
this->show_acceptance_cycle(current_pair->depth);
- throw simgrid::mc::LivenessError();
+ throw LivenessError();
}
}
this->previous_request_.clear();
}
this->previous_pair_ = current_pair->num;
- this->previous_request_ = simgrid::mc::request_get_dot_output(req, req_num);
+ this->previous_request_ = request_get_dot_output(req, req_num);
if (current_pair->search_cycle)
fprintf(dot_output, "%d [shape=doublecircle];\n", current_pair->num);
fflush(dot_output);
}
- XBT_DEBUG("Execute: %s",
- simgrid::mc::request_to_string(
- req, req_num, simgrid::mc::RequestType::simix).c_str());
+ XBT_DEBUG("Execute: %s", request_to_string(req, req_num, RequestType::simix).c_str());
/* Update stats */
mc_model_checker->executed_transitions++;
// For each enabled transition in the property automaton, push a
// (application_state, automaton_state) pair to the exploration stack:
for (int i = xbt_dynar_length(current_pair->automaton_state->out) - 1; i >= 0; i--) {
- xbt_automaton_transition_t transition_succ = (xbt_automaton_transition_t)xbt_dynar_get_as(
+ const xbt_automaton_transition* transition_succ = (xbt_automaton_transition_t)xbt_dynar_get_as(
current_pair->automaton_state->out, i, xbt_automaton_transition_t);
if (evaluate_label(transition_succ->label, *prop_values))
exploration_stack_.push_back(this->create_pair(current_pair.get(), transition_succ->dst, prop_values));
}
-
}
XBT_INFO("No property violation found.");
- simgrid::mc::session->log_state();
+ mc::session->log_state();
}
Checker* createLivenessChecker(Session& s)
return new LivenessChecker(s);
}
-}
-}
+} // namespace mc
+} // namespace simgrid
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
void remove_acceptance_pair(int pair_num);
void purge_visited_pairs();
void backtrack();
- std::shared_ptr<Pair> create_pair(Pair* pair, xbt_automaton_state_t state,
+ std::shared_ptr<Pair> create_pair(const Pair* pair, xbt_automaton_state_t state,
std::shared_ptr<const std::vector<int>> propositions);
// A stack of (application_state, automaton_state) pairs for DFS exploration:
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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 "src/xbt/mmalloc/mmprivate.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_safety, mc,
- "Logging specific to MC safety verification ");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_safety, mc, "Logging specific to MC safety verification ");
+
namespace simgrid {
namespace mc {
-void SafetyChecker::check_non_termination(simgrid::mc::State* current_state)
+void SafetyChecker::check_non_termination(const State* current_state)
{
for (auto state = stack_.rbegin(); state != stack_.rend(); ++state)
- if (snapshot_equal((*state)->system_state.get(), current_state->system_state.get())) {
+ if (snapshot_equal((*state)->system_state_.get(), current_state->system_state_.get())) {
XBT_INFO("Non-progressive cycle: state %d -> state %d", (*state)->num_, current_state->num_);
XBT_INFO("******************************************");
XBT_INFO("*** NON-PROGRESSIVE CYCLE DETECTED ***");
XBT_INFO("Counter-example execution trace:");
for (auto const& s : mc_model_checker->getChecker()->get_textual_trace())
XBT_INFO(" %s", s.c_str());
- simgrid::mc::dumpRecordPath();
- simgrid::mc::session->log_state();
+ dumpRecordPath();
+ session->log_state();
- throw simgrid::mc::TerminationError();
+ throw TerminationError();
}
}
int value = state->transition_.argument_;
smx_simcall_t req = &state->executed_req_;
if (req)
- trace.push_back(simgrid::mc::request_to_string(
- req, value, simgrid::mc::RequestType::executed));
+ trace.push_back(request_to_string(req, value, RequestType::executed));
}
return trace;
}
* This allows one to explore the call stack at will. */
while (not stack_.empty()) {
-
/* Get current state */
- simgrid::mc::State* state = stack_.back().get();
+ State* state = stack_.back().get();
XBT_DEBUG("**************************************************");
XBT_VERB("Exploration depth=%zu (state=%p, num %d)(%zu interleave)", stack_.size(), state, state->num_,
// If there are processes to interleave and the maximum depth has not been
// reached then perform one step of the exploration algorithm.
- XBT_DEBUG(
- "Execute: %s",
- simgrid::mc::request_to_string(req, state->transition_.argument_, simgrid::mc::RequestType::simix).c_str());
+ XBT_DEBUG("Execute: %s", request_to_string(req, state->transition_.argument_, RequestType::simix).c_str());
std::string req_str;
if (dot_output != nullptr)
- req_str = simgrid::mc::request_get_dot_output(req, state->transition_.argument_);
+ req_str = request_get_dot_output(req, state->transition_.argument_);
mc_model_checker->executed_transitions++;
this->get_session().execute(state->transition_);
/* Create the new expanded state (copy the state of MCed into our MCer data) */
- std::unique_ptr<simgrid::mc::State> next_state =
- std::unique_ptr<simgrid::mc::State>(new simgrid::mc::State(++expanded_states_count_));
+ std::unique_ptr<State> next_state = std::unique_ptr<State>(new State(++expanded_states_count_));
if (_sg_mc_termination)
this->check_non_termination(next_state.get());
/* If this is a new state (or if we don't care about state-equality reduction) */
if (visited_state_ == nullptr) {
-
/* Get an enabled process and insert it in the interleave set of the next state */
for (auto& remoteActor : mc_model_checker->process().actors()) {
auto actor = remoteActor.copy.get_buffer();
- if (simgrid::mc::actor_is_enabled(actor)) {
+ if (actor_is_enabled(actor)) {
next_state->add_interleaving_set(actor);
- if (reductionMode_ == simgrid::mc::ReductionMode::dpor)
+ if (reductionMode_ == ReductionMode::dpor)
break; // With DPOR, we take the first enabled transition
}
}
}
XBT_INFO("No property violation found.");
- simgrid::mc::session->log_state();
+ session->log_state();
}
void SafetyChecker::backtrack()
/* Check for deadlocks */
if (mc_model_checker->checkDeadlock()) {
MC_show_deadlock();
- throw simgrid::mc::DeadlockError();
+ throw DeadlockError();
}
- /* Traverse the stack backwards until a state with a non empty interleave
- set is found, deleting all the states that have it empty in the way.
- For each deleted state, check if the request that has generated it
- (from it's predecessor state), depends on any other previous request
- executed before it. If it does then add it to the interleave set of the
- state that executed that previous request. */
+ /* Traverse the stack backwards until a state with a non empty interleave set is found, deleting all the states that
+ * have it empty in the way. For each deleted state, check if the request that has generated it (from its
+ * predecessor state), depends on any other previous request executed before it. If it does then add it to the
+ * interleave set of the state that executed that previous request. */
while (not stack_.empty()) {
- std::unique_ptr<simgrid::mc::State> state = std::move(stack_.back());
+ std::unique_ptr<State> state = std::move(stack_.back());
stack_.pop_back();
- if (reductionMode_ == simgrid::mc::ReductionMode::dpor) {
- smx_simcall_t req = &state->internal_req;
+ if (reductionMode_ == ReductionMode::dpor) {
+ smx_simcall_t req = &state->internal_req_;
if (req->call_ == SIMCALL_MUTEX_LOCK || req->call_ == SIMCALL_MUTEX_TRYLOCK)
xbt_die("Mutex is currently not supported with DPOR, use --cfg=model-check/reduction:none");
- const smx_actor_t issuer = MC_smx_simcall_get_issuer(req);
+ const kernel::actor::ActorImpl* issuer = MC_smx_simcall_get_issuer(req);
for (auto i = stack_.rbegin(); i != stack_.rend(); ++i) {
- simgrid::mc::State* prev_state = i->get();
- if (simgrid::mc::request_depend(req, &prev_state->internal_req)) {
+ State* prev_state = i->get();
+ if (request_depend(req, &prev_state->internal_req_)) {
if (XBT_LOG_ISENABLED(mc_safety, xbt_log_priority_debug)) {
XBT_DEBUG("Dependent Transitions:");
int value = prev_state->transition_.argument_;
smx_simcall_t prev_req = &prev_state->executed_req_;
- XBT_DEBUG("%s (state=%d)",
- simgrid::mc::request_to_string(prev_req, value, simgrid::mc::RequestType::internal).c_str(),
+ XBT_DEBUG("%s (state=%d)", simgrid::mc::request_to_string(prev_req, value, RequestType::internal).c_str(),
prev_state->num_);
value = state->transition_.argument_;
prev_req = &state->executed_req_;
- XBT_DEBUG("%s (state=%d)",
- simgrid::mc::request_to_string(prev_req, value, simgrid::mc::RequestType::executed).c_str(),
+ XBT_DEBUG("%s (state=%d)", simgrid::mc::request_to_string(prev_req, value, RequestType::executed).c_str(),
state->num_);
}
prev_state->add_interleaving_set(issuer);
else
XBT_DEBUG("Process %p is in done set", req->issuer_);
-
break;
-
- } else if (req->issuer_ == prev_state->internal_req.issuer_) {
-
+ } else if (req->issuer_ == prev_state->internal_req_.issuer_) {
XBT_DEBUG("Simcall %s and %s with same issuer", SIMIX_simcall_name(req->call_),
- SIMIX_simcall_name(prev_state->internal_req.call_));
+ SIMIX_simcall_name(prev_state->internal_req_.call_));
break;
-
} else {
-
- const smx_actor_t previous_issuer = MC_smx_simcall_get_issuer(&prev_state->internal_req);
+ const kernel::actor::ActorImpl* previous_issuer = MC_smx_simcall_get_issuer(&prev_state->internal_req_);
XBT_DEBUG("Simcall %s, process %ld (state %d) and simcall %s, process %ld (state %d) are independent",
SIMIX_simcall_name(req->call_), issuer->get_pid(), state->num_,
- SIMIX_simcall_name(prev_state->internal_req.call_), previous_issuer->get_pid(), prev_state->num_);
+ SIMIX_simcall_name(prev_state->internal_req_.call_), previous_issuer->get_pid(), prev_state->num_);
}
}
}
void SafetyChecker::restore_state()
{
/* Intermediate backtracking */
- simgrid::mc::State* last_state = stack_.back().get();
- if (last_state->system_state) {
- last_state->system_state->restore(&mc_model_checker->process());
+ const State* last_state = stack_.back().get();
+ if (last_state->system_state_) {
+ last_state->system_state_->restore(&mc_model_checker->process());
return;
}
/* Restore the initial state */
- simgrid::mc::session->restore_initial_state();
+ session->restore_initial_state();
/* Traverse the stack from the state at position start and re-execute the transitions */
- for (std::unique_ptr<simgrid::mc::State> const& state : stack_) {
+ for (std::unique_ptr<State> const& state : stack_) {
if (state == stack_.back())
break;
session->execute(state->transition_);
SafetyChecker::SafetyChecker(Session& s) : Checker(s)
{
- reductionMode_ = simgrid::mc::reduction_mode;
+ reductionMode_ = reduction_mode;
if (_sg_mc_termination)
- reductionMode_ = simgrid::mc::ReductionMode::none;
- else if (reductionMode_ == simgrid::mc::ReductionMode::unset)
- reductionMode_ = simgrid::mc::ReductionMode::dpor;
+ reductionMode_ = ReductionMode::none;
+ else if (reductionMode_ == ReductionMode::unset)
+ reductionMode_ = ReductionMode::dpor;
if (_sg_mc_termination)
XBT_INFO("Check non progressive cycles");
else
XBT_INFO("Check a safety property. Reduction is: %s.",
- (reductionMode_ == simgrid::mc::ReductionMode::none ? "none":
- (reductionMode_ == simgrid::mc::ReductionMode::dpor ? "dpor": "unknown")));
- simgrid::mc::session->initialize();
+ (reductionMode_ == ReductionMode::none ? "none"
+ : (reductionMode_ == ReductionMode::dpor ? "dpor" : "unknown")));
+ session->initialize();
XBT_DEBUG("Starting the safety algorithm");
- std::unique_ptr<simgrid::mc::State> initial_state =
- std::unique_ptr<simgrid::mc::State>(new simgrid::mc::State(++expanded_states_count_));
+ std::unique_ptr<State> initial_state = std::unique_ptr<State>(new State(++expanded_states_count_));
XBT_DEBUG("**************************************************");
XBT_DEBUG("Initial state");
/* Get an enabled actor and insert it in the interleave set of the initial state */
for (auto& actor : mc_model_checker->process().actors())
- if (simgrid::mc::actor_is_enabled(actor.copy.get_buffer())) {
+ if (actor_is_enabled(actor.copy.get_buffer())) {
initial_state->add_interleaving_set(actor.copy.get_buffer());
- if (reductionMode_ != simgrid::mc::ReductionMode::none)
+ if (reductionMode_ != ReductionMode::none)
break;
}
return new SafetyChecker(s);
}
-}
-}
+} // namespace mc
+} // namespace simgrid
-/* Copyright (c) 2008-2019. The SimGrid Team.
+/* Copyright (c) 2008-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
void log_state() override;
private:
- void check_non_termination(simgrid::mc::State* current_state);
+ void check_non_termination(const State* current_state);
void backtrack();
void restore_state();
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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. */
-/* Copyright (c) 2015-2019. The SimGrid Team.
+/* Copyright (c) 2015-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
class ProcessComparisonState {
public:
- const std::vector<simgrid::mc::IgnoredHeapRegion>* to_ignore = nullptr;
+ const std::vector<IgnoredHeapRegion>* to_ignore = nullptr;
std::vector<HeapArea> equals_to;
- std::vector<simgrid::mc::Type*> types;
+ std::vector<Type*> types;
std::size_t heapsize = 0;
- void initHeapInformation(xbt_mheap_t heap, const std::vector<simgrid::mc::IgnoredHeapRegion>& i);
+ void initHeapInformation(const s_xbt_mheap_t* heap, const std::vector<IgnoredHeapRegion>& i);
};
class StateComparator {
compared_pointers.clear();
}
- int initHeapInformation(xbt_mheap_t heap1, xbt_mheap_t heap2, const std::vector<simgrid::mc::IgnoredHeapRegion>& i1,
- const std::vector<simgrid::mc::IgnoredHeapRegion>& i2);
+ int initHeapInformation(const s_xbt_mheap_t* heap1, const s_xbt_mheap_t* heap2,
+ const std::vector<IgnoredHeapRegion>& i1, const std::vector<IgnoredHeapRegion>& i2);
template <int rank> HeapArea& equals_to_(std::size_t i, std::size_t j)
{
this->equals_to_<2>(b2, f2).block_ == b1 && this->equals_to_<2>(b2, f2).fragment_ == f1;
}
- void match_equals(HeapLocationPairs* list);
+ void match_equals(const HeapLocationPairs* list);
};
-}
-}
+} // namespace mc
+} // namespace simgrid
/************************************************************************************/
namespace simgrid {
namespace mc {
-void StateComparator::match_equals(HeapLocationPairs* list)
+void StateComparator::match_equals(const HeapLocationPairs* list)
{
for (auto const& pair : *list) {
if (pair[0].fragment_ != -1) {
- this->equals_to_<1>(pair[0].block_, pair[0].fragment_) = simgrid::mc::HeapArea(pair[1].block_, pair[1].fragment_);
- this->equals_to_<2>(pair[1].block_, pair[1].fragment_) = simgrid::mc::HeapArea(pair[0].block_, pair[0].fragment_);
+ this->equals_to_<1>(pair[0].block_, pair[0].fragment_) = HeapArea(pair[1].block_, pair[1].fragment_);
+ this->equals_to_<2>(pair[1].block_, pair[1].fragment_) = HeapArea(pair[0].block_, pair[0].fragment_);
} else {
- this->equals_to_<1>(pair[0].block_, 0) = simgrid::mc::HeapArea(pair[1].block_, pair[1].fragment_);
- this->equals_to_<2>(pair[1].block_, 0) = simgrid::mc::HeapArea(pair[0].block_, pair[0].fragment_);
+ this->equals_to_<1>(pair[0].block_, 0) = HeapArea(pair[1].block_, pair[1].fragment_);
+ this->equals_to_<2>(pair[1].block_, 0) = HeapArea(pair[0].block_, pair[0].fragment_);
}
}
}
-void ProcessComparisonState::initHeapInformation(xbt_mheap_t heap, const std::vector<simgrid::mc::IgnoredHeapRegion>& i)
+void ProcessComparisonState::initHeapInformation(const s_xbt_mheap_t* heap, const std::vector<IgnoredHeapRegion>& i)
{
auto heaplimit = heap->heaplimit;
this->heapsize = heap->heapsize;
this->types.assign(heaplimit * MAX_FRAGMENT_PER_BLOCK, nullptr);
}
-int StateComparator::initHeapInformation(xbt_mheap_t heap1, xbt_mheap_t heap2,
- const std::vector<simgrid::mc::IgnoredHeapRegion>& i1,
- const std::vector<simgrid::mc::IgnoredHeapRegion>& i2)
+int StateComparator::initHeapInformation(const s_xbt_mheap_t* heap1, const s_xbt_mheap_t* heap2,
+ const std::vector<IgnoredHeapRegion>& i1,
+ const std::vector<IgnoredHeapRegion>& i2)
{
if ((heap1->heaplimit != heap2->heaplimit) || (heap1->heapsize != heap2->heapsize))
return -1;
static inline Region* MC_get_heap_region(const Snapshot& snapshot)
{
for (auto const& region : snapshot.snapshot_regions_)
- if (region->region_type() == simgrid::mc::RegionType::Heap)
+ if (region->region_type() == RegionType::Heap)
return region.get();
xbt_die("No heap region");
}
static bool heap_area_differ(StateComparator& state, const void* area1, const void* area2, const Snapshot& snapshot1,
const Snapshot& snapshot2, HeapLocationPairs* previous, Type* type, int pointer_level);
-static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgrid::mc::Snapshot& snapshot1,
- const simgrid::mc::Snapshot& snapshot2)
+static bool mmalloc_heap_differ(StateComparator& state, const Snapshot& snapshot1, const Snapshot& snapshot2)
{
- const simgrid::mc::RemoteClient& process = mc_model_checker->process();
+ const RemoteClient& process = mc_model_checker->process();
/* Check busy blocks */
size_t i1 = 1;
malloc_info heapinfo_temp2;
malloc_info heapinfo_temp2b;
- simgrid::mc::Region* heap_region1 = MC_get_heap_region(snapshot1);
- simgrid::mc::Region* heap_region2 = MC_get_heap_region(snapshot2);
+ const Region* heap_region1 = MC_get_heap_region(snapshot1);
+ const Region* heap_region2 = MC_get_heap_region(snapshot2);
// This is the address of std_heap->heapinfo in the application process:
void* heapinfo_address = &((xbt_mheap_t)process.heap_address)->heapinfo;
/* Try first to associate to same block in the other heap */
if (heapinfo2->type == heapinfo1->type && state.equals_to_<2>(i1, 0).valid_ == 0) {
- void* addr_block2 = (ADDR2UINT(i1) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
+ const void* addr_block2 = (ADDR2UINT(i1) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
if (not heap_area_differ(state, addr_block1, addr_block2, snapshot1, snapshot2, nullptr, nullptr, 0)) {
for (size_t k = 1; k < heapinfo2->busy_block.size; k++)
state.equals_to_<2>(i1 + k, 0) = HeapArea(i1, -1);
}
while (i2 < state.heaplimit && not equal) {
- void* addr_block2 = (ADDR2UINT(i2) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
+ const void* addr_block2 = (ADDR2UINT(i2) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
if (i2 == i1) {
i2++;
equal = true;
i1 += heapinfo1->busy_block.size;
}
-
i2++;
}
XBT_DEBUG("Block %zu not found (size_used = %zu, addr = %p)", i1, heapinfo1->busy_block.busy_size, addr_block1);
return true;
}
-
- } else { /* Fragmented block */
-
+ } else { /* Fragmented block */
for (size_t j1 = 0; j1 < (size_t)(BLOCKSIZE >> heapinfo1->type); j1++) {
-
if (heapinfo1->busy_frag.frag_size[j1] == -1) /* Free fragment_ */
continue;
/* Try first to associate to same fragment_ in the other heap */
if (heapinfo2->type == heapinfo1->type && not state.equals_to_<2>(i1, j1).valid_) {
- void* addr_block2 = (ADDR2UINT(i1) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
- void* addr_frag2 = (void*)((char*)addr_block2 + (j1 << heapinfo2->type));
+ const void* addr_block2 = (ADDR2UINT(i1) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
+ const void* addr_frag2 = (const char*)addr_block2 + (j1 << heapinfo2->type);
if (not heap_area_differ(state, addr_frag1, addr_frag2, snapshot1, snapshot2, nullptr, nullptr, 0))
equal = true;
}
if (state.equals_to_<2>(i2, j2).valid_)
continue;
- void* addr_block2 = (ADDR2UINT(i2) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
- void* addr_frag2 = (void*)((char*)addr_block2 + (j2 << heapinfo2b->type));
+ const void* addr_block2 = (ADDR2UINT(i2) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
+ const void* addr_frag2 = (const char*)addr_block2 + (j2 << heapinfo2b->type);
if (not heap_area_differ(state, addr_frag1, addr_frag2, snapshot1, snapshot2, nullptr, nullptr, 0)) {
equal = true;
break;
}
}
-
i2++;
}
return true;
}
}
-
i1++;
}
}
return true;
}
}
-
return false;
}
* @param check_ignore
* @return true when different, false otherwise (same or unknown)
*/
-static bool heap_area_differ_without_type(simgrid::mc::StateComparator& state, const void* real_area1,
- const void* real_area2, const simgrid::mc::Snapshot& snapshot1,
- const simgrid::mc::Snapshot& snapshot2, HeapLocationPairs* previous, int size,
- int check_ignore)
+static bool heap_area_differ_without_type(StateComparator& state, const void* real_area1, const void* real_area2,
+ const Snapshot& snapshot1, const Snapshot& snapshot2,
+ HeapLocationPairs* previous, int size, int check_ignore)
{
- const simgrid::mc::RemoteClient& process = mc_model_checker->process();
- simgrid::mc::Region* heap_region1 = MC_get_heap_region(snapshot1);
- simgrid::mc::Region* heap_region2 = MC_get_heap_region(snapshot2);
+ const RemoteClient& process = mc_model_checker->process();
+ const Region* heap_region1 = MC_get_heap_region(snapshot1);
+ const Region* heap_region2 = MC_get_heap_region(snapshot2);
for (int i = 0; i < size; ) {
if (check_ignore > 0) {
i = pointer_align + sizeof(void *);
continue;
}
-
return true;
}
-
i++;
}
-
return false;
}
* @param pointer_level
* @return true when different, false otherwise (same or unknown)
*/
-static bool heap_area_differ_with_type(simgrid::mc::StateComparator& state, const void* real_area1,
- const void* real_area2, const simgrid::mc::Snapshot& snapshot1,
- const simgrid::mc::Snapshot& snapshot2, HeapLocationPairs* previous,
- simgrid::mc::Type* type, int area_size, int check_ignore, int pointer_level)
+static bool heap_area_differ_with_type(StateComparator& state, const void* real_area1, const void* real_area2,
+ const Snapshot& snapshot1, const Snapshot& snapshot2,
+ HeapLocationPairs* previous, const Type* type, int area_size, int check_ignore,
+ int pointer_level)
{
// HACK: This should not happen but in practice, there are some
// DW_TAG_typedef without an associated DW_AT_type:
return false;
}
- simgrid::mc::Type* subtype;
- simgrid::mc::Type* subsubtype;
+ const Type* subtype;
+ const Type* subsubtype;
int elm_size;
const void* addr_pointed1;
const void* addr_pointed2;
- simgrid::mc::Region* heap_region1 = MC_get_heap_region(snapshot1);
- simgrid::mc::Region* heap_region2 = MC_get_heap_region(snapshot2);
+ const Region* heap_region1 = MC_get_heap_region(snapshot1);
+ const Region* heap_region2 = MC_get_heap_region(snapshot2);
switch (type->type) {
case DW_TAG_unspecified_type:
return true;
}
} else {
- for (simgrid::mc::Member& member : type->members) {
+ for (const simgrid::mc::Member& member : type->members) {
// TODO, optimize this? (for the offset case)
- void* real_member1 = simgrid::dwarf::resolve_member(real_area1, type, &member, &snapshot1);
- void* real_member2 = simgrid::dwarf::resolve_member(real_area2, type, &member, &snapshot2);
+ const void* real_member1 = dwarf::resolve_member(real_area1, type, &member, &snapshot1);
+ const void* real_member2 = dwarf::resolve_member(real_area2, type, &member, &snapshot2);
if (heap_area_differ_with_type(state, real_member1, real_member2, snapshot1, snapshot2, previous,
member.type, -1, check_ignore, 0))
return true;
* @param area_size
* @return DWARF type ID for given offset
*/
-static simgrid::mc::Type* get_offset_type(void* real_base_address, simgrid::mc::Type* type, int offset, int area_size,
- const simgrid::mc::Snapshot& snapshot)
+static Type* get_offset_type(void* real_base_address, Type* type, int offset, int area_size, const Snapshot& snapshot)
{
// Beginning of the block, the inferred variable type if the type of the block:
if (offset == 0)
return nullptr;
}
- for (simgrid::mc::Member& member : type->members) {
+ for (const simgrid::mc::Member& member : type->members) {
if (member.has_offset_location()) {
// We have the offset, use it directly (shortcut):
if (member.offset() == offset)
return member.type;
} else {
- void* real_member = simgrid::dwarf::resolve_member(real_base_address, type, &member, &snapshot);
+ void* real_member = dwarf::resolve_member(real_base_address, type, &member, &snapshot);
if ((char*)real_member - (char*)real_base_address == offset)
return member.type;
}
* @param pointer_level
* @return true when different, false otherwise (same or unknown)
*/
-static bool heap_area_differ(simgrid::mc::StateComparator& state, const void* area1, const void* area2,
- const simgrid::mc::Snapshot& snapshot1, const simgrid::mc::Snapshot& snapshot2,
- HeapLocationPairs* previous, simgrid::mc::Type* type, int pointer_level)
+static bool heap_area_differ(StateComparator& state, const void* area1, const void* area2, const Snapshot& snapshot1,
+ const Snapshot& snapshot2, HeapLocationPairs* previous, Type* type, int pointer_level)
{
const simgrid::mc::RemoteClient& process = mc_model_checker->process();
int new_size1 = -1;
int new_size2 = -1;
- simgrid::mc::Type* new_type1 = nullptr;
- simgrid::mc::Type* new_type2 = nullptr;
+ Type* new_type1 = nullptr;
+ Type* new_type2 = nullptr;
bool match_pairs = false;
}
// Get block number:
- block1 = ((char*)area1 - (char*)state.std_heap_copy.heapbase) / BLOCKSIZE + 1;
- block2 = ((char*)area2 - (char*)state.std_heap_copy.heapbase) / BLOCKSIZE + 1;
+ block1 = ((const char*)area1 - (const char*)state.std_heap_copy.heapbase) / BLOCKSIZE + 1;
+ block2 = ((const char*)area2 - (const char*)state.std_heap_copy.heapbase) / BLOCKSIZE + 1;
// If either block is a stack block:
if (is_block_stack((int) block1) && is_block_stack((int) block2)) {
}
// If either block is not in the expected area of memory:
- if (((char*)area1 < (char*)state.std_heap_copy.heapbase) || (block1 > (ssize_t)state.processStates[0].heapsize) ||
- (block1 < 1) || ((char*)area2 < (char*)state.std_heap_copy.heapbase) ||
+ if (((const char*)area1 < (const char*)state.std_heap_copy.heapbase) ||
+ (block1 > (ssize_t)state.processStates[0].heapsize) || (block1 < 1) ||
+ ((const char*)area2 < (const char*)state.std_heap_copy.heapbase) ||
(block2 > (ssize_t)state.processStates[1].heapsize) || (block2 < 1)) {
return true;
}
type_size = type->byte_size;
}
- simgrid::mc::Region* heap_region1 = MC_get_heap_region(snapshot1);
- simgrid::mc::Region* heap_region2 = MC_get_heap_region(snapshot2);
+ const Region* heap_region1 = MC_get_heap_region(snapshot1);
+ const Region* heap_region2 = MC_get_heap_region(snapshot2);
const malloc_info* heapinfo1 =
(const malloc_info*)heap_region1->read(&heapinfo_temp1, &heapinfos1[block1], sizeof(malloc_info));
return false;
}
- if (heapinfo1->busy_block.ignore > 0
- && heapinfo2->busy_block.ignore == heapinfo1->busy_block.ignore)
+ if (heapinfo1->busy_block.ignore > 0 && heapinfo2->busy_block.ignore == heapinfo1->busy_block.ignore)
check_ignore = heapinfo1->busy_block.ignore;
} else if ((heapinfo1->type > 0) && (heapinfo2->type > 0)) { /* Fragmented block */
}
// Type inference from the block type.
else if (state.types_<1>(block1, frag1) != nullptr || state.types_<2>(block2, frag2) != nullptr) {
- offset1 = (char*)area1 - (char*)real_addr_frag1;
- offset2 = (char*)area2 - (char*)real_addr_frag2;
+ offset1 = (const char*)area1 - (const char*)real_addr_frag1;
+ offset2 = (const char*)area2 - (const char*)real_addr_frag2;
if (state.types_<1>(block1, frag1) != nullptr && state.types_<2>(block2, frag2) != nullptr) {
new_type1 = get_offset_type(real_addr_frag1, state.types_<1>(block1, frag1), offset1, size, snapshot1);
}
if (new_type1 != nullptr && new_type2 != nullptr && new_type1 != new_type2) {
-
type = new_type1;
while (type->byte_size == 0 && type->subtype != nullptr)
type = type->subtype;
if ((heapinfo1->busy_frag.ignore[frag1] > 0) &&
(heapinfo2->busy_frag.ignore[frag2] == heapinfo1->busy_frag.ignore[frag1]))
check_ignore = heapinfo1->busy_frag.ignore[frag1];
-
} else
return true;
state.match_equals(previous);
return false;
}
-
-}
-}
+} // namespace mc
+} // namespace simgrid
/************************** Snapshot comparison *******************************/
/******************************************************************************/
static bool areas_differ_with_type(simgrid::mc::StateComparator& state, const void* real_area1,
const simgrid::mc::Snapshot& snapshot1, simgrid::mc::Region* region1,
const void* real_area2, const simgrid::mc::Snapshot& snapshot2,
- simgrid::mc::Region* region2, simgrid::mc::Type* type, int pointer_level)
+ simgrid::mc::Region* region2, const simgrid::mc::Type* type, int pointer_level)
{
- simgrid::mc::Type* subtype;
- simgrid::mc::Type* subsubtype;
+ const simgrid::mc::Type* subtype;
+ const simgrid::mc::Type* subsubtype;
int elm_size;
int i;
}
case DW_TAG_structure_type:
case DW_TAG_class_type:
- for (simgrid::mc::Member& member : type->members) {
- void* member1 = simgrid::dwarf::resolve_member(real_area1, type, &member, &snapshot1);
- void* member2 = simgrid::dwarf::resolve_member(real_area2, type, &member, &snapshot2);
+ for (const simgrid::mc::Member& member : type->members) {
+ const void* member1 = simgrid::dwarf::resolve_member(real_area1, type, &member, &snapshot1);
+ const void* member2 = simgrid::dwarf::resolve_member(real_area2, type, &member, &snapshot2);
simgrid::mc::Region* subregion1 = snapshot1.get_region(member1, region1); // region1 is hinted
simgrid::mc::Region* subregion2 = snapshot2.get_region(member2, region2); // region2 is hinted
if (areas_differ_with_type(state, member1, snapshot1, subregion1, member2, snapshot2, subregion2, member.type,
return false;
}
-static bool global_variables_differ(simgrid::mc::StateComparator& state, simgrid::mc::ObjectInformation* object_info,
- simgrid::mc::Region* r1, simgrid::mc::Region* r2,
- const simgrid::mc::Snapshot& snapshot1, const simgrid::mc::Snapshot& snapshot2)
+static bool global_variables_differ(simgrid::mc::StateComparator& state,
+ const simgrid::mc::ObjectInformation* object_info, simgrid::mc::Region* r1,
+ simgrid::mc::Region* r2, const simgrid::mc::Snapshot& snapshot1,
+ const simgrid::mc::Snapshot& snapshot2)
{
xbt_assert(r1 && r2, "Missing region.");
|| (char *) current_var.address > (char *) object_info->end_rw)
continue;
- simgrid::mc::Type* bvariable_type = current_var.type;
+ const simgrid::mc::Type* bvariable_type = current_var.type;
if (areas_differ_with_type(state, current_var.address, snapshot1, r1, current_var.address, snapshot2, r2,
bvariable_type, 0)) {
XBT_VERB("Global variable %s (%p) is different between snapshots", current_var.name.c_str(), current_var.address);
}
/* Init heap information used in heap comparison algorithm */
- xbt_mheap_t heap1 =
- static_cast<xbt_mheap_t>(s1->read_bytes(alloca(sizeof(struct mdesc)), sizeof(struct mdesc),
- remote(process.heap_address), simgrid::mc::ReadOptions::lazy()));
- xbt_mheap_t heap2 =
- static_cast<xbt_mheap_t>(s2->read_bytes(alloca(sizeof(struct mdesc)), sizeof(struct mdesc),
- remote(process.heap_address), simgrid::mc::ReadOptions::lazy()));
+ const s_xbt_mheap_t* heap1 = static_cast<xbt_mheap_t>(s1->read_bytes(
+ alloca(sizeof(s_xbt_mheap_t)), sizeof(s_xbt_mheap_t), remote(process.heap_address), ReadOptions::lazy()));
+ const s_xbt_mheap_t* heap2 = static_cast<xbt_mheap_t>(s2->read_bytes(
+ alloca(sizeof(s_xbt_mheap_t)), sizeof(s_xbt_mheap_t), remote(process.heap_address), ReadOptions::lazy()));
if (state_comparator.initHeapInformation(heap1, heap2, s1->to_ignore_, s2->to_ignore_) == -1) {
XBT_VERB("(%d - %d) Different heap information", s1->num_state_, s2->num_state_);
return false;
return true;
}
-
-}
-}
+} // namespace mc
+} // namespace simgrid
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
intptr_t second;
switch (atom) {
-
// Registers:
-
case DW_OP_breg0:
case DW_OP_breg1:
case DW_OP_breg2:
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
* the process memory, etc. All those informations are gathered in
* the evaluation context.
*/
-class ExpressionContext {
-public:
- ExpressionContext()
- : cursor(nullptr)
- , frame_base(nullptr)
- , address_space(nullptr)
- , object_info(nullptr)
- {
- }
+struct ExpressionContext {
/** CPU state (registers) */
- unw_cursor_t* cursor;
- void* frame_base;
- /** Address space used to read memory */
- const simgrid::mc::AddressSpace* address_space;
- simgrid::mc::ObjectInformation* object_info;
+ unw_cursor_t* cursor = nullptr;
+ void* frame_base = nullptr;
+ const simgrid::mc::AddressSpace* address_space = nullptr; /** Address space used to read memory */
+ simgrid::mc::ObjectInformation* object_info = nullptr;
};
/** When an error happens in the execution of a DWARF expression */
private:
// Values of the stack (the top is stack_[size_ - 1]):
uintptr_t stack_[max_size]{0};
- size_t size_;
+ size_t size_ = 0;
public:
- ExpressionStack() : size_(0) {}
-
// Access:
std::size_t size() const { return size_; }
bool empty() const { return size_ == 0; }
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/** Debug information about a given function or scope within a function */
class Frame {
public:
- Frame();
-
/** Kind of scope (DW_TAG_subprogram, DW_TAG_inlined_subroutine, etc.) */
int tag = DW_TAG_invalid;
std::string name;
/** Range of instruction addresses for which this scope is valid */
- simgrid::xbt::Range<std::uint64_t> range;
+ simgrid::xbt::Range<std::uint64_t> range{0, 0};
simgrid::dwarf::LocationList frame_base_location;
void* frame_base(unw_cursor_t& unw_cursor) const;
void remove_variable(char* name);
};
-
-inline Frame::Frame()
-{
- this->tag = 0;
- this->range = {0, 0};
- this->id = 0;
- this->abstract_origin_id = 0;
- this->object_info = nullptr;
-}
-
} // namespace mc
} // namespace simgrid
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
/** Resolve a location expression */
Location resolve(simgrid::dwarf::DwarfExpression const& expression, simgrid::mc::ObjectInformation* object_info,
- unw_cursor_t* c, void* frame_pointer_address, simgrid::mc::AddressSpace* address_space)
+ unw_cursor_t* c, void* frame_pointer_address, const simgrid::mc::AddressSpace* address_space)
{
simgrid::dwarf::ExpressionContext context;
context.frame_base = frame_pointer_address;
}
Location resolve(simgrid::dwarf::LocationList const& locations, simgrid::mc::ObjectInformation* object_info,
- unw_cursor_t* c, void* frame_pointer_address, simgrid::mc::AddressSpace* address_space)
+ unw_cursor_t* c, void* frame_pointer_address, const simgrid::mc::AddressSpace* address_space)
{
unw_word_t ip = 0;
if (c && unw_get_reg(c, UNW_REG_IP, &ip))
return simgrid::dwarf::resolve(*expression, object_info, c, frame_pointer_address, address_space);
}
-LocationList location_list(simgrid::mc::ObjectInformation& info, Dwarf_Attribute& attr)
+LocationList location_list(const simgrid::mc::ObjectInformation& info, Dwarf_Attribute& attr)
{
LocationList locations;
std::ptrdiff_t offset = 0;
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
*/
class Location {
private:
- void* memory_;
+ void* memory_ = nullptr;
int register_id_ = 0;
public:
explicit Location(void* x) : memory_(x) {}
- explicit Location(int register_id) : memory_(nullptr), register_id_(register_id) {}
+ explicit Location(int register_id) : register_id_(register_id) {}
// Type of location:
bool in_register() const { return memory_ == nullptr; }
bool in_memory() const { return memory_ != nullptr; }
XBT_PRIVATE
Location resolve(simgrid::dwarf::DwarfExpression const& expression, simgrid::mc::ObjectInformation* object_info,
- unw_cursor_t* c, void* frame_pointer_address, simgrid::mc::AddressSpace* address_space);
+ unw_cursor_t* c, void* frame_pointer_address, const simgrid::mc::AddressSpace* address_space);
Location resolve(simgrid::dwarf::LocationList const& locations, simgrid::mc::ObjectInformation* object_info,
- unw_cursor_t* c, void* frame_pointer_address, simgrid::mc::AddressSpace* address_space);
+ unw_cursor_t* c, void* frame_pointer_address, const simgrid::mc::AddressSpace* address_space);
XBT_PRIVATE
-simgrid::dwarf::LocationList location_list(simgrid::mc::ObjectInformation& info, Dwarf_Attribute& attr);
+simgrid::dwarf::LocationList location_list(const simgrid::mc::ObjectInformation& info, Dwarf_Attribute& attr);
} // namespace dwarf
} // namespace simgrid
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
namespace simgrid {
namespace mc {
-/* For an executable object, addresses are virtual address
- * (there is no offset) i.e.
- * \f$\text{virtual address} = \{dwarf address}\f$
+/* For an executable object, addresses are virtual address (there is no offset) i.e.
+ * \f$\text{virtual address} = \{dwarf address}\f$
*
- * For a shared object, the addresses are offset from the beginning
- * of the shared object (the base address of the mapped shared
- * object must be used as offset
+ * For a shared object, the addresses are offset from the beginning of the shared object (the base address of the
+ * mapped shared object must be used as offset
* i.e. \f$\text{virtual address} = \text{shared object base address}
* + \text{dwarf address}\f$.
*/
if (this->executable())
return nullptr;
- // For an a shared-object (ET_DYN, including position-independent executables)
- // the base address is its lowest address:
+ // For an a shared-object (ET_DYN, including position-independent executables) the base address is its lowest address:
void* result = this->start_exec;
if (this->start_rw != nullptr && result > (void*)this->start_rw)
result = this->start_rw;
return result;
}
-simgrid::mc::Frame* ObjectInformation::find_function(const void* ip) const
+Frame* ObjectInformation::find_function(const void* ip) const
{
/* This is implemented by binary search on a sorted array.
*
* We could use std::binary_search by including the high_pc inside
* the FunctionIndexEntry.
*/
- const simgrid::mc::FunctionIndexEntry* base = this->functions_index.data();
- int i = 0;
- int j = this->functions_index.size() - 1;
+ const FunctionIndexEntry* base = this->functions_index.data();
+ int i = 0;
+ int j = this->functions_index.size() - 1;
while (j >= i) {
int k = i + ((j - i) / 2);
return nullptr;
}
-const simgrid::mc::Variable* ObjectInformation::find_variable(const char* name) const
+const Variable* ObjectInformation::find_variable(const char* name) const
{
- for (simgrid::mc::Variable const& variable : this->global_variables) {
+ for (Variable const& variable : this->global_variables) {
if (variable.name == name)
return &variable;
}
while (first <= last) {
size_type cursor = first + (last - first) / 2;
- simgrid::mc::Variable& current_var = this->global_variables[cursor];
+ const Variable& current_var = this->global_variables[cursor];
int cmp = current_var.name.compare(name);
if (cmp == 0) {
-
// Find the whole range:
first = cursor;
while (first != 0 && this->global_variables[first - 1].name == name)
/** Ignore a local variable in a scope
*
- * Ignore all instances of variables with a given name in
- * any (possibly inlined) subprogram with a given namespaced
+ * Ignore all instances of variables with a given name in any (possibly inlined) subprogram with a given namespaced
* name.
*
* @param var_name Name of the local variable to ignore
* @param subprogram (possibly inlined) Subprogram of the scope current scope
* @param scope Current scope
*/
-static void remove_local_variable(simgrid::mc::Frame& scope, const char* var_name, const char* subprogram_name,
- simgrid::mc::Frame const& subprogram)
+static void remove_local_variable(Frame& scope, const char* var_name, const char* subprogram_name,
+ Frame const& subprogram)
{
typedef std::vector<Variable>::size_type size_type;
// If the current subprogram matches the given name:
if ((subprogram_name == nullptr || (not subprogram.name.empty() && subprogram.name == subprogram_name)) &&
not scope.variables.empty()) {
-
// Try to find the variable and remove it:
size_type start = 0;
size_type end = scope.variables.size() - 1;
// Binary search:
while (start <= end) {
size_type cursor = start + (end - start) / 2;
- simgrid::mc::Variable& current_var = scope.variables[cursor];
+ const Variable& current_var = scope.variables[cursor];
int compare = current_var.name.compare(var_name);
if (compare == 0) {
// Variable found, remove it:
}
// And recursive processing in nested scopes:
- for (simgrid::mc::Frame& nested_scope : scope.scopes) {
+ for (Frame& nested_scope : scope.scopes) {
// The new scope may be an inlined subroutine, in this case we want to use its
// namespaced name in recursive calls:
- simgrid::mc::Frame const& nested_subprogram =
- nested_scope.tag == DW_TAG_inlined_subroutine ? nested_scope : subprogram;
+ Frame const& nested_subprogram = nested_scope.tag == DW_TAG_inlined_subroutine ? nested_scope : subprogram;
remove_local_variable(nested_scope, var_name, subprogram_name, nested_subprogram);
}
}
void ObjectInformation::remove_local_variable(const char* var_name, const char* subprogram_name)
{
for (auto& entry : this->subprograms)
- simgrid::mc::remove_local_variable(entry.second, var_name, subprogram_name, entry.second);
+ mc::remove_local_variable(entry.second, var_name, subprogram_name, entry.second);
}
/** @brief Fills the position of the segments (executable, read-only, read/write) */
// TODO, use the ELF segment information for more robustness
-void find_object_address(std::vector<simgrid::xbt::VmMap> const& maps, simgrid::mc::ObjectInformation* result)
+void find_object_address(std::vector<xbt::VmMap> const& maps, ObjectInformation* result)
{
const int PROT_RW = PROT_READ | PROT_WRITE;
const int PROT_RX = PROT_READ | PROT_EXEC;
- std::string name = simgrid::xbt::Path(result->file_name).get_base_name();
+ std::string name = xbt::Path(result->file_name).get_base_name();
for (size_t i = 0; i < maps.size(); ++i) {
simgrid::xbt::VmMap const& reg = maps[i];
else if (reg.prot == PROT_READ) {
xbt_assert(not result->start_ro,
"Multiple read-only segments for %s, not supported. Compiling with the following may help: "
- "-Wl,-znorelro -Wl,-znoseparate-code",
+ "-Wl,-znorelro -Wl,-znoseparate-code",
maps[i].pathname.c_str());
result->start_ro = (char*)reg.start_addr;
result->end_ro = (char*)reg.end_addr;
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
const char* name);
/** Augment the current module with informations about the other ones */
-XBT_PRIVATE void postProcessObjectInformation(simgrid::mc::RemoteClient* process, simgrid::mc::ObjectInformation* info);
+XBT_PRIVATE void postProcessObjectInformation(const simgrid::mc::RemoteClient* process,
+ simgrid::mc::ObjectInformation* info);
} // namespace mc
} // namespace simgrid
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
* @param unit the DIE of the compile unit of the current DIE
* @param frame containing frame if any
*/
-static void MC_dwarf_handle_variable_die(simgrid::mc::ObjectInformation* info, Dwarf_Die* die, Dwarf_Die* unit,
+static void MC_dwarf_handle_variable_die(simgrid::mc::ObjectInformation* info, Dwarf_Die* die, const Dwarf_Die* unit,
simgrid::mc::Frame* frame, const char* ns);
/** @brief Get the DW_TAG_type of the DIE
static TagClass classify_tag(int tag)
{
switch (tag) {
-
case DW_TAG_array_type:
case DW_TAG_class_type:
case DW_TAG_enumeration_type:
*/
inline XBT_PRIVATE const char* tagname(Dwarf_Die* die)
{
- return simgrid::dwarf::tagname(dwarf_tag(die));
+ return tagname(dwarf_tag(die));
}
} // namespace dwarf
* @param member the member of the type
* @param child DIE of the member (DW_TAG_member)
*/
-static void MC_dwarf_fill_member_location(simgrid::mc::Type* type, simgrid::mc::Member* member, Dwarf_Die* child)
+static void MC_dwarf_fill_member_location(const simgrid::mc::Type* type, simgrid::mc::Member* member, Dwarf_Die* child)
{
xbt_assert(not dwarf_hasattr(child, DW_AT_data_bit_offset), "Can't groke DW_AT_data_bit_offset.");
* @param unit DIE of the compilation unit containing the type DIE
* @param type the type
*/
-static void MC_dwarf_add_members(simgrid::mc::ObjectInformation* /*info*/, Dwarf_Die* die, Dwarf_Die* /*unit*/,
- simgrid::mc::Type* type)
+static void MC_dwarf_add_members(const simgrid::mc::ObjectInformation* /*info*/, Dwarf_Die* die,
+ const Dwarf_Die* /*unit*/, simgrid::mc::Type* type)
{
int res;
Dwarf_Die child;
static int mc_anonymous_variable_index = 0;
static std::unique_ptr<simgrid::mc::Variable> MC_die_to_variable(simgrid::mc::ObjectInformation* info, Dwarf_Die* die,
- Dwarf_Die* /*unit*/, simgrid::mc::Frame* frame,
- const char* ns)
+ const Dwarf_Die* /*unit*/,
+ const simgrid::mc::Frame* frame, const char* ns)
{
// Skip declarations:
if (MC_dwarf_attr_flag(die, DW_AT_declaration, false))
return variable;
}
-static void MC_dwarf_handle_variable_die(simgrid::mc::ObjectInformation* info, Dwarf_Die* die, Dwarf_Die* unit,
+static void MC_dwarf_handle_variable_die(simgrid::mc::ObjectInformation* info, Dwarf_Die* die, const Dwarf_Die* unit,
simgrid::mc::Frame* frame, const char* ns)
{
std::unique_ptr<simgrid::mc::Variable> variable = MC_die_to_variable(info, die, unit, frame, ns);
static Elf64_Half get_type(Elf* elf)
{
- Elf64_Ehdr* ehdr64 = elf64_getehdr(elf);
+ const Elf64_Ehdr* ehdr64 = elf64_getehdr(elf);
if (ehdr64)
return ehdr64->e_type;
- Elf32_Ehdr* ehdr32 = elf32_getehdr(elf);
+ const Elf32_Ehdr* ehdr32 = elf32_getehdr(elf);
if (ehdr32)
return ehdr32->e_type;
xbt_die("Could not get ELF heeader");
// Iterate over the program headers and find the PT_NOTE ones:
for (size_t i = 0; i < phnum; ++i) {
GElf_Phdr phdr_temp;
- GElf_Phdr* phdr = gelf_getphdr(elf, i, &phdr_temp);
+ const GElf_Phdr* phdr = gelf_getphdr(elf, i, &phdr_temp);
if (phdr->p_type != PT_NOTE)
continue;
namespace mc {
/** @brief Finds informations about a given shared object/executable */
-std::shared_ptr<simgrid::mc::ObjectInformation> createObjectInformation(std::vector<simgrid::xbt::VmMap> const& maps,
- const char* name)
+std::shared_ptr<ObjectInformation> createObjectInformation(std::vector<xbt::VmMap> const& maps, const char* name)
{
- std::shared_ptr<simgrid::mc::ObjectInformation> result = std::make_shared<simgrid::mc::ObjectInformation>();
- result->file_name = name;
+ std::shared_ptr<ObjectInformation> result = std::make_shared<ObjectInformation>();
+ result->file_name = name;
simgrid::mc::find_object_address(maps, result.get());
MC_load_dwarf(result.get());
MC_post_process_variables(result.get());
/*************************************************************************/
-void postProcessObjectInformation(simgrid::mc::RemoteClient* process, simgrid::mc::ObjectInformation* info)
+void postProcessObjectInformation(const RemoteClient* process, ObjectInformation* info)
{
for (auto& t : info->types) {
- simgrid::mc::Type* type = &(t.second);
- simgrid::mc::Type* subtype = type;
+ Type* type = &(t.second);
+ Type* subtype = type;
while (subtype->type == DW_TAG_typedef || subtype->type == DW_TAG_volatile_type ||
subtype->type == DW_TAG_const_type)
if (subtype->subtype)
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
XBT_PRIVATE const char* attrname(int attr);
XBT_PRIVATE const char* tagname(int tag);
-XBT_PRIVATE void* resolve_member(const void* base, simgrid::mc::Type* type, simgrid::mc::Member* member,
+XBT_PRIVATE void* resolve_member(const void* base, const simgrid::mc::Type* type, const simgrid::mc::Member* member,
const simgrid::mc::AddressSpace* snapshot);
XBT_PRIVATE
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
* @param snapshot Snapshot (or nullptr)
* @return Process address of the given member of the 'object' struct/class
*/
-void* resolve_member(const void* base, simgrid::mc::Type* /*type*/, simgrid::mc::Member* member,
+void* resolve_member(const void* base, const simgrid::mc::Type* /*type*/, const simgrid::mc::Member* member,
const simgrid::mc::AddressSpace* address_space)
{
ExpressionContext state;
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
int UnwindContext::find_proc_info(unw_addr_space_t /*as*/, unw_word_t ip, unw_proc_info_t* pip, int need_unwind_info,
void* arg) noexcept
{
- simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
+ const simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
return unw_get_accessors(context->process_->unw_underlying_addr_space)
->find_proc_info(context->process_->unw_underlying_addr_space, ip, pip, need_unwind_info,
context->process_->unw_underlying_context);
*/
void UnwindContext::put_unwind_info(unw_addr_space_t /*as*/, unw_proc_info_t* pip, void* arg) noexcept
{
- simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
+ const simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
return unw_get_accessors(context->process_->unw_underlying_addr_space)
->put_unwind_info(context->process_->unw_underlying_addr_space, pip, context->process_->unw_underlying_context);
}
*/
int UnwindContext::get_dyn_info_list_addr(unw_addr_space_t /*as*/, unw_word_t* dilap, void* arg) noexcept
{
- simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
+ const simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
return unw_get_accessors(context->process_->unw_underlying_addr_space)
->get_dyn_info_list_addr(context->process_->unw_underlying_addr_space, dilap,
context->process_->unw_underlying_context);
*/
int UnwindContext::access_mem(unw_addr_space_t /*as*/, unw_word_t addr, unw_word_t* valp, int write, void* arg) noexcept
{
- simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
+ const simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
if (write)
return -UNW_EREADONLYREG;
context->address_space_->read_bytes(valp, sizeof(unw_word_t), remote(addr));
unw_context_t* context = &as_context->unwind_context_;
if (write)
return -UNW_EREADONLYREG;
- greg_t* preg = (greg_t*)get_reg(context, regnum);
+ const greg_t* preg = (greg_t*)get_reg(context, regnum);
if (not preg)
return -UNW_EBADREG;
*valp = *preg;
int UnwindContext::get_proc_name(unw_addr_space_t /*as*/, unw_word_t addr, char* bufp, size_t buf_len, unw_word_t* offp,
void* arg) noexcept
{
- simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
- simgrid::mc::Frame* frame = context->process_->find_function(remote(addr));
+ const simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
+ const simgrid::mc::Frame* frame = context->process_->find_function(remote(addr));
if (not frame)
return -UNW_ENOINFO;
*offp = (unw_word_t)frame->range.begin() - addr;
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
static unw_addr_space_t createUnwindAddressSpace();
};
-void dumpStack(FILE* file, unw_cursor_t&& cursor);
-void dumpStack(FILE* file, pid_t pid);
+void dumpStack(FILE* file, unw_cursor_t* cursor);
} // namespace mc
} // namespace simgrid
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
*/
static inline pid_t _UPT_getpid(void* arg)
{
- _UPT_info* info = static_cast<_UPT_info*>(arg);
+ const _UPT_info* info = static_cast<_UPT_info*>(arg);
return info->pid;
}
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
while (not simix_global->actors_to_run.empty()) {
simix_global->run_all_actors();
for (smx_actor_t const& process : simix_global->actors_that_ran) {
- smx_simcall_t req = &process->simcall;
+ const s_smx_simcall* req = &process->simcall;
if (req->call_ != SIMCALL_NONE && not simgrid::mc::request_is_visible(req))
process->simcall_handle(0);
}
}
#if SIMGRID_HAVE_MC
xbt_dynar_reset(simix_global->actors_vector);
- for (std::pair<aid_t, smx_actor_t> const& kv : simix_global->process_list) {
+ for (std::pair<const aid_t, smx_actor_t> const& kv : simix_global->process_list) {
xbt_dynar_push_as(simix_global->actors_vector, smx_actor_t, kv.second);
}
#endif
case SIMCALL_COMM_WAIT: {
/* FIXME: check also that src and dst processes are not suspended */
- simgrid::kernel::activity::CommImpl* act =
- static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_wait__getraw__comm(req));
+ const kernel::activity::CommImpl* act =
+ static_cast<kernel::activity::CommImpl*>(simcall_comm_wait__getraw__comm(req));
if (act->src_timeout_ || act->dst_timeout_) {
/* If it has a timeout it will be always be enabled (regardless of who declared the timeout),
simgrid::kernel::activity::CommImpl** comms = simcall_comm_waitany__get__comms(req);
size_t count = simcall_comm_waitany__get__count(req);
for (unsigned int index = 0; index < count; ++index) {
- auto* comm = comms[index];
+ auto const* comm = comms[index];
if (comm->src_actor_ && comm->dst_actor_)
return true;
}
}
case SIMCALL_MUTEX_LOCK: {
- smx_mutex_t mutex = simcall_mutex_lock__get__mutex(req);
+ const kernel::activity::MutexImpl* mutex = simcall_mutex_lock__get__mutex(req);
- if (mutex->owner_ == nullptr)
+ if (mutex->get_owner() == nullptr)
return true;
- return mutex->owner_->get_pid() == req->issuer_->get_pid();
+ return mutex->get_owner()->get_pid() == req->issuer_->get_pid();
}
case SIMCALL_SEM_ACQUIRE: {
/* This is the list of requests that are visible from the checker algorithm.
* Any other requests are handled right away on the application side.
*/
-bool request_is_visible(smx_simcall_t req)
+bool request_is_visible(const s_smx_simcall* req)
{
#if SIMGRID_HAVE_MC
xbt_assert(mc_model_checker == nullptr, "This should be called from the client side");
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
XBT_PRIVATE bool actor_is_enabled(smx_actor_t process);
/** Check if the given simcall is visible */
-XBT_PRIVATE bool request_is_visible(smx_simcall_t req);
-
+XBT_PRIVATE bool request_is_visible(const s_smx_simcall* req);
}
}
-/* Copyright (c) 2008-2019. The SimGrid Team.
+/* Copyright (c) 2008-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
DATA_DIFF,
};
-static inline e_mc_call_type_t MC_get_call_type(smx_simcall_t req)
+static inline e_mc_call_type_t MC_get_call_type(const s_smx_simcall* req)
{
switch (req->call_) {
case SIMCALL_COMM_ISEND:
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
namespace simgrid {
namespace mc {
-void dumpStack(FILE* file, unw_cursor_t&& cursor)
+void dumpStack(FILE* file, unw_cursor_t* cursor)
{
int nframe = 0;
char buffer[100];
unw_word_t off;
do {
- const char* name = not unw_get_proc_name(&cursor, buffer, 100, &off) ? buffer : "?";
+ const char* name = not unw_get_proc_name(cursor, buffer, 100, &off) ? buffer : "?";
// Unmangle C++ names:
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);
+ 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.get(), (std::uint64_t)rip,
(std::uint64_t)rsp);
#else
#endif
++nframe;
- } while(unw_step(&cursor));
+ } while (unw_step(cursor));
}
}
}
#endif
-double MC_process_clock_get(smx_actor_t process)
+double MC_process_clock_get(const simgrid::kernel::actor::ActorImpl* process)
{
if (simgrid::mc::processes_time.empty())
return 0;
return -1;
}
-void MC_process_clock_add(smx_actor_t process, double amount)
+void MC_process_clock_add(const simgrid::kernel::actor::ActorImpl* process, double amount)
{
simgrid::mc::processes_time[process->get_pid()] += amount;
}
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
-/* Copyright (c) 2008-2019. The SimGrid Team.
+/* Copyright (c) 2008-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
smx_actor_t process = SIMIX_process_from_PID(transition.pid_);
if (not process)
xbt_die("Unexpected process (pid:%d).", transition.pid_);
- smx_simcall_t simcall = &(process->simcall);
+ const s_smx_simcall* simcall = &(process->simcall);
if (simcall == nullptr || simcall->call_ == SIMCALL_NONE)
xbt_die("No simcall for process %d.", transition.pid_);
if (not simgrid::mc::request_is_visible(simcall) || not simgrid::mc::actor_is_enabled(process))
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
return false;
// Those are internal requests, we do not need indirection because those objects are copies:
- kernel::activity::CommImpl* synchro1 = MC_get_comm(r1);
- kernel::activity::CommImpl* synchro2 = MC_get_comm(r2);
+ const kernel::activity::CommImpl* synchro1 = MC_get_comm(r1);
+ const kernel::activity::CommImpl* synchro2 = MC_get_comm(r2);
if ((r1->call_ == SIMCALL_COMM_ISEND || r1->call_ == SIMCALL_COMM_IRECV) && r2->call_ == SIMCALL_COMM_WAIT) {
- smx_mailbox_t mbox = MC_get_mbox(r1);
+ const kernel::activity::MailboxImpl* mbox = MC_get_mbox(r1);
if (mbox != synchro2->mbox_cpy
&& simcall_comm_wait__get__timeout(r2) <= 0)
return request_depend_asymmetric(req1, req2) && request_depend_asymmetric(req2, req1);
// Those are internal requests, we do not need indirection because those objects are copies:
- kernel::activity::CommImpl* synchro1 = MC_get_comm(req1);
- kernel::activity::CommImpl* synchro2 = MC_get_comm(req2);
+ const kernel::activity::CommImpl* synchro1 = MC_get_comm(req1);
+ const kernel::activity::CommImpl* synchro2 = MC_get_comm(req2);
switch (req1->call_) {
case SIMCALL_COMM_ISEND:
p = pointer_to_string(remote_act);
simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_synchro;
- simgrid::kernel::activity::CommImpl* act;
+ const simgrid::kernel::activity::CommImpl* act;
if (use_remote_comm) {
mc_model_checker->process().read(temp_synchro,
remote(static_cast<simgrid::kernel::activity::CommImpl*>(remote_act)));
simgrid::kernel::activity::CommImpl* remote_act =
static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_test__getraw__comm(req));
simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_synchro;
- simgrid::kernel::activity::CommImpl* act;
+ const simgrid::kernel::activity::CommImpl* act;
if (use_remote_comm) {
mc_model_checker->process().read(temp_synchro,
remote(static_cast<simgrid::kernel::activity::CommImpl*>(remote_act)));
? simcall_mutex_lock__get__mutex(req)
: simcall_mutex_trylock__get__mutex(req)));
args = bprintf("locked = %d, owner = %d, sleeping = n/a", mutex.get_buffer()->is_locked(),
- mutex.get_buffer()->owner_ != nullptr
+ mutex.get_buffer()->get_owner() != nullptr
? (int)mc_model_checker->process()
- .resolve_actor(simgrid::mc::remote(mutex.get_buffer()->owner_))
+ .resolve_actor(simgrid::mc::remote(mutex.get_buffer()->get_owner()))
->get_pid()
: -1);
break;
Remote<kernel::activity::CommImpl> temp_comm;
mc_model_checker->process().read(temp_comm, remote(remote_act));
- kernel::activity::CommImpl* comm = temp_comm.get_buffer();
+ const kernel::activity::CommImpl* comm = temp_comm.get_buffer();
return comm->src_actor_.get() && comm->dst_actor_.get();
}
kernel::activity::ActivityImpl* remote_act = simcall_comm_wait__getraw__comm(req);
Remote<kernel::activity::CommImpl> temp_comm;
mc_model_checker->process().read(temp_comm, remote(static_cast<kernel::activity::CommImpl*>(remote_act)));
- kernel::activity::CommImpl* comm = temp_comm.get_buffer();
+ const kernel::activity::CommImpl* comm = temp_comm.get_buffer();
- smx_actor_t src_proc = mc_model_checker->process().resolve_actor(mc::remote(comm->src_actor_.get()));
- smx_actor_t dst_proc = mc_model_checker->process().resolve_actor(mc::remote(comm->dst_actor_.get()));
+ const kernel::actor::ActorImpl* src_proc =
+ mc_model_checker->process().resolve_actor(mc::remote(comm->src_actor_.get()));
+ const kernel::actor::ActorImpl* dst_proc =
+ mc_model_checker->process().resolve_actor(mc::remote(comm->dst_actor_.get()));
if (issuer->get_host())
label =
xbt::string_printf("[(%ld)%s] Wait [(%ld)->(%ld)]", issuer->get_pid(), MC_smx_actor_get_host_name(issuer),
kernel::activity::ActivityImpl* remote_act = simcall_comm_test__getraw__comm(req);
Remote<simgrid::kernel::activity::CommImpl> temp_comm;
mc_model_checker->process().read(temp_comm, remote(static_cast<kernel::activity::CommImpl*>(remote_act)));
- kernel::activity::CommImpl* comm = temp_comm.get_buffer();
+ const kernel::activity::CommImpl* comm = temp_comm.get_buffer();
if (comm->src_actor_.get() == nullptr || comm->dst_actor_.get() == nullptr) {
if (issuer->get_host())
label = xbt::string_printf("[(%ld)%s] Test FALSE", issuer->get_pid(), MC_smx_actor_get_host_name(issuer));
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
* @param target Local vector (to be filled with copies of `s_smx_actor_t`)
* @param remote_dynar Address of the process dynar in the remote list
*/
-static void MC_process_refresh_simix_actor_dynar(simgrid::mc::RemoteClient* process,
+static void MC_process_refresh_simix_actor_dynar(const simgrid::mc::RemoteClient* process,
std::vector<simgrid::mc::ActorInformation>& target,
simgrid::mc::RemotePtr<s_xbt_dynar_t> remote_dynar)
{
if (mc_model_checker == nullptr)
return actor->get_host()->get_cname();
- simgrid::mc::RemoteClient* process = &mc_model_checker->process();
+ const simgrid::mc::RemoteClient* process = &mc_model_checker->process();
// Read the simgrid::xbt::string in the MCed process:
simgrid::mc::ActorInformation* info = actor_info_cast(actor);
- auto remote_string_address = remote((simgrid::xbt::string_data*)&actor->get_host()->get_name());
+ auto remote_string_address =
+ remote(reinterpret_cast<const simgrid::xbt::string_data*>(&actor->get_host()->get_name()));
simgrid::xbt::string_data remote_string = process->read(remote_string_address);
char hostname[remote_string.len];
process->read_bytes(hostname, remote_string.len + 1, remote(remote_string.data));
const char* MC_smx_actor_get_name(smx_actor_t actor)
{
- simgrid::mc::RemoteClient* process = &mc_model_checker->process();
+ const simgrid::mc::RemoteClient* process = &mc_model_checker->process();
if (mc_model_checker == nullptr)
return actor->get_cname();
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
State::State(unsigned long state_number) : num_(state_number)
{
- this->internal_comm.clear();
- this->internal_req = s_smx_simcall();
- this->executed_req_ = s_smx_simcall();
+ this->internal_comm_.clear();
actor_states_.resize(MC_smx_get_maxpid());
/* Stateful model checking */
if ((_sg_mc_checkpoint > 0 && (state_number % _sg_mc_checkpoint == 0)) || _sg_mc_termination) {
- system_state = std::make_shared<simgrid::mc::Snapshot>(num_);
+ system_state_ = std::make_shared<simgrid::mc::Snapshot>(num_);
if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
MC_state_copy_incomplete_communications_pattern(this);
MC_state_copy_index_communications_pattern(this);
remote(static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_wait__getraw__comm(&actor->simcall)));
simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_act;
mc_model_checker->process().read(temp_act, remote_act);
- simgrid::kernel::activity::CommImpl* act = temp_act.get_buffer();
+ const simgrid::kernel::activity::CommImpl* act = temp_act.get_buffer();
if (act->src_actor_.get() && act->dst_actor_.get())
state->transition_.argument_ = 0; // OK
else if (act->src_actor_.get() == nullptr && act->type_ == simgrid::kernel::activity::CommImpl::Type::READY &&
state->transition_.pid_ = actor->get_pid();
state->executed_req_ = *req;
// Fetch the data of the request and translate it:
- state->internal_req = *req;
+ state->internal_req_ = *req;
/* The waitany and testany request are transformed into a wait or test request over the corresponding communication
* action so it can be treated later by the dependence function. */
switch (req->call_) {
case SIMCALL_COMM_WAITANY: {
- state->internal_req.call_ = SIMCALL_COMM_WAIT;
+ state->internal_req_.call_ = SIMCALL_COMM_WAIT;
simgrid::kernel::activity::CommImpl* remote_comm;
remote_comm = mc_model_checker->process().read(
remote(simcall_comm_waitany__get__comms(req) + state->transition_.argument_));
- mc_model_checker->process().read(state->internal_comm, remote(remote_comm));
- simcall_comm_wait__set__comm(&state->internal_req, state->internal_comm.get_buffer());
- simcall_comm_wait__set__timeout(&state->internal_req, 0);
+ mc_model_checker->process().read(state->internal_comm_, remote(remote_comm));
+ simcall_comm_wait__set__comm(&state->internal_req_, state->internal_comm_.get_buffer());
+ simcall_comm_wait__set__timeout(&state->internal_req_, 0);
break;
}
case SIMCALL_COMM_TESTANY:
- state->internal_req.call_ = SIMCALL_COMM_TEST;
+ state->internal_req_.call_ = SIMCALL_COMM_TEST;
if (state->transition_.argument_ > 0) {
simgrid::kernel::activity::CommImpl* remote_comm = mc_model_checker->process().read(
remote(simcall_comm_testany__get__comms(req) + state->transition_.argument_));
- mc_model_checker->process().read(state->internal_comm, remote(remote_comm));
+ mc_model_checker->process().read(state->internal_comm_, remote(remote_comm));
}
- simcall_comm_test__set__comm(&state->internal_req, state->internal_comm.get_buffer());
- simcall_comm_test__set__result(&state->internal_req, state->transition_.argument_);
+ simcall_comm_test__set__comm(&state->internal_req_, state->internal_comm_.get_buffer());
+ simcall_comm_test__set__result(&state->internal_req_, state->transition_.argument_);
break;
case SIMCALL_COMM_WAIT:
- mc_model_checker->process().read_bytes(&state->internal_comm, sizeof(state->internal_comm),
+ mc_model_checker->process().read_bytes(&state->internal_comm_, sizeof(state->internal_comm_),
remote(simcall_comm_wait__getraw__comm(req)));
- simcall_comm_wait__set__comm(&state->executed_req_, state->internal_comm.get_buffer());
- simcall_comm_wait__set__comm(&state->internal_req, state->internal_comm.get_buffer());
+ simcall_comm_wait__set__comm(&state->executed_req_, state->internal_comm_.get_buffer());
+ simcall_comm_wait__set__comm(&state->internal_req_, state->internal_comm_.get_buffer());
break;
case SIMCALL_COMM_TEST:
- mc_model_checker->process().read_bytes(&state->internal_comm, sizeof(state->internal_comm),
+ mc_model_checker->process().read_bytes(&state->internal_comm_, sizeof(state->internal_comm_),
remote(simcall_comm_test__getraw__comm(req)));
- simcall_comm_test__set__comm(&state->executed_req_, state->internal_comm.get_buffer());
- simcall_comm_test__set__comm(&state->internal_req, state->internal_comm.get_buffer());
+ simcall_comm_test__set__comm(&state->executed_req_, state->internal_comm_.get_buffer());
+ simcall_comm_test__set__comm(&state->internal_req_, state->internal_comm_.get_buffer());
break;
default:
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
* SIMCALL_COMM_TESTANY is translated to a SIMCALL_COMM_TEST
* and SIMCALL_COMM_WAITANY to a SIMCALL_COMM_WAIT.
*/
- s_smx_simcall internal_req;
+ s_smx_simcall internal_req_;
/* Can be used as a copy of the remote synchro object */
- simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> internal_comm;
+ simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> internal_comm_;
/** Snapshot of system state (if needed) */
- std::shared_ptr<simgrid::mc::Snapshot> system_state;
+ std::shared_ptr<simgrid::mc::Snapshot> system_state_;
// For CommunicationDeterminismChecker
std::vector<std::vector<simgrid::mc::PatternCommunication>> incomplete_comm_pattern_;
explicit State(unsigned long state_number);
std::size_t interleave_size() const;
- void add_interleaving_set(smx_actor_t actor) { this->actor_states_[actor->get_pid()].consider(); }
+ void add_interleaving_set(const simgrid::kernel::actor::ActorImpl* actor)
+ {
+ this->actor_states_[actor->get_pid()].consider();
+ }
Transition get_transition() const;
};
}
-/* Copyright (c) 2015-2019. The SimGrid Team.
+/* Copyright (c) 2015-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
}
public:
- Channel() = default;
explicit Channel(int sock) : socket_(sock) {}
~Channel();
Channel(Channel const&) = delete;
Channel& operator=(Channel const&) = delete;
- // Move:
- Channel(Channel&& that) : socket_(that.socket_) { that.socket_ = -1; }
- Channel& operator=(Channel&& that)
- {
- this->socket_ = that.socket_;
- that.socket_ = -1;
- return *this;
- }
-
// Send
int send(const void* message, size_t size) const;
int send(e_mc_message_type type) const
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
_sg_do_model_check = 1;
// Fetch socket from MC_ENV_SOCKET_FD:
- char* fd_env = std::getenv(MC_ENV_SOCKET_FD);
+ const char* fd_env = std::getenv(MC_ENV_SOCKET_FD);
if (not fd_env)
xbt_die("No MC socket passed in the environment");
int fd =
return instance_.get();
}
-void Client::handle_deadlock_check(s_mc_message_t*)
+void Client::handle_deadlock_check(const s_mc_message_t*)
{
bool deadlock = false;
if (not simix_global->process_list.empty()) {
s_mc_message_int_t answer{MC_MESSAGE_DEADLOCK_CHECK_REPLY, deadlock};
xbt_assert(channel_.send(answer) == 0, "Could not send response");
}
-void Client::handle_continue(s_mc_message_t*)
+void Client::handle_continue(const s_mc_message_t*)
{
/* Nothing to do */
}
-void Client::handle_simcall(s_mc_message_simcall_handle_t* message)
+void Client::handle_simcall(const s_mc_message_simcall_handle_t* message)
{
smx_actor_t process = SIMIX_process_from_PID(message->pid);
if (not process)
xbt_die("Could not send MESSAGE_WAITING to model-checker");
}
-void Client::handle_actor_enabled(s_mc_message_actor_enabled_t* msg)
+void Client::handle_actor_enabled(const s_mc_message_actor_enabled_t* msg)
{
bool res = simgrid::mc::actor_is_enabled(SIMIX_process_from_PID(msg->aid));
s_mc_message_int_t answer{MC_MESSAGE_ACTOR_ENABLED_REPLY, res};
if (received_size < 0)
xbt_die("Could not receive commands from the model-checker");
- s_mc_message_t* message = (s_mc_message_t*)message_buffer;
+ const s_mc_message_t* message = (s_mc_message_t*)message_buffer;
switch (message->type) {
-
case MC_MESSAGE_DEADLOCK_CHECK:
xbt_assert(received_size == sizeof(s_mc_message_t), "Unexpected size for DEADLOCK_CHECK (%zd != %zu)",
received_size, sizeof(s_mc_message_t));
void Client::ignore_heap(void* address, std::size_t size)
{
- xbt_mheap_t heap = mmalloc_get_current_heap();
+ const s_xbt_mheap_t* heap = mmalloc_get_current_heap();
s_mc_message_ignore_heap_t message;
message.type = MC_MESSAGE_IGNORE_HEAP;
void Client::declare_stack(void* stack, size_t size, ucontext_t* context)
{
- xbt_mheap_t heap = mmalloc_get_current_heap();
+ const s_xbt_mheap_t* heap = mmalloc_get_current_heap();
s_stack_region_t region;
memset(®ion, 0, sizeof(region));
if (channel_.send(message))
xbt_die("Could not send STACK_REGION to model-checker");
}
-}
-}
+} // namespace mc
+} // namespace simgrid
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
void handle_messages();
private:
- void handle_deadlock_check(s_mc_message_t* msg);
- void handle_continue(s_mc_message_t* msg);
- void handle_simcall(s_mc_message_simcall_handle_t* message);
- void handle_actor_enabled(s_mc_message_actor_enabled_t* msg);
+ void handle_deadlock_check(const s_mc_message_t* msg);
+ void handle_continue(const s_mc_message_t* msg);
+ void handle_simcall(const s_mc_message_simcall_handle_t* message);
+ void handle_actor_enabled(const s_mc_message_actor_enabled_t* msg);
public:
Channel const& get_channel() const { return channel_; }
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
continue;
xbt_assert(c > 0, "Could not read string from remote process");
- void* p = memchr(res.data() + off, '\0', c);
+ const void* p = memchr(res.data() + off, '\0', c);
if (p)
return std::string(res.data());
}
unsigned int cursor = 0;
- IgnoredRegion* current_region = nullptr;
+ const IgnoredRegion* current_region = nullptr;
int start = 0;
int end = ignored_regions_.size() - 1;
size_type cursor;
while (start <= end) {
cursor = start + (end - start) / 2;
- auto& current_region = ignored_heap_[cursor];
+ auto const& current_region = ignored_heap_[cursor];
if (current_region.address == region.address)
return;
else if (current_region.address < region.address)
size_type cursor;
while (start <= end) {
cursor = (start + end) / 2;
- auto& region = ignored_heap_[cursor];
+ auto const& region = ignored_heap_[cursor];
if (region.address < address)
start = cursor + 1;
else if ((char*)region.address <= ((char*)address + size)) {
return;
}
- simgrid::mc::dumpStack(stderr, std::move(cursor));
+ simgrid::mc::dumpStack(stderr, &cursor);
_UPT_destroy(context);
unw_destroy_addr_space(as);
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
* as a `uint64_t`.
*/
template <class T> class RemotePtr {
- std::uint64_t address_;
+ std::uint64_t address_ = 0;
public:
- RemotePtr() : address_(0) {}
- explicit RemotePtr(std::nullptr_t) : address_(0) {}
+ RemotePtr() = default;
+ explicit RemotePtr(std::nullptr_t) {}
explicit RemotePtr(std::uint64_t address) : address_(address) {}
explicit RemotePtr(T* address) : address_((std::uintptr_t)address) {}
explicit RemotePtr(Remote<T*> p) : address_((std::uintptr_t)*p.get_buffer()) {}
-/* Copyright (c) 2015-2019. The SimGrid Team.
+/* Copyright (c) 2015-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
* @param page_count Number of pages of the region
* @return Snapshot page numbers of this new snapshot
*/
-ChunkedData::ChunkedData(PageStore& store, AddressSpace& as, RemotePtr<void> addr, std::size_t page_count)
+ChunkedData::ChunkedData(PageStore& store, const AddressSpace& as, RemotePtr<void> addr, std::size_t page_count)
+ : store_(&store)
{
- store_ = &store;
this->pagenos_.resize(page_count);
std::vector<char> buffer(xbt_pagesize);
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
for (std::size_t const& pageno : pagenos_)
store_->ref_page(pageno);
}
- ChunkedData(ChunkedData&& that) : store_(that.store_), pagenos_(std::move(that.pagenos_))
+ ChunkedData(ChunkedData&& that) : pagenos_(std::move(that.pagenos_))
{
- that.store_ = nullptr;
+ std::swap(store_, that.store_);
that.pagenos_.clear();
}
ChunkedData& operator=(ChunkedData const& that)
const std::size_t* pagenos() const { return pagenos_.data(); }
/** Get a a pointer to a chunk */
- const void* page(std::size_t i) const { return store_->get_page(pagenos_[i]); }
+ void* page(std::size_t i) const { return store_->get_page(pagenos_[i]); }
- ChunkedData(PageStore& store, AddressSpace& as, RemotePtr<void> addr, std::size_t page_count);
+ ChunkedData(PageStore& store, const AddressSpace& as, RemotePtr<void> addr, std::size_t page_count);
};
} // namespace mc
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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 Compute a hash for the given memory page
*
- * The page is used before inserting the page in the page store
- * in order to find duplicate of this page in the page store.
+ * The page is used before inserting the page in the page store in order to find duplicate of this page in the page
+ * store.
*
* @param data Memory page
* @return hash off the page
// ***** snapshot_page_manager
-PageStore::PageStore(std::size_t size) : memory_(nullptr), capacity_(size), top_index_(0)
+PageStore::PageStore(std::size_t size) : capacity_(size)
{
// Using mmap in order to be able to expand the region by relocating it somewhere else in the virtual memory space:
void* memory =
std::size_t PageStore::alloc_page()
{
if (this->free_pages_.empty()) {
-
// Expand the region:
if (this->top_index_ == this->capacity_)
// All the pages are allocated, we need add more pages:
// Use a page from the top:
return this->top_index_++;
-
} else {
-
// Use a page from free_pages_ (inside of the region):
size_t res = this->free_pages_[this->free_pages_.size() - 1];
this->free_pages_.pop_back();
}
/** Store a page in memory */
-std::size_t PageStore::store_page(void* page)
+std::size_t PageStore::store_page(const void* page)
{
xbt_assert(top_index_ <= this->capacity_, "top_index is not consistent");
for (size_t const& pageno : page_set) {
const void* snapshot_page = this->get_page(pageno);
if (memcmp(page, snapshot_page, xbt_pagesize) == 0) {
-
// If a page with the same content is already in the page store it's reused and its refcount is incremented.
page_counts_[pageno]++;
return pageno;
// Otherwise, a new page is allocated in the page store and the content of the page is `memcpy()`-ed to this new page.
std::size_t pageno = alloc_page();
xbt_assert(this->page_counts_[pageno] == 0, "Allocated page is already used");
- void* snapshot_page = (void*)this->get_page(pageno);
+ void* snapshot_page = this->get_page(pageno);
memcpy(snapshot_page, page, xbt_pagesize);
page_set.insert(pageno);
page_counts_[pageno]++;
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
void ref_page(size_t pageno);
/** @brief Store a page in the page store */
- std::size_t store_page(void* page);
+ std::size_t store_page(const void* page);
/** @brief Get a page from its page number
*
* @param pageno Number of the memory page in the store
* @return Start of the page
*/
- const void* get_page(std::size_t pageno) const;
+ void* get_page(std::size_t pageno) const;
// Debug/test methods
++this->page_counts_[pageno];
}
-XBT_ALWAYS_INLINE const void* PageStore::get_page(std::size_t pageno) const
+XBT_ALWAYS_INLINE void* PageStore::get_page(std::size_t pageno) const
{
return (void*)simgrid::mc::mmu::join(pageno, (std::uintptr_t)this->memory_);
}
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
}
}
-static XBT_ALWAYS_INLINE void* mc_translate_address_region(uintptr_t addr, simgrid::mc::Region* region)
+static XBT_ALWAYS_INLINE void* mc_translate_address_region(uintptr_t addr, const simgrid::mc::Region* region)
{
auto split = simgrid::mc::mmu::split(addr - region->start().address());
auto pageno = split.first;
auto offset = split.second;
- const void* snapshot_page = region->get_chunks().page(pageno);
+ void* snapshot_page = region->get_chunks().page(pageno);
return (char*)snapshot_page + offset;
}
-void* Region::read(void* target, const void* addr, std::size_t size)
+void* Region::read(void* target, const void* addr, std::size_t size) const
{
xbt_assert(contain(simgrid::mc::remote(addr)), "Trying to read out of the region boundary.");
// Last byte of the region:
- void* end = (char*)addr + size - 1;
+ const void* end = (const char*)addr + size - 1;
if (simgrid::mc::mmu::same_chunk((std::uintptr_t)addr, (std::uintptr_t)end)) {
// The memory is contained in a single page:
return mc_translate_address_region((uintptr_t)addr, this);
// Read each page:
while (simgrid::mc::mmu::split((std::uintptr_t)addr).first != page_end) {
- void* snapshot_addr = mc_translate_address_region((uintptr_t)addr, this);
+ const void* snapshot_addr = mc_translate_address_region((uintptr_t)addr, this);
void* next_page = (void*)simgrid::mc::mmu::join(simgrid::mc::mmu::split((std::uintptr_t)addr).first + 1, 0);
- size_t readable = (char*)next_page - (char*)addr;
+ size_t readable = (char*)next_page - (const char*)addr;
memcpy(dest, snapshot_addr, readable);
- addr = (char*)addr + readable;
+ addr = (const char*)addr + readable;
dest = (char*)dest + readable;
size -= readable;
}
// Read the end:
- void* snapshot_addr = mc_translate_address_region((uintptr_t)addr, this);
+ const void* snapshot_addr = mc_translate_address_region((uintptr_t)addr, this);
memcpy(dest, snapshot_addr, size);
return target;
* @param region2 Region of the address in the second snapshot
* @return same semantic as memcmp
*/
-int MC_snapshot_region_memcmp(const void* addr1, simgrid::mc::Region* region1, const void* addr2,
- simgrid::mc::Region* region2, size_t size)
+int MC_snapshot_region_memcmp(const void* addr1, const simgrid::mc::Region* region1, const void* addr2,
+ const simgrid::mc::Region* region2, size_t size)
{
// Using alloca() for large allocations may trigger stack overflow:
// use malloc if the buffer is too big.
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
* @param size Size of the data to read in bytes
* @return Pointer where the data is located (either target buffer or original location)
*/
- void* read(void* target, const void* addr, std::size_t size);
+ void* read(void* target, const void* addr, std::size_t size) const;
};
} // namespace mc
} // namespace simgrid
-int MC_snapshot_region_memcmp(const void* addr1, simgrid::mc::Region* region1, const void* addr2,
- simgrid::mc::Region* region2, std::size_t size);
+int MC_snapshot_region_memcmp(const void* addr1, const simgrid::mc::Region* region1, const void* addr2,
+ const simgrid::mc::Region* region2, std::size_t size);
-static XBT_ALWAYS_INLINE void* MC_region_read_pointer(simgrid::mc::Region* region, const void* addr)
+static XBT_ALWAYS_INLINE void* MC_region_read_pointer(const simgrid::mc::Region* region, const void* addr)
{
void* res;
return *(void**)region->read(&res, addr, sizeof(void*));
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
/************************************* Take Snapshot ************************************/
/****************************************************************************************/
-void simgrid::mc::Snapshot::snapshot_regions(simgrid::mc::RemoteClient* process)
+void Snapshot::snapshot_regions(RemoteClient* process)
{
snapshot_regions_.clear();
for (auto const& object_info : process->object_infos)
- add_region(simgrid::mc::RegionType::Data, object_info.get(), object_info->start_rw,
- object_info->end_rw - object_info->start_rw);
+ add_region(RegionType::Data, object_info.get(), object_info->start_rw, object_info->end_rw - object_info->start_rw);
- xbt_mheap_t heap = process->get_heap();
+ const s_xbt_mheap_t* heap = process->get_heap();
void* start_heap = heap->base;
void* end_heap = heap->breakval;
- add_region(simgrid::mc::RegionType::Heap, nullptr, start_heap, (char*)end_heap - (char*)start_heap);
+ add_region(RegionType::Heap, nullptr, start_heap, (char*)end_heap - (char*)start_heap);
heap_bytes_used_ = mmalloc_get_bytes_used_remote(heap->heaplimit, process->get_malloc_info());
}
* @param ip Instruction pointer
* @return true if the variable is valid
* */
-static bool valid_variable(simgrid::mc::Variable* var, simgrid::mc::Frame* scope, const void* ip)
+static bool valid_variable(const simgrid::mc::Variable* var, simgrid::mc::Frame* scope, const void* ip)
{
// The variable is not yet valid:
if (scope->range.begin() + var->start_scope > (std::uint64_t)ip)
return true;
}
-static void fill_local_variables_values(mc_stack_frame_t stack_frame, simgrid::mc::Frame* scope,
+static void fill_local_variables_values(mc_stack_frame_t stack_frame, Frame* scope,
std::vector<s_local_variable_t>& result)
{
if (not scope || not scope->range.contain(stack_frame->ip))
return;
- for (simgrid::mc::Variable& current_variable : scope->variables) {
-
+ for (const Variable& current_variable : scope->variables) {
if (not valid_variable(¤t_variable, scope, (void*)stack_frame->ip))
continue;
if (current_variable.address != nullptr)
new_var.address = current_variable.address;
else if (not current_variable.location_list.empty()) {
- simgrid::dwarf::Location location = simgrid::dwarf::resolve(
- current_variable.location_list, current_variable.object_info, &(stack_frame->unw_cursor),
- (void*)stack_frame->frame_base, &mc_model_checker->process());
+ dwarf::Location location = simgrid::dwarf::resolve(current_variable.location_list, current_variable.object_info,
+ &(stack_frame->unw_cursor), (void*)stack_frame->frame_base,
+ &mc_model_checker->process());
if (not location.in_memory())
xbt_die("Cannot handle non-address variable");
new_var.address = location.address();
-
} else
xbt_die("No address");
}
// Recursive processing of nested scopes:
- for (simgrid::mc::Frame& nested_scope : scope->scopes)
+ for (Frame& nested_scope : scope->scopes)
fill_local_variables_values(stack_frame, &nested_scope, result);
}
return variables;
}
-static std::vector<s_mc_stack_frame_t> unwind_stack_frames(simgrid::mc::UnwindContext* stack_context)
+static std::vector<s_mc_stack_frame_t> unwind_stack_frames(UnwindContext* stack_context)
{
- simgrid::mc::RemoteClient* process = &mc_model_checker->process();
+ const RemoteClient* process = &mc_model_checker->process();
std::vector<s_mc_stack_frame_t> result;
unw_cursor_t c = stack_context->cursor();
// TODO, check condition check (unw_init_local==0 means end of frame)
while (1) {
-
s_mc_stack_frame_t stack_frame;
stack_frame.unw_cursor = c;
// TODO, use real addresses in frame_t instead of fixing it here
- simgrid::mc::Frame* frame = process->find_function(remote(ip));
+ Frame* frame = process->find_function(remote(ip));
stack_frame.frame = frame;
if (frame) {
return result;
}
-void simgrid::mc::Snapshot::snapshot_stacks(simgrid::mc::RemoteClient* process)
+void Snapshot::snapshot_stacks(RemoteClient* process)
{
for (auto const& stack : process->stack_areas()) {
s_mc_snapshot_stack_t st;
}
}
-static void snapshot_handle_ignore(simgrid::mc::Snapshot* snapshot)
+static void snapshot_handle_ignore(Snapshot* snapshot)
{
xbt_assert(snapshot->process());
for (auto const& region : snapshot->process()->ignored_regions())
snapshot->process()->clear_bytes(remote(region.addr), region.size);
}
-static void snapshot_ignore_restore(simgrid::mc::Snapshot* snapshot)
+
+static void snapshot_ignore_restore(const simgrid::mc::Snapshot* snapshot)
{
for (auto const& ignored_data : snapshot->ignored_data_)
snapshot->process()->write_bytes(ignored_data.data.data(), ignored_data.data.size(), remote(ignored_data.start));
}
-Snapshot::Snapshot(int num_state, RemoteClient* process)
- : AddressSpace(process), num_state_(num_state), heap_bytes_used_(0), enabled_processes_(), hash_(0)
+Snapshot::Snapshot(int num_state, RemoteClient* process) : AddressSpace(process), num_state_(num_state)
{
XBT_DEBUG("Taking snapshot %i", num_state);
void Snapshot::add_region(RegionType type, ObjectInformation* object_info, void* start_addr, std::size_t size)
{
- if (type == simgrid::mc::RegionType::Data)
+ if (type == RegionType::Data)
xbt_assert(object_info, "Missing object info for object.");
- else if (type == simgrid::mc::RegionType::Heap)
+ else if (type == RegionType::Heap)
xbt_assert(not object_info, "Unexpected object info for heap region.");
- simgrid::mc::Region* region = new Region(type, start_addr, size);
+ Region* region = new Region(type, start_addr, size);
region->object_info(object_info);
- snapshot_regions_.push_back(std::unique_ptr<simgrid::mc::Region>(std::move(region)));
+ snapshot_regions_.push_back(std::unique_ptr<Region>(std::move(region)));
}
void* Snapshot::read_bytes(void* buffer, std::size_t size, RemotePtr<void> address, ReadOptions options) const
{
- Region* region = this->get_region((void*)address.address());
+ const Region* region = this->get_region((void*)address.address());
if (region) {
void* res = region->read(buffer, (void*)address.address(), size);
if (buffer == res || options & ReadOptions::lazy())
XBT_DEBUG("Restore snapshot %i", num_state_);
// Restore regions
- for (std::unique_ptr<simgrid::mc::Region> const& region : snapshot_regions_) {
+ for (std::unique_ptr<Region> const& region : snapshot_regions_) {
if (region) // privatized variables are not snapshotted
region.get()->restore();
}
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
/* Regular use */
bool on_heap(const void* address) const
{
- const xbt_mheap_t heap = process()->get_heap();
+ const s_xbt_mheap_t* heap = process()->get_heap();
return address >= heap->heapbase && address < heap->breakval;
}
// To be private
int num_state_;
- std::size_t heap_bytes_used_;
+ std::size_t heap_bytes_used_ = 0;
std::vector<std::unique_ptr<Region>> snapshot_regions_;
std::set<pid_t> enabled_processes_;
std::vector<std::size_t> stack_sizes_;
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
void snap_test_helper::read_whole_region()
{
for (int n = 1; n != 32; ++n) {
-
prologue_return ret = prologue(n);
const void* read = ret.region->read(ret.dstn, ret.src, ret.size);
INFO("Mismatch in MC_region_read()");
void snap_test_helper::read_region_parts()
{
for (int n = 1; n != 32; ++n) {
-
prologue_return ret = prologue(n);
for (int j = 0; j != 100; ++j) {
void snap_test_helper::compare_region_parts()
{
for (int n = 1; n != 32; ++n) {
-
prologue_return ret = prologue(n);
for (int j = 0; j != 100; ++j) {
void snap_test_helper::read_pointer()
{
-
prologue_return ret = prologue(1);
memcpy(ret.src, &mc_model_checker, sizeof(void*));
- simgrid::mc::Region* region2 = new simgrid::mc::Region(simgrid::mc::RegionType::Data, ret.src, ret.size);
+ const simgrid::mc::Region* region2 = new simgrid::mc::Region(simgrid::mc::RegionType::Data, ret.src, ret.size);
INFO("Mismtach in MC_region_read_pointer()");
REQUIRE(MC_region_read_pointer(region2, ret.src) == mc_model_checker);
TEST_CASE("MC::Snapshot: A copy/snapshot of a given memory region", "MC::Snapshot")
{
-
INFO("Sparse snapshot (using pages)");
snap_test_helper::Init();
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
* @return the position of the finished communication if any
* (but it may have failed, use MSG_comm_get_status() to know its status), or -1 if none is finished
*/
-int MSG_comm_testany(xbt_dynar_t comms)
+int MSG_comm_testany(const_xbt_dynar_t comms)
{
int finished_index = -1;
}
/** @brief Destroys the provided communication. */
-void MSG_comm_destroy(msg_comm_t comm)
+void MSG_comm_destroy(const_msg_comm_t comm)
{
delete comm;
}
* @return the position of the first finished communication
* (but it may have failed, use MSG_comm_get_status() to know its status)
*/
-int MSG_comm_waitany(xbt_dynar_t comms)
+int MSG_comm_waitany(const_xbt_dynar_t comms)
{
int finished_index = -1;
* @param comm a finished communication
* @return the status of the communication, or #MSG_OK if no error occurred during the communication
*/
-msg_error_t MSG_comm_get_status(msg_comm_t comm)
+msg_error_t MSG_comm_get_status(const_msg_comm_t comm)
{
-
return comm->get_status();
}
* @param comm the communication where to get the task
* @return the task from the communication
*/
-msg_task_t MSG_comm_get_task(msg_comm_t comm)
+msg_task_t MSG_comm_get_task(const_msg_comm_t comm)
{
xbt_assert(comm, "Invalid parameter");
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
}
/* ************************** Actors *************************** */
-int MSG_process_get_PID(sg_actor_t actor)
+int MSG_process_get_PID(const_sg_actor_t actor)
{
return sg_actor_get_PID(actor);
}
-int MSG_process_get_PPID(sg_actor_t actor)
+int MSG_process_get_PPID(const_sg_actor_t actor)
{
return sg_actor_get_PPID(actor);
}
{
return sg_actor_by_PID(PID);
}
-const char* MSG_process_get_name(sg_actor_t actor)
+const char* MSG_process_get_name(const_sg_actor_t actor)
{
return sg_actor_get_name(actor);
}
-sg_host_t MSG_process_get_host(sg_actor_t actor)
+sg_host_t MSG_process_get_host(const_sg_actor_t actor)
{
return sg_actor_get_host(actor);
}
-xbt_dict_t MSG_process_get_properties(sg_actor_t actor)
+xbt_dict_t MSG_process_get_properties(const_sg_actor_t actor)
{
return sg_actor_get_properties(actor);
}
-const char* MSG_process_get_property_value(sg_actor_t actor, const char* name)
+const char* MSG_process_get_property_value(const_sg_actor_t actor, const char* name)
{
return sg_actor_get_property_value(actor, name);
}
*
* This function checks whether @a process is a valid pointer and returns the user data associated to this process.
*/
-void* MSG_process_get_data(msg_process_t process)
+void* MSG_process_get_data(const_sg_actor_t process)
{
xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
}
/** @brief Take an extra reference on that process to prevent it to be garbage-collected */
-void MSG_process_ref(msg_process_t process)
+void MSG_process_ref(const_sg_actor_t process)
{
sg_actor_ref(process);
}
/** @brief Release a reference on that process so that it can get be garbage-collected */
-void MSG_process_unref(msg_process_t process)
+void MSG_process_unref(const_sg_actor_t process)
{
sg_actor_unref(process);
}
{
return sg_zone_get_root();
}
-const char* MSG_zone_get_name(sg_netzone_t zone)
+const char* MSG_zone_get_name(const_sg_netzone_t zone)
{
return sg_zone_get_name(zone);
}
{
return sg_zone_get_by_name(name);
}
-void MSG_zone_get_sons(sg_netzone_t zone, xbt_dict_t whereto)
+void MSG_zone_get_sons(const_sg_netzone_t zone, xbt_dict_t whereto)
{
return sg_zone_get_sons(zone, whereto);
}
-const char* MSG_zone_get_property_value(sg_netzone_t zone, const char* name)
+const char* MSG_zone_get_property_value(const_sg_netzone_t zone, const char* name)
{
return sg_zone_get_property_value(zone, name);
}
-void MSG_zone_set_property_value(sg_netzone_t zone, const char* name, char* value)
+void MSG_zone_set_property_value(sg_netzone_t zone, const char* name, const char* value)
{
sg_zone_set_property_value(zone, name, value);
}
-void MSG_zone_get_hosts(sg_netzone_t zone, xbt_dynar_t whereto)
+void MSG_zone_get_hosts(const_sg_netzone_t zone, xbt_dynar_t whereto)
{
sg_zone_get_hosts(zone, whereto);
}
/* ************************** Storages *************************** */
-const char* MSG_storage_get_name(sg_storage_t storage)
+const char* MSG_storage_get_name(const_sg_storage_t storage)
{
return sg_storage_get_name(storage);
}
{
return sg_storage_get_by_name(name);
}
-xbt_dict_t MSG_storage_get_properties(sg_storage_t storage)
+xbt_dict_t MSG_storage_get_properties(const_sg_storage_t storage)
{
return sg_storage_get_properties(storage);
}
{
sg_storage_set_property_value(storage, name, value);
}
-const char* MSG_storage_get_property_value(sg_storage_t storage, const char* name)
+const char* MSG_storage_get_property_value(const_sg_storage_t storage, const char* name)
{
return sg_storage_get_property_value(storage, name);
}
{
sg_storage_set_data(storage, data);
}
-void* MSG_storage_get_data(sg_storage_t storage)
+void* MSG_storage_get_data(const_sg_storage_t storage)
{
return sg_storage_get_data(storage);
}
-const char* MSG_storage_get_host(sg_storage_t storage)
+const char* MSG_storage_get_host(const_sg_storage_t storage)
{
return sg_storage_get_host(storage);
}
{
return sg_host_by_name(name);
}
-const char* MSG_host_get_name(sg_host_t host)
+const char* MSG_host_get_name(const_sg_host_t host)
{
return sg_host_get_name(host);
}
-void* MSG_host_get_data(sg_host_t host)
+void* MSG_host_get_data(const_sg_host_t host)
{
return sg_host_data(host);
}
{
return sg_host_get_mounted_storage_list(host);
}
-xbt_dynar_t MSG_host_get_attached_storage_lists(sg_host_t host)
+xbt_dynar_t MSG_host_get_attached_storage_lists(const_sg_host_t host)
{
return sg_host_get_attached_storage_list(host);
}
-double MSG_host_get_speed(sg_host_t host)
+double MSG_host_get_speed(const_sg_host_t host)
{
return sg_host_speed(host);
}
-double MSG_host_get_power_peak_at(sg_host_t host, int pstate_index)
+double MSG_host_get_power_peak_at(const_sg_host_t host, int pstate_index)
{
return sg_host_get_pstate_speed(host, pstate_index);
}
-int MSG_host_get_core_number(sg_host_t host)
+int MSG_host_get_core_number(const_sg_host_t host)
{
return sg_host_core_count(host);
}
-int MSG_host_get_nb_pstates(sg_host_t host)
+int MSG_host_get_nb_pstates(const_sg_host_t host)
{
return sg_host_get_nb_pstates(host);
}
-int MSG_host_get_pstate(sg_host_t host)
+int MSG_host_get_pstate(const_sg_host_t host)
{
return sg_host_get_pstate(host);
}
{
sg_host_turn_off(h);
}
-int MSG_host_is_on(sg_host_t h)
+int MSG_host_is_on(const_sg_host_t h)
{
return sg_host_is_on(h);
}
-xbt_dict_t MSG_host_get_properties(sg_host_t host)
+xbt_dict_t MSG_host_get_properties(const_sg_host_t host)
{
return sg_host_get_properties(host);
}
-const char* MSG_host_get_property_value(sg_host_t host, const char* name)
+const char* MSG_host_get_property_value(const_sg_host_t host, const char* name)
{
return sg_host_get_property_value(host, name);
}
{
sg_host_set_property_value(host, name, value);
}
-void MSG_host_get_process_list(sg_host_t host, xbt_dynar_t whereto)
+void MSG_host_get_process_list(const_sg_host_t host, xbt_dynar_t whereto)
{
sg_host_get_actor_list(host, whereto);
}
return sg_host_self();
}
-double MSG_host_get_load(sg_host_t host)
+double MSG_host_get_load(const_sg_host_t host)
{
return sg_host_load(host);
}
{
return sg_vm_is_suspended(vm);
}
-const char* MSG_vm_get_name(sg_vm_t vm)
+const char* MSG_vm_get_name(const_sg_vm_t vm)
{
return sg_vm_get_name(vm);
}
{
sg_vm_set_ramsize(vm, size);
}
-size_t MSG_vm_get_ramsize(sg_vm_t vm)
+size_t MSG_vm_get_ramsize(const_sg_vm_t vm)
{
return sg_vm_get_ramsize(vm);
}
-sg_host_t MSG_vm_get_pm(sg_vm_t vm)
+sg_host_t MSG_vm_get_pm(const_sg_vm_t vm)
{
return sg_vm_get_pm(vm);
}
return sg_barrier_init(count);
}
-void MSG_barrier_destroy(sg_bar_t bar)
+void MSG_barrier_destroy(const_sg_bar_t bar)
{
sg_barrier_destroy(bar);
}
{
return sg_sem_get_capacity(sem);
}
-void MSG_sem_destroy(sg_sem_t sem)
+void MSG_sem_destroy(const_sg_sem_t sem)
{
sg_sem_destroy(sem);
}
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
/**************** datatypes **********************************/
namespace simgrid {
+
+extern template class XBT_PUBLIC xbt::Extendable<msg::Task>;
+
namespace msg {
class Task : public xbt::Extendable<Task> {
std::string name_ = "";
Task& operator=(const Task&) = delete;
~Task() = default;
- bool is_used() { return is_used_; }
- bool is_parallel() { return parallel_; }
+ bool is_used() const { return is_used_; }
+ bool is_parallel() const { return parallel_; }
void set_used();
void set_not_used() { this->is_used_ = false; }
const std::string& get_name() const { return name_; }
- const char* get_cname() { return name_.c_str(); }
+ const char* get_cname() const { return name_.c_str(); }
void set_name(const char* new_name) { name_ = std::string(new_name); }
- void set_tracing_category(const char* category) { tracing_category_ = category ? std::string(category) : ""; }
- const std::string& get_tracing_category() { return tracing_category_; }
+ void set_tracing_category(const char* category) { tracing_category_ = category ? category : ""; }
+ const std::string& get_tracing_category() const { return tracing_category_; }
bool has_tracing_category() { return not tracing_category_.empty(); }
XBT_ATTRIB_DEPRECATED_v329("Please use set_data()") void* get_user_data() { return get_data(); }
XBT_ATTRIB_DEPRECATED_v329("Please use get_data()") void set_user_data(void* data) { set_data(data); }
- long long int get_id() { return id_; }
- double get_priority() { return priority_; }
+ long long int get_id() const { return id_; }
+ double get_priority() const { return priority_; }
void set_priority(double priority);
void set_bound(double bound) { bound_ = bound; }
- double get_bound() { return bound_; }
+ double get_bound() const { return bound_; }
void set_rate(double rate) { rate_ = rate; }
- double get_rate() { return rate_; }
+ double get_rate() const { return rate_; }
void set_timeout(double timeout) { timeout_ = timeout; }
- s4u::Actor* get_sender();
- s4u::Host* get_source();
+ s4u::Actor* get_sender() const;
+ s4u::Host* get_source() const;
s4u::ExecPtr compute = nullptr; /* S4U modeling of computation */
s4u::CommPtr comm = nullptr; /* S4U modeling of communication */
bool test();
msg_error_t wait_for(double timeout);
void set_status(msg_error_t status) { status_ = status; }
- msg_error_t get_status() { return status_; }
+ msg_error_t get_status() const { return status_; }
};
} // namespace msg
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
* @param name a name for the object. It is for user-level information and can be nullptr.
* @param code is a function describing the behavior of the process.
* @param data a pointer to any data one may want to attach to the new object. It is for user-level information and
- * can be nullptr. It can be retrieved with the function @ref MSG_process_get_data.
+ * can be nullptr. It can be retrieved with the function MSG_process_get_data().
* @param host the location where the new process is executed.
* @param argc first argument passed to @a code
* @param argv second argument passed to @a code
* @param name a name for the object. It is for user-level information and can be nullptr.
* @param code is a function describing the behavior of the process.
* @param data a pointer to any data one may want to attach to the new object. It is for user-level information and
- * can be nullptr. It can be retrieved with the function @ref MSG_process_get_data.
+ * can be nullptr. It can be retrieved with the function MSG_process_get_data().
* @param host the location where the new process is executed.
* @param argc first argument passed to @a code
* @param argv second argument passed to @a code. WARNING, these strings are freed by the SimGrid kernel when the
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_task, msg, "Logging specific to MSG (task)");
namespace simgrid {
+
+template class xbt::Extendable<msg::Task>;
+
namespace msg {
Task::Task(const std::string& name, double flops_amount, double bytes_amount, void* data)
compute->set_name(name_)
->set_tracing_category(tracing_category_)
- ->set_timeout(timeout_)
->set_priority(1 / priority_)
->set_bound(bound_)
- ->wait();
+ ->wait_for(timeout_);
set_not_used();
XBT_DEBUG("Execution task '%s' finished", get_cname());
priority_ = 1.0 / priority;
}
-s4u::Actor* Task::get_sender()
+s4u::Actor* Task::get_sender() const
{
return comm ? comm->get_sender() : nullptr;
}
-s4u::Host* Task::get_source()
+s4u::Host* Task::get_source() const
{
return comm ? comm->get_sender()->get_host() : nullptr;
}
* @param message_size a value of the amount of data (in bytes) needed to transfer this new task. If 0, then it cannot
* be transferred with MSG_task_send() and MSG_task_recv(). This value has to be >=0.
* @param data a pointer to any data may want to attach to the new object. It is for user-level information and can
- * be nullptr. It can be retrieved with the function @ref MSG_task_get_data.
+ * be nullptr. It can be retrieved with the function MSG_task_get_data().
* @return The new corresponding object.
*/
msg_task_t MSG_task_create(const char *name, double flop_amount, double message_size, void *data)
{
- return simgrid::msg::Task::create(name ? std::string(name) : "", flop_amount, message_size, data);
+ return simgrid::msg::Task::create(name ? name : "", flop_amount, message_size, data);
}
/** @brief Creates a new parallel task
* @param bytes_amount an array of @p host_nb* @p host_nb doubles.
* @param data a pointer to any data may want to attach to the new object.
* It is for user-level information and can be nullptr.
- * It can be retrieved with the function @ref MSG_task_get_data().
+ * It can be retrieved with the function MSG_task_get_data().
*/
msg_task_t MSG_parallel_task_create(const char *name, int host_nb, const msg_host_t * host_list,
double *flops_amount, double *bytes_amount, void *data)
}
/** @brief Return the user data of the given task */
-void* MSG_task_get_data(msg_task_t task)
+void* MSG_task_get_data(const_msg_task_t task)
{
return task->get_data();
}
}
/** @brief Returns the sender of the given task */
-msg_process_t MSG_task_get_sender(msg_task_t task)
+msg_process_t MSG_task_get_sender(const_msg_task_t task)
{
return task->get_sender();
}
/** @brief Returns the source (the sender's host) of the given task */
-msg_host_t MSG_task_get_source(msg_task_t task)
+msg_host_t MSG_task_get_source(const_msg_task_t task)
{
return task->get_source();
}
/** @brief Returns the name of the given task. */
-const char *MSG_task_get_name(msg_task_t task)
+const char* MSG_task_get_name(const_msg_task_t task)
{
return task->get_cname();
}
*
* It works for either parallel or sequential tasks.
*/
-double MSG_task_get_remaining_work_ratio(msg_task_t task)
+double MSG_task_get_remaining_work_ratio(const_msg_task_t task)
{
xbt_assert((task != nullptr), "Cannot get information from a nullptr task");
if (task->compute) {
* It works for sequential tasks, but the remaining amount of work is not a scalar value for parallel tasks.
* So you will get an exception if you call this function on parallel tasks. Just don't do it.
*/
-double MSG_task_get_flops_amount(msg_task_t task) {
+double MSG_task_get_flops_amount(const_msg_task_t task)
+{
if (task->compute != nullptr) {
return task->compute->get_remaining();
} else {
* If the communication does not exist it will return 0.
* So, if the communication has FINISHED or FAILED it returns zero.
*/
-double MSG_task_get_remaining_communication(msg_task_t task)
+double MSG_task_get_remaining_communication(const_msg_task_t task)
{
XBT_DEBUG("calling simcall_communication_get_remains(%p)", task->comm.get());
return task->comm->get_remaining();
}
/** @brief Returns the size of the data attached to the given task. */
-double MSG_task_get_bytes_amount(msg_task_t task)
+double MSG_task_get_bytes_amount(const_msg_task_t task)
{
xbt_assert(task != nullptr, "Invalid parameter");
return task->bytes_amount;
* @brief Sets the tracing category of a task.
*
* This function should be called after the creation of a MSG task, to define the category of that task. The
- * first parameter task must contain a task that was =created with the function #MSG_task_create. The second
+ * first parameter task must contain a task that was =created with the function MSG_task_create(). The second
* parameter category must contain a category that was previously declared with the function #TRACE_category
* (or with #TRACE_category_with_color).
*
- * See @ref outcomes_vizu for details on how to trace the (categorized) resource utilization.
+ * @beginrst
+ * See :ref:`outcomes_vizu` for details on how to trace the (categorized) resource utilization.
+ * @endrst
*
* @param task the task that is going to be categorized
* @param category the name of the category to be associated to the task
* @param task the task to be considered
* @return Returns the name of the tracing category of the given task, "" otherwise
*/
-const char* MSG_task_get_category(msg_task_t task)
+const char* MSG_task_get_category(const_msg_task_t task)
{
return task->get_tracing_category().c_str();
}
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
static void on_exec_creation(simgrid::s4u::Actor const&, simgrid::s4u::Exec const& e)
{
auto exec = static_cast<simgrid::kernel::activity::ExecImpl*>(e.get_impl());
- simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(exec->get_host());
+ const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(exec->get_host());
if (vm == nullptr)
return;
static void on_exec_completion(simgrid::s4u::Actor const&, simgrid::s4u::Exec const& e)
{
auto exec = static_cast<simgrid::kernel::activity::ExecImpl*>(e.get_impl());
- simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(exec->get_host());
+ const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(exec->get_host());
if (vm == nullptr)
return;
}
}
-void sg_vm_start_dirty_page_tracking(sg_vm_t vm)
+void sg_vm_start_dirty_page_tracking(const_sg_vm_t vm)
{
vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->start_tracking();
}
-void sg_vm_stop_dirty_page_tracking(sg_vm_t vm)
+void sg_vm_stop_dirty_page_tracking(const_sg_vm_t vm)
{
vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->stop_tracking();
}
-double sg_vm_lookup_computed_flops(sg_vm_t vm)
+double sg_vm_lookup_computed_flops(const_sg_vm_t vm)
{
return vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->computed_flops_lookup();
}
-void sg_vm_set_dirty_page_intensity(sg_vm_t vm, double intensity)
+void sg_vm_set_dirty_page_intensity(const_sg_vm_t vm, double intensity)
{
vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->set_intensity(intensity);
}
-double sg_vm_get_dirty_page_intensity(sg_vm_t vm)
+double sg_vm_get_dirty_page_intensity(const_sg_vm_t vm)
{
return vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->get_intensity();
}
-void sg_vm_set_working_set_memory(sg_vm_t vm, sg_size_t size)
+void sg_vm_set_working_set_memory(const_sg_vm_t vm, sg_size_t size)
{
vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->set_working_set_memory(size);
}
-sg_size_t sg_vm_get_working_set_memory(sg_vm_t vm)
+sg_size_t sg_vm_get_working_set_memory(const_sg_vm_t vm)
{
return vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->get_working_set_memory();
}
-void sg_vm_set_migration_speed(sg_vm_t vm, double speed)
+void sg_vm_set_migration_speed(const_sg_vm_t vm, double speed)
{
vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->set_migration_speed(speed);
}
-double sg_vm_get_migration_speed(sg_vm_t vm)
+double sg_vm_get_migration_speed(const_sg_vm_t vm)
{
return vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->get_migration_speed();
}
-double sg_vm_get_max_downtime(sg_vm_t vm)
+double sg_vm_get_max_downtime(const_sg_vm_t vm)
{
return vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->get_max_downtime();
}
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_file, s4u, "S4U files");
int sg_storage_max_file_descriptors = 1024;
+/** @defgroup plugin_filesystem Plugin FileSystem
+ *
+ * This adds the notion of Files on top of the storage notion that provided by the core of SimGrid.
+ * Activate this plugin at will.
+ */
+
namespace simgrid {
+
+template class xbt::Extendable<s4u::File>;
+
namespace s4u {
simgrid::xbt::Extension<Disk, FileSystemDiskExt> FileSystemDiskExt::EXTENSION_ID;
simgrid::xbt::Extension<Storage, FileSystemStorageExt> FileSystemStorageExt::EXTENSION_ID;
simgrid::xbt::Extension<Host, FileDescriptorHostExt> FileDescriptorHostExt::EXTENSION_ID;
-File::File(const std::string& fullpath, void* userdata) : File(fullpath, Host::current(), userdata){}
-
-File::File(const std::string& fullpath, sg_host_t host, void* userdata) : fullpath_(fullpath)
+Storage* File::find_local_storage_on(Host* host)
{
- this->set_data(userdata);
- // this cannot fail because we get a xbt_die if the mountpoint does not exist
- if (not host->get_mounted_storages().empty()) {
- Storage* st = nullptr;
- size_t longest_prefix_length = 0;
- XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath_.c_str(), host->get_cname());
+ Storage* st = nullptr;
+ size_t longest_prefix_length = 0;
+ XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath_.c_str(), host->get_cname());
- for (auto const& mnt : host->get_mounted_storages()) {
- XBT_DEBUG("See '%s'", mnt.first.c_str());
- mount_point_ = fullpath_.substr(0, mnt.first.length());
+ for (auto const& mnt : host->get_mounted_storages()) {
+ XBT_DEBUG("See '%s'", mnt.first.c_str());
+ mount_point_ = fullpath_.substr(0, mnt.first.length());
- if (mount_point_ == mnt.first && mnt.first.length() > longest_prefix_length) {
- /* The current mount name is found in the full path and is bigger than the previous*/
- longest_prefix_length = mnt.first.length();
- st = mnt.second;
- }
+ if (mount_point_ == mnt.first && mnt.first.length() > longest_prefix_length) {
+ /* The current mount name is found in the full path and is bigger than the previous*/
+ longest_prefix_length = mnt.first.length();
+ st = mnt.second;
+ }
+ }
+ if (longest_prefix_length > 0) { /* Mount point found, split fullpath_ into mount_name and path+filename*/
+ mount_point_ = fullpath_.substr(0, longest_prefix_length);
+ path_ = fullpath_.substr(longest_prefix_length, fullpath_.length());
+ } else
+ xbt_die("Can't find mount point for '%s' on '%s'", fullpath_.c_str(), host->get_cname());
+
+ return st;
+}
+
+Disk* File::find_local_disk_on(const Host* host)
+{
+ Disk* d = nullptr;
+ size_t longest_prefix_length = 0;
+ for (auto const& disk : host->get_disks()) {
+ std::string current_mount;
+ if (disk->get_host() != host)
+ current_mount = disk->extension<FileSystemDiskExt>()->get_mount_point(disk->get_host());
+ else
+ current_mount = disk->extension<FileSystemDiskExt>()->get_mount_point();
+ mount_point_ = fullpath_.substr(0, current_mount.length());
+ if (mount_point_ == current_mount && current_mount.length() > longest_prefix_length) {
+ /* The current mount name is found in the full path and is bigger than the previous*/
+ longest_prefix_length = current_mount.length();
+ d = disk;
}
if (longest_prefix_length > 0) { /* Mount point found, split fullpath_ into mount_name and path+filename*/
mount_point_ = fullpath_.substr(0, longest_prefix_length);
- path_ = fullpath_.substr(longest_prefix_length, fullpath_.length());
+ if (mount_point_ == std::string("/"))
+ path_ = fullpath_;
+ else
+ path_ = fullpath_.substr(longest_prefix_length, fullpath_.length());
+ XBT_DEBUG("%s + %s", mount_point_.c_str(), path_.c_str());
} else
xbt_die("Can't find mount point for '%s' on '%s'", fullpath_.c_str(), host->get_cname());
+ }
+ return d;
+}
+
+File::File(const std::string& fullpath, void* userdata) : File(fullpath, Host::current(), userdata) {}
- local_storage_ = st;
+File::File(const std::string& fullpath, sg_host_t host, void* userdata) : fullpath_(fullpath)
+{
+ this->set_data(userdata);
+ // this cannot fail because we get a xbt_die if the mountpoint does not exist
+ if (not host->get_mounted_storages().empty()) {
+ local_storage_ = find_local_storage_on(host);
}
if (not host->get_disks().empty()) {
- Disk* d = nullptr;
- size_t longest_prefix_length = 0;
- for (auto const& disk : host->get_disks()) {
- std::string current_mount;
- if (disk->get_host() != host)
- current_mount = disk->extension<FileSystemDiskExt>()->get_mount_point(disk->get_host());
- else
- current_mount = disk->extension<FileSystemDiskExt>()->get_mount_point();
- mount_point_ = fullpath_.substr(0, current_mount.length());
- if (mount_point_ == current_mount && current_mount.length() > longest_prefix_length) {
- /* The current mount name is found in the full path and is bigger than the previous*/
- longest_prefix_length = current_mount.length();
- d = disk;
- }
- if (longest_prefix_length > 0) { /* Mount point found, split fullpath_ into mount_name and path+filename*/
- mount_point_ = fullpath_.substr(0, longest_prefix_length);
- if (mount_point_ == std::string("/"))
- path_ = fullpath_;
- else
- path_ = fullpath_.substr(longest_prefix_length, fullpath_.length());
- XBT_DEBUG("%s + %s", mount_point_.c_str(), path_.c_str());
- } else
- xbt_die("Can't find mount point for '%s' on '%s'", fullpath_.c_str(), host->get_cname());
- }
- local_disk_ = d;
+ local_disk_ = find_local_disk_on(host);
}
// assign a file descriptor id to the newly opened File
}
/** @brief Write into a file (local or remote)
+ * @ingroup plugin_filesystem
*
* @param size of the file to write
* @return the number of bytes successfully write or -1 if an error occurred
*/
-sg_size_t File::write(sg_size_t size, int write_inside)
+sg_size_t File::write_on_disk(sg_size_t size, bool write_inside)
{
- if (size == 0) /* Nothing to write, return */
- return 0;
sg_size_t write_size = 0;
- Host* host = nullptr;
-
/* Find the host where the file is physically located (remote or local)*/
- if (local_storage_)
- host = local_storage_->get_host();
- if (local_disk_)
- host = local_disk_->get_host();
+ Host* host = local_disk_->get_host();
if (host && host->get_name() != Host::current()->get_name()) {
/* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", host->get_cname(), size);
Host::current()->send_to(host, size);
}
-
- if (local_storage_) {
- XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu' '%llu:%llu'", get_path(), local_storage_->get_cname(), size,
- size_, sg_storage_get_size_used(local_storage_), sg_storage_get_size(local_storage_));
- // If the storage is full before even starting to write
- if (sg_storage_get_size_used(local_storage_) >= sg_storage_get_size(local_storage_))
- return 0;
- if (write_inside == 0) {
- /* Subtract the part of the file that might disappear from the used sized on the storage element */
- local_storage_->extension<FileSystemStorageExt>()->decr_used_size(size_ - current_position_);
- write_size = local_storage_->write(size);
- local_storage_->extension<FileSystemStorageExt>()->incr_used_size(write_size);
- current_position_ += write_size;
+ XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu' '%llu:%llu'", get_path(), local_disk_->get_cname(), size, size_,
+ sg_disk_get_size_used(local_disk_), sg_disk_get_size(local_disk_));
+ // If the storage is full before even starting to write
+ if (sg_disk_get_size_used(local_disk_) >= sg_disk_get_size(local_disk_))
+ return 0;
+ if (not write_inside) {
+ /* Subtract the part of the file that might disappear from the used sized on the storage element */
+ local_disk_->extension<FileSystemDiskExt>()->decr_used_size(size_ - current_position_);
+ write_size = local_disk_->write(size);
+ local_disk_->extension<FileSystemDiskExt>()->incr_used_size(write_size);
+ current_position_ += write_size;
+ size_ = current_position_;
+ } else {
+ write_size = local_disk_->write(size);
+ current_position_ += write_size;
+ if (current_position_ > size_)
size_ = current_position_;
- } else {
- write_size = local_storage_->write(size);
- current_position_ += write_size;
- if (current_position_ > size_)
- size_ = current_position_;
- }
- std::map<std::string, sg_size_t>* content = local_storage_->extension<FileSystemStorageExt>()->get_content();
+ }
+ std::map<std::string, sg_size_t>* content = local_disk_->extension<FileSystemDiskExt>()->get_content();
- content->erase(path_);
- content->insert({path_, size_});
+ content->erase(path_);
+ content->insert({path_, size_});
+
+ return write_size;
+}
+
+sg_size_t File::write_on_storage(sg_size_t size, bool write_inside)
+{
+ sg_size_t write_size = 0;
+ /* Find the host where the file is physically located (remote or local)*/
+ Host* host = local_storage_->get_host();
+
+ if (host && host->get_name() != Host::current()->get_name()) {
+ /* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
+ XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", host->get_cname(), size);
+ Host::current()->send_to(host, size);
}
- if (local_disk_) {
- XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu' '%llu:%llu'", get_path(), local_disk_->get_cname(), size, size_,
- sg_disk_get_size_used(local_disk_), sg_disk_get_size(local_disk_));
- // If the storage is full before even starting to write
- if (sg_disk_get_size_used(local_disk_) >= sg_disk_get_size(local_disk_))
- return 0;
- if (write_inside == 0) {
- /* Subtract the part of the file that might disappear from the used sized on the storage element */
- local_disk_->extension<FileSystemDiskExt>()->decr_used_size(size_ - current_position_);
- write_size = local_disk_->write(size);
- local_disk_->extension<FileSystemDiskExt>()->incr_used_size(write_size);
- current_position_ += write_size;
+ XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu' '%llu:%llu'", get_path(), local_storage_->get_cname(), size, size_,
+ sg_storage_get_size_used(local_storage_), sg_storage_get_size(local_storage_));
+ // If the storage is full before even starting to write
+ if (sg_storage_get_size_used(local_storage_) >= sg_storage_get_size(local_storage_))
+ return 0;
+ if (not write_inside) {
+ /* Subtract the part of the file that might disappear from the used sized on the storage element */
+ local_storage_->extension<FileSystemStorageExt>()->decr_used_size(size_ - current_position_);
+ write_size = local_storage_->write(size);
+ local_storage_->extension<FileSystemStorageExt>()->incr_used_size(write_size);
+ current_position_ += write_size;
+ size_ = current_position_;
+ } else {
+ write_size = local_storage_->write(size);
+ current_position_ += write_size;
+ if (current_position_ > size_)
size_ = current_position_;
- } else {
- write_size = local_disk_->write(size);
- current_position_ += write_size;
- if (current_position_ > size_)
- size_ = current_position_;
- }
- std::map<std::string, sg_size_t>* content = local_disk_->extension<FileSystemDiskExt>()->get_content();
-
- content->erase(path_);
- content->insert({path_, size_});
}
+ std::map<std::string, sg_size_t>* content = local_storage_->extension<FileSystemStorageExt>()->get_content();
+
+ content->erase(path_);
+ content->insert({path_, size_});
+
return write_size;
}
+sg_size_t File::write(sg_size_t size, bool write_inside)
+{
+ if (size == 0) /* Nothing to write, return */
+ return 0;
+
+ if (local_disk_)
+ return write_on_disk(size, write_inside);
+ if (local_storage_)
+ return write_on_storage(size, write_inside);
+
+ return 0;
+}
+
sg_size_t File::size()
{
return size_;
current_position_ += read_size;
Host* dst_host = host;
+ size_t longest_prefix_length = 0;
if (local_storage_) {
/* Find the host that owns the storage where the file has to be copied */
- Storage* storage_dest = nullptr;
- size_t longest_prefix_length = 0;
+ const Storage* storage_dest = nullptr;
for (auto const& elm : host->get_mounted_storages()) {
std::string mount_point = std::string(fullpath).substr(0, elm.first.size());
}
if (local_disk_) {
- size_t longest_prefix_length = 0;
- Disk* dst_disk = nullptr;
+ const Disk* dst_disk = nullptr;
for (auto const& disk : host->get_disks()) {
std::string current_mount = disk->extension<FileSystemDiskExt>()->get_mount_point();
return res;
}
-FileSystemDiskExt::FileSystemDiskExt(simgrid::s4u::Disk* ptr)
+FileSystemDiskExt::FileSystemDiskExt(const Disk* ptr)
{
const char* size_str = ptr->get_property("size");
if (size_str)
content_.reset(parse_content(content_str));
}
-FileSystemStorageExt::FileSystemStorageExt(simgrid::s4u::Storage* ptr)
+FileSystemStorageExt::FileSystemStorageExt(const Storage* ptr) : size_(ptr->get_impl()->size_)
{
content_.reset(parse_content(ptr->get_impl()->content_name_));
- size_ = ptr->get_impl()->size_;
}
std::map<std::string, sg_size_t>* FileSystemDiskExt::parse_content(const std::string& filename)
}
/* **************************** Public interface *************************** */
+/** @brief Initialize the file system plugin.
+ @ingroup plugin_filesystem
+
+ @beginrst
+ See the examples in :ref:`s4u_ex_disk_io`.
+ @endrst
+ */
void sg_storage_file_system_init()
{
sg_storage_max_file_descriptors = 1024;
return fd->write(size);
}
-void sg_file_close(sg_file_t fd)
+void sg_file_close(const_sg_file_t fd)
{
delete fd;
}
+/** Retrieves the path to the file
+ * @ingroup plugin_filesystem
+ */
const char* sg_file_get_name(sg_file_t fd)
{
xbt_assert((fd != nullptr), "Invalid file descriptor");
return fd->get_path();
}
+/** Retrieves the size of the file
+ * @ingroup plugin_filesystem
+ */
sg_size_t sg_file_get_size(sg_file_t fd)
{
return fd->size();
fd->dump();
}
-void* sg_file_get_data(sg_file_t fd)
+/** Retrieves the user data associated with the file
+ * @ingroup plugin_filesystem
+ */
+void* sg_file_get_data(const_sg_file_t fd)
{
return fd->get_data();
}
+/** Changes the user data associated with the file
+ * @ingroup plugin_filesystem
+ */
void sg_file_set_data(sg_file_t fd, void* data)
{
fd->set_data(data);
}
/**
- * @brief Set the file position indicator in the sg_file_t by adding offset bytes
- * to the position specified by origin (either SEEK_SET, SEEK_CUR, or SEEK_END).
+ * @brief Set the file position indicator in the sg_file_t by adding offset bytes to the position specified by origin (either SEEK_SET, SEEK_CUR, or SEEK_END).
+ * @ingroup plugin_filesystem
*
* @param fd : file object that identifies the stream
* @param offset : number of bytes to offset from origin
/**
* @brief Copy a file to another location on a remote host.
+ * @ingroup plugin_filesystem
+ *
* @param file : the file to move
* @param host : the remote host where the file has to be copied
* @param fullpath : the complete path destination on the remote host
/**
* @brief Move a file to another location on a remote host.
+ * @ingroup plugin_filesystem
+ *
* @param file : the file to move
* @param host : the remote host where the file has to be moved
* @param fullpath : the complete path destination on the remote host
return file->remote_move(host, fullpath);
}
-sg_size_t sg_disk_get_size_free(sg_disk_t d)
+sg_size_t sg_disk_get_size_free(const_sg_disk_t d)
{
return d->extension<FileSystemDiskExt>()->get_size() - d->extension<FileSystemDiskExt>()->get_used_size();
}
-sg_size_t sg_disk_get_size_used(sg_disk_t d)
+sg_size_t sg_disk_get_size_used(const_sg_disk_t d)
{
return d->extension<FileSystemDiskExt>()->get_used_size();
}
-sg_size_t sg_disk_get_size(sg_disk_t d)
+sg_size_t sg_disk_get_size(const_sg_disk_t d)
{
return d->extension<FileSystemDiskExt>()->get_size();
}
-const char* sg_disk_get_mount_point(sg_disk_t d)
+const char* sg_disk_get_mount_point(const_sg_disk_t d)
{
return d->extension<FileSystemDiskExt>()->get_mount_point();
}
-sg_size_t sg_storage_get_size_free(sg_storage_t st)
+sg_size_t sg_storage_get_size_free(const_sg_storage_t st)
{
return st->extension<FileSystemStorageExt>()->get_size() - st->extension<FileSystemStorageExt>()->get_used_size();
}
-sg_size_t sg_storage_get_size_used(sg_storage_t st)
+sg_size_t sg_storage_get_size_used(const_sg_storage_t st)
{
return st->extension<FileSystemStorageExt>()->get_used_size();
}
-sg_size_t sg_storage_get_size(sg_storage_t st)
+sg_size_t sg_storage_get_size(const_sg_storage_t st)
{
return st->extension<FileSystemStorageExt>()->get_size();
}
-xbt_dict_t sg_storage_get_content(sg_storage_t storage)
+xbt_dict_t sg_storage_get_content(const_sg_storage_t storage)
{
- std::map<std::string, sg_size_t>* content = storage->extension<simgrid::s4u::FileSystemStorageExt>()->get_content();
+ const std::map<std::string, sg_size_t>* content =
+ storage->extension<simgrid::s4u::FileSystemStorageExt>()->get_content();
// Note: ::operator delete is ok here (no destructor called) since the dict elements are of POD type sg_size_t.
xbt_dict_t content_as_dict = xbt_dict_new_homogeneous(::operator delete);
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
* global configuration
*/
class Governor {
-
-private:
simgrid::s4u::Host* const host_;
double sampling_rate_;
- int min_pstate; //< Never use a pstate less than this one
- int max_pstate; //< Never use a pstate larger than this one
+ int min_pstate = cfg_min_pstate; //< Never use a pstate less than this one
+ int max_pstate = cfg_max_pstate; //< Never use a pstate larger than this one
public:
explicit Governor(simgrid::s4u::Host* ptr)
: host_(ptr)
- , min_pstate(cfg_min_pstate)
- , max_pstate(cfg_max_pstate == max_pstate_not_limited ? host_->get_pstate_count() - 1 : cfg_max_pstate)
{
+ if (cfg_max_pstate == max_pstate_not_limited)
+ max_pstate = host_->get_pstate_count() - 1;
init();
}
virtual ~Governor() = default;
// FIXME I think that this fires at the same time for all hosts, so when the src sends something,
// the dst will be notified even though it didn't even arrive at the recv yet
simgrid::s4u::Link::on_communicate.connect(
- [this](kernel::resource::NetworkAction const&, s4u::Host* src, s4u::Host* dst) {
+ [this](const kernel::resource::NetworkAction&, const s4u::Host* src, const s4u::Host* dst) {
if ((get_host() == src || get_host() == dst) && iteration_running) {
post_task();
}
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
SIMGRID_REGISTER_PLUGIN(host_energy, "Cpu energy consumption.", &sg_host_energy_plugin_init)
-/** @defgroup plugin_host_energy
+/** @defgroup plugin_host_energy plugin_host_energy Plugin Host Energy
@beginrst
+
This is the energy plugin, enabling to account not only for computation time, but also for the dissipated energy in the
simulated platform.
-To activate this plugin, first call :cpp:func:`sg_host_energy_plugin_init()` before your :cpp:func:`MSG_init()`, and then use
-:cpp:func:`MSG_host_get_consumed_energy()` to retrieve the consumption of a given host.
+To activate this plugin, first call :cpp:func:`sg_host_energy_plugin_init()` before your loading your platform, and
+then use :cpp:func:`sg_host_get_consumed_energy()` to retrieve the consumption of a given host.
When the host is on, this energy consumption naturally depends on both the current CPU load and the host energy profile.
According to our measurements, the consumption is somehow linear in the amount of cores at full speed, with an
-abnormality when all the cores are idle. The full details are in `our scientific paper <https://hal.inria.fr/hal-01523608>`_
-on that topic.
+abnormality when all the cores are idle. The full details are in `our scientific paper
+<https://hal.inria.fr/hal-01523608>`_ on that topic.
As a result, our energy model takes 4 parameters:
- - ``Idle`` wattage (i.e., instantaneous consumption in Watt) when your host is up and running, but without anything to do.
+ - ``Idle`` wattage (i.e., instantaneous consumption in Watt) when your host is up and running, but without anything to
+ do.
- ``Epsilon`` wattage when all cores are at 0 or epsilon%, but not in Idle state.
- ``AllCores`` wattage when all cores of the host are at 100%.
- ``Off`` wattage when the host is turned off.
</table>
To change the pstate of a given CPU, use the following functions:
-:cpp:func:`MSG_host_get_nb_pstates()`, :cpp:func:`simgrid::s4u::Host::set_pstate()`, :cpp:func:`MSG_host_get_power_peak_at()`.
+:cpp:func:`MSG_host_get_nb_pstates()`, :cpp:func:`simgrid::s4u::Host::set_pstate()`,
+:cpp:func:`MSG_host_get_power_peak_at()`.
.. raw:: html
*/
int pstate_ = 0;
const int pstate_off_ = -1;
+ double watts_off_ = 0.0; /*< Consumption when the machine is turned off (shutdown) */
+ double total_energy_ = 0.0; /*< Total energy consumed by the host */
+ double last_updated_ = surf_get_clock(); /*< Timestamp of the last energy update event*/
/* Only used to split total energy into unused/used hosts.
* If you want to get this info for something else, rather use the host_load plugin
double get_watt_min_at(int pstate);
double get_watt_max_at(int pstate);
double get_power_range_slope_at(int pstate);
+ double get_last_update_time() { return last_updated_; }
void update();
-
- double watts_off_ = 0.0; /*< Consumption when the machine is turned off (shutdown) */
- double total_energy_ = 0.0; /*< Total energy consumed by the host */
- double last_updated_; /*< Timestamp of the last energy update event*/
};
simgrid::xbt::Extension<simgrid::s4u::Host, HostEnergy> HostEnergy::EXTENSION_ID;
/* Computes the consumption so far. Called lazily on need. */
void HostEnergy::update()
{
- double start_time = this->last_updated_;
+ double start_time = last_updated_;
double finish_time = surf_get_clock();
//
// We may have start == finish if the past consumption was updated since the simcall was started
// Even in this case, we need to save the pstate for the next call (after this if),
// which may have changed since that recent update.
if (start_time < finish_time) {
- double previous_energy = this->total_energy_;
+ double previous_energy = total_energy_;
double instantaneous_power_consumption = this->get_current_watts_value();
// TODO Trace: Trace energy_this_step from start_time to finish_time in host->getName()
- this->total_energy_ = previous_energy + energy_this_step;
- this->last_updated_ = finish_time;
+ total_energy_ = previous_energy + energy_this_step;
+ last_updated_ = finish_time;
XBT_DEBUG("[update_energy of %s] period=[%.8f-%.8f]; current speed=%.2E flop/s (pstate %i); total consumption "
"before: %.8f J -> added now: %.8f J",
- host_->get_cname(), start_time, finish_time, host_->get_pstate_speed(this->pstate_), this->pstate_,
- previous_energy, energy_this_step);
+ host_->get_cname(), start_time, finish_time, host_->get_pstate_speed(pstate_), pstate_, previous_energy,
+ energy_this_step);
}
/* Save data for the upcoming time interval: whether it's on/off and the pstate if it's on */
- this->pstate_ = host_->is_on() ? host_->get_pstate() : pstate_off_;
+ pstate_ = host_->is_on() ? host_->get_pstate() : pstate_off_;
}
-HostEnergy::HostEnergy(simgrid::s4u::Host* ptr) : host_(ptr), last_updated_(surf_get_clock())
+HostEnergy::HostEnergy(simgrid::s4u::Host* ptr) : host_(ptr)
{
init_watts_range_list();
simgrid::s4u::Host* host = cpu->get_host();
if (host != nullptr) {
// If it's a VM, take the corresponding PM
- simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
+ const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
if (vm) // If it's a VM, take the corresponding PM
host = vm->get_pm();
// Get the host_energy extension for the relevant host
HostEnergy* host_energy = host->extension<HostEnergy>();
- if (host_energy->last_updated_ < surf_get_clock())
+ if (host_energy->get_last_update_time() < surf_get_clock())
host_energy->update();
}
}
/** @ingroup plugin_host_energy
* @brief Enable host energy plugin
- * @details Enable energy plugin to get joules consumption of each cpu. Call this function before #MSG_init().
+ * @details Enable energy plugin to get joules consumption of each cpu. Call this function before loading your platform.
*/
void sg_host_energy_plugin_init()
{
simgrid::s4u::Exec::on_start.connect([](simgrid::s4u::Actor const&, simgrid::s4u::Exec const& activity) {
if (activity.get_host_number() == 1) { // We only run on one host
simgrid::s4u::Host* host = activity.get_host();
- simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
+ const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
if (vm != nullptr)
host = vm->get_pm();
xbt_assert(host != nullptr);
* The result is that the actor requesting this value will be interrupted,
* the value will be updated in kernel mode before returning the control to the requesting actor.
*/
-double sg_host_get_consumed_energy(sg_host_t host)
+double sg_host_get_consumed_energy(const_sg_host_t host)
{
ensure_plugin_inited();
return host->extension<HostEnergy>()->get_consumed_energy();
/** @ingroup plugin_host_energy
* @brief Get the amount of watt dissipated when the host is idling
*/
-double sg_host_get_idle_consumption(sg_host_t host)
+double sg_host_get_idle_consumption(const_sg_host_t host)
{
ensure_plugin_inited();
return host->extension<HostEnergy>()->get_watt_idle_at(0);
/** @ingroup plugin_host_energy
* @brief Get the amount of watt dissipated at the given pstate when the host is idling
*/
-double sg_host_get_idle_consumption_at(sg_host_t host, int pstate)
+double sg_host_get_idle_consumption_at(const_sg_host_t host, int pstate)
{
ensure_plugin_inited();
return host->extension<HostEnergy>()->get_watt_idle_at(pstate);
/** @ingroup plugin_host_energy
* @brief Get the amount of watt dissipated at the given pstate when the host is at 0 or epsilon% CPU usage.
*/
-double sg_host_get_wattmin_at(sg_host_t host, int pstate)
+double sg_host_get_wattmin_at(const_sg_host_t host, int pstate)
{
ensure_plugin_inited();
return host->extension<HostEnergy>()->get_watt_min_at(pstate);
/** @ingroup plugin_host_energy
* @brief Returns the amount of watt dissipated at the given pstate when the host burns CPU at 100%
*/
-double sg_host_get_wattmax_at(sg_host_t host, int pstate)
+double sg_host_get_wattmax_at(const_sg_host_t host, int pstate)
{
ensure_plugin_inited();
return host->extension<HostEnergy>()->get_watt_max_at(pstate);
/** @ingroup plugin_host_energy
* @brief Returns the power slope at the given pstate
*/
-double sg_host_get_power_range_slope_at(sg_host_t host, int pstate)
+double sg_host_get_power_range_slope_at(const_sg_host_t host, int pstate)
{
ensure_plugin_inited();
return host->extension<HostEnergy>()->get_power_range_slope_at(pstate);
/** @ingroup plugin_host_energy
* @brief Returns the current consumption of the host
*/
-double sg_host_get_current_consumption(sg_host_t host)
+double sg_host_get_current_consumption(const_sg_host_t host)
{
ensure_plugin_inited();
return host->extension<HostEnergy>()->get_current_watts_value();
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
// Makes sure that this plugin can be activated from the command line with ``--cfg=plugin:host_load``
SIMGRID_REGISTER_PLUGIN(host_load, "Cpu load", &sg_host_load_plugin_init)
-/** @defgroup plugin_host_load
+/** @defgroup plugin_host_load Simple plugin that monitors the current load for each host.
@beginrst
-
-Simple plugin that monitors the current load for each host.
-
In addition, this constitutes a good introductory example on how to write a plugin.
It attaches an extension to each host to store some data, and places callbacks in the following signals:
- :cpp:member:`simgrid::s4u::Host::on_creation`: Attach a new extension to the newly created host.
- :cpp:member:`simgrid::s4u::Exec::on_start`: Make note that a new execution started, increasing the load.
- :cpp:member:`simgrid::s4u::Exec::on_completion`: Make note that an execution completed, decreasing the load.
- - :cpp:member:`simgrid::s4u::Host::on_state_change`: Do what is appropriate when the host gets suspended, turned off or similar.
+ - :cpp:member:`simgrid::s4u::Host::on_state_change`: Do what is appropriate when the host gets suspended, turned off
+ or similar.
- :cpp:member:`simgrid::s4u::Host::on_speed_change`: Do what is appropriate when the DVFS is modified.
Note that extensions are automatically destroyed when the host gets destroyed.
, last_reset_(surf_get_clock())
, current_speed_(host_->get_speed())
, current_flops_(host_->get_load())
- , theor_max_flops_(0)
{
}
~HostLoad() = default;
simgrid::s4u::Exec::on_start.connect([](simgrid::s4u::Actor const&, simgrid::s4u::Exec const& activity) {
if (activity.get_host_number() == 1) { // We only run on one host
simgrid::s4u::Host* host = activity.get_host();
- simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
+ const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
if (vm != nullptr)
host = vm->get_pm();
xbt_assert(host != nullptr);
simgrid::s4u::Exec::on_completion.connect([](simgrid::s4u::Actor const&, simgrid::s4u::Exec const& activity) {
if (activity.get_host_number() == 1) { // We only run on one host
simgrid::s4u::Host* host = activity.get_host();
- simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
+ const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
if (vm != nullptr)
host = vm->get_pm();
xbt_assert(host != nullptr);
/** @brief Returns the current load of that host, as a ratio = achieved_flops / (core_current_speed * core_amount)
* @ingroup plugin_host_load
*/
-double sg_host_get_current_load(sg_host_t host)
+double sg_host_get_current_load(const_sg_host_t host)
{
xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin.");
/** @brief Returns the current load of that host
* @ingroup plugin_host_load
*/
-double sg_host_get_avg_load(sg_host_t host)
+double sg_host_get_avg_load(const_sg_host_t host)
{
xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin.");
/** @brief Returns the time this host was idle since the last reset
* @ingroup plugin_host_load
*/
-double sg_host_get_idle_time(sg_host_t host)
+double sg_host_get_idle_time(const_sg_host_t host)
{
xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin.");
/** @brief Returns the time this host was idle since the beginning of the simulation
* @ingroup plugin_host_load
*/
-double sg_host_get_total_idle_time(sg_host_t host)
+double sg_host_get_total_idle_time(const_sg_host_t host)
{
xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin.");
/** @brief Returns the amount of flops computed by that host since the last reset
* @ingroup plugin_host_load
*/
-double sg_host_get_computed_flops(sg_host_t host)
+double sg_host_get_computed_flops(const_sg_host_t host)
{
xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin.");
/** @brief Resets the idle time and flops amount of that host
* @ingroup plugin_host_load
*/
-void sg_host_load_reset(sg_host_t host)
+void sg_host_load_reset(const_sg_host_t host)
{
xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin.");
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
SIMGRID_REGISTER_PLUGIN(link_energy, "Link energy consumption.", &sg_link_energy_plugin_init)
-/** @defgroup plugin_link_energy
+/** @defgroup plugin_link_energy Plugin Link Energy
This is the link energy plugin, accounting for the dissipated energy in the simulated platform.
The second property means that when your host is turned off, it will dissipate only 10 Watts (please note that these
values are arbitrary).
- To simulate the energy-related elements, first call the simgrid#energy#sg_link_energy_plugin_init() before your
- #MSG_init(),
+ To simulate the energy-related elements, first call the sg_link_energy_plugin_init() before loading the platform
and then use the following function to retrieve the consumption of a given link: sg_link_get_consumed_energy().
*/
private:
double get_power();
- simgrid::s4u::Link* link_{};
+ s4u::Link* link_{};
bool inited_{false};
double idle_{0.0};
double last_updated_{0.0}; /*< Timestamp of the last energy update event*/
};
-simgrid::xbt::Extension<simgrid::s4u::Link, LinkEnergy> LinkEnergy::EXTENSION_ID;
+xbt::Extension<s4u::Link, LinkEnergy> LinkEnergy::EXTENSION_ID;
void LinkEnergy::update()
{
double LinkEnergy::get_power()
{
-
if (!inited_)
return 0.0;
double LinkEnergy::get_consumed_energy()
{
if (last_updated_ < surf_get_clock()) // We need to simcall this as it modifies the environment
- simgrid::kernel::actor::simcall(std::bind(&LinkEnergy::update, this));
+ kernel::actor::simcall(std::bind(&LinkEnergy::update, this));
return this->total_energy_;
}
} // namespace plugin
using simgrid::plugin::LinkEnergy;
/* **************************** events callback *************************** */
-static void on_communicate(simgrid::kernel::resource::NetworkAction const& action, simgrid::s4u::Host*,
- simgrid::s4u::Host*)
+static void on_communicate(const simgrid::kernel::resource::NetworkAction& action, const simgrid::s4u::Host*,
+ const simgrid::s4u::Host*)
{
XBT_DEBUG("onCommunicate is called");
for (simgrid::kernel::resource::LinkImpl* link : action.links()) {
-
if (link == nullptr)
continue;
/** @ingroup plugin_link_energy
* @brief Enable energy plugin
* @details Enable energy plugin to get joules consumption of each cpu. You should call this function before
- * #MSG_init().
+ * loading your platform.
*/
void sg_link_energy_plugin_init()
{
* The result is that the actor requesting this value will be interrupted,
* the value will be updated in kernel mode before returning the control to the requesting actor.
*/
-double sg_link_get_consumed_energy(sg_link_t link)
+double sg_link_get_consumed_energy(const_sg_link_t link)
{
if (not LinkEnergy::EXTENSION_ID.valid())
throw simgrid::xbt::InitializationError("The Energy plugin is not active. Please call sg_link_energy_plugin_init() "
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
}
namespace simgrid {
+
+template class xbt::Extendable<vm::VirtualMachineImpl>;
+
namespace vm {
/*************
* Callbacks *
static void add_active_exec(s4u::Actor const&, s4u::Exec const& task)
{
- s4u::VirtualMachine* vm = dynamic_cast<s4u::VirtualMachine*>(task.get_host());
+ const s4u::VirtualMachine* vm = dynamic_cast<s4u::VirtualMachine*>(task.get_host());
if (vm != nullptr) {
VirtualMachineImpl* vm_impl = vm->get_impl();
- vm_impl->active_tasks_ = vm_impl->active_tasks_ + 1;
+ vm_impl->add_active_exec();
vm_impl->update_action_weight();
}
}
static void remove_active_exec(s4u::Actor const&, s4u::Exec const& task)
{
- s4u::VirtualMachine* vm = dynamic_cast<s4u::VirtualMachine*>(task.get_host());
+ const s4u::VirtualMachine* vm = dynamic_cast<s4u::VirtualMachine*>(task.get_host());
if (vm != nullptr) {
VirtualMachineImpl* vm_impl = vm->get_impl();
- vm_impl->active_tasks_ = vm_impl->active_tasks_ - 1;
+ vm_impl->remove_active_exec();
vm_impl->update_action_weight();
}
}
static void add_active_activity(kernel::activity::ActivityImpl const& act)
{
- s4u::VirtualMachine* vm = get_vm_from_activity(act);
+ const s4u::VirtualMachine* vm = get_vm_from_activity(act);
if (vm != nullptr) {
VirtualMachineImpl *vm_impl = vm->get_impl();
- vm_impl->active_tasks_ = vm_impl->active_tasks_ + 1;
+ vm_impl->add_active_exec();
vm_impl->update_action_weight();
}
}
static void remove_active_activity(kernel::activity::ActivityImpl const& act)
{
- s4u::VirtualMachine* vm = get_vm_from_activity(act);
+ const s4u::VirtualMachine* vm = get_vm_from_activity(act);
if (vm != nullptr) {
VirtualMachineImpl *vm_impl = vm->get_impl();
- vm_impl->active_tasks_ = vm_impl->active_tasks_ - 1;
+ vm_impl->remove_active_exec();
vm_impl->update_action_weight();
}
}
/* iterate for all virtual machines */
for (s4u::VirtualMachine* const& ws_vm : VirtualMachineImpl::allVms_) {
- kernel::resource::Cpu* cpu = ws_vm->pimpl_cpu;
+ const kernel::resource::Cpu* cpu = ws_vm->pimpl_cpu;
- double solved_value =
- ws_vm->get_impl()->action_->get_variable()->get_value(); // this is X1 in comment above, what
- // this VM got in the sharing on the PM
+ // solved_value below is X1 in comment above: what this VM got in the sharing on the PM
+ double solved_value = ws_vm->get_impl()->get_action()->get_variable()->get_value();
XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value, ws_vm->get_cname(), ws_vm->get_pm()->get_cname());
xbt_assert(cpu->get_model() == surf_cpu_model_vm);
VirtualMachineImpl::VirtualMachineImpl(simgrid::s4u::VirtualMachine* piface, simgrid::s4u::Host* host_PM,
int core_amount, size_t ramsize)
- : HostImpl(piface), physical_host_(host_PM), core_amount_(core_amount), user_bound_(std::numeric_limits<double>::max()), ramsize_(ramsize)
+ : HostImpl(piface), physical_host_(host_PM), core_amount_(core_amount), ramsize_(ramsize)
{
/* Register this VM to the list of all VMs */
allVms_.push_back(piface);
void VirtualMachineImpl::update_action_weight(){
/* The impact of the VM over its PM is the min between its vCPU amount and the amount of tasks it contains */
- int impact = std::min(active_tasks_, get_core_amount());
+ int impact = std::min(active_execs_, get_core_amount());
- XBT_DEBUG("set the weight of the dummy CPU action of VM%p on PM to %d (#tasks: %d)", this, impact, active_tasks_);
+ XBT_DEBUG("set the weight of the dummy CPU action of VM%p on PM to %d (#tasks: %u)", this, impact, active_execs_);
if (impact > 0)
action_->set_sharing_penalty(1. / impact);
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
#define VM_INTERFACE_HPP_
namespace simgrid {
+
+extern template class XBT_PUBLIC xbt::Extendable<vm::VirtualMachineImpl>;
+
namespace vm {
/************
friend simgrid::s4u::VirtualMachine;
public:
- explicit VirtualMachineImpl(s4u::VirtualMachine* piface, s4u::Host* host, int core_amount, size_t ramsize);
- ~VirtualMachineImpl();
-
/** @brief Callbacks fired after VM creation. Signature: `void(VirtualMachineImpl&)` */
static xbt::signal<void(simgrid::vm::VirtualMachineImpl&)> on_creation;
/** @brief Callbacks fired after VM destruction. Signature: `void(VirtualMachineImpl const&)` */
static xbt::signal<void(simgrid::vm::VirtualMachineImpl const&)> on_destruction;
+ static std::deque<s4u::VirtualMachine*> allVms_;
+
+ explicit VirtualMachineImpl(s4u::VirtualMachine* piface, s4u::Host* host, int core_amount, size_t ramsize);
+ ~VirtualMachineImpl();
+
virtual void suspend(kernel::actor::ActorImpl* issuer);
virtual void resume();
virtual void shutdown(kernel::actor::ActorImpl* issuer);
/** @brief Get the physical host on which the given VM is running */
s4u::Host* get_physical_host() { return physical_host_; }
- sg_size_t get_ramsize() { return ramsize_; }
+ sg_size_t get_ramsize() const { return ramsize_; }
void set_ramsize(sg_size_t ramsize) { ramsize_ = ramsize; }
- s4u::VirtualMachine::state get_state() { return vm_state_; }
+ s4u::VirtualMachine::state get_state() const { return vm_state_; }
void set_state(s4u::VirtualMachine::state state) { vm_state_ = state; }
- int get_core_amount() { return core_amount_; }
+ unsigned int get_core_amount() { return core_amount_; }
+ kernel::resource::Action* get_action() { return action_; }
virtual void set_bound(double bound);
- /* The vm object of the lower layer */
- kernel::resource::Action* action_ = nullptr;
- static std::deque<s4u::VirtualMachine*> allVms_;
- bool is_migrating_ = false;
- int active_tasks_ = 0;
-
void update_action_weight();
+ void add_active_exec() { active_execs_++; }
+ void remove_active_exec() { active_execs_--; }
+
+ void start_migration() { is_migrating_ = true; }
+ void end_migration() { is_migrating_ = false; }
+ bool is_migrating() const { return is_migrating_; }
+
private:
+ kernel::resource::Action* action_ = nullptr;
+ unsigned int active_execs_ = 0;
s4u::Host* physical_host_;
- int core_amount_;
- double user_bound_;
- size_t ramsize_ = 0;
+ unsigned int core_amount_;
+ double user_bound_ = std::numeric_limits<double>::max();
+ size_t ramsize_ = 0;
s4u::VirtualMachine::state vm_state_ = s4u::VirtualMachine::state::CREATED;
+ bool is_migrating_ = false;
};
/*********
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
namespace simgrid {
namespace vm {
-simgrid::xbt::Extension<s4u::Host, VmMigrationExt> VmMigrationExt::EXTENSION_ID;
+xbt::Extension<s4u::Host, VmMigrationExt> VmMigrationExt::EXTENSION_ID;
void VmMigrationExt::ensureVmMigrationExtInstalled()
{
if (not EXTENSION_ID.valid())
- EXTENSION_ID = simgrid::s4u::Host::extension_create<VmMigrationExt>();
+ EXTENSION_ID = s4u::Host::extension_create<VmMigrationExt>();
}
void MigrationRx::operator()()
std::string("__mig_stage3:") + vm_->get_cname() + "(" + src_pm_->get_cname() + "-" + dst_pm_->get_cname() + ")";
while (not received_finalize) {
- std::string* payload = static_cast<std::string*>(mbox->get());
+ const std::string* payload = static_cast<std::string*>(mbox->get());
if (finalize_task_name == *payload)
received_finalize = true;
vm_->resume();
// Now the VM is running on the new host (the migration is completed) (even if the SRC crash)
- vm_->get_impl()->is_migrating_ = false;
+ vm_->get_impl()->end_migration();
XBT_DEBUG("VM(%s) moved from PM(%s) to PM(%s)", vm_->get_cname(), src_pm_->get_cname(), dst_pm_->get_cname());
if (TRACE_vm_is_enabled()) {
counter++;
// start link
- container_t msg = simgrid::instr::Container::by_name(vm_->get_name());
- simgrid::instr::Container::get_root()->get_link("VM_LINK")->start_event(msg, "M", key);
+ container_t msg = instr::Container::by_name(vm_->get_name());
+ instr::Container::get_root()->get_link("VM_LINK")->start_event(msg, "M", key);
// destroy existing container of this vm
- simgrid::instr::Container::by_name(vm_->get_name())->remove_from_parent();
+ instr::Container::by_name(vm_->get_name())->remove_from_parent();
// create new container on the new_host location
- new simgrid::instr::Container(vm_->get_name(), "VM", simgrid::instr::Container::by_name(dst_pm_->get_name()));
+ new instr::Container(vm_->get_name(), "VM", instr::Container::by_name(dst_pm_->get_name()));
// end link
- msg = simgrid::instr::Container::by_name(vm_->get_name());
- simgrid::instr::Container::get_root()->get_link("VM_LINK")->end_event(msg, "M", key);
+ msg = instr::Container::by_name(vm_->get_name());
+ instr::Container::get_root()->get_link("VM_LINK")->end_event(msg, "M", key);
}
// Inform the SRC that the migration has been correctly performed
std::string* payload = new std::string("__mig_stage4:");
skip_stage2 = true;
} else if (sent > ramsize)
XBT_CRITICAL("bug");
-
} catch (const Exception&) {
// hostfailure (if you want to know whether this is the SRC or the DST check directly in send_migration_data code)
// Stop the dirty page tracking an return (there is no memory space to release)
/* Stage2: send update pages iteratively until the size of remaining states becomes smaller than threshold value. */
if (not skip_stage2) {
-
int stage2_round = 0;
/* just after stage1, nothing has been updated. But, we have to send the data updated during stage1 */
sg_size_t updated_size = get_updated_size(computed_during_stage1, dp_rate, dp_cap);
/* When the remaining size is below the threshold value, move to stage 3. */
while (threshold < remaining_size) {
-
XBT_DEBUG("mig-stage 2:%d updated_size %llu computed_during_stage1 %f dp_rate %f dp_cap %llu", stage2_round,
updated_size, computed_during_stage1, dp_rate, dp_cap);
// effectively the VM on the DST node.
XBT_DEBUG("mig: tx_done");
}
-}
-}
+} // namespace vm
+} // namespace simgrid
static void onVirtualMachineShutdown(simgrid::s4u::VirtualMachine const& vm)
{
- if (vm.get_impl()->is_migrating_) {
+ if (vm.get_impl()->is_migrating()) {
vm.extension<simgrid::vm::VmMigrationExt>()->rx_->kill();
vm.extension<simgrid::vm::VmMigrationExt>()->tx_->kill();
vm.extension<simgrid::vm::VmMigrationExt>()->issuer_->kill();
- vm.get_impl()->is_migrating_ = false;
+ vm.get_impl()->end_migration();
}
}
return vm;
}
-int sg_vm_is_migrating(simgrid::s4u::VirtualMachine* vm)
+int sg_vm_is_migrating(const simgrid::s4u::VirtualMachine* vm)
{
- return vm->get_impl()->is_migrating_;
+ return vm->get_impl()->is_migrating();
}
void sg_vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm)
throw simgrid::VmFailureException(
XBT_THROW_POINT,
simgrid::xbt::string_printf("Cannot migrate VM '%s' that is not running yet.", vm->get_cname()));
- if (vm->get_impl()->is_migrating_)
+ if (vm->get_impl()->is_migrating())
throw simgrid::VmFailureException(
XBT_THROW_POINT,
simgrid::xbt::string_printf("Cannot migrate VM '%s' that is already migrating.", vm->get_cname()));
- vm->get_impl()->is_migrating_ = true;
+ vm->get_impl()->start_migration();
simgrid::s4u::VirtualMachine::on_migration_start(*vm);
std::string rx_name =
tx->join();
rx->join();
- vm->get_impl()->is_migrating_ = false;
+ vm->get_impl()->end_migration();
simgrid::s4u::VirtualMachine::on_migration_end(*vm);
}
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
Host::destroy();
}
-simgrid::s4u::Host* VirtualMachine::get_pm()
+simgrid::s4u::Host* VirtualMachine::get_pm() const
{
return pimpl_vm_->get_physical_host();
}
return kernel::actor::simcall([this]() { return pimpl_vm_->get_state(); });
}
-size_t VirtualMachine::get_ramsize()
+size_t VirtualMachine::get_ramsize() const
{
return pimpl_vm_->get_ramsize();
}
return new simgrid::s4u::VirtualMachine(name, pm, coreAmount);
}
-const char* sg_vm_get_name(sg_vm_t vm)
+const char* sg_vm_get_name(const_sg_vm_t vm)
{
return vm->get_cname();
}
/** @brief Get the physical host of a given VM. */
-sg_host_t sg_vm_get_pm(sg_vm_t vm)
+sg_host_t sg_vm_get_pm(const_sg_vm_t vm)
{
return vm->get_pm();
}
vm->set_ramsize(size);
}
-size_t sg_vm_get_ramsize(sg_vm_t vm)
+size_t sg_vm_get_ramsize(const_sg_vm_t vm)
{
return vm->get_ramsize();
}
}
/** @brief Immediately kills all processes within the given VM.
- * Any memory that they allocated will be leaked, unless you used #MSG_process_on_exit().
*
- * No extra delay occurs. If you want to simulate this too, you want to use a #MSG_process_sleep().
+ @beginrst
+
+ The memory allocated by these actors is leaked, unless you used :cpp:func:`simgrid::s4u::Actor::on_exit`.
+
+ @endrst
+ *
+ * No extra delay occurs by default. You may let your actor sleep by a specific amount to simulate any extra delay that you want.
*/
void sg_vm_shutdown(sg_vm_t vm)
{
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_actor, s4u, "S4U actors");
namespace simgrid {
+
+template class xbt::Extendable<s4u::Actor>;
+
namespace s4u {
xbt::signal<void(Actor&)> s4u::Actor::on_creation;
ActorPtr Actor::create(const std::string& name, s4u::Host* host, const std::string& function,
std::vector<std::string> args)
{
- simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(function);
+ const simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(function);
return create(name, host, factory(std::move(args)));
}
-void intrusive_ptr_add_ref(Actor* actor)
+void intrusive_ptr_add_ref(const Actor* actor)
{
intrusive_ptr_add_ref(actor->pimpl_);
}
-void intrusive_ptr_release(Actor* actor)
+void intrusive_ptr_release(const Actor* actor)
{
intrusive_ptr_release(actor->pimpl_);
}
s4u::Actor::on_migration_start(*this);
}
- auto* previous_location = get_host();
+ const s4u::Host* previous_location = get_host();
kernel::actor::simcall([this, new_host]() {
if (pimpl_->waiting_synchro != nullptr) {
void parallel_execute(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
const std::vector<double>& bytes_amounts)
{
- parallel_execute(hosts, flops_amounts, bytes_amounts, -1);
+ exec_init(hosts, flops_amounts, bytes_amounts)->wait();
}
void parallel_execute(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
- const std::vector<double>& bytes_amounts, double timeout)
+ const std::vector<double>& bytes_amounts, double timeout) // XBT_ATTRIB_DEPRECATED_v329
+{
+ exec_init(hosts, flops_amounts, bytes_amounts)->wait_for(timeout);
+}
+
+ExecPtr exec_init(double flops_amount)
+{
+ return ExecPtr(new ExecSeq(get_host(), flops_amount));
+}
+
+ExecPtr exec_init(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
+ const std::vector<double>& bytes_amounts)
{
xbt_assert(hosts.size() > 0, "Your parallel executions must span over at least one host.");
xbt_assert(hosts.size() == flops_amounts.size() || flops_amounts.empty(),
xbt_assert(std::all_of(bytes_amounts.begin(), bytes_amounts.end(), [](double elm) { return std::isfinite(elm); }),
"flops_amounts comprises infinite values!");
- exec_init(hosts, flops_amounts, bytes_amounts)->set_timeout(timeout)->wait();
-}
-
-ExecPtr exec_init(double flops_amount)
-{
- return ExecPtr(new ExecSeq(get_host(), flops_amount));
-}
-
-ExecPtr exec_init(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
- const std::vector<double>& bytes_amounts)
-{
return ExecPtr(new ExecPar(hosts, flops_amounts, bytes_amounts));
}
kernel::actor::simcall_blocking<void>([self] { self->suspend(); });
}
-void resume()
-{
- kernel::actor::ActorImpl* self = simgrid::kernel::actor::ActorImpl::self();
- kernel::actor::simcall([self] { self->resume(); });
- Actor::on_resume(*self->ciface());
-}
-
void exit()
{
kernel::actor::ActorImpl* self = simgrid::kernel::actor::ActorImpl::self();
*
* This function checks whether @a actor is a valid pointer and return its PID (or 0 in case of problem).
*/
-aid_t sg_actor_get_PID(sg_actor_t actor)
+aid_t sg_actor_get_PID(const_sg_actor_t actor)
{
/* Do not raise an exception here: this function is called by the logs
* and the exceptions, so it would be called back again and again */
* This function checks whether @a actor is a valid pointer and return its parent's PID.
* Returns -1 if the actor has not been created by any other actor.
*/
-aid_t sg_actor_get_PPID(sg_actor_t actor)
+aid_t sg_actor_get_PPID(const_sg_actor_t actor)
{
return actor->get_ppid();
}
/** @ingroup m_actor_management
* @brief Return the name of an actor.
*/
-const char* sg_actor_get_name(sg_actor_t actor)
+const char* sg_actor_get_name(const_sg_actor_t actor)
{
return actor->get_cname();
}
-sg_host_t sg_actor_get_host(sg_actor_t actor)
+sg_host_t sg_actor_get_host(const_sg_actor_t actor)
{
return actor->get_host();
}
* @param name a property name
* @return value of a property (or nullptr if the property is not set)
*/
-const char* sg_actor_get_property_value(sg_actor_t actor, const char* name)
+const char* sg_actor_get_property_value(const_sg_actor_t actor, const char* name)
{
return actor->get_property(name);
}
*
* This function returns all the parameters associated with an actor
*/
-xbt_dict_t sg_actor_get_properties(sg_actor_t actor)
+xbt_dict_t sg_actor_get_properties(const_sg_actor_t actor)
{
xbt_assert(actor != nullptr, "Invalid parameter: First argument must not be nullptr");
xbt_dict_t as_dict = xbt_dict_new_homogeneous(xbt_free_f);
}
/** @brief Take an extra reference on that actor to prevent it to be garbage-collected */
-void sg_actor_ref(sg_actor_t actor)
+void sg_actor_ref(const_sg_actor_t actor)
{
intrusive_ptr_add_ref(actor);
}
/** @brief Release a reference on that actor so that it can get be garbage-collected */
-void sg_actor_unref(sg_actor_t actor)
+void sg_actor_unref(const_sg_actor_t actor)
{
intrusive_ptr_release(actor);
}
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
namespace simgrid {
namespace s4u {
-Barrier::Barrier(unsigned int expected_processes)
- : mutex_(Mutex::create()), cond_(ConditionVariable::create()), expected_actors_(expected_processes)
-{
-}
-
/** @brief Create a new barrier
*
* See @ref s4u_raii.
}
/** @brief Initializes a barrier, with count elements */
-void sg_barrier_destroy(sg_bar_t bar)
+void sg_barrier_destroy(const_sg_bar_t bar)
{
delete bar;
}
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
}
}
-int Comm::wait_any_for(std::vector<CommPtr>* comms, double timeout)
+int Comm::wait_any_for(const std::vector<CommPtr>* comms, double timeout)
{
std::unique_ptr<kernel::activity::CommImpl* []> rcomms(new kernel::activity::CommImpl*[comms->size()]);
std::transform(begin(*comms), end(*comms), rcomms.get(),
return simcall_comm_waitany(rcomms.get(), comms->size(), timeout);
}
-void Comm::wait_all(std::vector<CommPtr>* comms)
+void Comm::wait_all(const std::vector<CommPtr>* comms)
{
// TODO: this should be a simcall or something
// TODO: we are missing a version with timeout
}
return this;
}
-int Comm::test_any(std::vector<CommPtr>* comms)
+int Comm::test_any(const std::vector<CommPtr>* comms)
{
std::unique_ptr<kernel::activity::CommImpl* []> rcomms(new kernel::activity::CommImpl*[comms->size()]);
std::transform(begin(*comms), end(*comms), rcomms.get(),
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
{
kernel::activity::ConditionVariableImpl* cond =
kernel::actor::simcall([] { return new kernel::activity::ConditionVariableImpl(); });
- return ConditionVariablePtr(&cond->cond_, false);
+ return ConditionVariablePtr(cond->get_iface(), false);
}
/**
simcall_cond_wait(cond_, lock->pimpl_);
}
-void ConditionVariable::wait(std::unique_lock<Mutex>& lock)
+void ConditionVariable::wait(const std::unique_lock<Mutex>& lock)
{
simcall_cond_wait(cond_, lock.mutex()->pimpl_);
}
-std::cv_status s4u::ConditionVariable::wait_for(std::unique_lock<Mutex>& lock, double timeout)
+std::cv_status s4u::ConditionVariable::wait_for(const std::unique_lock<Mutex>& lock, double timeout)
{
// The simcall uses -1 for "any timeout" but we don't want this:
if (timeout < 0)
}
}
-std::cv_status ConditionVariable::wait_until(std::unique_lock<Mutex>& lock, double timeout_time)
+std::cv_status ConditionVariable::wait_until(const std::unique_lock<Mutex>& lock, double timeout_time)
{
double now = SIMIX_get_clock();
double timeout;
simgrid::kernel::actor::simcall([this]() { cond_->broadcast(); });
}
-void intrusive_ptr_add_ref(ConditionVariable* cond)
+void intrusive_ptr_add_ref(const ConditionVariable* cond)
{
intrusive_ptr_add_ref(cond->cond_);
}
-void intrusive_ptr_release(ConditionVariable* cond)
+void intrusive_ptr_release(const ConditionVariable* cond)
{
intrusive_ptr_release(cond->cond_);
}
cond->notify_all();
}
-void sg_cond_destroy(sg_cond_t cond)
+void sg_cond_destroy(const_sg_cond_t cond)
{
delete cond;
}
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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 "src/kernel/resource/DiskImpl.hpp"
namespace simgrid {
-namespace xbt {
-template class Extendable<s4u::Disk>;
-} // namespace xbt
+
+template class xbt::Extendable<s4u::Disk>;
namespace s4u {
return this->pimpl_->get_read_bandwidth();
}
-double Disk::get_write_bandwidth()
+double Disk::get_write_bandwidth() const
{
return pimpl_->get_write_bandwidth();
}
-Host* Disk::get_host()
+Host* Disk::get_host() const
{
return pimpl_->get_host();
}
IoPtr Disk::write_async(sg_size_t size)
{
-
return IoPtr(io_init(size, Io::OpType::WRITE)->start());
}
/* s4u::Engine Simulation Engine and global functions. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
return link == pimpl->links_.end() ? nullptr : link->second->get_iface();
}
-void Engine::link_register(const std::string& name, Link* link)
+void Engine::link_register(const std::string& name, const Link* link)
{
pimpl->links_[name] = link->get_impl();
}
return storage == pimpl->storages_.end() ? nullptr : storage->second->get_iface();
}
-void Engine::storage_register(const std::string& name, Storage* storage)
+void Engine::storage_register(const std::string& name, const Storage* storage)
{
pimpl->storages_[name] = storage->get_impl();
}
{
std::vector<ActorPtr> actor_list;
actor_list.push_back(simgrid::s4u::Actor::self());
- for (auto& kv : simix_global->process_list) {
+ for (auto const& kv : simix_global->process_list) {
actor_list.push_back(kv.second->iface());
}
return actor_list;
std::vector<ActorPtr> Engine::get_filtered_actors(const std::function<bool(ActorPtr)>& filter)
{
std::vector<ActorPtr> actor_list;
- for (auto& kv : simix_global->process_list) {
+ for (auto const& kv : simix_global->process_list) {
if (filter(kv.second->iface()))
actor_list.push_back(kv.second->iface());
}
return pimpl->netzone_root_->get_iface();
}
/** @brief Set the root netzone, containing all others. Once set, it cannot be changed. */
-void Engine::set_netzone_root(s4u::NetZone* netzone)
+void Engine::set_netzone_root(const s4u::NetZone* netzone)
{
xbt_assert(pimpl->netzone_root_ == nullptr, "The root NetZone cannot be changed once set");
pimpl->netzone_root_ = netzone->get_impl();
/** @brief Register a new netpoint to the system */
void Engine::netpoint_register(kernel::routing::NetPoint* point)
{
- // simgrid::kernel::actor::simcall([&]{ FIXME: this segfaults in set_thread
- pimpl->netpoints_[point->get_name()] = point;
- // });
+ simgrid::kernel::actor::simcall([this, point] { pimpl->netpoints_[point->get_name()] = point; });
}
/** @brief Unregister a given netpoint */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
}
Exec* Exec::wait()
+{
+ return this->wait_for(-1);
+}
+
+Exec* Exec::wait_for(double timeout)
{
if (state_ == State::INITED)
- start();
- simcall_execution_wait(pimpl_);
+ vetoable_start();
+ simcall_execution_wait(pimpl_, timeout);
state_ = State::FINISHED;
on_completion(*Actor::self(), *this);
this->release_dependencies();
return this;
}
-Exec* Exec::wait_for(double)
-{
- THROW_UNIMPLEMENTED;
-}
-
int Exec::wait_any_for(std::vector<ExecPtr>* execs, double timeout)
{
std::unique_ptr<kernel::activity::ExecImpl* []> rexecs(new kernel::activity::ExecImpl*[execs->size()]);
std::transform(begin(*execs), end(*execs), rexecs.get(),
[](const ExecPtr& exec) { return static_cast<kernel::activity::ExecImpl*>(exec->pimpl_.get()); });
- return simcall_execution_waitany_for(rexecs.get(), execs->size(), timeout);
+
+ int changed_pos = simcall_execution_waitany_for(rexecs.get(), execs->size(), timeout);
+ if (changed_pos != -1)
+ execs->at(changed_pos)->release_dependencies();
+ return changed_pos;
}
Exec* Exec::cancel()
bound_ = bound;
return this;
}
-ExecPtr Exec::set_timeout(double timeout)
+ExecPtr Exec::set_timeout(double timeout) // XBT_ATTRIB_DEPRECATED_v329
{
xbt_assert(state_ == State::INITED, "Cannot change the bound of an exec after its start");
timeout_ = timeout;
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
XBT_LOG_EXTERNAL_CATEGORY(surf_route);
namespace simgrid {
-namespace xbt {
-template class Extendable<s4u::Host>;
-} // namespace xbt
+
+template class xbt::Extendable<s4u::Host>;
namespace s4u {
*
* Daemons and regular actors are all mixed in this list.
*/
-std::vector<ActorPtr> Host::get_all_actors()
+std::vector<ActorPtr> Host::get_all_actors() const
{
return pimpl_->get_all_actors();
}
/** @brief Returns how many actors (daemonized or not) have been launched on this host */
-int Host::get_actor_count()
+int Host::get_actor_count() const
{
return pimpl_->get_actor_count();
}
* walk through the routing components tree and find a route between hosts
* by calling each "get_route" function in each routing component.
*/
-void Host::route_to(Host* dest, std::vector<Link*>& links, double* latency)
+void Host::route_to(const Host* dest, std::vector<Link*>& links, double* latency) const
{
std::vector<kernel::resource::LinkImpl*> linkImpls;
this->route_to(dest, linkImpls, latency);
}
/** @brief Just like Host::routeTo, but filling an array of link implementations */
-void Host::route_to(Host* dest, std::vector<kernel::resource::LinkImpl*>& links, double* latency)
+void Host::route_to(const Host* dest, std::vector<kernel::resource::LinkImpl*>& links, double* latency) const
{
kernel::routing::NetZoneImpl::get_global_route(pimpl_netpoint_, dest->get_netpoint(), links, latency);
if (XBT_LOG_ISENABLED(surf_route, xbt_log_priority_debug)) {
std::unordered_map<std::string, Storage*> const& Host::get_mounted_storages()
{
- if (mounts_ == nullptr) {
- mounts_ = new std::unordered_map<std::string, Storage*>();
- for (auto const& m : this->pimpl_->storage_) {
- mounts_->insert({m.first, m.second->get_iface()});
- }
- }
+ if (mounts_ == nullptr)
+ mounts_ = pimpl_->get_mounted_storages();
+
return *mounts_;
}
return res;
}
-const char* sg_host_get_name(sg_host_t host)
+const char* sg_host_get_name(const_sg_host_t host)
{
return host->get_cname();
}
-void* sg_host_extension_get(sg_host_t host, size_t ext)
+void* sg_host_extension_get(const_sg_host_t host, size_t ext)
{
return host->extension(ext);
}
// ========= Layering madness ==============*
// ========== User data Layer ==========
-void* sg_host_data(sg_host_t host)
+void* sg_host_data(const_sg_host_t host)
{
return host->get_data();
}
xbt_dict_t res = xbt_dict_new_homogeneous(nullptr);
for (auto const& elm : host->get_mounted_storages()) {
const char* mount_name = elm.first.c_str();
- sg_storage_t storage = elm.second;
+ const simgrid::s4u::Storage* storage = elm.second;
xbt_dict_set(res, mount_name, (void*)storage->get_cname());
}
return res;
}
-xbt_dynar_t sg_host_get_attached_storage_list(sg_host_t host)
+xbt_dynar_t sg_host_get_attached_storage_list(const_sg_host_t host)
{
xbt_dynar_t storage_dynar = xbt_dynar_new(sizeof(const char*), nullptr);
std::vector<const char*> storage_vector = host->get_attached_storages();
// =========== user-level functions ===============
// ================================================
/** @brief Returns the total speed of a host */
-double sg_host_speed(sg_host_t host)
+double sg_host_speed(const_sg_host_t host)
{
return host->get_speed();
}
* @param pstate_index pstate to test
* @return Returns the processor speed associated with pstate_index
*/
-double sg_host_get_pstate_speed(sg_host_t host, int pstate_index)
+double sg_host_get_pstate_speed(const_sg_host_t host, int pstate_index)
{
return host->get_pstate_speed(pstate_index);
}
* @param host a host
* @return the number of cores
*/
-int sg_host_core_count(sg_host_t host)
+int sg_host_core_count(const_sg_host_t host)
{
return host->get_core_count();
}
-double sg_host_get_available_speed(sg_host_t host)
+double sg_host_get_available_speed(const_sg_host_t host)
{
return host->get_available_speed();
}
*
* See also @ref plugin_energy.
*/
-int sg_host_get_nb_pstates(sg_host_t host)
+int sg_host_get_nb_pstates(const_sg_host_t host)
{
return host->get_pstate_count();
}
*
* See also @ref plugin_energy.
*/
-int sg_host_get_pstate(sg_host_t host)
+int sg_host_get_pstate(const_sg_host_t host)
{
return host->get_pstate();
}
* @param host host to test
* @return Returns true if the host is up and running, and false if it's currently down
*/
-int sg_host_is_on(sg_host_t host)
+int sg_host_is_on(const_sg_host_t host)
{
return host->is_on();
}
/** @brief Get the properties of a host */
-xbt_dict_t sg_host_get_properties(sg_host_t host)
+xbt_dict_t sg_host_get_properties(const_sg_host_t host)
{
xbt_dict_t as_dict = xbt_dict_new_homogeneous(xbt_free_f);
const std::unordered_map<std::string, std::string>* props = host->get_properties();
* @param name a property name
* @return value of a property (or nullptr if property not set)
*/
-const char* sg_host_get_property_value(sg_host_t host, const char* name)
+const char* sg_host_get_property_value(const_sg_host_t host, const char* name)
{
return host->get_property(name);
}
* @param to where to
* @param links [OUT] where to store the list of links (must exist, cannot be nullptr).
*/
-void sg_host_route(sg_host_t from, sg_host_t to, xbt_dynar_t links)
+void sg_host_route(const_sg_host_t from, const_sg_host_t to, xbt_dynar_t links)
{
std::vector<simgrid::s4u::Link*> vlinks;
from->route_to(to, vlinks, nullptr);
* @param from where from
* @param to where to
*/
-double sg_host_route_latency(sg_host_t from, sg_host_t to)
+double sg_host_route_latency(const_sg_host_t from, const_sg_host_t to)
{
std::vector<simgrid::s4u::Link*> vlinks;
double res = 0;
* @param from where from
* @param to where to
*/
-double sg_host_route_bandwidth(sg_host_t from, sg_host_t to)
+double sg_host_route_bandwidth(const_sg_host_t from, const_sg_host_t to)
{
double min_bandwidth = -1.0;
}
/** @brief Displays debugging information about a host */
-void sg_host_dump(sg_host_t host)
+void sg_host_dump(const_sg_host_t host)
{
XBT_INFO("Displaying host %s", host->get_cname());
XBT_INFO(" - speed: %.0f", host->get_speed());
* @param host a host
* @param whereto a dynar in which we should push actors living on that host
*/
-void sg_host_get_actor_list(sg_host_t host, xbt_dynar_t whereto)
+void sg_host_get_actor_list(const_sg_host_t host, xbt_dynar_t whereto)
{
- auto actors = host->get_all_actors();
- for (auto& actor : actors)
+ auto const actors = host->get_all_actors();
+ for (auto const& actor : actors)
xbt_dynar_push(whereto, &actor);
}
/* needs to be public and without simcall for exceptions and logging events */
const char* sg_host_self_get_name()
{
- return SIMIX_is_maestro() ? "" : simgrid::kernel::actor::ActorImpl::self()->get_host()->get_cname();
+ const char* res = "";
+ if (not SIMIX_is_maestro()) {
+ const simgrid::s4u::Host* host = simgrid::kernel::actor::ActorImpl::self()->get_host();
+ if (host != nullptr)
+ res = host->get_cname();
+ }
+ return res;
}
-double sg_host_load(sg_host_t host)
+double sg_host_load(const_sg_host_t host)
{
return host->get_load();
}
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
Io* Io::wait()
{
- simcall_io_wait(pimpl_);
- state_ = State::FINISHED;
- return this;
+ return this->wait_for(-1);
}
-Io* Io::wait_for(double)
+Io* Io::wait_for(double timeout)
{
- THROW_UNIMPLEMENTED;
+ simcall_io_wait(pimpl_, timeout);
+ state_ = State::FINISHED;
+ return this;
}
bool Io::test()
if (state_ == State::INITED)
this->start();
- THROW_UNIMPLEMENTED;
+ if (simcall_io_test(pimpl_)) {
+ state_ = State::FINISHED;
+ return true;
+ }
- // return false
+ return false;
}
/** @brief Returns the amount of flops that remain to be done */
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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/log.h"
namespace simgrid {
+
+template class xbt::Extendable<s4u::Link>;
+
namespace s4u {
xbt::signal<void(Link&)> Link::on_creation;
{
return this->pimpl_->get_cname();
}
-bool Link::is_used()
+bool Link::is_used() const
{
return this->pimpl_->is_used();
}
return this->pimpl_->get_bandwidth();
}
-Link::SharingPolicy Link::get_sharing_policy()
+Link::SharingPolicy Link::get_sharing_policy() const
{
return this->pimpl_->get_sharing_policy();
}
-double Link::get_usage()
+double Link::get_usage() const
{
return this->pimpl_->get_constraint()->get_usage();
}
/* **************************** Public C interface *************************** */
-const char* sg_link_name(sg_link_t link)
+const char* sg_link_name(const_sg_link_t link)
{
return link->get_cname();
}
return simgrid::s4u::Link::by_name(name);
}
-int sg_link_is_shared(sg_link_t link)
+int sg_link_is_shared(const_sg_link_t link)
{
return (int)link->get_sharing_policy();
}
-double sg_link_bandwidth(sg_link_t link)
+double sg_link_bandwidth(const_sg_link_t link)
{
return link->get_bandwidth();
}
-double sg_link_latency(sg_link_t link)
+double sg_link_latency(const_sg_link_t link)
{
return link->get_latency();
}
-void* sg_link_data(sg_link_t link)
+void* sg_link_data(const_sg_link_t link)
{
return link->get_data();
}
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
return res;
}
-smx_activity_t Mailbox::iprobe(int type, int (*match_fun)(void*, void*, kernel::activity::CommImpl*), void* data)
+smx_activity_t Mailbox::iprobe(int type, bool (*match_fun)(void*, void*, kernel::activity::CommImpl*), void* data)
{
return kernel::actor::simcall([this, type, match_fun, data] { return pimpl_->iprobe(type, match_fun, data); });
}
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
}
/* refcounting of the intrusive_ptr is delegated to the implementation object */
-void intrusive_ptr_add_ref(Mutex* mutex)
+void intrusive_ptr_add_ref(const Mutex* mutex)
{
xbt_assert(mutex);
if (mutex->pimpl_)
mutex->pimpl_->ref();
}
-void intrusive_ptr_release(Mutex* mutex)
+void intrusive_ptr_release(const Mutex* mutex)
{
xbt_assert(mutex);
if (mutex->pimpl_)
return mutex->try_lock();
}
-void sg_mutex_destroy(sg_mutex_t mutex)
+void sg_mutex_destroy(const_sg_mutex_t mutex)
{
delete mutex;
}
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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 Returns the list of direct children (no grand-children) */
-std::vector<NetZone*> NetZone::get_children()
+std::vector<NetZone*> NetZone::get_children() const
{
std::vector<NetZone*> res;
for (auto child : *(pimpl_->get_children()))
* Only the hosts that are directly contained in this NetZone are retrieved,
* not the ones contained in sub-netzones.
*/
-std::vector<Host*> NetZone::get_all_hosts()
+std::vector<Host*> NetZone::get_all_hosts() const
{
return pimpl_->get_all_hosts();
}
return simgrid::s4u::Engine::get_instance()->get_netzone_root();
}
-const char* sg_zone_get_name(sg_netzone_t netzone)
+const char* sg_zone_get_name(const_sg_netzone_t netzone)
{
return netzone->get_cname();
}
return simgrid::s4u::Engine::get_instance()->netzone_by_name_or_null(name);
}
-void sg_zone_get_sons(sg_netzone_t netzone, xbt_dict_t whereto)
+void sg_zone_get_sons(const_sg_netzone_t netzone, xbt_dict_t whereto)
{
for (auto const& elem : netzone->get_children()) {
xbt_dict_set(whereto, elem->get_cname(), static_cast<void*>(elem));
}
}
-const char* sg_zone_get_property_value(sg_netzone_t netzone, const char* name)
+const char* sg_zone_get_property_value(const_sg_netzone_t netzone, const char* name)
{
return netzone->get_property(name);
}
-void sg_zone_set_property_value(sg_netzone_t netzone, const char* name, char* value)
+void sg_zone_set_property_value(sg_netzone_t netzone, const char* name, const char* value)
{
netzone->set_property(name, value);
}
-void sg_zone_get_hosts(sg_netzone_t netzone, xbt_dynar_t whereto)
+void sg_zone_get_hosts(const_sg_netzone_t netzone, xbt_dynar_t whereto)
{
/* converts vector to dynar */
std::vector<simgrid::s4u::Host*> hosts = netzone->get_all_hosts();
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
Semaphore::~Semaphore()
{
if (sem_ != nullptr) {
- xbt_assert(sem_->sleeping_.empty(), "Cannot destroy semaphore since someone is still using it");
+ xbt_assert(not sem_->is_used(), "Cannot destroy semaphore since someone is still using it");
delete sem_;
}
}
return sem->get_capacity();
}
-void sg_sem_destroy(sg_sem_t sem)
+void sg_sem_destroy(const_sg_sem_t sem)
{
delete sem;
}
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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 "src/surf/StorageImpl.hpp"
namespace simgrid {
-namespace xbt {
-template class Extendable<s4u::Storage>;
-} // namespace xbt
+
+template class xbt::Extendable<s4u::Storage>;
namespace s4u {
return Engine::get_instance()->storage_by_name_or_null(name);
}
-const char* Storage::get_type()
+const char* Storage::get_type() const
{
- return pimpl_->typeId_.c_str();
+ return pimpl_->get_type();
}
const std::unordered_map<std::string, std::string>* Storage::get_properties() const
IoPtr Storage::write_async(sg_size_t size)
{
-
return IoPtr(io_init(size, Io::OpType::WRITE)->start());
}
*
* This functions checks whether a storage is a valid pointer or not and return its name.
*/
-const char* sg_storage_get_name(sg_storage_t storage)
+const char* sg_storage_get_name(const_sg_storage_t storage)
{
xbt_assert((storage != nullptr), "Invalid parameters");
return storage->get_cname();
}
-const char* sg_storage_get_host(sg_storage_t storage)
+const char* sg_storage_get_host(const_sg_storage_t storage)
{
xbt_assert((storage != nullptr), "Invalid parameters");
return storage->get_host()->get_cname();
* @param storage a storage
* @return a dict containing the properties
*/
-xbt_dict_t sg_storage_get_properties(sg_storage_t storage)
+xbt_dict_t sg_storage_get_properties(const_sg_storage_t storage)
{
xbt_assert((storage != nullptr), "Invalid parameters (storage is nullptr)");
xbt_dict_t as_dict = xbt_dict_new_homogeneous(xbt_free_f);
* @param name a property name
* @return value of a property (or nullptr if property not set)
*/
-const char* sg_storage_get_property_value(sg_storage_t storage, const char* name)
+const char* sg_storage_get_property_value(const_sg_storage_t storage, const char* name)
{
return storage->get_property(name);
}
return res;
}
-void* sg_storage_get_data(sg_storage_t storage)
+void* sg_storage_get_data(const_sg_storage_t storage)
{
xbt_assert((storage != nullptr), "Invalid parameters");
return storage->get_data();
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* Ensure that transfer tasks have unique names even though a file is used several times */
void uniq_transfer_task_name(SD_task_t task)
{
- SD_task_t child = *(task->successors->begin());
- SD_task_t parent = *(task->predecessors->begin());
+ const_SD_task_t child = *(task->successors->begin());
+ const_SD_task_t parent = *(task->predecessors->begin());
std::string new_name =
std::string(SD_task_get_name(parent)) + "_" + SD_task_get_name(task) + "_" + SD_task_get_name(child);
SD_task_set_name(task, new_name.c_str());
}
-static bool children_are_marked(SD_task_t task){
+static bool children_are_marked(const_SD_task_t task)
+{
return std::none_of(task->successors->begin(), task->successors->end(),
[](const SD_task_t& elm) { return not elm->marked; }) &&
std::none_of(task->outputs->begin(), task->outputs->end(),
[](const SD_task_t& elm) { return not elm->marked; });
}
-static bool parents_are_marked(SD_task_t task){
+static bool parents_are_marked(const_SD_task_t task)
+{
return std::none_of(task->predecessors->begin(), task->predecessors->end(),
[](const SD_task_t& elm) { return not elm->marked; }) &&
std::none_of(task->inputs->begin(), task->inputs->end(), [](const SD_task_t& elm) { return not elm->marked; });
}
-bool acyclic_graph_detail(xbt_dynar_t dag){
+bool acyclic_graph_detail(const_xbt_dynar_t dag)
+{
unsigned int count;
bool all_marked = true;
SD_task_t task = nullptr;
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
if (comp != computers.end()) {
computer = comp->second;
} else {
- computer = new std::vector<SD_task_t>;
+ computer = new std::vector<SD_task_t>();
computers.insert({char_performer, computer});
}
if (static_cast<unsigned int>(order) < computer->size()) {
- SD_task_t task_test = computer->at(order);
+ const s_SD_task_t* task_test = computer->at(order);
if (task_test && task_test != task) {
/* the user gave the same order to several tasks */
schedule_success = false;
std::sort(edges.begin(), edges.end(), [](const Agedge_t* a, const Agedge_t* b) { return AGSEQ(a) < AGSEQ(b); });
for (Agedge_t* edge : edges) {
- char *src_name=agnameof(agtail(edge));
- char *dst_name=agnameof(aghead(edge));
+ const char* src_name = agnameof(agtail(edge));
+ const char* dst_name = agnameof(aghead(edge));
double size = atof(agget(edge, (char *) "size"));
SD_task_t src = jobs.at(src_name);
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
/* main loop */
while (elapsed_time >= 0 && (how_long < 0 || 0.00001 < (how_long - total_time)) &&
not sd_global->watch_point_reached) {
-
XBT_DEBUG("Total time: %f", total_time);
elapsed_time = surf_solve(how_long > 0 ? surf_get_clock() + how_long - total_time: -1.0);
/* let's see which tasks are done */
for (auto const& model : all_existing_models) {
- simgrid::kernel::resource::Action* action = model->extract_done_action();
+ const simgrid::kernel::resource::Action* action = model->extract_done_action();
while (action != nullptr && action->get_data() != nullptr) {
SD_task_t task = static_cast<SD_task_t>(action->get_data());
XBT_VERB("Task '%s' done", SD_task_get_name(task));
void SD_simulate_with_update(double how_long, xbt_dynar_t changed_tasks_dynar)
{
- std::set<SD_task_t> *changed_tasks = simgrid::sd::simulate(how_long);
+ const std::set<SD_task_t>* changed_tasks = simgrid::sd::simulate(how_long);
for (auto const& task : *changed_tasks)
xbt_dynar_push(changed_tasks_dynar, &task);
}
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* @return the user data associated with this task (can be @c nullptr)
* @see SD_task_set_data()
*/
-void *SD_task_get_data(SD_task_t task)
+void* SD_task_get_data(const_SD_task_t task)
{
return task->data;
}
* #SD_NOT_SCHEDULED, #SD_SCHEDULED, #SD_RUNNABLE, #SD_RUNNING, #SD_DONE or #SD_FAILED
* @see e_SD_task_state_t
*/
-e_SD_task_state_t SD_task_get_state(SD_task_t task)
+e_SD_task_state_t SD_task_get_state(const_SD_task_t task)
{
return task->state;
}
* @param task a task
* @return the name of this task (can be @c nullptr)
*/
-const char *SD_task_get_name(SD_task_t task)
+const char* SD_task_get_name(const_SD_task_t task)
{
return task->name;
}
* @return a newly allocated dynar comprising the parents of this task
*/
-xbt_dynar_t SD_task_get_parents(SD_task_t task)
+xbt_dynar_t SD_task_get_parents(const_SD_task_t task)
{
xbt_dynar_t parents = xbt_dynar_new(sizeof(SD_task_t), nullptr);
* @param task a task
* @return a newly allocated dynar comprising the parents of this task
*/
-xbt_dynar_t SD_task_get_children(SD_task_t task)
+xbt_dynar_t SD_task_get_children(const_SD_task_t task)
{
xbt_dynar_t children = xbt_dynar_new(sizeof(SD_task_t), nullptr);
* Only call this on already scheduled tasks!
* @param task a task
*/
-int SD_task_get_workstation_count(SD_task_t task)
+int SD_task_get_workstation_count(const_SD_task_t task)
{
return task->allocation->size();
}
* Only call this on already scheduled tasks!
* @param task a task
*/
-sg_host_t *SD_task_get_workstation_list(SD_task_t task)
+sg_host_t* SD_task_get_workstation_list(const_SD_task_t task)
{
return task->allocation->data();
}
* @return the total amount of work (computation or data transfer) for this task
* @see SD_task_get_remaining_amount()
*/
-double SD_task_get_amount(SD_task_t task)
+double SD_task_get_amount(const_SD_task_t task)
{
return task->amount;
}
* @param task a parallel task assuming Amdahl's law as speedup model
* @return the alpha parameter (serial part of a task in percent) for this task
*/
-double SD_task_get_alpha(SD_task_t task)
+double SD_task_get_alpha(const_SD_task_t task)
{
xbt_assert(SD_task_get_kind(task) == SD_TASK_COMP_PAR_AMDAHL, "Alpha parameter is not defined for this kind of task");
return task->alpha;
* @return the remaining amount of work (computation or data transfer) of this task
* @see SD_task_get_amount()
*/
-double SD_task_get_remaining_amount(SD_task_t task)
+double SD_task_get_remaining_amount(const_SD_task_t task)
{
if (task->surf_action)
return task->surf_action->get_remains();
return (task->state == SD_DONE) ? 0 : task->amount;
}
-e_SD_task_kind_t SD_task_get_kind(SD_task_t task)
+e_SD_task_kind_t SD_task_get_kind(const_SD_task_t task)
{
return task->kind;
}
/** @brief Displays debugging information about a task */
-void SD_task_dump(SD_task_t task)
+void SD_task_dump(const_SD_task_t task)
{
XBT_INFO("Displaying task %s", SD_task_get_name(task));
if (task->state == SD_RUNNABLE)
}
/** @brief Dumps the task in dotty formalism into the FILE* passed as second argument */
-void SD_task_dotty(SD_task_t task, void *out)
+void SD_task_dotty(const_SD_task_t task, void* out)
{
FILE *fout = static_cast<FILE*>(out);
fprintf(fout, " T%p [label=\"%.20s\"", task, task->name);
* If src is nullptr, checks whether dst has any pre-dependency.
* If dst is nullptr, checks whether src has any post-dependency.
*/
-int SD_task_dependency_exists(SD_task_t src, SD_task_t dst)
+int SD_task_dependency_exists(const_SD_task_t src, SD_task_t dst)
{
xbt_assert(src != nullptr || dst != nullptr, "Invalid parameter: both src and dst are nullptr");
* @param bytes_amount communication amount between each pair of hosts (i.e., a matrix of host_count*host_count doubles)
* @see SD_schedule()
*/
-double SD_task_get_execution_time(SD_task_t /*task*/, int host_count, const sg_host_t* host_list,
+double SD_task_get_execution_time(const_SD_task_t /*task*/, int host_count, const sg_host_t* host_list,
const double* flops_amount, const double* bytes_amount)
{
xbt_assert(host_count > 0, "Invalid parameter");
* @param task: a task
* @return the start time of this task
*/
-double SD_task_get_start_time(SD_task_t task)
+double SD_task_get_start_time(const_SD_task_t task)
{
if (task->surf_action)
return task->surf_action->get_start_time();
* @param task: a task
* @return the start time of this task
*/
-double SD_task_get_finish_time(SD_task_t task)
+double SD_task_get_finish_time(const_SD_task_t task)
{
if (task->surf_action) /* should never happen as actions are destroyed right after their completion */
return task->surf_action->get_finish_time();
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
/* SimDag private functions */
XBT_PRIVATE void SD_task_set_state(SD_task_t task, e_SD_task_state_t new_state);
XBT_PRIVATE void SD_task_run(SD_task_t task);
-XBT_PRIVATE bool acyclic_graph_detail(xbt_dynar_t dag);
+XBT_PRIVATE bool acyclic_graph_detail(const_xbt_dynar_t dag);
XBT_PRIVATE void uniq_transfer_task_name(SD_task_t task);
XBT_PRIVATE const char *__get_state_name(e_SD_task_state_t state);
#endif
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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. */
-/* Copyright (c) 2015-2019. The SimGrid Team.
+/* Copyright (c) 2015-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
return &i->second;
}
-}
-}
+} // namespace util
+} // namespace simgrid
#endif
/* */
/* This is somehow the "libc" of SimGrid */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
*
* @param execution The execution synchro
*/
-e_smx_state_t simcall_execution_wait(const smx_activity_t& execution)
+e_smx_state_t simcall_execution_wait(const smx_activity_t& execution, double timeout)
{
- return (e_smx_state_t)simcall_BODY_execution_wait(static_cast<simgrid::kernel::activity::ExecImpl*>(execution.get()));
+ return (e_smx_state_t)simcall_BODY_execution_wait(static_cast<simgrid::kernel::activity::ExecImpl*>(execution.get()),
+ timeout);
}
bool simcall_execution_test(const smx_activity_t& execution)
* @ingroup simix_comm_management
*/
void simcall_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff,
- size_t src_buff_size, int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+ size_t src_buff_size, bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data,
double timeout)
{
*/
smx_activity_t simcall_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff,
size_t src_buff_size,
- int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+ bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
void (*clean_fun)(void*),
void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
void* data, bool detached)
* @ingroup simix_comm_management
*/
void simcall_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size,
- int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+ bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data,
double timeout, double rate)
{
* @ingroup simix_comm_management
*/
smx_activity_t simcall_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size,
- int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+ bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
void* data, double rate)
{
* @ingroup simix_comm_management
*/
smx_activity_t simcall_comm_iprobe(smx_mailbox_t mbox, int type,
- int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), void* data)
+ bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), void* data)
{
xbt_assert(mbox, "No rendez-vous point defined for iprobe");
return simcall_BODY_sem_acquire_timeout(sem, timeout);
}
-e_smx_state_t simcall_io_wait(const smx_activity_t& io)
+e_smx_state_t simcall_io_wait(const smx_activity_t& io, double timeout)
{
- return (e_smx_state_t)simcall_BODY_io_wait(static_cast<simgrid::kernel::activity::IoImpl*>(io.get()));
+ return (e_smx_state_t)simcall_BODY_io_wait(static_cast<simgrid::kernel::activity::IoImpl*>(io.get()), timeout);
+}
+
+bool simcall_io_test(const smx_activity_t& io)
+{
+ return simcall_BODY_io_test(static_cast<simgrid::kernel::activity::IoImpl*>(io.get()));
}
void simcall_run_kernel(std::function<void()> const& code, simgrid::mc::SimcallInspector* t)
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
/* DO NOT EVER CHANGE THIS FILE */
/* */
/* change simcalls specification in src/simix/simcalls.in */
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved. */
/**********************************************************************/
/*
{
simgrid::simix::marshal<simgrid::kernel::activity::ExecImpl*>(simcall->args_[0], arg);
}
+static inline double simcall_execution_wait__get__timeout(smx_simcall_t simcall)
+{
+ return simgrid::simix::unmarshal<double>(simcall->args_[1]);
+}
+static inline double simcall_execution_wait__getraw__timeout(smx_simcall_t simcall)
+{
+ return simgrid::simix::unmarshal_raw<double>(simcall->args_[1]);
+}
+static inline void simcall_execution_wait__set__timeout(smx_simcall_t simcall, double arg)
+{
+ simgrid::simix::marshal<double>(simcall->args_[1], arg);
+}
static inline int simcall_execution_wait__get__result(smx_simcall_t simcall)
{
return simgrid::simix::unmarshal<int>(simcall->result_);
{
simgrid::simix::marshal<simgrid::kernel::activity::IoImpl*>(simcall->args_[0], arg);
}
+static inline double simcall_io_wait__get__timeout(smx_simcall_t simcall)
+{
+ return simgrid::simix::unmarshal<double>(simcall->args_[1]);
+}
+static inline double simcall_io_wait__getraw__timeout(smx_simcall_t simcall)
+{
+ return simgrid::simix::unmarshal_raw<double>(simcall->args_[1]);
+}
+static inline void simcall_io_wait__set__timeout(smx_simcall_t simcall, double arg)
+{
+ simgrid::simix::marshal<double>(simcall->args_[1], arg);
+}
static inline sg_size_t simcall_io_wait__get__result(smx_simcall_t simcall)
{
return simgrid::simix::unmarshal<sg_size_t>(simcall->result_);
simgrid::simix::marshal<sg_size_t>(simcall->result_, result);
}
+static inline simgrid::kernel::activity::IoImpl* simcall_io_test__get__io(smx_simcall_t simcall)
+{
+ return simgrid::simix::unmarshal<simgrid::kernel::activity::IoImpl*>(simcall->args_[0]);
+}
+static inline simgrid::kernel::activity::IoImpl* simcall_io_test__getraw__io(smx_simcall_t simcall)
+{
+ return simgrid::simix::unmarshal_raw<simgrid::kernel::activity::IoImpl*>(simcall->args_[0]);
+}
+static inline void simcall_io_test__set__io(smx_simcall_t simcall, simgrid::kernel::activity::IoImpl* arg)
+{
+ simgrid::simix::marshal<simgrid::kernel::activity::IoImpl*>(simcall->args_[0], arg);
+}
+static inline bool simcall_io_test__get__result(smx_simcall_t simcall)
+{
+ return simgrid::simix::unmarshal<bool>(simcall->result_);
+}
+static inline bool simcall_io_test__getraw__result(smx_simcall_t simcall)
+{
+ return simgrid::simix::unmarshal_raw<bool>(simcall->result_);
+}
+static inline void simcall_io_test__set__result(smx_simcall_t simcall, bool result)
+{
+ simgrid::simix::marshal<bool>(simcall->result_, result);
+}
+
static inline int simcall_mc_random__get__min(smx_simcall_t simcall)
{
return simgrid::simix::unmarshal<int>(simcall->args_[0]);
/* The prototype of all simcall handlers, automatically generated for you */
-XBT_PRIVATE void simcall_HANDLER_execution_wait(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* execution);
+XBT_PRIVATE void simcall_HANDLER_execution_wait(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* execution, double timeout);
XBT_PRIVATE void simcall_HANDLER_execution_waitany_for(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl** execs, size_t count, double timeout);
XBT_PRIVATE void simcall_HANDLER_execution_test(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* execution);
XBT_PRIVATE void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, unsigned char* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout);
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_io_wait(smx_simcall_t simcall, simgrid::kernel::activity::IoImpl* io);
+XBT_PRIVATE void simcall_HANDLER_io_wait(smx_simcall_t simcall, simgrid::kernel::activity::IoImpl* io, double timeout);
+XBT_PRIVATE void simcall_HANDLER_io_test(smx_simcall_t simcall, simgrid::kernel::activity::IoImpl* io);
XBT_PRIVATE int simcall_HANDLER_mc_random(smx_simcall_t simcall, int min, int max);
/* DO NOT EVER CHANGE THIS FILE */
/* */
/* change simcalls specification in src/simix/simcalls.in */
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved. */
/**********************************************************************/
/*
return simgrid::simix::unmarshal<R>(self->simcall.result_);
}
-inline static int simcall_BODY_execution_wait(simgrid::kernel::activity::ExecImpl* execution)
+inline static int simcall_BODY_execution_wait(simgrid::kernel::activity::ExecImpl* execution, double timeout)
{
if (0) /* Go to that function to follow the code flow through the simcall barrier */
- simcall_HANDLER_execution_wait(&SIMIX_process_self()->simcall, execution);
- return simcall<int, simgrid::kernel::activity::ExecImpl*>(SIMCALL_EXECUTION_WAIT, execution);
+ simcall_HANDLER_execution_wait(&SIMIX_process_self()->simcall, execution, timeout);
+ return simcall<int, simgrid::kernel::activity::ExecImpl*, double>(SIMCALL_EXECUTION_WAIT, execution, timeout);
}
inline static int simcall_BODY_execution_waitany_for(simgrid::kernel::activity::ExecImpl** execs, size_t count, double timeout)
return simcall<int, smx_sem_t, double>(SIMCALL_SEM_ACQUIRE_TIMEOUT, sem, timeout);
}
-inline static sg_size_t simcall_BODY_io_wait(simgrid::kernel::activity::IoImpl* io)
+inline static sg_size_t simcall_BODY_io_wait(simgrid::kernel::activity::IoImpl* io, double timeout)
{
if (0) /* Go to that function to follow the code flow through the simcall barrier */
- simcall_HANDLER_io_wait(&SIMIX_process_self()->simcall, io);
- return simcall<sg_size_t, simgrid::kernel::activity::IoImpl*>(SIMCALL_IO_WAIT, io);
+ simcall_HANDLER_io_wait(&SIMIX_process_self()->simcall, io, timeout);
+ return simcall<sg_size_t, simgrid::kernel::activity::IoImpl*, double>(SIMCALL_IO_WAIT, io, timeout);
+}
+
+inline static bool simcall_BODY_io_test(simgrid::kernel::activity::IoImpl* io)
+{
+ if (0) /* Go to that function to follow the code flow through the simcall barrier */
+ simcall_HANDLER_io_test(&SIMIX_process_self()->simcall, io);
+ return simcall<bool, simgrid::kernel::activity::IoImpl*>(SIMCALL_IO_TEST, io);
}
inline static int simcall_BODY_mc_random(int min, int max)
/* DO NOT EVER CHANGE THIS FILE */
/* */
/* change simcalls specification in src/simix/simcalls.in */
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved. */
/**********************************************************************/
/*
SIMCALL_SEM_ACQUIRE,
SIMCALL_SEM_ACQUIRE_TIMEOUT,
SIMCALL_IO_WAIT,
+ SIMCALL_IO_TEST,
SIMCALL_MC_RANDOM,
SIMCALL_RUN_KERNEL,
SIMCALL_RUN_BLOCKING,
/* DO NOT EVER CHANGE THIS FILE */
/* */
/* change simcalls specification in src/simix/simcalls.in */
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved. */
/**********************************************************************/
/*
"SIMCALL_SEM_ACQUIRE",
"SIMCALL_SEM_ACQUIRE_TIMEOUT",
"SIMCALL_IO_WAIT",
+ "SIMCALL_IO_TEST",
"SIMCALL_MC_RANDOM",
"SIMCALL_RUN_KERNEL",
"SIMCALL_RUN_BLOCKING",
void simgrid::kernel::actor::ActorImpl::simcall_handle(int value) {
XBT_DEBUG("Handling simcall %p: %s", &simcall, SIMIX_simcall_name(simcall.call_));
SIMCALL_SET_MC_VALUE(simcall, value);
- if (context_->iwannadie)
+ if (context_->wannadie())
return;
switch (simcall.call_) {
case SIMCALL_EXECUTION_WAIT:
- simcall_HANDLER_execution_wait(&simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::ExecImpl*>(simcall.args_[0]));
+ simcall_HANDLER_execution_wait(&simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::ExecImpl*>(simcall.args_[0]), simgrid::simix::unmarshal<double>(simcall.args_[1]));
break;
case SIMCALL_EXECUTION_WAITANY_FOR:
break;
case SIMCALL_IO_WAIT:
- simcall_HANDLER_io_wait(&simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::IoImpl*>(simcall.args_[0]));
+ simcall_HANDLER_io_wait(&simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::IoImpl*>(simcall.args_[0]), simgrid::simix::unmarshal<double>(simcall.args_[1]));
+ break;
+
+ case SIMCALL_IO_TEST:
+ simcall_HANDLER_io_test(&simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::IoImpl*>(simcall.args_[0]));
break;
case SIMCALL_MC_RANDOM:
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
XBT_PUBLIC_DATA const char* simcall_names[]; /* Name of each simcall */
-typedef int (*simix_match_func_t)(void*, void*, simgrid::kernel::activity::CommImpl*);
+typedef bool (*simix_match_func_t)(void*, void*, simgrid::kernel::activity::CommImpl*);
typedef void (*simix_copy_data_func_t)(simgrid::kernel::activity::CommImpl*, void*, size_t);
typedef void (*simix_clean_func_t)(void*);
typedef void (*FPtr)(void); // Hide the ugliness
-# Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2014-2020. 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.
# Last but not the least, you should declare the new simix call in
# ./include/simgrid/simix.h (otherwise you will get a warning at compile time)
-int execution_wait(simgrid::kernel::activity::ExecImpl* execution) [[block]];
+int execution_wait(simgrid::kernel::activity::ExecImpl* execution, double timeout) [[block]];
int execution_waitany_for(simgrid::kernel::activity::ExecImpl** execs, size_t count, double timeout) [[block]];
bool execution_test(simgrid::kernel::activity::ExecImpl* execution) [[block]];
void sem_acquire(smx_sem_t sem) [[block]];
int sem_acquire_timeout(smx_sem_t sem, double timeout) [[block]];
-sg_size_t io_wait(simgrid::kernel::activity::IoImpl* io) [[block]];
+sg_size_t io_wait(simgrid::kernel::activity::IoImpl* io, double timeout) [[block]];
+bool io_test(simgrid::kernel::activity::IoImpl* io) [[block]];
int mc_random(int min, int max);
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2014-2020. 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.
res.append(indent + 'case SIMCALL_%s:' % (self.name.upper()))
if self.need_handler:
call = "simcall_HANDLER_%s(&simcall%s%s)" % (self.name,
- ", " if len(args) > 0 else "",
+ ", " if args else "",
', '.join(args))
else:
call = "SIMIX_%s(%s)" % (self.name, ', '.join(args))
self.name,
''.join(', %s %s' % (arg.rettype(), arg.name)
for i, arg in enumerate(self.args)))
- else:
- return ""
+ return ""
def parse(fn):
fd.write(
'/* change simcalls specification in src/simix/simcalls.in */\n')
fd.write(
- '/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */\n')
+ '/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved. */\n')
fd.write(
'/**********************************************************************/\n\n')
fd.write('/*\n')
' XBT_DEBUG("Handling simcall %p: %s", &simcall, SIMIX_simcall_name(simcall.call_));\n')
fd.write(' SIMCALL_SET_MC_VALUE(simcall, value);\n')
fd.write(
- ' if (context_->iwannadie)\n')
+ ' if (context_->wannadie())\n')
fd.write(' return;\n')
fd.write(' switch (simcall.call_) {\n')
/* a fast and simple context switching library */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
{
simgrid::kernel::routing::ActorCreationArgs actor;
- sg_host_t host = sg_host_by_name(process_host);
+ const simgrid::s4u::Host* host = sg_host_by_name(process_host);
if (not host)
throw std::invalid_argument(simgrid::xbt::string_printf("Host '%s' unknown", process_host));
actor.host = process_host;
}
// Check we know how to handle this function name:
- simgrid::simix::ActorCodeFactory& parse_code = SIMIX_get_actor_code_factory(process_function);
+ const simgrid::simix::ActorCodeFactory& parse_code = SIMIX_get_actor_code_factory(process_function);
xbt_assert(parse_code, "Function '%s' unknown", process_function);
actor.function = process_function;
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
/* register a function to be called by SURF after the environment creation */
sg_platf_init();
simgrid::s4u::Engine::on_platform_created.connect(surf_presolve);
-
- simgrid::s4u::Storage::on_creation.connect([](simgrid::s4u::Storage const& storage) {
- sg_storage_t s = simgrid::s4u::Storage::by_name(storage.get_name());
- xbt_assert(s != nullptr, "Storage not found for name %s", storage.get_cname());
- });
}
if (simgrid::config::get_value<bool>("debug/clean-atexit"))
{
if (simix_global == nullptr) // SimDag
return true;
- simgrid::kernel::actor::ActorImpl* self = SIMIX_process_self();
+ const simgrid::kernel::actor::ActorImpl* self = SIMIX_process_self();
return self == nullptr || self == simix_global->maestro_;
}
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
*ierr = MPI_Type_free_keyval( keyval);
}
-void mpi_type_get_extent_ (int* datatype, MPI_Aint * lb, MPI_Aint * extent, int* ierr){
-
- *ierr = MPI_Type_get_extent(simgrid::smpi::Datatype::f2c(*datatype), lb, extent);
+void mpi_type_get_extent_(int* datatype, MPI_Aint* lb, MPI_Aint* extent, int* ierr)
+{
+ *ierr = MPI_Type_get_extent(simgrid::smpi::Datatype::f2c(*datatype), lb, extent);
}
-void mpi_type_get_true_extent_ (int* datatype, MPI_Aint * lb, MPI_Aint * extent, int* ierr){
- *ierr = MPI_Type_get_true_extent(simgrid::smpi::Datatype::f2c(*datatype), lb, extent);
+void mpi_type_get_true_extent_(int* datatype, MPI_Aint* lb, MPI_Aint* extent, int* ierr)
+{
+ *ierr = MPI_Type_get_true_extent(simgrid::smpi::Datatype::f2c(*datatype), lb, extent);
}
void mpi_type_commit_(int* datatype, int* ierr){
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
char error_string[MPI_MAX_ERROR_STRING]; \
int error_size; \
PMPI_Error_string(ret, error_string, &error_size); \
- if ((errhan) == nullptr || (errhan)->errhandler() == MPI_ERRORS_RETURN) \
+ MPI_Errhandler err = (errhan) ? (errhan)->errhandler() : MPI_ERRHANDLER_NULL; \
+ if (err == MPI_ERRHANDLER_NULL || err == MPI_ERRORS_RETURN) \
XBT_WARN("%s - returned %.*s instead of MPI_SUCCESS", __func__, error_size, error_string); \
- else if ((errhan)->errhandler() == MPI_ERRORS_ARE_FATAL) \
+ else if (err == MPI_ERRORS_ARE_FATAL) \
xbt_die("%s - returned %.*s instead of MPI_SUCCESS", __func__, error_size, error_string); \
else \
- (errhan)->errhandler()->call((errhan), ret); \
+ err->call((errhan), ret); \
+ if (err != MPI_ERRHANDLER_NULL) \
+ simgrid::smpi::Errhandler::unref(err); \
MC_assert(not MC_is_active()); /* Only fail in MC mode */ \
} \
XBT_VERB("SMPI - Leaving %s", __func__); \
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
int PMPI_Get_library_version (char *version,int *len){
smpi_bench_end();
- snprintf(version, MPI_MAX_LIBRARY_VERSION_STRING, "SMPI Version %d.%d. Copyright The Simgrid Team 2007-2019",
+ snprintf(version, MPI_MAX_LIBRARY_VERSION_STRING, "SMPI Version %d.%d. Copyright The SimGrid Team 2007-2020",
SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR);
*len = strlen(version) > MPI_MAX_LIBRARY_VERSION_STRING ? MPI_MAX_LIBRARY_VERSION_STRING : strlen(version);
smpi_bench_begin();
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
int rank = simgrid::s4u::this_actor::get_pid();
int dt_size_recv = recvtype->is_replayable() ? 1 : recvtype->size();
- std::vector<int>* trace_recvcounts = new std::vector<int>;
+ std::vector<int>* trace_recvcounts = new std::vector<int>();
if (comm->rank() == root) {
for (int i = 0; i < comm->size(); i++) // copy data to avoid bad free
trace_recvcounts->push_back(recvcounts[i] * dt_size_recv);
int rank = simgrid::s4u::this_actor::get_pid();
int dt_size_recv = recvtype->is_replayable() ? 1 : recvtype->size();
- std::vector<int>* trace_recvcounts = new std::vector<int>;
+ 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);
}
int rank = simgrid::s4u::this_actor::get_pid();
int dt_size_send = sendtype->is_replayable() ? 1 : sendtype->size();
- std::vector<int>* trace_sendcounts = new std::vector<int>;
+ std::vector<int>* trace_sendcounts = new std::vector<int>();
if (comm->rank() == root) {
for (int i = 0; i < comm->size(); i++) { // copy data to avoid bad free
trace_sendcounts->push_back(sendcounts[i] * dt_size_send);
smpi_bench_end();
int rank = simgrid::s4u::this_actor::get_pid();
- std::vector<int>* trace_recvcounts = new std::vector<int>;
+ std::vector<int>* trace_recvcounts = new std::vector<int>();
int dt_send_size = datatype->is_replayable() ? 1 : datatype->size();
int totalcount = 0;
smpi_bench_end();
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>;
+ std::vector<int>* trace_sendcounts = new std::vector<int>();
+ std::vector<int>* trace_recvcounts = new std::vector<int>();
int dt_size_recv = recvtype->size();
const int* real_sendcounts = sendcounts;
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>;
+ std::vector<int>* trace_sendcounts = new std::vector<int>();
+ std::vector<int>* trace_recvcounts = new std::vector<int>();
const int* real_sendcounts = sendcounts;
const int* real_senddispls = senddispls;
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
int PMPI_Comm_call_errhandler(MPI_Comm comm,int errorcode){
CHECK_COMM(1)
- comm->errhandler()->call(comm, errorcode);
+ MPI_Errhandler err = comm->errhandler();
+ err->call(comm, errorcode);
+ simgrid::smpi::Errhandler::unref(err);
return MPI_SUCCESS;
}
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
if (file == nullptr) {
return MPI_ERR_WIN;
}
- file->errhandler()->call(file, errorcode);
+ MPI_Errhandler err = file->errhandler();
+ err->call(file, errorcode);
+ simgrid::smpi::Errhandler::unref(err);
return MPI_SUCCESS;
}
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
int src_traced = getPid(comm, src);
// 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>;
+ 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(my_proc_id, __func__,
CHECK_TYPE(3, datatype)
int size = datatype->get_extent() * count;
+ xbt_assert(size > 0);
void* recvbuf = xbt_new0(char, size);
retval = MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count, datatype, src, recvtag, comm, status);
if(retval==MPI_SUCCESS){
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
CHECK_NEGATIVE(2, MPI_ERR_ARG, ndims)
for (int i = 0; i < ndims; i++)
CHECK_NEGATIVE(2, MPI_ERR_ARG, dims[i])
- simgrid::smpi::Topo_Cart* topo = new simgrid::smpi::Topo_Cart(comm_old, ndims, dims, periodic, reorder, comm_cart);
+ const simgrid::smpi::Topo_Cart* topo =
+ new simgrid::smpi::Topo_Cart(comm_old, ndims, dims, periodic, reorder, comm_cart);
if (*comm_cart == MPI_COMM_NULL) {
delete topo;
} else {
if (topo==nullptr) {
return MPI_ERR_ARG;
}
- MPIR_Cart_Topology cart = topo->sub(remain_dims, comm_new);
+ const simgrid::smpi::Topo_Cart* cart = topo->sub(remain_dims, comm_new);
if(*comm_new==MPI_COMM_NULL)
delete cart;
if(cart==nullptr)
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
int PMPI_Win_call_errhandler(MPI_Win win,int errorcode){
CHECK_WIN(1, win)
- win->errhandler()->call(win, errorcode);
+ MPI_Errhandler err = win->errhandler();
+ err->call(win, errorcode);
+ simgrid::smpi::Errhandler::unref(err);
return MPI_SUCCESS;
}
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* Function: is_2dmesh
- * Return: int
+ * Return: bool
* Inputs:
num: the number of processors in a communicator
****************************************************************************/
#ifndef TWOD
#define TWOD
-static int is_2dmesh(int num, int *i, int *j)
+static bool is_2dmesh(int num, int* i, int* j)
{
int x, max = num / 2;
x = sqrt(double(num));
*j = x;
}
- return 1;
+ return true;
}
x++;
}
- return 0;
+ return false;
}
#endif
/*****************************************************************************
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
*****************************************************************************/
/*****************************************************************************
- * Function: is_2dmesh
- * return: int
+ * Function: is_3dmesh
+ * return: bool
* num: the number of processors in a communicator
* i: x dimension
* j: y dimension
****************************************************************************/
#ifndef THREED
#define THREED
-static int is_3dmesh(int num, int *i, int *j, int *k)
+static bool is_3dmesh(int num, int* i, int* j, int* k)
{
int x, max = num / 3;
x = cbrt(num);
if ((num % (x * x)) == 0) {
*i = *j = x;
*k = num / (x * x);
- return 1;
+ return true;
}
x++;
}
- return 0;
+ return false;
}
#endif
/*****************************************************************************
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* Exchange the data between the node leaders*/
if (local_rank == 0 && (leader_comm_size > 1)) {
/*When data in each socket is different*/
- if (comm->is_uniform() != 1) {
+ if (not comm->is_uniform()) {
int *node_sizes = NULL;
int i = 0;
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
int mpi_errno = MPI_SUCCESS;
int newrank = 0;
int mask, pof2, i, send_idx, recv_idx, last_idx, send_cnt;
- int dst, is_commutative, rem, newdst, recv_cnt;
+ int dst, rem, newdst, recv_cnt;
MPI_Aint true_lb, true_extent, extent;
if (count == 0) {
int comm_size = comm->size();
int rank = comm->rank();
- is_commutative = (op==MPI_OP_NULL || op->is_commutative());
+ bool is_commutative = (op == MPI_OP_NULL || op->is_commutative());
/* need to allocate temporary buffer to store incoming data */
datatype->extent(&true_lb, &true_extent);
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
num_procs = comm->size();
send_chunk = send_type->get_extent();
recv_chunk = recv_type->get_extent();
- int pof2 = ((num_procs != 0) && ((num_procs & (~num_procs + 1)) == num_procs));
+ bool pof2 = ((num_procs != 0) && ((num_procs & (~num_procs + 1)) == num_procs));
for (i = 0; i < num_procs; i++) {
- if (pof2 == 1) {
+ if (pof2) {
/* use exclusive-or algorithm */
src = dst = rank ^ i;
} else {
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
{
int mpi_errno = MPI_SUCCESS;
int comm_size;
- int two_level_bcast = 1;
+ bool two_level_bcast = true;
size_t nbytes = 0;
- int is_homogeneous, is_contig;
+ bool is_homogeneous, is_contig;
MPI_Aint type_size;
unsigned char* tmp_buf = nullptr;
MPI_Comm shmem_comm;
// rank = comm->rank();
/*
if (HANDLE_GET_KIND(datatype) == HANDLE_KIND_BUILTIN)*/
- is_contig = 1;
+ is_contig = true;
/* else {
MPID_Datatype_get_ptr(datatype, dtp);
is_contig = dtp->is_contig;
}
*/
- is_homogeneous = 1;
+ is_homogeneous = true;
#ifdef MPID_HAS_HETERO
if (comm_ptr->is_hetero)
- is_homogeneous = 0;
+ is_homogeneous = false;
#endif
/* MPI_Type_size() might not give the accurate size of the packed
nbytes = (size_t) (count) * (type_size);
if (comm_size <= mv2_bcast_two_level_system_size) {
if (nbytes > mv2_bcast_short_msg && nbytes < mv2_bcast_large_msg) {
- two_level_bcast = 1;
+ two_level_bcast = true;
} else {
- two_level_bcast = 0;
+ two_level_bcast = false;
}
}
- if (two_level_bcast == 1
+ if (two_level_bcast
#if defined(_MCST_SUPPORT_)
|| comm_ptr->ch.is_mcast_ok
#endif
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
-/* Copyright (c) 2011-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2011-2020. 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. */
int relative_rank, mask;
int mpi_errno = MPI_SUCCESS;
int scatter_size, curr_size, recv_size = 0;
- int j, k, i, tmp_mask, is_contig, is_homogeneous;
+ int j, k, i, tmp_mask;
+ bool is_contig, is_homogeneous;
MPI_Aint type_size = 0, nbytes = 0;
int relative_dst, dst_tree_root, my_tree_root, send_offset;
int recv_offset, tree_root, nprocs_completed, offset;
if (comm_size == 1) goto fn_exit;
//if (HANDLE_GET_KIND(datatype) == HANDLE_KIND_BUILTIN)
- if(datatype->flags() & DT_FLAG_CONTIGUOUS)
- is_contig = 1;
- else {
- is_contig = 0;
- }
+ is_contig = ((datatype->flags() & DT_FLAG_CONTIGUOUS) != 0);
- is_homogeneous = 1;
+ is_homogeneous = true;
/* MPI_Type_size() might not give the accurate size of the packed
* datatype for heterogeneous systems (because of padding, encoding,
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
extern MV2_Gather_function_ptr MV2_Gather_inter_leader_function;
extern MV2_Gather_function_ptr MV2_Gather_intra_node_function;
-#define TEMP_BUF_HAS_NO_DATA (0)
-#define TEMP_BUF_HAS_DATA (1)
-
+#define TEMP_BUF_HAS_NO_DATA (false)
+#define TEMP_BUF_HAS_DATA (true)
namespace simgrid{
namespace smpi{
* intra node gather function
* errflag - (out) to record errors
*/
-static int MPIR_pt_pt_intra_gather( const void *sendbuf, int sendcnt, MPI_Datatype sendtype,
- void *recvbuf, int recvcnt, MPI_Datatype recvtype,
- int root, int rank,
- void *tmp_buf, int nbytes,
- int is_data_avail,
- MPI_Comm comm,
- MV2_Gather_function_ptr intra_node_fn_ptr)
+static int MPIR_pt_pt_intra_gather(const void* sendbuf, int sendcnt, MPI_Datatype sendtype, void* recvbuf, int recvcnt,
+ MPI_Datatype recvtype, int root, int rank, void* tmp_buf, int nbytes,
+ bool is_data_avail, MPI_Comm comm, MV2_Gather_function_ptr intra_node_fn_ptr)
{
int mpi_errno = MPI_SUCCESS;
MPI_Aint recvtype_extent = 0; /* Datatype extent */
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
extent = datatype->get_extent();
unsigned char* tmp_buf = smpi_get_tmp_sendbuffer(count * extent);
- int is_commutative = (op==MPI_OP_NULL || op->is_commutative());
+ bool is_commutative = (op == MPI_OP_NULL || op->is_commutative());
mask = 1;
int lroot;
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
MPI_Comm comm)
{
int mpi_errno = MPI_SUCCESS;
- int rank, is_commutative;
+ int rank;
int src, k;
MPI_Request send_request;
int index=0;
datatype->extent(&true_lb, &true_extent);
extent = datatype->get_extent();
- is_commutative = (op==MPI_OP_NULL || op->is_commutative());
+ bool is_commutative = (op == MPI_OP_NULL || op->is_commutative());
if (rank != root) {
recvbuf = (void*)smpi_get_tmp_recvbuffer(count * std::max(extent, true_extent));
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
const unsigned char* in_buf = nullptr;
unsigned char *out_buf = nullptr, *tmp_buf = nullptr;
MPI_Aint true_lb, true_extent, extent;
- int is_commutative = 0, stride = 0;
+ int stride = 0;
int intra_node_root=0;
//if not set (use of the algo directly, without mvapich2 selector)
leader_of_root = comm->group()->rank(leaders_map[root]);
leader_root = leader_comm->group()->rank(leaders_map[root]);
- is_commutative= (op==MPI_OP_NULL || op->is_commutative());
+ bool is_commutative = (op == MPI_OP_NULL || op->is_commutative());
datatype->extent(&true_lb,
&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 (stride <= MV2_INTRA_SHMEM_REDUCE_MSG && is_commutative) {
if (local_rank == 0 ) {
tmp_buf = smpi_get_tmp_sendbuffer(count * std::max(extent, true_extent));
tmp_buf = tmp_buf - true_lb;
*this step*/
if (MV2_Reduce_intra_function == & MPIR_Reduce_shmem_MV2)
{
- if (is_commutative == 1 && (count * (std::max(extent, true_extent)) < SHMEM_COLL_BLOCK_SIZE)) {
+ if (is_commutative && (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,
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
REDUCE_LIMITS
namespace simgrid{
namespace smpi{
-static int MPI_I_anyReduce(const void* Sendbuf, void* Recvbuf, int count, MPI_Datatype mpi_datatype, MPI_Op mpi_op, int root, MPI_Comm comm, int is_all)
+static int MPI_I_anyReduce(const void* Sendbuf, void* Recvbuf, int count, MPI_Datatype mpi_datatype, MPI_Op mpi_op,
+ int root, MPI_Comm comm, bool is_all)
{
char *scr1buf, *scr2buf, *scr3buf, *xxx, *sendbuf, *recvbuf;
int myrank, size, x_base, x_size, computed, idx;
int reduce__rab(const void* Sendbuf, void* Recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
{
- return( MPI_I_anyReduce(Sendbuf, Recvbuf, count, datatype, op, root, comm, 0) );
+ return MPI_I_anyReduce(Sendbuf, Recvbuf, count, datatype, op, root, comm, false);
}
int allreduce__rab(const void* Sendbuf, void* Recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
{
- return( MPI_I_anyReduce(Sendbuf, Recvbuf, count, datatype, op, -1, comm, 1) );
+ return MPI_I_anyReduce(Sendbuf, Recvbuf, count, datatype, op, -1, comm, true);
}
}
}
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
unsigned char* tmp_recvbuf;
int mpi_errno = MPI_SUCCESS;
int total_count, dst, src;
- int is_commutative;
comm_size = comm->size();
rank = comm->rank();
extent =datatype->get_extent();
datatype->extent(&true_lb, &true_extent);
- if (op->is_commutative()) {
- is_commutative = 1;
- }
+ bool is_commutative = (op == MPI_OP_NULL || op->is_commutative());
int* disps = new int[comm_size];
int mask, dst_tree_root, my_tree_root, j, k;
int received;
MPI_Datatype sendtype, recvtype;
- int nprocs_completed, tmp_mask, tree_root, is_commutative=0;
+ int nprocs_completed, tmp_mask, tree_root;
comm_size = comm->size();
rank = comm->rank();
extent =datatype->get_extent();
datatype->extent(&true_lb, &true_extent);
- if ((op==MPI_OP_NULL) || op->is_commutative()) {
- is_commutative = 1;
- }
+ bool is_commutative = (op == MPI_OP_NULL || op->is_commutative());
int* disps = new int[comm_size];
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
/* smpi_coll.c -- various optimized routing for collectives */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
/* selector with default/naive Simgrid algorithms. These should not be trusted for performance evaluations */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
/* selector for collective algorithms based on openmpi's default coll_tuned_decision_fixed selector */
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* selector for collective algorithms based on mpich decision logic */
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
block_dsize = dsize * count;
/*MPICH uses SMP algorithms for all commutative ops now*/
- if(!comm->is_smp_comm()){
+ if (not comm->is_smp_comm()) {
if(comm->get_leaders_comm()==MPI_COMM_NULL){
comm->init_smp();
}
//int segsize = 0;
size_t message_size, dsize;
- if(!comm->is_smp_comm()){
+ if (not comm->is_smp_comm()) {
if(comm->get_leaders_comm()==MPI_COMM_NULL){
comm->init_smp();
}
int communicator_size=0;
size_t message_size, dsize;
- if(!comm->is_smp_comm()){
+ if (not comm->is_smp_comm()) {
if(comm->get_leaders_comm()==MPI_COMM_NULL){
comm->init_smp();
}
if( (op==MPI_OP_NULL || op->is_commutative()) && total_message_size > 524288) {
return reduce_scatter__mpich_pair(sbuf, rbuf, rcounts, dtype, op, comm);
} else if ((op != MPI_OP_NULL && not op->is_commutative())) {
- int is_block_regular = 1;
+ bool is_block_regular = true;
for (i = 0; i < (comm_size - 1); ++i) {
if (rcounts[i] != rcounts[i + 1]) {
- is_block_regular = 0;
+ is_block_regular = false;
break;
}
}
/* selector for collective algorithms based on mvapich decision logic */
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
int mpi_errno = MPI_SUCCESS;
long nbytes = 0, comm_size, recvtype_size;
int range = 0;
- int partial_sub_ok = 0;
+ bool partial_sub_ok = false;
int conf_index = 0;
int range_threshold = 0;
- int is_two_level = 0;
MPI_Comm shmem_comm;
//MPI_Comm *shmem_commptr=NULL;
/* Get the size of the communicator */
do {
if (local_size == mv2_allgather_table_ppn_conf[i]) {
conf_index = i;
- partial_sub_ok = 1;
+ partial_sub_ok = true;
break;
}
i++;
} while(i < mv2_allgather_num_ppn_conf);
}
conf_check_end:
- if (partial_sub_ok != 1) {
+ if (not partial_sub_ok) {
conf_index = 0;
}
mv2_allgather_thresholds_table[conf_index][range].inter_leader[range_threshold].
MV2_pt_Allgatherction;
- is_two_level = mv2_allgather_thresholds_table[conf_index][range].two_level[range_threshold];
+ bool is_two_level = mv2_allgather_thresholds_table[conf_index][range].two_level[range_threshold];
/* intracommunicator */
- if(is_two_level ==1){
- if(partial_sub_ok ==1){
+ if (is_two_level) {
+ if (partial_sub_ok) {
if (comm->is_blocked()){
mpi_errno = MPIR_2lvl_Allgather_MV2(sendbuf, sendcount, sendtype,
recvbuf, recvcount, recvtype,
MPI_Aint sendtype_size = 0;
long nbytes = 0;
- int is_commutative = 0;
MPI_Aint true_lb, true_extent;
sendtype_size=datatype->size();
nbytes = count * sendtype_size;
datatype->extent(&true_lb, &true_extent);
- is_commutative = op->is_commutative();
+ bool is_commutative = op->is_commutative();
{
int range = 0, range_threshold = 0, range_threshold_intra = 0;
- int is_two_level = 0;
+ bool is_two_level = false;
/* Search for the corresponding system size inside the tuning table */
while ((range < (mv2_size_allreduce_tuning_table - 1)) &&
}
/* Search for corresponding inter-leader function */
/* skip mcast pointers if mcast is not available */
- if(mv2_allreduce_thresholds_table[range].mcast_enabled != 1){
+ if (not mv2_allreduce_thresholds_table[range].mcast_enabled) {
while ((range_threshold < (mv2_allreduce_thresholds_table[range].size_inter_table - 1))
&& ((mv2_allreduce_thresholds_table[range].
inter_leader[range_threshold].MV2_pt_Allreducection
&& (mv2_allreduce_thresholds_table[range].inter_leader[range_threshold].max != -1)) {
range_threshold++;
}
- if(mv2_allreduce_thresholds_table[range].is_two_level_allreduce[range_threshold] == 1){
- is_two_level = 1;
+ if (mv2_allreduce_thresholds_table[range].is_two_level_allreduce[range_threshold]) {
+ is_two_level = true;
}
/* Search for corresponding intra-node function */
while ((range_threshold_intra <
{
MV2_Allreducection = &MPIR_Allreduce_pt2pt_rd_MV2;
}
- if(is_two_level != 1) {
+ if (not is_two_level) {
MV2_Allreducection = &MPIR_Allreduce_pt2pt_rd_MV2;
}
}
- if(is_two_level == 1){
- // check if shm is ready, if not use other algorithm first
- if (is_commutative) {
+ if (is_two_level) {
+ // check if shm is ready, if not use other algorithm first
+ if (is_commutative) {
if(comm->get_leaders_comm()==MPI_COMM_NULL){
comm->init_smp();
}
mpi_errno = MPIR_Allreduce_two_level_MV2(sendbuf, recvbuf, count,
datatype, op, comm);
- } else {
+ } else {
mpi_errno = MPIR_Allreduce_pt2pt_rd_MV2(sendbuf, recvbuf, count,
datatype, op, comm);
- }
+ }
} else {
mpi_errno = MV2_Allreducection(sendbuf, recvbuf, count,
datatype, op, comm);
{
int mpi_errno = MPI_SUCCESS;
int comm_size/*, rank*/;
- int two_level_bcast = 1;
+ bool two_level_bcast = true;
long nbytes = 0;
int range = 0;
int range_threshold = 0;
int range_threshold_intra = 0;
- // int is_homogeneous, is_contig;
MPI_Aint type_size;
//, position;
// unsigned char *tmp_buf = NULL;
comm_size = comm->size();
//rank = comm->rank();
- //is_contig=1;
+ // bool is_contig = true;
/* if (HANDLE_GET_KIND(datatype) == HANDLE_KIND_BUILTIN)*/
-/* is_contig = 1;*/
+/* is_contig = true;*/
/* else {*/
/* MPID_Datatype_get_ptr(datatype, dtp);*/
/* is_contig = dtp->is_contig;*/
/* }*/
- // is_homogeneous = 1;
+ // bool is_homogeneous = true;
/* MPI_Type_size() might not give the accurate size of the packed
* datatype for heterogeneous systems (because of padding, encoding,
#else
mv2_bcast_thresholds_table[range].is_two_level_bcast[range_threshold];
#endif
- if (two_level_bcast == 1) {
+ if (two_level_bcast) {
// if (not is_contig || not is_homogeneous) {
// tmp_buf = smpi_get_tmp_sendbuffer(nbytes);
int range = 0;
int range_threshold = 0;
int range_intra_threshold = 0;
- int is_commutative, pof2;
+ int pof2;
int comm_size = 0;
long nbytes = 0;
int sendtype_size;
- int is_two_level = 0;
+ bool is_two_level = false;
comm_size = comm->size();
sendtype_size=datatype->size();
if (count == 0)
return MPI_SUCCESS;
- is_commutative = (op==MPI_OP_NULL || op->is_commutative());
+ bool is_commutative = (op == MPI_OP_NULL || op->is_commutative());
/* find nearest power-of-two less than or equal to comm_size */
for( pof2 = 1; pof2 <= comm_size; pof2 <<= 1 );
{
mv2_reduce_inter_knomial_factor = mv2_reduce_thresholds_table[range].inter_k_degree;
}
- if(mv2_reduce_thresholds_table[range].is_two_level_reduce[range_threshold] == 1){
- is_two_level = 1;
+ if (mv2_reduce_thresholds_table[range].is_two_level_reduce[range_threshold]) {
+ is_two_level = true;
}
/* We call Reduce function */
- if(is_two_level == 1)
- {
- if (is_commutative == 1) {
+ if (is_two_level) {
+ if (is_commutative) {
if(comm->get_leaders_comm()==MPI_COMM_NULL){
comm->init_smp();
}
mpi_errno = MPIR_Reduce_two_level_helper_MV2(sendbuf, recvbuf, count,
datatype, op, root, comm);
- } else {
+ } else {
mpi_errno = MPIR_Reduce_binomial_MV2(sendbuf, recvbuf, count,
datatype, op, root, comm);
- }
+ }
} else if(MV2_Reduce_function == &MPIR_Reduce_inter_knomial_wrapper_MV2 ){
- if(is_commutative ==1)
+ if (is_commutative)
{
mpi_errno = MV2_Reduce_function(sendbuf, recvbuf, count,
datatype, op, root, comm);
int mpi_errno = MPI_SUCCESS;
int i = 0, comm_size = comm->size(), total_count = 0, type_size =
0, nbytes = 0;
- int is_commutative = 0;
int* disps = new int[comm_size];
if(mv2_red_scat_thresholds_table==NULL)
init_mv2_reduce_scatter_tables_stampede();
- is_commutative=(op==MPI_OP_NULL || op->is_commutative());
+ bool is_commutative = (op == MPI_OP_NULL || op->is_commutative());
for (i = 0; i < comm_size; i++) {
disps[i] = total_count;
total_count += recvcnts[i];
recvcnts, datatype,
op, comm);
} else {
- int is_block_regular = 1;
+ bool is_block_regular = true;
for (i = 0; i < (comm_size - 1); ++i) {
if (recvcnts[i] != recvcnts[i+1]) {
- is_block_regular = 0;
+ is_block_regular = false;
break;
}
}
int mpi_errno = MPI_SUCCESS;
// int mpi_errno_ret = MPI_SUCCESS;
int rank, nbytes, comm_size;
- int partial_sub_ok = 0;
+ bool partial_sub_ok = false;
int conf_index = 0;
MPI_Comm shmem_comm;
// MPID_Comm *shmem_commptr=NULL;
do {
if (local_size == mv2_scatter_table_ppn_conf[i]) {
conf_index = i;
- partial_sub_ok = 1;
+ partial_sub_ok = true;
break;
}
i++;
}
}
- if (partial_sub_ok != 1) {
+ if (not partial_sub_ok) {
conf_index = 0;
}
/* This is the tuning used by MVAPICH for Stampede platform based on (MV2_ARCH_INTEL_XEON_E5_2680_16,
* MV2_HCA_MLX_CX_FDR) */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
struct mv2_allgather_tuning_table {
int numproc;
- int two_level[MV2_MAX_NB_THRESHOLDS];
+ bool two_level[MV2_MAX_NB_THRESHOLDS];
int size_inter_table;
mv2_allgather_tuning_element inter_leader[MV2_MAX_NB_THRESHOLDS];
};
mv2_allgather_tuning_table mv2_tmp_allgather_thresholds_table_1ppn[] = {
{
2,
- {0},
+ {false},
1,
{
{0, -1, &MPIR_Allgather_Ring_MV2},
},
{
4,
- {0, 0},
+ {false, false},
2,
{
{0, 262144, &MPIR_Allgather_RD_MV2}, {262144, -1, &MPIR_Allgather_Ring_MV2},
},
{
8,
- {0, 0},
+ {false, false},
2,
{
{0, 131072, &MPIR_Allgather_RD_MV2}, {131072, -1, &MPIR_Allgather_Ring_MV2},
},
{
16,
- {0, 0},
+ {false, false},
2,
{
{0, 131072, &MPIR_Allgather_RD_MV2}, {131072, -1, &MPIR_Allgather_Ring_MV2},
},
{
32,
- {0, 0},
+ {false, false},
2,
{
{0, 65536, &MPIR_Allgather_RD_MV2}, {65536, -1, &MPIR_Allgather_Ring_MV2},
},
{
64,
- {0, 0},
+ {false, false},
2,
{
{0, 32768, &MPIR_Allgather_RD_MV2}, {32768, -1, &MPIR_Allgather_Ring_MV2},
mv2_allgather_tuning_table mv2_tmp_allgather_thresholds_table_2ppn[] = {
{
4,
- {0, 0},
+ {false, false},
2,
{
{0, 524288, &MPIR_Allgather_RD_MV2}, {524288, -1, &MPIR_Allgather_Ring_MV2},
},
{
8,
- {0, 1, 0},
+ {false, true, false},
2,
{
{0, 32768, &MPIR_Allgather_RD_MV2},
},
{
16,
- {0, 1, 0},
+ {false, true, false},
2,
{
{0, 16384, &MPIR_Allgather_RD_MV2},
},
{
32,
- {1, 1, 0},
+ {true, true, false},
2,
{
{0, 65536, &MPIR_Allgather_RD_MV2},
},
{
64,
- {1, 1, 0},
+ {true, true, false},
2,
{
{0, 32768, &MPIR_Allgather_RD_MV2},
},
{
128,
- {1, 1, 0},
+ {true, true, false},
2,
{
{0, 65536, &MPIR_Allgather_RD_MV2},
mv2_allgather_tuning_table mv2_tmp_allgather_thresholds_table_16ppn[] = {
{
16,
- {0, 0},
+ {false, false},
2,
{
{0, 1024, &MPIR_Allgather_RD_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2},
},
{
32,
- {0, 0},
+ {false, false},
2,
{
{0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2},
},
{
64,
- {0, 0},
+ {false, false},
2,
{
{0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2},
},
{
128,
- {0, 0},
+ {false, false},
2,
{
{0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2},
},
{
256,
- {0, 0},
+ {false, false},
2,
{
{0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2},
},
{
512,
- {0, 0},
+ {false, false},
2,
{
{0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2},
struct mv2_allreduce_tuning_table {
int numproc;
- int mcast_enabled;
- int is_two_level_allreduce[MV2_MAX_NB_THRESHOLDS];
+ bool mcast_enabled;
+ bool is_two_level_allreduce[MV2_MAX_NB_THRESHOLDS];
int size_inter_table;
mv2_allreduce_tuning_element inter_leader[MV2_MAX_NB_THRESHOLDS];
int size_intra_table;
mv2_allreduce_tuning_table mv2_tmp_allreduce_thresholds_table[] = {
{
16,
- 0,
- {1, 0},
+ false,
+ {true, false},
2,
{
{0, 1024, &MPIR_Allreduce_pt2pt_rd_MV2}, {1024, -1, &MPIR_Allreduce_pt2pt_rs_MV2},
},
{
32,
- 0,
- {1, 1, 0},
+ false,
+ {true, true, false},
3,
{
{0, 1024, &MPIR_Allreduce_pt2pt_rd_MV2},
},
{
64,
- 0,
- {1, 1, 0},
+ false,
+ {true, true, false},
3,
{
{0, 512, &MPIR_Allreduce_pt2pt_rd_MV2},
},
{
128,
- 0,
- {1, 1, 0},
+ false,
+ {true, true, false},
3,
{
{0, 512, &MPIR_Allreduce_pt2pt_rd_MV2},
},
{
256,
- 0,
- {1, 1, 0},
+ false,
+ {true, true, false},
3,
{
{0, 512, &MPIR_Allreduce_pt2pt_rd_MV2},
},
{
512,
- 0,
- {1, 1, 0},
+ false,
+ {true, true, false},
3,
{
{0, 512, &MPIR_Allreduce_pt2pt_rd_MV2},
},
{
1024,
- 0,
- {1, 1, 1, 0},
+ false,
+ {true, true, true, false},
4,
{
{0, 512, &MPIR_Allreduce_pt2pt_rd_MV2},
},
{
2048,
- 0,
- {1, 1, 1, 0},
+ false,
+ {true, true, true, false},
4,
{
{0, 64, &MPIR_Allreduce_pt2pt_rd_MV2},
int bcast_segment_size;
int intra_node_knomial_factor;
int inter_node_knomial_factor;
- int is_two_level_bcast[MV2_MAX_NB_THRESHOLDS];
+ bool is_two_level_bcast[MV2_MAX_NB_THRESHOLDS];
int size_inter_table;
mv2_bcast_tuning_element inter_leader[MV2_MAX_NB_THRESHOLDS];
int size_intra_table;
8192,
4,
4,
- {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
+ {true, true, true, true, true, true, true, true, true, true, true},
11,
{{0, 8, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2},
{8, 16, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
8192,
4,
4,
- {1, 1, 1, 1, 1, 1, 1, 1},
+ {true, true, true, true, true, true, true, true},
8,
{{0, 128, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2},
{128, 256, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
8192,
4,
4,
- {1, 1, 1, 1, 1, 1, 1, 1, 1},
+ {true, true, true, true, true, true, true, true, true},
9,
{{0, 2, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
{2, 4, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8},
8192,
4,
4,
- {1, 1, 1, 0},
+ {true, true, true, false},
4,
{{0, 8192, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8},
{8192, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
8192,
4,
4,
- {1, 1, 1, 1, 1},
+ {true, true, true, true, true},
5,
{{0, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
{16384, 131072, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2},
8192,
4,
4,
- {1, 1, 1, 1, 1},
+ {true, true, true, true, true},
5,
{{0, 4096, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8},
{4096, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
8192,
4,
4,
- {1, 1, 1, 1, 1},
+ {true, true, true, true, true},
5,
{{0, 8192, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8},
{8192, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
8192,
4,
4,
- {1, 1, 1, 1, 1, 1, 1},
+ {true, true, true, true, true, true, true},
7,
{{0, 16, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8},
{16, 32, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
int numproc;
int inter_k_degree;
int intra_k_degree;
- int is_two_level_reduce[MV2_MAX_NB_THRESHOLDS];
+ bool is_two_level_reduce[MV2_MAX_NB_THRESHOLDS];
int size_inter_table;
mv2_reduce_tuning_element inter_leader[MV2_MAX_NB_THRESHOLDS];
int size_intra_table;
16,
4,
4,
- {1, 0, 0},
+ {true, false, false},
3,
{
{0, 262144, &MPIR_Reduce_inter_knomial_wrapper_MV2},
32,
4,
4,
- {1, 1, 1, 1, 0, 0, 0},
+ {true, true, true, true, false, false, false},
7,
{
{0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2},
64,
4,
4,
- {1, 1, 1, 1, 0},
+ {true, true, true, true, false},
5,
{
{0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2},
128,
4,
4,
- {1, 0, 1, 0, 1, 0},
+ {true, false, true, false, true, false},
6,
{
{0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2},
256,
4,
4,
- {1, 1, 1, 0, 1, 1, 0},
+ {true, true, true, false, true, true, false},
7,
{
{0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2},
512,
4,
4,
- {1, 0, 1, 1, 1, 0},
+ {true, false, true, true, true, false},
6,
{
{0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2},
1024,
4,
4,
- {1, 0, 1, 1, 1},
+ {true, false, true, true, true},
5,
{
{0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2},
2048,
4,
4,
- {1, 0, 1, 1, 1, 1},
+ {true, false, true, true, true, true},
6,
{
{0, 2048, &MPIR_Reduce_inter_knomial_wrapper_MV2},
/* Asynchronous parts of the basic collective algorithms, meant to be used both for the naive default implementation, but also for non blocking collectives */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
/* selector for collective algorithms based on openmpi's default coll_tuned_decision_fixed selector */
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* * the use the recursive doubling algorithm, otherwise*/
/* * bruck is the one we want.*/
{
- int has_one = 0;
+ bool has_one = false;
for( ; communicator_size > 0; communicator_size >>= 1 ) {
if( communicator_size & 0x1 ) {
if( has_one )
return barrier__ompi_bruck(comm);
- has_one = 1;
+ has_one = true;
}
}
}
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
/* High level handling of collective algorithms */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
namespace smpi{
class Comm : public F2C, public Keyval{
+ friend Topo;
MPI_Group group_;
- SMPI_Topo_type topoType_;
+ SMPI_Topo_type topoType_ = MPI_INVALID_TOPO;
MPI_Topology topo_; // to be replaced by an union
- int refcount_;
- MPI_Comm leaders_comm_; // inter-node communicator
- MPI_Comm intra_comm_; // intra-node communicator . For MPI_COMM_WORLD this can't be used, as var is global.
- // use an intracomm stored in the process data instead
- int* leaders_map_; // who is the leader of each process
- int is_uniform_;
- int* non_uniform_map_; // set if smp nodes have a different number of processes allocated
- int is_blocked_; // are ranks allocated on the same smp node contiguous ?
- int is_smp_comm_; // set to 0 in case this is already an intra-comm or a leader-comm to avoid recursion
+ int refcount_ = 1;
+ MPI_Comm leaders_comm_ = MPI_COMM_NULL; // inter-node communicator
+ MPI_Comm intra_comm_ = MPI_COMM_NULL; // intra-node communicator. For MPI_COMM_WORLD this can't be used, as var is
+ // global. Use an intracomm stored in the process data instead
+ int* leaders_map_ = nullptr; // who is the leader of each process
+ int is_uniform_ = 1;
+ int* non_uniform_map_ = nullptr; // set if smp nodes have a different number of processes allocated
+ int is_blocked_ = 0; // are ranks allocated on the same smp node contiguous ?
+ bool is_smp_comm_ = false; // set to false in case this is already an intra-comm or a leader-comm to avoid
+ // recursion
std::list<MPI_Win> rma_wins_; // attached windows for synchronization.
std::string name_;
- MPI_Info info_;
+ MPI_Info info_ = MPI_INFO_NULL;
int id_;
- MPI_Errhandler errhandler_;
+ MPI_Errhandler errhandler_ = MPI_ERRORS_ARE_FATAL;
public:
static std::unordered_map<int, smpi_key_elem> keyvals_;
static int keyval_id_;
Comm() = default;
- Comm(MPI_Group group, MPI_Topology topo, int smp = 0, int id=MPI_UNDEFINED);
+ Comm(MPI_Group group, MPI_Topology topo, bool smp = false, int id = MPI_UNDEFINED);
int dup(MPI_Comm* newcomm);
int dup_with_info(MPI_Info info, MPI_Comm* newcomm);
MPI_Group group();
MPI_Comm get_leaders_comm();
MPI_Comm get_intra_comm();
MPI_Comm find_intra_comm(int* leader);
- int is_uniform();
- int is_blocked();
- int is_smp_comm();
+ bool is_uniform();
+ bool is_blocked();
+ bool is_smp_comm();
MPI_Comm split(int color, int key);
void cleanup_smp();
void ref();
void add_rma_win(MPI_Win win);
void remove_rma_win(MPI_Win win);
void finish_rma_calls();
- MPI_Comm split_type(int type, int key, MPI_Info info);
+ MPI_Comm split_type(int type, int key, const Info* info);
};
} // namespace smpi
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
namespace smpi{
class Datatype : public F2C, public Keyval{
- char* name_;
+ char* name_ = nullptr;
/* The id here is the (unique) datatype id used for this datastructure.
* It's default value is set to -1 since some code expects this return value
* when no other id has been assigned
MPI_Aint lb_;
MPI_Aint ub_;
int flags_;
- int refcount_;
+ int refcount_ = 1;
public:
static std::unordered_map<int, smpi_key_elem> keyvals_;
void commit();
bool is_valid();
bool is_basic();
- static const char* encode(MPI_Datatype dt) { return dt->id.c_str(); }
+ static const char* encode(const Datatype* dt) { return dt->id.c_str(); }
static MPI_Datatype decode(const std::string& datatype_id);
bool is_replayable();
void addflag(int flag);
static int keyval_create(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval,
void* extra_state);
static int keyval_free(int* keyval);
- int pack(const void* inbuf, int incount, void* outbuf, int outcount, int* position, MPI_Comm comm);
- int unpack(const void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Comm comm);
+ int pack(const void* inbuf, int incount, void* outbuf, int outcount, int* position, const Comm* comm);
+ int unpack(const void* inbuf, int insize, int* position, void* outbuf, int outcount, const Comm* comm);
static int create_contiguous(int count, MPI_Datatype old_type, MPI_Aint lb, MPI_Datatype* new_type);
static int create_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type);
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* Handle Fortan - C conversion for MPI Types*/
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
// Beware of collisions if id in mpif.h is not unique
static std::unordered_map<std::string, F2C*>* f2c_lookup_;
static int f2c_id_;
- int my_f2c_id_;
+ int my_f2c_id_ = -1;
protected:
static std::unordered_map<std::string, F2C*>* f2c_lookup();
static char* get_key(char* key, int id);
static void delete_lookup();
static std::unordered_map<std::string, F2C*>* lookup();
- F2C() : my_f2c_id_(-1){}
+ F2C() {}
virtual ~F2C() = default;
//Override these to handle specific values.
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
int sync();
int seek(MPI_Offset offset, int whence);
int seek_shared(MPI_Offset offset, int whence);
- int set_view(MPI_Offset disp, MPI_Datatype etype, MPI_Datatype filetype, const char *datarep, MPI_Info info);
+ int set_view(MPI_Offset disp, MPI_Datatype etype, MPI_Datatype filetype, const char* datarep, const Info* info);
int get_view(MPI_Offset *disp, MPI_Datatype *etype, MPI_Datatype *filetype, char *datarep);
MPI_Info info();
void set_info( MPI_Info info);
static int write_ordered(MPI_File fh, const void *buf, int count,MPI_Datatype datatype, MPI_Status *status);
template <int (*T)(MPI_File, void *, int, MPI_Datatype, MPI_Status *)> int op_all(void *buf, int count,MPI_Datatype datatype, MPI_Status *status);
static int close(MPI_File *fh);
- static int del(const char *filename, MPI_Info info);
+ static int del(const char* filename, const Info* info);
MPI_Errhandler errhandler();
void set_errhandler( MPI_Errhandler errhandler);
};
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
public:
Info() = default;
- explicit Info(Info* orig) : map_(orig->map_) {}
+ explicit Info(const Info* orig) : map_(orig->map_) {}
~Info() = default;
void ref();
static void unref(MPI_Info info);
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
template <typename T> int attr_delete(int keyval);
template <typename T> int attr_get(int keyval, void* attr_value, int* flag);
template <typename T> int attr_put(int keyval, void* attr_value);
- template <typename T> static int call_deleter(T* obj, smpi_key_elem elem, int keyval, void * value, int* flag);
+ template <typename T>
+ static int call_deleter(T* obj, const s_smpi_key_elem_t* elem, int keyval, void* value, int* flag);
template <typename T> void cleanup_attr();
};
template <typename T> int Keyval::attr_get(int keyval, void* attr_value, int* flag){
- smpi_key_elem elem = T::keyvals_.at(keyval);
+ const s_smpi_key_elem_t* elem = T::keyvals_.at(keyval);
if(elem==nullptr)
return MPI_ERR_ARG;
if(attributes()->empty()){
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
smpi_mpi_generalized_request_funcs generalized_funcs;
MPI_Request* nbc_requests_;
int nbc_requests_size_;
+ static bool match_common(MPI_Request req, MPI_Request sender, MPI_Request receiver);
public:
Request() = default;
static int waitall(int count, MPI_Request requests[], MPI_Status status[]);
static int waitsome(int incount, MPI_Request requests[], int* indices, MPI_Status status[]);
- static int match_send(void* a, void* b, kernel::activity::CommImpl* ignored);
- static int match_recv(void* a, void* b, kernel::activity::CommImpl* ignored);
+ static bool match_send(void* a, void* b, kernel::activity::CommImpl* ignored);
+ static bool match_recv(void* a, void* b, kernel::activity::CommImpl* ignored);
static int grequest_start( MPI_Grequest_query_function *query_fn, MPI_Grequest_free_function *free_fn, MPI_Grequest_cancel_function *cancel_fn, void *extra_state, MPI_Request *request);
static int grequest_complete( MPI_Request request);
- static int get_status(MPI_Request req, int* flag, MPI_Status * status);
+ static int get_status(const Request* req, int* flag, MPI_Status* status);
static void free_f(int id);
static Request* f2c(int);
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
static void empty(MPI_Status * status);
static int cancelled (const MPI_Status * status);
static void set_cancelled (MPI_Status * status, int flag);
-static void set_elements (MPI_Status * status, MPI_Datatype , int count);
+static void set_elements(MPI_Status* status, const Datatype*, int count);
static int get_count(const MPI_Status * status, MPI_Datatype datatype);
};
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
namespace smpi{
class Topo {
- MPI_Comm comm_;
+ MPI_Comm comm_ = MPI_COMM_NULL;
public:
virtual ~Topo() = default;
MPI_Comm getComm() const { return comm_; }
- void setComm(MPI_Comm comm) { comm_ = comm; }
+ void setComm(MPI_Comm comm);
};
class Topo_Cart: public Topo {
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
void* base_;
MPI_Aint size_;
int disp_unit_;
- int assert_;
+ int assert_ = 0;
MPI_Info info_;
MPI_Comm comm_;
std::vector<MPI_Request> *requests_;
int get_accumulate(const 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_Request* request=nullptr);
- int compare_and_swap(const void *origin_addr, void *compare_addr,
- void *result_addr, MPI_Datatype datatype, int target_rank,
- MPI_Aint target_disp);
+ int compare_and_swap(const void* origin_addr, const void* compare_addr, void* result_addr, MPI_Datatype datatype,
+ int target_rank, MPI_Aint target_disp);
static Win* f2c(int id);
int lock(int lock_type, int rank, int assert);
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
return key;
}
-void TRACE_smpi_setup_container(int rank, sg_host_t host)
+void TRACE_smpi_setup_container(int rank, const_sg_host_t host)
{
container_t father = simgrid::instr::Container::get_root();
if (TRACE_smpi_is_grouped()) {
TRACE_smpi_setup_container(rank, sg_host_self());
simgrid::s4u::this_actor::on_exit([self](bool) { smpi_container(self->get_pid())->remove_from_parent(); });
#if HAVE_PAPI
- container_t container = smpi_container(rank);
+ const simgrid::instr::Container* container = smpi_container(rank);
papi_counter_t counters = smpi_process()->papi_counters();
for (auto const& it : counters) {
}
/**************** Functions to trace the migration of tasks. *****************/
-void TRACE_smpi_process_change_host(int rank, sg_host_t new_host)
+void TRACE_smpi_process_change_host(int rank, const_sg_host_t new_host)
{
if (not TRACE_smpi_is_enabled()) return;
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
#if HAVE_PAPI
if (not smpi_cfg_papi_events_file().empty() && TRACE_smpi_is_enabled()) {
- container_t container =
+ const simgrid::instr::Container* container =
simgrid::instr::Container::by_name(std::string("rank-") + std::to_string(simgrid::s4u::this_actor::get_pid()));
- papi_counter_t& counter_data = smpi_process()->papi_counters();
+ const papi_counter_t& counter_data = smpi_process()->papi_counters();
for (auto const& pair : counter_data) {
simgrid::instr::VariableType* variable = static_cast<simgrid::instr::VariableType*>(container->type_->by_name(pair.first));
auto sample = samples.find(loc);
if (sample == samples.end())
xbt_die("Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
- LocalData& data = sample->second;
+ const LocalData& data = sample->second;
if (data.benching) {
// we need to run a new bench
xbt_die("Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
if (smpi_process()->sampling()){//end of loop, but still sampling needed
- LocalData& data = sample->second;
+ const LocalData& data = sample->second;
smpi_process()->set_sampling(0);
smpi_execute(data.mean * iter_count);
smpi_bench_begin();
}
/** Required for Fortran bindings */
-void smpi_trace_set_call_location_(const char* file, int* line)
+void smpi_trace_set_call_location_(const char* file, const int* line)
{
smpi_trace_set_call_location(file, *line);
}
/** Required for Fortran if -fsecond-underscore is activated */
-void smpi_trace_set_call_location__(const char* file, int* line)
+void smpi_trace_set_call_location__(const char* file, const int* line)
{
smpi_trace_set_call_location(file, *line);
}
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
-/* Copyright (c) 2004-2019. The SimGrid Team.
+/* Copyright (c) 2004-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
void smpi_deployment_register_process(const std::string& instance_id, int rank, simgrid::s4u::Actor* actor)
{
- Instance& instance = smpi_instances.at(instance_id);
+ const Instance& instance = smpi_instances.at(instance_id);
instance.comm_world_->group()->set_mapping(actor, rank);
}
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
};
}
-static void memcpy_private(void* dest, const void* src, std::vector<std::pair<size_t, size_t>>& private_blocks)
+static void memcpy_private(void* dest, const void* src, const std::vector<std::pair<size_t, size_t>>& private_blocks)
{
for (auto const& block : private_blocks)
memcpy((uint8_t*)dest+block.first, (uint8_t*)src+block.first, block.second-block.first);
}
-static void check_blocks(std::vector<std::pair<size_t, size_t>> &private_blocks, size_t buff_size) {
+static void check_blocks(const std::vector<std::pair<size_t, size_t>>& private_blocks, size_t buff_size)
+{
for (auto const& block : private_blocks)
xbt_assert(block.first <= block.second && block.second <= buff_size, "Oops, bug in shared malloc.");
}
if (got == -1) {
xbt_assert(errno == EINTR, "Cannot read from %s", src.c_str());
} else {
- char* p = buf;
+ const char* p = buf;
int todo = got;
while (int done = write(fdout, p, todo)) {
if (done == -1) {
/* This is a ... heavy way to count the MPI ranks */
int rank_counts = 0;
- simgrid::s4u::Actor::on_creation.connect([&rank_counts](simgrid::s4u::Actor& actor) {
+ simgrid::s4u::Actor::on_creation.connect([&rank_counts](const simgrid::s4u::Actor& actor) {
if (not actor.is_daemon())
rank_counts++;
});
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
static void smpi_get_executable_global_size()
{
char buffer[PATH_MAX];
- char* full_name = realpath(xbt_binary_name, buffer);
- xbt_assert(full_name != nullptr, "Could not resolve real path of binary file '%s'", xbt_binary_name);
+ const char* full_name = realpath(simgrid::xbt::binary_name.c_str(), buffer);
+ xbt_assert(full_name != nullptr, "Could not resolve real path of binary file '%s'",
+ simgrid::xbt::binary_name.c_str());
std::vector<simgrid::xbt::VmMap> map = simgrid::xbt::get_memory_map(getpid());
for (auto i = map.begin(); i != map.end() ; ++i) {
XBT_DEBUG("Switching data frame to the one of process %ld", actor->get_pid());
simgrid::smpi::ActorExt* process = smpi_process_remote(actor);
int current = process->privatized_region()->file_descriptor;
- void* tmp = mmap(TOPAGE(smpi_data_exe_start), smpi_data_exe_size, PROT_RW, MAP_FIXED | MAP_SHARED, current, 0);
+ const void* tmp = mmap(TOPAGE(smpi_data_exe_start), smpi_data_exe_size, PROT_RW, MAP_FIXED | MAP_SHARED, current, 0);
if (tmp != TOPAGE(smpi_data_exe_start))
xbt_die("Couldn't map the new region (errno %d): %s", errno, strerror(errno));
smpi_loaded_page = actor->get_pid();
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
typedef std::tuple</*sender*/ int, /* receiver */ int, /* tag */ int> req_key_t;
typedef std::unordered_map<req_key_t, MPI_Request, hash_tuple::hash<std::tuple<int,int,int>>> req_storage_t;
-void log_timed_action(simgrid::xbt::ReplayAction& action, double clock)
+void log_timed_action(const simgrid::xbt::ReplayAction& action, double clock)
{
if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){
std::string s = boost::algorithm::join(action, " ");
void get_requests(std::vector<MPI_Request>& vec)
{
- for (auto& pair : store) {
+ for (auto const& pair : store) {
auto& req = pair.second;
auto my_proc_id = simgrid::s4u::this_actor::get_pid();
if (req != MPI_REQUEST_NULL && (req->src() == my_proc_id || req->dst() == my_proc_id)) {
{
std::string s = boost::algorithm::join(action, " ");
xbt_assert(req_storage.size(), "action wait not preceded by any irecv or isend: %s", s.c_str());
+ const WaitTestParser& args = get_args();
MPI_Request request = req_storage.find(args.src, args.dst, args.tag);
req_storage.remove(request);
// Must be taken before Request::wait() since the request may be set to
// MPI_REQUEST_NULL by Request::wait!
bool is_wait_for_receive = (request->flags() & MPI_REQ_RECV);
- // TODO: Here we take the rank while we normally take the process id (look for my_proc_id)
+ // TODO: Here we take the rank while we normally take the process id (look for get_pid())
TRACE_smpi_comm_in(rank, __func__, new simgrid::instr::WaitTIData(args.src, args.dst, args.tag));
MPI_Status status;
void SendAction::kernel(simgrid::xbt::ReplayAction&)
{
+ const SendRecvParser& args = get_args();
int dst_traced = MPI_COMM_WORLD->group()->actor(args.partner)->get_pid();
- TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::Pt2PtTIData(name, args.partner, args.size,
- args.tag, Datatype::encode(args.datatype1)));
+ TRACE_smpi_comm_in(
+ get_pid(), __func__,
+ new simgrid::instr::Pt2PtTIData(get_name(), args.partner, args.size, args.tag, Datatype::encode(args.datatype1)));
if (not TRACE_smpi_view_internals())
- TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, args.tag, args.size * args.datatype1->size());
+ TRACE_smpi_send(get_pid(), get_pid(), dst_traced, args.tag, args.size * args.datatype1->size());
- if (name == "send") {
+ if (get_name() == "send") {
Request::send(nullptr, args.size, args.datatype1, args.partner, args.tag, MPI_COMM_WORLD);
- } else if (name == "isend") {
+ } else if (get_name() == "isend") {
MPI_Request request = Request::isend(nullptr, args.size, args.datatype1, args.partner, args.tag, MPI_COMM_WORLD);
req_storage.add(request);
} else {
- xbt_die("Don't know this action, %s", name.c_str());
+ xbt_die("Don't know this action, %s", get_name().c_str());
}
- TRACE_smpi_comm_out(my_proc_id);
+ TRACE_smpi_comm_out(get_pid());
}
void RecvAction::kernel(simgrid::xbt::ReplayAction&)
{
- TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::Pt2PtTIData(name, args.partner, args.size,
- args.tag, Datatype::encode(args.datatype1)));
+ const SendRecvParser& args = get_args();
+ TRACE_smpi_comm_in(
+ get_pid(), __func__,
+ new simgrid::instr::Pt2PtTIData(get_name(), args.partner, args.size, args.tag, Datatype::encode(args.datatype1)));
MPI_Status status;
// unknown size from the receiver point of view
- if (args.size <= 0.0) {
+ double arg_size = args.size;
+ if (arg_size <= 0.0) {
Request::probe(args.partner, args.tag, MPI_COMM_WORLD, &status);
- args.size = status.count;
+ arg_size = status.count;
}
bool is_recv = false; // Help analyzers understanding that status is not used unintialized
- if (name == "recv") {
+ if (get_name() == "recv") {
is_recv = true;
- Request::recv(nullptr, args.size, args.datatype1, args.partner, args.tag, MPI_COMM_WORLD, &status);
- } else if (name == "irecv") {
- MPI_Request request = Request::irecv(nullptr, args.size, args.datatype1, args.partner, args.tag, MPI_COMM_WORLD);
+ Request::recv(nullptr, arg_size, args.datatype1, args.partner, args.tag, MPI_COMM_WORLD, &status);
+ } else if (get_name() == "irecv") {
+ MPI_Request request = Request::irecv(nullptr, arg_size, args.datatype1, args.partner, args.tag, MPI_COMM_WORLD);
req_storage.add(request);
} else {
THROW_IMPOSSIBLE;
}
- TRACE_smpi_comm_out(my_proc_id);
+ TRACE_smpi_comm_out(get_pid());
if (is_recv && not TRACE_smpi_view_internals()) {
int src_traced = MPI_COMM_WORLD->group()->actor(status.MPI_SOURCE)->get_pid();
- TRACE_smpi_recv(src_traced, my_proc_id, args.tag);
+ TRACE_smpi_recv(src_traced, get_pid(), args.tag);
}
}
void ComputeAction::kernel(simgrid::xbt::ReplayAction&)
{
+ const ComputeParser& args = get_args();
if (smpi_cfg_simulate_computation()) {
smpi_execute_flops(args.flops/smpi_adjust_comp_speed());
}
void SleepAction::kernel(simgrid::xbt::ReplayAction&)
{
+ const SleepParser& args = get_args();
XBT_DEBUG("Sleep for: %lf secs", args.time);
int rank = simgrid::s4u::this_actor::get_pid();
TRACE_smpi_sleeping_in(rank, args.time);
void LocationAction::kernel(simgrid::xbt::ReplayAction&)
{
+ const LocationParser& args = get_args();
smpi_trace_set_call_location(args.filename.c_str(), args.line);
}
void TestAction::kernel(simgrid::xbt::ReplayAction&)
{
+ const WaitTestParser& args = get_args();
MPI_Request request = req_storage.find(args.src, args.dst, args.tag);
req_storage.remove(request);
// if request is null here, this may mean that a previous test has succeeded
// Different times in traced application and replayed version may lead to this
// In this case, ignore the extra calls.
if (request != MPI_REQUEST_NULL) {
- TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("test"));
+ TRACE_smpi_comm_in(get_pid(), __func__, new simgrid::instr::NoOpTIData("test"));
MPI_Status status;
int flag = 0;
else
req_storage.add(request);
- TRACE_smpi_comm_out(my_proc_id);
+ TRACE_smpi_comm_out(get_pid());
}
}
const unsigned int count_requests = req_storage.size();
if (count_requests > 0) {
- TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::Pt2PtTIData("waitall", -1, count_requests, ""));
+ TRACE_smpi_comm_in(get_pid(), __func__, new simgrid::instr::Pt2PtTIData("waitall", -1, count_requests, ""));
std::vector<std::pair</*sender*/int,/*recv*/int>> sender_receiver;
std::vector<MPI_Request> reqs;
req_storage.get_requests(reqs);
- for (const auto& req : reqs) {
+ for (auto const& req : reqs) {
if (req && (req->flags() & MPI_REQ_RECV)) {
sender_receiver.push_back({req->src(), req->dst()});
}
Request::waitall(count_requests, &(reqs.data())[0], MPI_STATUSES_IGNORE);
req_storage.get_store().clear();
- for (auto& pair : sender_receiver) {
+ for (auto const& pair : sender_receiver) {
TRACE_smpi_recv(pair.first, pair.second, 0);
}
- TRACE_smpi_comm_out(my_proc_id);
+ TRACE_smpi_comm_out(get_pid());
}
}
void BarrierAction::kernel(simgrid::xbt::ReplayAction&)
{
- TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("barrier"));
+ TRACE_smpi_comm_in(get_pid(), __func__, new simgrid::instr::NoOpTIData("barrier"));
colls::barrier(MPI_COMM_WORLD);
- TRACE_smpi_comm_out(my_proc_id);
+ TRACE_smpi_comm_out(get_pid());
}
void BcastAction::kernel(simgrid::xbt::ReplayAction&)
{
- TRACE_smpi_comm_in(my_proc_id, "action_bcast",
- new simgrid::instr::CollTIData("bcast", MPI_COMM_WORLD->group()->actor(args.root)->get_pid(),
- -1.0, args.size, -1, Datatype::encode(args.datatype1), ""));
+ const BcastArgParser& args = get_args();
+ TRACE_smpi_comm_in(get_pid(), "action_bcast",
+ new simgrid::instr::CollTIData("bcast", MPI_COMM_WORLD->group()->actor(args.root)->get_pid(), -1.0,
+ args.size, -1, Datatype::encode(args.datatype1), ""));
colls::bcast(send_buffer(args.size * args.datatype1->size()), args.size, args.datatype1, args.root, MPI_COMM_WORLD);
- TRACE_smpi_comm_out(my_proc_id);
+ TRACE_smpi_comm_out(get_pid());
}
void ReduceAction::kernel(simgrid::xbt::ReplayAction&)
{
- TRACE_smpi_comm_in(my_proc_id, "action_reduce",
- new simgrid::instr::CollTIData("reduce", MPI_COMM_WORLD->group()->actor(args.root)->get_pid(),
- args.comp_size, args.comm_size, -1,
- Datatype::encode(args.datatype1), ""));
+ const ReduceArgParser& args = get_args();
+ TRACE_smpi_comm_in(get_pid(), "action_reduce",
+ new simgrid::instr::CollTIData("reduce", MPI_COMM_WORLD->group()->actor(args.root)->get_pid(),
+ args.comp_size, args.comm_size, -1,
+ Datatype::encode(args.datatype1), ""));
colls::reduce(send_buffer(args.comm_size * args.datatype1->size()),
recv_buffer(args.comm_size * args.datatype1->size()), args.comm_size, args.datatype1, MPI_OP_NULL,
args.root, MPI_COMM_WORLD);
private_execute_flops(args.comp_size);
- TRACE_smpi_comm_out(my_proc_id);
+ TRACE_smpi_comm_out(get_pid());
}
void AllReduceAction::kernel(simgrid::xbt::ReplayAction&)
{
- TRACE_smpi_comm_in(my_proc_id, "action_allreduce", new simgrid::instr::CollTIData("allreduce", -1, args.comp_size, args.comm_size, -1,
- Datatype::encode(args.datatype1), ""));
+ const AllReduceArgParser& args = get_args();
+ TRACE_smpi_comm_in(get_pid(), "action_allreduce",
+ new simgrid::instr::CollTIData("allreduce", -1, args.comp_size, args.comm_size, -1,
+ Datatype::encode(args.datatype1), ""));
colls::allreduce(send_buffer(args.comm_size * args.datatype1->size()),
recv_buffer(args.comm_size * args.datatype1->size()), args.comm_size, args.datatype1, MPI_OP_NULL,
MPI_COMM_WORLD);
private_execute_flops(args.comp_size);
- TRACE_smpi_comm_out(my_proc_id);
+ TRACE_smpi_comm_out(get_pid());
}
void AllToAllAction::kernel(simgrid::xbt::ReplayAction&)
{
- TRACE_smpi_comm_in(my_proc_id, "action_alltoall",
- new simgrid::instr::CollTIData("alltoall", -1, -1.0, args.send_size, args.recv_size,
- Datatype::encode(args.datatype1),
- Datatype::encode(args.datatype2)));
+ const AllToAllArgParser& args = get_args();
+ TRACE_smpi_comm_in(get_pid(), "action_alltoall",
+ new simgrid::instr::CollTIData("alltoall", -1, -1.0, args.send_size, args.recv_size,
+ Datatype::encode(args.datatype1),
+ Datatype::encode(args.datatype2)));
colls::alltoall(send_buffer(args.send_size * args.comm_size * args.datatype1->size()), args.send_size, args.datatype1,
recv_buffer(args.recv_size * args.comm_size * args.datatype2->size()), args.recv_size, args.datatype2,
MPI_COMM_WORLD);
- TRACE_smpi_comm_out(my_proc_id);
+ TRACE_smpi_comm_out(get_pid());
}
void GatherAction::kernel(simgrid::xbt::ReplayAction&)
{
- TRACE_smpi_comm_in(my_proc_id, name.c_str(), new simgrid::instr::CollTIData(name, (name == "gather") ? args.root : -1, -1.0, args.send_size, args.recv_size,
- Datatype::encode(args.datatype1), Datatype::encode(args.datatype2)));
+ const GatherArgParser& args = get_args();
+ TRACE_smpi_comm_in(get_pid(), get_name().c_str(),
+ new simgrid::instr::CollTIData(get_name(), (get_name() == "gather") ? args.root : -1, -1.0,
+ args.send_size, args.recv_size, Datatype::encode(args.datatype1),
+ Datatype::encode(args.datatype2)));
- if (name == "gather") {
+ if (get_name() == "gather") {
int rank = MPI_COMM_WORLD->rank();
colls::gather(send_buffer(args.send_size * args.datatype1->size()), args.send_size, args.datatype1,
(rank == args.root) ? recv_buffer(args.recv_size * args.comm_size * args.datatype2->size()) : nullptr,
args.recv_size, args.datatype2, args.root, MPI_COMM_WORLD);
- }
- else
+ } else
colls::allgather(send_buffer(args.send_size * args.datatype1->size()), args.send_size, args.datatype1,
recv_buffer(args.recv_size * args.datatype2->size()), args.recv_size, args.datatype2,
MPI_COMM_WORLD);
- TRACE_smpi_comm_out(my_proc_id);
+ TRACE_smpi_comm_out(get_pid());
}
void GatherVAction::kernel(simgrid::xbt::ReplayAction&)
{
int rank = MPI_COMM_WORLD->rank();
+ const GatherVArgParser& args = get_args();
+ TRACE_smpi_comm_in(get_pid(), get_name().c_str(),
+ new simgrid::instr::VarCollTIData(
+ get_name(), (get_name() == "gatherv") ? args.root : -1, args.send_size, nullptr, -1,
+ args.recvcounts, Datatype::encode(args.datatype1), Datatype::encode(args.datatype2)));
- TRACE_smpi_comm_in(my_proc_id, name.c_str(), new simgrid::instr::VarCollTIData(
- name, (name == "gatherv") ? args.root : -1, args.send_size, nullptr, -1, args.recvcounts,
- Datatype::encode(args.datatype1), Datatype::encode(args.datatype2)));
-
- if (name == "gatherv") {
+ if (get_name() == "gatherv") {
colls::gatherv(send_buffer(args.send_size * args.datatype1->size()), args.send_size, args.datatype1,
(rank == args.root) ? recv_buffer(args.recv_size_sum * args.datatype2->size()) : nullptr,
args.recvcounts->data(), args.disps.data(), args.datatype2, args.root, MPI_COMM_WORLD);
- }
- else {
+ } else {
colls::allgatherv(send_buffer(args.send_size * args.datatype1->size()), args.send_size, args.datatype1,
recv_buffer(args.recv_size_sum * args.datatype2->size()), args.recvcounts->data(),
args.disps.data(), args.datatype2, MPI_COMM_WORLD);
}
- TRACE_smpi_comm_out(my_proc_id);
+ TRACE_smpi_comm_out(get_pid());
}
void ScatterAction::kernel(simgrid::xbt::ReplayAction&)
{
int rank = MPI_COMM_WORLD->rank();
- TRACE_smpi_comm_in(my_proc_id, "action_scatter", new simgrid::instr::CollTIData(name, args.root, -1.0, args.send_size, args.recv_size,
- Datatype::encode(args.datatype1),
- Datatype::encode(args.datatype2)));
+ const ScatterArgParser& args = get_args();
+ TRACE_smpi_comm_in(get_pid(), "action_scatter",
+ new simgrid::instr::CollTIData(get_name(), args.root, -1.0, args.send_size, args.recv_size,
+ Datatype::encode(args.datatype1),
+ Datatype::encode(args.datatype2)));
colls::scatter(send_buffer(args.send_size * args.datatype1->size()), args.send_size, args.datatype1,
(rank == args.root) ? recv_buffer(args.recv_size * args.datatype2->size()) : nullptr, args.recv_size,
args.datatype2, args.root, MPI_COMM_WORLD);
- TRACE_smpi_comm_out(my_proc_id);
+ TRACE_smpi_comm_out(get_pid());
}
void ScatterVAction::kernel(simgrid::xbt::ReplayAction&)
{
int rank = MPI_COMM_WORLD->rank();
- TRACE_smpi_comm_in(my_proc_id, "action_scatterv", new simgrid::instr::VarCollTIData(name, args.root, -1, args.sendcounts, args.recv_size,
- nullptr, Datatype::encode(args.datatype1),
- Datatype::encode(args.datatype2)));
+ const ScatterVArgParser& args = get_args();
+ TRACE_smpi_comm_in(get_pid(), "action_scatterv",
+ new simgrid::instr::VarCollTIData(get_name(), args.root, -1, args.sendcounts, args.recv_size,
+ nullptr, Datatype::encode(args.datatype1),
+ Datatype::encode(args.datatype2)));
colls::scatterv((rank == args.root) ? send_buffer(args.send_size_sum * args.datatype1->size()) : nullptr,
args.sendcounts->data(), args.disps.data(), args.datatype1,
recv_buffer(args.recv_size * args.datatype2->size()), args.recv_size, args.datatype2, args.root,
MPI_COMM_WORLD);
- TRACE_smpi_comm_out(my_proc_id);
+ TRACE_smpi_comm_out(get_pid());
}
void ReduceScatterAction::kernel(simgrid::xbt::ReplayAction&)
{
- TRACE_smpi_comm_in(my_proc_id, "action_reducescatter",
+ const ReduceScatterArgParser& args = get_args();
+ TRACE_smpi_comm_in(
+ get_pid(), "action_reducescatter",
new simgrid::instr::VarCollTIData("reducescatter", -1, 0, nullptr, -1, args.recvcounts,
- std::to_string(args.comp_size), /* ugly hack to print comp_size */
- Datatype::encode(args.datatype1)));
+ std::to_string(args.comp_size), /* ugly hack to print comp_size */
+ Datatype::encode(args.datatype1)));
colls::reduce_scatter(send_buffer(args.recv_size_sum * args.datatype1->size()),
recv_buffer(args.recv_size_sum * args.datatype1->size()), args.recvcounts->data(),
args.datatype1, MPI_OP_NULL, MPI_COMM_WORLD);
private_execute_flops(args.comp_size);
- TRACE_smpi_comm_out(my_proc_id);
+ TRACE_smpi_comm_out(get_pid());
}
void AllToAllVAction::kernel(simgrid::xbt::ReplayAction&)
{
- TRACE_smpi_comm_in(my_proc_id, __func__,
- new simgrid::instr::VarCollTIData(
- "alltoallv", -1, args.send_size_sum, args.sendcounts, args.recv_size_sum, args.recvcounts,
- Datatype::encode(args.datatype1), Datatype::encode(args.datatype2)));
+ const AllToAllVArgParser& args = get_args();
+ TRACE_smpi_comm_in(get_pid(), __func__,
+ new simgrid::instr::VarCollTIData(
+ "alltoallv", -1, args.send_size_sum, args.sendcounts, args.recv_size_sum, args.recvcounts,
+ Datatype::encode(args.datatype1), Datatype::encode(args.datatype2)));
colls::alltoallv(send_buffer(args.send_buf_size * args.datatype1->size()), args.sendcounts->data(),
args.senddisps.data(), args.datatype1, recv_buffer(args.recv_buf_size * args.datatype2->size()),
args.recvcounts->data(), args.recvdisps.data(), args.datatype2, MPI_COMM_WORLD);
- TRACE_smpi_comm_out(my_proc_id);
+ TRACE_smpi_comm_out(get_pid());
}
} // Replay Namespace
}} // namespace simgrid::smpi
TRACE_smpi_comm_in(my_proc_id, "smpi_replay_run_init", new simgrid::instr::NoOpTIData("init"));
TRACE_smpi_comm_out(my_proc_id);
xbt_replay_action_register("init", [](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::InitAction().execute(action); });
- xbt_replay_action_register("finalize", [](simgrid::xbt::ReplayAction&) { /* nothing to do */ });
+ xbt_replay_action_register("finalize", [](simgrid::xbt::ReplayAction const&) { /* nothing to do */ });
xbt_replay_action_register("comm_size", [](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::CommunicatorAction().execute(action); });
xbt_replay_action_register("comm_split",[](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::CommunicatorAction().execute(action); });
xbt_replay_action_register("comm_dup", [](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::CommunicatorAction().execute(action); });
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
smpi_shared_malloc_bogusfile = mkstemp(name);
XBT_DEBUG("bogusfile : %s\n", name);
unlink(name);
- char* dumb = new char[smpi_shared_malloc_blocksize](); // zero initialized
+ const char* dumb = new char[smpi_shared_malloc_blocksize](); // zero initialized
ssize_t err = write(smpi_shared_malloc_bogusfile, dumb, smpi_shared_malloc_blocksize);
if(err<0)
xbt_die("Could not write bogus file for shared malloc");
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);
+ const 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 "
"size of the mapped file using --cfg=smpi/shared-malloc-blocksize:newvalue (default 1048576) ? "
"You can also try using the sysctl vm.max_map_count. "
if(low_page_start_offset < low_page_stop_offset) {
XBT_DEBUG("\t\tglobal shared allocation, mmap block start");
void* pos = (void*)((unsigned long)mem + low_page_start_offset);
- void* res = mmap(pos, low_page_stop_offset-low_page_start_offset, PROT_READ | PROT_WRITE, mmap_base_flag, // not a full huge page
- smpi_shared_malloc_bogusfile, 0);
+ const void* res = mmap(pos, low_page_stop_offset - low_page_start_offset, PROT_READ | PROT_WRITE,
+ mmap_base_flag, // not a full huge page
+ smpi_shared_malloc_bogusfile, 0);
xbt_assert(res == pos, "Could not map folded virtual memory (%s). Do you perhaps need to increase the "
"size of the mapped file using --cfg=smpi/shared-malloc-blocksize:newvalue (default 1048576) ?"
"You can also try using the sysctl vm.max_map_count",
size_t high_page_stop_offset = stop_offset == size ? size : ALIGN_DOWN((int64_t)stop_offset, PAGE_SIZE);
if(high_page_stop_offset > stop_block_offset) {
void* pos = (void*)((unsigned long)mem + stop_block_offset);
- void* res = mmap(pos, high_page_stop_offset-stop_block_offset, PROT_READ | PROT_WRITE, mmap_base_flag, // not a full huge page
- smpi_shared_malloc_bogusfile, 0);
+ const void* res = mmap(pos, high_page_stop_offset - stop_block_offset, PROT_READ | PROT_WRITE,
+ mmap_base_flag, // not a full huge page
+ smpi_shared_malloc_bogusfile, 0);
xbt_assert(res == pos, "Could not map folded virtual memory (%s). Do you perhaps need to increase the "
"size of the mapped file using --cfg=smpi/shared-malloc-blocksize:newvalue (default 1048576) ?"
"You can also try using the sysctl vm.max_map_count",
-/* Copyright (c) 2016-2019. The SimGrid Team.
+/* Copyright (c) 2016-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
std::unordered_map<int, smpi_key_elem> Comm::keyvals_;
int Comm::keyval_id_=0;
-Comm::Comm(MPI_Group group, MPI_Topology topo, int smp, int in_id) : group_(group), topo_(topo),is_smp_comm_(smp), id_(in_id)
+Comm::Comm(MPI_Group group, MPI_Topology topo, bool smp, int in_id)
+ : group_(group), topo_(topo), is_smp_comm_(smp), id_(in_id)
{
- refcount_ = 1;
- topoType_ = MPI_INVALID_TOPO;
- intra_comm_ = MPI_COMM_NULL;
- leaders_comm_ = MPI_COMM_NULL;
- is_uniform_ = 1;
- non_uniform_map_ = nullptr;
- leaders_map_ = nullptr;
- is_blocked_ = 0;
- info_ = MPI_INFO_NULL;
- errhandler_ = MPI_ERRORS_ARE_FATAL;
+ errhandler_->ref();
//First creation of comm is done before SIMIX_run, so only do comms for others
if(in_id==MPI_UNDEFINED && smp==0 && this->rank()!=MPI_UNDEFINED ){
int id;
Comm::destroy(smpi_process()->comm_world());
return;
}
- delete comm->topo_; // there's no use count on topos
Comm::unref(comm);
}
(*newcomm)->info_=MPI_INFO_NULL;
}
if(info != MPI_INFO_NULL){
+ info->ref();
(*newcomm)->info_=info;
}
return ret;
else return intra_comm_;
}
-int Comm::is_uniform(){
+bool Comm::is_uniform()
+{
if (this == MPI_COMM_UNINITIALIZED)
return smpi_process()->comm_world()->is_uniform();
- return is_uniform_;
+ return is_uniform_ != 0;
}
-int Comm::is_blocked(){
+bool Comm::is_blocked()
+{
if (this == MPI_COMM_UNINITIALIZED)
return smpi_process()->comm_world()->is_blocked();
- return is_blocked_;
+ return is_blocked_ != 0;
}
-int Comm::is_smp_comm(){
+bool Comm::is_smp_comm()
+{
if (this == MPI_COMM_UNINITIALIZED)
return smpi_process()->comm_world()->is_smp_comm();
return is_smp_comm_;
if(comm->refcount_==0){
comm->cleanup_smp();
comm->cleanup_attr<Comm>();
+ if (comm->info_ != MPI_INFO_NULL)
+ simgrid::smpi::Info::unref(comm->info_);
+ if (comm->errhandler_ != MPI_ERRHANDLER_NULL)
+ simgrid::smpi::Errhandler::unref(comm->errhandler_);
+ delete comm->topo_; // there's no use count on topos
delete comm;
}
}
leader_group_size++;
}
}
+ xbt_assert(leader_group_size > 0);
std::sort(leader_list, leader_list + leader_group_size);
MPI_Group leaders_group = new Group(leader_group_size);
break;
}
}
- if(is_uniform==0 && this->is_uniform()!=0){
+ if (is_uniform == 0 && this->is_uniform()) {
non_uniform_map_ = non_uniform_map;
}else{
xbt_free(non_uniform_map);
}
}
-MPI_Info Comm::info(){
- if(info_== MPI_INFO_NULL)
+MPI_Info Comm::info()
+{
+ if (info_ == MPI_INFO_NULL)
info_ = new Info();
info_->ref();
return info_;
}
-void Comm::set_info(MPI_Info info){
- if(info_!= MPI_INFO_NULL)
+void Comm::set_info(MPI_Info info)
+{
+ if (info_ != MPI_INFO_NULL)
+ simgrid::smpi::Info::unref(info);
+ info_ = info;
+ if (info_ != MPI_INFO_NULL)
info->ref();
- info_=info;
}
-MPI_Errhandler Comm::errhandler(){
+MPI_Errhandler Comm::errhandler()
+{
+ if (errhandler_ != MPI_ERRHANDLER_NULL)
+ errhandler_->ref();
return errhandler_;
}
-void Comm::set_errhandler(MPI_Errhandler errhandler){
- errhandler_=errhandler;
- if(errhandler_!= MPI_ERRHANDLER_NULL)
- errhandler->ref();
+void Comm::set_errhandler(MPI_Errhandler errhandler)
+{
+ if (errhandler_ != MPI_ERRHANDLER_NULL)
+ simgrid::smpi::Errhandler::unref(errhandler_);
+ errhandler_ = errhandler;
+ if (errhandler_ != MPI_ERRHANDLER_NULL)
+ errhandler_->ref();
}
-MPI_Comm Comm::split_type(int type, int /*key*/, MPI_Info)
+MPI_Comm Comm::split_type(int type, int /*key*/, const Info*)
{
//MPI_UNDEFINED can be given to some nodes... but we need them to still perform the smp part which is collective
if(type != MPI_COMM_TYPE_SHARED && type != MPI_UNDEFINED){
/* smpi_datatype.cpp -- MPI primitives to handle datatypes */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
{
id = std::to_string(ident);
}
-Datatype::Datatype(int size,MPI_Aint lb, MPI_Aint ub, int flags) : name_(nullptr), size_(size), lb_(lb), ub_(ub), flags_(flags), refcount_(1){
+
+Datatype::Datatype(int size, MPI_Aint lb, MPI_Aint ub, int flags) : size_(size), lb_(lb), ub_(ub), flags_(flags)
+{
#if SIMGRID_HAVE_MC
if(MC_is_active())
MC_ignore(&(refcount_), sizeof(refcount_));
#endif
}
-//for predefined types, so in_use = 0.
+// for predefined types, so refcount_ = 0.
Datatype::Datatype(char* name, int ident, int size, MPI_Aint lb, MPI_Aint ub, int flags)
: name_(name), id(std::to_string(ident)), size_(size), lb_(lb), ub_(ub), flags_(flags), refcount_(0)
{
#endif
}
-Datatype::Datatype(Datatype *datatype, int* ret) : name_(nullptr), size_(datatype->size_), lb_(datatype->lb_), ub_(datatype->ub_), flags_(datatype->flags_), refcount_(1)
+Datatype::Datatype(Datatype* datatype, int* ret)
+ : size_(datatype->size_), lb_(datatype->lb_), ub_(datatype->ub_), flags_(datatype->flags_)
{
flags_ &= ~DT_FLAG_PREDEFINED;
*ret = MPI_SUCCESS;
name_ = xbt_strdup(name);
}
-int Datatype::pack(const void* inbuf, int incount, void* outbuf, int outcount, int* position, MPI_Comm)
+int Datatype::pack(const void* inbuf, int incount, void* outbuf, int outcount, int* position, const Comm*)
{
if (outcount - *position < incount*static_cast<int>(size_))
return MPI_ERR_OTHER;
return MPI_SUCCESS;
}
-int Datatype::unpack(const void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Comm)
+int Datatype::unpack(const void* inbuf, int insize, int* position, void* outbuf, int outcount, const Comm*)
{
if (outcount*static_cast<int>(size_)> insize)
return MPI_ERR_OTHER;
/* smpi_datatype.cpp -- MPI primitives to handle datatypes */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
Type_Hindexed::Type_Hindexed(int size, MPI_Aint lb, MPI_Aint ub, int flags, int count, const int* block_lengths,
const MPI_Aint* block_indices, MPI_Datatype old_type)
- : Datatype(size, lb, ub, flags), block_count_(count), old_type_(old_type)
+ : Datatype(size, lb, ub, flags)
+ , block_count_(count)
+ , block_lengths_(new int[count])
+ , block_indices_(new MPI_Aint[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, const int* block_lengths,
const int* block_indices, MPI_Datatype old_type, MPI_Aint factor)
- : Datatype(size, lb, ub, flags), block_count_(count), old_type_(old_type)
+ : Datatype(size, lb, ub, flags)
+ , block_count_(count)
+ , block_lengths_(new int[count])
+ , block_indices_(new MPI_Aint[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] * factor;
{
}
-Type_Struct::Type_Struct(int size,MPI_Aint lb, MPI_Aint ub, int flags, int count, const int* block_lengths, const MPI_Aint* block_indices, const MPI_Datatype* old_types): Datatype(size, lb, ub, flags), block_count_(count){
- block_lengths_= new int[count];
- block_indices_= new MPI_Aint[count];
- old_types_= new MPI_Datatype[count];
+Type_Struct::Type_Struct(int size, MPI_Aint lb, MPI_Aint ub, int flags, int count, const int* block_lengths,
+ const MPI_Aint* block_indices, const MPI_Datatype* old_types)
+ : Datatype(size, lb, ub, flags)
+ , block_count_(count)
+ , block_lengths_(new int[count])
+ , block_indices_(new MPI_Aint[count])
+ , old_types_(new MPI_Datatype[count])
+{
for (int i = 0; i < count; i++) {
block_lengths_[i]=block_lengths[i];
block_indices_[i]=block_indices[i];
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
int F2C::add_f()
{
if (f2c_lookup_ == nullptr)
- f2c_lookup_ = new std::unordered_map<std::string, F2C*>;
+ f2c_lookup_ = new std::unordered_map<std::string, F2C*>();
char key[KEY_SIZE];
my_f2c_id_=f2c_id_;
int F2C::c2f()
{
if (f2c_lookup_ == nullptr) {
- f2c_lookup_ = new std::unordered_map<std::string, F2C*>;
+ f2c_lookup_ = new std::unordered_map<std::string, F2C*>();
}
if(my_f2c_id_==-1)
F2C* F2C::f2c(int id)
{
if (f2c_lookup_ == nullptr)
- f2c_lookup_ = new std::unordered_map<std::string, F2C*>;
+ f2c_lookup_ = new std::unordered_map<std::string, F2C*>();
if(id >= 0){
char key[KEY_SIZE];
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
namespace smpi{
File::File(MPI_Comm comm, const char *filename, int amode, MPI_Info info): comm_(comm), flags_(amode), info_(info) {
+ if (info_ != MPI_INFO_NULL)
+ info_->ref();
std::string fullname=filename;
if (simgrid::s4u::Host::current()->get_disks().empty())
xbt_die("SMPI/IO : Trying to open file on a diskless host ! Add one to your platform file");
int size= comm_->size() + FP_SIZE;
list_ = new char[size];
errhandler_= SMPI_default_File_Errhandler;
+ errhandler_->ref();
memset(list_, 0, size);
shared_file_pointer_ = new MPI_Offset();
shared_mutex_ = s4u::Mutex::create();
*shared_file_pointer_ = 0;
win_=new Win(list_, size, 1, MPI_INFO_NULL, comm_);
}else{
+ errhandler_ = MPI_ERRHANDLER_NULL;
win_=new Win(list_, 0, 1, MPI_INFO_NULL, comm_);
}
simgrid::smpi::colls::bcast(&shared_file_pointer_, 1, MPI_AINT, 0, comm);
}
delete win_;
delete file_;
+ if (info_ != MPI_INFO_NULL)
+ simgrid::smpi::Info::unref(info_);
+ if (errhandler_ != MPI_ERRHANDLER_NULL)
+ simgrid::smpi::Errhandler::unref(errhandler_);
}
int File::close(MPI_File *fh){
return MPI_SUCCESS;
}
- int File::del(const char* filename, MPI_Info)
+ int File::del(const char* filename, const Info*)
{
//get the file with MPI_MODE_DELETE_ON_CLOSE and then close it
File* f = new File(MPI_COMM_SELF,filename,MPI_MODE_DELETE_ON_CLOSE|MPI_MODE_RDWR, nullptr);
MPI_Offset movesize = datatype->get_extent()*count;
MPI_Offset writesize = datatype->size()*count;
XBT_DEBUG("Position before write in MPI_File %s : %llu",fh->file_->get_path(),fh->file_->tell());
- MPI_Offset write = fh->file_->write(writesize, 1);
+ MPI_Offset write = fh->file_->write(writesize, true);
XBT_VERB("Write in MPI_File %s, %lld bytes written, readsize %lld bytes, movesize %lld", fh->file_->get_path(), write, writesize, movesize);
if(writesize!=movesize){
fh->file_->seek(position+movesize, SEEK_SET);
return ret;
}
- int File::set_view(MPI_Offset disp, MPI_Datatype etype, MPI_Datatype filetype, const char *datarep, MPI_Info info){
+ int File::set_view(MPI_Offset /*disp*/, MPI_Datatype etype, MPI_Datatype filetype, const char* datarep, const Info*)
+ {
etype_=etype;
filetype_=filetype;
datarep_=std::string(datarep);
return MPI_SUCCESS;
}
- int File::get_view(MPI_Offset *disp, MPI_Datatype *etype, MPI_Datatype *filetype, char *datarep){
+ int File::get_view(MPI_Offset* /*disp*/, MPI_Datatype* etype, MPI_Datatype* filetype, char* datarep)
+ {
*etype=etype_;
*filetype=filetype_;
snprintf(datarep, MPI_MAX_NAME_STRING+1, "%s", datarep_.c_str());
return simgrid::smpi::colls::barrier(comm_);
}
- MPI_Info File::info(){
- if(info_== MPI_INFO_NULL)
+ MPI_Info File::info()
+ {
+ if (info_ == MPI_INFO_NULL)
info_ = new Info();
info_->ref();
return info_;
}
- void File::set_info(MPI_Info info){
- if(info_!= MPI_INFO_NULL)
- info->ref();
- info_=info;
+ void File::set_info(MPI_Info info)
+ {
+ if (info_ != MPI_INFO_NULL)
+ simgrid::smpi::Info::unref(info_);
+ info_ = info;
+ if (info_ != MPI_INFO_NULL)
+ info_->ref();
}
MPI_Comm File::comm(){
return comm_;
}
- MPI_Errhandler File::errhandler(){
+ MPI_Errhandler File::errhandler()
+ {
+ if (errhandler_ != MPI_ERRHANDLER_NULL)
+ errhandler_->ref();
return errhandler_;
}
- void File::set_errhandler(MPI_Errhandler errhandler){
- errhandler_=errhandler;
- if(errhandler_!= MPI_ERRHANDLER_NULL)
- errhandler->ref();
+ void File::set_errhandler(MPI_Errhandler errhandler)
+ {
+ if (errhandler_ != MPI_ERRHANDLER_NULL)
+ simgrid::smpi::Errhandler::unref(errhandler_);
+ errhandler_ = errhandler;
+ if (errhandler_ != MPI_ERRHANDLER_NULL)
+ errhandler_->ref();
}
}
}
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
return &attributes_;
}
-template <> int Keyval::call_deleter<Comm>(Comm* obj, smpi_key_elem elem, int keyval, void* value, int* /*flag*/)
+template <>
+int Keyval::call_deleter<Comm>(Comm* obj, const s_smpi_key_elem_t* elem, int keyval, void* value, int* /*flag*/)
{
int ret = MPI_SUCCESS;
if(elem->delete_fn.comm_delete_fn!=MPI_NULL_DELETE_FN)
return ret;
}
-template <> int Keyval::call_deleter<Win>(Win* obj, smpi_key_elem elem, int keyval, void* value, int* /*flag*/)
+template <>
+int Keyval::call_deleter<Win>(Win* obj, const s_smpi_key_elem_t* elem, int keyval, void* value, int* /*flag*/)
{
int ret = MPI_SUCCESS;
if(elem->delete_fn.win_delete_fn!=MPI_NULL_DELETE_FN)
}
template <>
-int Keyval::call_deleter<Datatype>(Datatype* obj, smpi_key_elem elem, int keyval, void* value, int* /*flag*/)
+int Keyval::call_deleter<Datatype>(Datatype* obj, const s_smpi_key_elem_t* elem, int keyval, void* value, int* /*flag*/)
{
int ret = MPI_SUCCESS;
if(elem->delete_fn.type_delete_fn!=MPI_NULL_DELETE_FN)
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
}
}
-int Request::match_recv(void* a, void* b, simgrid::kernel::activity::CommImpl*)
+bool Request::match_common(MPI_Request req, MPI_Request sender, MPI_Request receiver)
{
- MPI_Request ref = static_cast<MPI_Request>(a);
- MPI_Request req = static_cast<MPI_Request>(b);
- XBT_DEBUG("Trying to match a recv of src %d against %d, tag %d against %d, id %d against %d",ref->src_,req->src_, ref->tag_, req->tag_,ref->comm_->id(),req->comm_->id());
-
- xbt_assert(ref, "Cannot match recv against null reference");
- xbt_assert(req, "Cannot match recv against null request");
- if((ref->comm_->id()==MPI_UNDEFINED || req->comm_->id() == MPI_UNDEFINED || (ref->comm_->id()==req->comm_->id()))
- && ((ref->src_ == MPI_ANY_SOURCE && (ref->comm_->group()->rank(req->src_) != MPI_UNDEFINED)) || req->src_ == ref->src_)
- && ((ref->tag_ == MPI_ANY_TAG && req->tag_ >=0) || req->tag_ == ref->tag_)){
- //we match, we can transfer some values
- if(ref->src_ == MPI_ANY_SOURCE)
- ref->real_src_ = req->src_;
- if(ref->tag_ == MPI_ANY_TAG)
- ref->real_tag_ = req->tag_;
- if(ref->real_size_ < req->real_size_)
- ref->truncated_ = true;
- if (req->detached_)
- ref->detached_sender_=req; //tie the sender to the receiver, as it is detached and has to be freed in the receiver
- if(req->cancelled_==0)
+ xbt_assert(sender, "Cannot match against null sender");
+ xbt_assert(receiver, "Cannot match against null receiver");
+ XBT_DEBUG("Trying to match %s of sender src %d against %d, tag %d against %d, id %d against %d",
+ (req == receiver ? "send" : "recv"), sender->src_, receiver->src_, sender->tag_, receiver->tag_,
+ sender->comm_->id(), receiver->comm_->id());
+
+ if ((receiver->comm_->id() == MPI_UNDEFINED || sender->comm_->id() == MPI_UNDEFINED ||
+ receiver->comm_->id() == sender->comm_->id()) &&
+ ((receiver->src_ == MPI_ANY_SOURCE && (receiver->comm_->group()->rank(sender->src_) != MPI_UNDEFINED)) ||
+ receiver->src_ == sender->src_) &&
+ ((receiver->tag_ == MPI_ANY_TAG && sender->tag_ >= 0) || receiver->tag_ == sender->tag_)) {
+ // we match, we can transfer some values
+ if (receiver->src_ == MPI_ANY_SOURCE)
+ receiver->real_src_ = sender->src_;
+ if (receiver->tag_ == MPI_ANY_TAG)
+ receiver->real_tag_ = sender->tag_;
+ if (receiver->real_size_ < sender->real_size_)
+ receiver->truncated_ = true;
+ if (sender->detached_)
+ receiver->detached_sender_ = sender; // tie the sender to the receiver, as it is detached and has to be freed in
+ // the receiver
+ if (req->cancelled_ == 0)
req->cancelled_ = -1; // mark as uncancelable
XBT_DEBUG("match succeeded");
- return 1;
- }else return 0;
+ return true;
+ }
+ return false;
}
-int Request::match_send(void* a, void* b, simgrid::kernel::activity::CommImpl*)
+bool Request::match_recv(void* a, void* b, simgrid::kernel::activity::CommImpl*)
{
MPI_Request ref = static_cast<MPI_Request>(a);
MPI_Request req = static_cast<MPI_Request>(b);
- XBT_DEBUG("Trying to match a send of src %d against %d, tag %d against %d, id %d against %d",ref->src_,req->src_, ref->tag_, req->tag_,ref->comm_->id(),req->comm_->id());
- xbt_assert(ref, "Cannot match send against null reference");
- xbt_assert(req, "Cannot match send against null request");
-
- if((ref->comm_->id()==MPI_UNDEFINED || req->comm_->id() == MPI_UNDEFINED || (ref->comm_->id()==req->comm_->id()))
- && ((req->src_ == MPI_ANY_SOURCE && (req->comm_->group()->rank(ref->src_) != MPI_UNDEFINED)) || req->src_ == ref->src_)
- && ((req->tag_ == MPI_ANY_TAG && ref->tag_ >=0)|| req->tag_ == ref->tag_)){
- if(req->src_ == MPI_ANY_SOURCE)
- req->real_src_ = ref->src_;
- if(req->tag_ == MPI_ANY_TAG)
- req->real_tag_ = ref->tag_;
- if(req->real_size_ < ref->real_size_)
- req->truncated_ = true;
- if (ref->detached_)
- req->detached_sender_=ref; //tie the sender to the receiver, as it is detached and has to be freed in the receiver
- if(req->cancelled_==0)
- req->cancelled_ = -1; // mark as uncancelable
- XBT_DEBUG("match succeeded");
- return 1;
- } else
- return 0;
+ return match_common(req, req, ref);
+}
+
+bool Request::match_send(void* a, void* b, simgrid::kernel::activity::CommImpl*)
+{
+ MPI_Request ref = static_cast<MPI_Request>(a);
+ MPI_Request req = static_cast<MPI_Request>(b);
+ return match_common(req, ref, req);
}
void Request::print_request(const char *message)
if (request->action_ != nullptr){
kernel::activity::CommImplPtr sync_comm = boost::static_pointer_cast<kernel::activity::CommImpl>(request->action_);
- MPI_Request req = static_cast<MPI_Request>(sync_comm->src_data_);
+ const Request* req = static_cast<MPI_Request>(sync_comm->src_data_);
*flag = 1;
if (status != MPI_STATUS_IGNORE && (req->flags_ & MPI_REQ_PREPARED) == 0) {
status->MPI_SOURCE = comm->group()->rank(req->src_);
}
}
-int Request::get_status(MPI_Request req, int* flag, MPI_Status* status)
+int Request::get_status(const Request* req, int* flag, MPI_Status* status)
{
*flag=0;
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
status->cancelled=flag;
}
-void Status::set_elements (MPI_Status * status, MPI_Datatype , int count){
+void Status::set_elements(MPI_Status* status, const Datatype*, int count)
+{
status->count=count;
}
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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 <vector>
/* static functions */
-static int assignnodes(int ndim, int nfactor, int *pfacts,int **pdims);
+static int assignnodes(int ndim, int nfactor, const int* pfacts, int** pdims);
static int getfactors(int num, int *nfators, int **factors);
namespace simgrid{
namespace smpi{
+void Topo::setComm(MPI_Comm comm)
+{
+ xbt_assert(not comm_);
+ comm_ = comm;
+ if (comm_)
+ comm_->topo_ = this;
+}
+
/*******************************************************************************
* Cartesian topologies
******************************************************************************/
} else {
if(comm_cart != nullptr){
if (rank == 0) {
- *comm_cart = new Comm(new Group(MPI_COMM_SELF->group()), this);
+ MPI_Group group = new Group(MPI_COMM_SELF->group());
+ *comm_cart = new Comm(group, this);
} else {
*comm_cart = MPI_COMM_NULL;
}
/* Get # of free-to-be-assigned processes and # of free dimensions */
int freeprocs = nnodes;
int freedims = 0;
- int *p = dims;
+ const int* p = dims;
for (int i = 0; i < ndims; ++i) {
if (*p == 0) {
++freedims;
* - ptr to array of dimensions (returned value)
* Returns: - 0 or ERROR
*/
-static int assignnodes(int ndim, int nfactor, int *pfacts, int **pdims)
+static int assignnodes(int ndim, int nfactor, const int* pfacts, int** pdims)
{
int *pmin;
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
std::unordered_map<int, smpi_key_elem> Win::keyvals_;
int Win::keyval_id_=0;
-Win::Win(void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, int allocated, int dynamic): base_(base), size_(size), disp_unit_(disp_unit), assert_(0), info_(info), comm_(comm), allocated_(allocated), dynamic_(dynamic){
- int comm_size = comm->size();
- rank_ = comm->rank();
+Win::Win(void* base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, int allocated, int dynamic)
+ : base_(base)
+ , size_(size)
+ , disp_unit_(disp_unit)
+ , info_(info)
+ , comm_(comm)
+ , rank_(comm->rank())
+ , allocated_(allocated)
+ , dynamic_(dynamic)
+{
XBT_DEBUG("Creating window");
if(info!=MPI_INFO_NULL)
info->ref();
+ int comm_size = comm->size();
name_ = nullptr;
opened_ = 0;
group_ = MPI_GROUP_NULL;
}
mode_=0;
errhandler_=MPI_ERRORS_ARE_FATAL;
+ errhandler_->ref();
comm->add_rma_win(this);
comm->ref();
if (name_ != nullptr){
xbt_free(name_);
}
- if(info_!=MPI_INFO_NULL){
- MPI_Info_free(&info_);
- }
+ if (info_ != MPI_INFO_NULL)
+ simgrid::smpi::Info::unref(info_);
+ if (errhandler_ != MPI_ERRHANDLER_NULL)
+ simgrid::smpi::Errhandler::unref(errhandler_);
comm_->remove_rma_win(this);
}
}
-MPI_Info Win::info(){
- if(info_== MPI_INFO_NULL)
+MPI_Info Win::info()
+{
+ if (info_ == MPI_INFO_NULL)
info_ = new Info();
info_->ref();
return info_;
return dynamic_;
}
-void Win::set_info(MPI_Info info){
- if(info_!= MPI_INFO_NULL)
- info->ref();
- info_=info;
+void Win::set_info(MPI_Info info)
+{
+ if (info_ != MPI_INFO_NULL)
+ simgrid::smpi::Info::unref(info_);
+ info_ = info;
+ if (info_ != MPI_INFO_NULL)
+ info_->ref();
}
void Win::set_name(const char* name){
MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Request* request)
{
//get receiver pointer
- MPI_Win recv_win = connected_wins_[target_rank];
+ const Win* recv_win = connected_wins_[target_rank];
if(opened_==0){//check that post/start has been done
// no fence or start .. lock ok ?
MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Request* request)
{
//get sender pointer
- MPI_Win send_win = connected_wins_[target_rank];
+ const Win* send_win = connected_wins_[target_rank];
if(opened_==0){//check that post/start has been done
// no fence or start .. lock ok ?
if(target_count*target_datatype->get_extent()>send_win->size_)
return MPI_ERR_ARG;
- void* send_addr = static_cast<void*>(static_cast<char*>(send_win->base_) + target_disp * send_win->disp_unit_);
+ const void* send_addr = static_cast<void*>(static_cast<char*>(send_win->base_) + target_disp * send_win->disp_unit_);
XBT_DEBUG("Entering MPI_Get from %d", target_rank);
if(target_rank != comm_->rank()){
{
XBT_DEBUG("Entering MPI_Win_Accumulate");
//get receiver pointer
- MPI_Win recv_win = connected_wins_[target_rank];
+ const Win* recv_win = connected_wins_[target_rank];
if(opened_==0){//check that post/start has been done
// no fence or start .. lock ok ?
int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Request*)
{
//get sender pointer
- MPI_Win send_win = connected_wins_[target_rank];
+ const Win* send_win = connected_wins_[target_rank];
if(opened_==0){//check that post/start has been done
// no fence or start .. lock ok ?
return MPI_SUCCESS;
}
-int Win::compare_and_swap(const void *origin_addr, void *compare_addr,
- void *result_addr, MPI_Datatype datatype, int target_rank,
- MPI_Aint target_disp){
+int Win::compare_and_swap(const void* origin_addr, const void* compare_addr, void* result_addr, MPI_Datatype datatype,
+ int target_rank, MPI_Aint target_disp)
+{
//get sender pointer
- MPI_Win send_win = connected_wins_[target_rank];
+ const Win* send_win = connected_wins_[target_rank];
if(opened_==0){//check that post/start has been done
// no fence or start .. lock ok ?
int Win::shared_query(int rank, MPI_Aint* size, int* disp_unit, void* baseptr)
{
- MPI_Win target_win = rank != MPI_PROC_NULL ? connected_wins_[rank] : nullptr;
+ const Win* target_win = rank != MPI_PROC_NULL ? connected_wins_[rank] : nullptr;
for (int i = 0; not target_win && i < comm_->size(); i++) {
if (connected_wins_[i]->size_ > 0)
target_win = connected_wins_[i];
*static_cast<void**>(baseptr) = target_win->base_;
} else {
*size = 0;
- *static_cast<void**>(baseptr) = xbt_malloc(0);
+ *static_cast<void**>(baseptr) = nullptr;
}
return MPI_SUCCESS;
}
MPI_Errhandler Win::errhandler()
{
+ if (errhandler_ != MPI_ERRHANDLER_NULL)
+ errhandler_->ref();
return errhandler_;
}
void Win::set_errhandler(MPI_Errhandler errhandler)
{
+ if (errhandler_ != MPI_ERRHANDLER_NULL)
+ simgrid::smpi::Errhandler::unref(errhandler_);
errhandler_ = errhandler;
if (errhandler_ != MPI_ERRHANDLER_NULL)
- errhandler->ref();
+ errhandler_->ref();
}
} // namespace smpi
} // namespace simgrid
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
{
simgrid::s4u::Engine* engine = simgrid::s4u::Engine::get_instance();
std::vector<simgrid::s4u::Host*> available_hosts =
- engine->get_filtered_hosts([](simgrid::s4u::Host* host) { return host->is_on(); });
+ engine->get_filtered_hosts([](const simgrid::s4u::Host* host) { return host->is_on(); });
xbt_assert(available_hosts.size() > 0, "No hosts available; are they all switched off?");
// TODO: Account for daemon background load (-> use especially the availability file)
std::vector<simgrid::s4u::ActorPtr> all_actors =
engine->get_filtered_actors([](simgrid::s4u::ActorPtr actor) { return not actor->is_daemon(); });
- for (auto& actor : all_actors) {
+ for (auto const& actor : all_actors) {
new_mapping.assign(actor, actor->get_host());
}
// Sort the actors, from highest to lowest load; we then just iterate over these actors
heap_handle update_handle = usable_hosts.push(host); // Required to update elements in the heap
additional_load[host] = {update_handle, 0}; // Save the handle for later
const double total_flops_computed = sg_host_get_computed_flops(host);
- for (auto& actor : actors) {
+ for (auto const& actor : actors) {
additional_load[host].load += actor_computation[actor->get_pid()] / total_flops_computed; // Normalize load - this allows comparison
// even between hosts with different frequencies
XBT_DEBUG("Actor %li -> %f", actor->get_pid(), actor_computation[actor->get_pid()]);
}
// Implementation of the Greedy algorithm
- for (auto& actor : all_actors) {
+ for (auto const& actor : all_actors) {
simgrid::s4u::Host* target_host = usable_hosts.top(); // This is the host with the lowest load
simgrid::s4u::Host* cur_mapped_host = new_mapping.get_host(actor);
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
void for_each_actor(simgrid::s4u::Host* host, const std::function<void(simgrid::s4u::ActorPtr)>& callback)
{
auto range = host_to_actors.equal_range(host);
- std::for_each(
- range.first,
- range.second,
- [&callback](host_to_actors_map_t::value_type& x) { callback(x.second); }
- );
+ std::for_each(range.first, range.second,
+ [&callback](host_to_actors_map_t::value_type const& x) { callback(x.second); });
}
};
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
simgrid::s4u::Host* cur_host = simgrid::s4u::this_actor::get_host();
simgrid::s4u::Host* migrate_to_host;
- TRACE_migration_call(my_proc_id, nullptr);
+ TRACE_migration_call(get_pid(), nullptr);
// We only migrate every "cfg_migration_frequency"-times, not at every call
migration_call_counter[simgrid::s4u::Actor::self()]++;
static bool was_executed = false;
if (not was_executed) {
was_executed = true;
- XBT_DEBUG("Process %li runs the load balancer", my_proc_id);
+ XBT_DEBUG("Process %li runs the load balancer", get_pid());
smpi_bench_begin();
lb.run();
smpi_bench_end();
if (cur_host != migrate_to_host) { // Origin and dest are not the same -> migrate
std::vector<simgrid::s4u::Host*> migration_hosts = {cur_host, migrate_to_host};
std::vector<double> comp_amount = {0, 0};
- std::vector<double> comm_amount = {0, /*must not be 0*/ std::max(args.memory_consumption, 1.0), 0, 0};
+ std::vector<double> comm_amount = {0, /*must not be 0*/ std::max(get_args().memory_consumption, 1.0), 0, 0};
xbt_os_timer_t timer = smpi_process()->timer();
xbt_os_threadtimer_start(timer);
- simgrid::s4u::this_actor::parallel_execute(migration_hosts, comp_amount, comm_amount, -1.0);
+ simgrid::s4u::this_actor::parallel_execute(migration_hosts, comp_amount, comm_amount);
xbt_os_threadtimer_stop(timer);
smpi_execute(xbt_os_timer_elapsed(timer));
// Update the process and host mapping in SimGrid.
- XBT_DEBUG("Migrating process %li from %s to %s", my_proc_id, cur_host->get_cname(), migrate_to_host->get_cname());
- TRACE_smpi_process_change_host(my_proc_id, migrate_to_host);
+ XBT_DEBUG("Migrating process %li from %s to %s", get_pid(), cur_host->get_cname(), migrate_to_host->get_cname());
+ TRACE_smpi_process_change_host(get_pid(), migrate_to_host);
simgrid::s4u::this_actor::set_host(migrate_to_host);
}
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
#!/usr/bin/env sh
-# Copyright (c) 2007-2019. The SimGrid Team.
+# Copyright (c) 2007-2020. The SimGrid Team.
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it
list_add LINKARGS "-lsimgrid" ${LINKER_UNDEFINED_ERROR:+"-Wl,-z,defs"}
fi
-# By default, we execute the commands instead of only showing them to cmake
-Show=
-
list_set CMDARGS
while [ $# -gt 0 ]; do
ARG="$1"
;;
'-show'|'-compile-info'|'-link-info')
# Dry run displaying commands instead of executing them. Useful to cmake
- Show=echo
+ show=1
;;
*)
list_add CMDARGS "${ARG}"
list_add_not_empty CMDLINE "${LINKARGS}"
eval $(list_get CMDLINE)
-$Show "$@"
+if [ "x$VERBOSE" = x1 -o "x$show" = x1 ] ; then
+ echo "$@"
+ [ "x$show" = x1 ] && exit 0
+fi
+"$@"
#!/usr/bin/env sh
-# Copyright (c) 2014-2019. The SimGrid Team.
+# Copyright (c) 2014-2020. The SimGrid Team.
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it
list_add LINKARGS "@libdir@\libsimgrid.dll"
fi
-# By default, we execute the commands instead of only showing them to cmake
-show=
-
list_set CMDARGS
while [ $# -gt 0 ]; do
ARG="$1"
#!/usr/bin/env sh
-# Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2012-2020. 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.
NEEDS_OUTPUT=1
-# By default, we execute the commands instead of only showing them to cmake
-Show=
-
list_set CMDLINE "${REAL_FORTRAN_COMPILER}"
list_add_not_empty CMDLINE "${FFLAGS}"
while [ $# -gt 0 ]; do
;;
'-show'|'-compile-info'|'-link-info')
# Dry run displaying commands instead of executing them. Useful to cmake
- Show=echo
+ show=1
;;
*)
list_add CMDLINE "${ARG}"
list_add_not_empty CMDLINE "${LINKARGS}"
eval $(list_get CMDLINE)
-$Show "$@"
+if [ "x$VERBOSE" = x1 -o "x$show" = x1 ] ; then
+ echo "$@"
+ [ "x$show" = x1 ] && exit 0
+fi
+"$@"
#!/usr/bin/env sh
-# Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2012-2020. 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.
TRACE_CALL_LOCATION=0
NEEDS_OUTPUT=1
-# By default, we execute the commands instead of only showing them to cmake
-Show=
-
list_set CMDLINE "${REAL_FORTRAN_COMPILER}"
list_add_not_empty CMDLINE "${FFLAGS}"
while [ $# -gt 0 ]; do
;;
'-show'|'-compile-info'|'-link-info')
# Dry run displaying commands instead of executing them. Useful to cmake
- Show=echo
+ show=1
;;
*)
list_add CMDLINE "${ARG}"
list_add_not_empty CMDLINE "${LINKARGS}"
eval $(list_get CMDLINE)
-$Show "$@"
+if [ "x$VERBOSE" = x1 -o "x$show" = x1 ] ; then
+ echo "$@"
+ [ "x$show" = x1 ] && exit 0
+fi
+"$@"
#!/usr/bin/env sh
-# Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2007-2020. 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.
#!/usr/bin/env sh
-# Copyright (c) 2013-2019. The SimGrid Team.
+# Copyright (c) 2013-2020. The SimGrid Team.
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
}
// When a host is turned off, we want to keep only the actors that should restart for when it will boot again.
// Then get rid of the others.
- auto elm = remove_if(begin(actors_at_boot_), end(actors_at_boot_), [](kernel::actor::ProcessArg* arg) {
+ auto elm = remove_if(begin(actors_at_boot_), end(actors_at_boot_), [](const kernel::actor::ProcessArg* arg) {
if (arg->auto_restart)
return false;
delete arg;
return disks;
}
-void HostImpl::add_disk(s4u::Disk* disk)
+void HostImpl::set_disks(const std::vector<kernel::resource::DiskImpl*>& disks, s4u::Host* host)
+{
+ disks_ = std::move(disks);
+ for (auto d : disks_)
+ d->set_host(host);
+}
+
+void HostImpl::add_disk(const s4u::Disk* disk)
{
disks_.push_back(disk->get_impl());
}
storages.push_back(s.second->get_iface()->get_cname());
return storages;
}
-
+std::unordered_map<std::string, s4u::Storage*>* HostImpl::get_mounted_storages()
+{
+ std::unordered_map<std::string, s4u::Storage*>* mounts = new std::unordered_map<std::string, s4u::Storage*>();
+ for (auto const& m : storage_) {
+ mounts->insert({m.first, m.second->get_iface()});
+ }
+ return mounts;
+}
} // namespace surf
} // namespace simgrid
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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 SURF_HOST_INTERFACE_HPP_
-#define SURF_HOST_INTERFACE_HPP_
+#ifndef SURF_HOST_INTERFACE_HPP
+#define SURF_HOST_INTERFACE_HPP
#include "src/kernel/actor/ActorImpl.hpp"
#include "src/kernel/resource/DiskImpl.hpp"
class XBT_PRIVATE HostImpl : public xbt::PropertyHolder {
std::vector<kernel::actor::ProcessArg*> actors_at_boot_;
s4u::Host* piface_ = nullptr; // FIXME: why don't we store a s4u::Host here as we do everywhere else?
+ std::map<std::string, kernel::resource::StorageImpl*> storage_;
+ std::vector<kernel::resource::DiskImpl*> disks_;
public:
friend simgrid::vm::VirtualMachineImpl;
virtual ~HostImpl();
std::vector<s4u::Disk*> get_disks();
- void add_disk(s4u::Disk* disk);
+ void set_disks(const std::vector<kernel::resource::DiskImpl*>& disks, s4u::Host* host);
+ void add_disk(const s4u::Disk* disk);
void remove_disk(const std::string& disk_name);
/** @brief Get the vector of storages (by names) attached to the Host */
virtual std::vector<const char*> get_attached_storages();
-
- std::map<std::string, kernel::resource::StorageImpl*> storage_;
- std::vector<kernel::resource::DiskImpl*> disks_;
+ std::unordered_map<std::string, s4u::Storage*>* get_mounted_storages();
+ void set_storages(const std::map<std::string, kernel::resource::StorageImpl*>& storages) { storage_ = storages; }
s4u::Host* get_iface() { return piface_; }
XBT_PUBLIC_DATA simgrid::surf::HostModel* surf_host_model;
-#endif /* SURF_Host_INTERFACE_HPP_ */
+#endif /* SURF_HOST_INTERFACE_HPP */
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
: Resource(model, name, maxminSystem->constraint_new(this, std::max(bread, bwrite)))
, piface_(name, this)
, typeId_(type_id)
+ , attach_(attach)
, content_name_(content_name)
, size_(size)
- , attach_(attach)
{
StorageImpl::turn_on();
XBT_DEBUG("Create resource with Bread '%f' Bwrite '%f' and Size '%llu'", bread, bwrite, size);
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
*/
class StorageImpl : public Resource, public xbt::PropertyHolder {
s4u::Storage piface_;
+ lmm::Constraint* constraint_read_; /* Constraint for maximum write bandwidth*/
+ lmm::Constraint* constraint_write_; /* Constraint for maximum write bandwidth*/
+
+ std::string typeId_;
+ bool currently_destroying_ = false;
+ // Name of the host to which this storage is attached. Only used at platform parsing time, then the interface stores
+ // the Host directly.
+ std::string attach_;
public:
+ const std::string content_name_; // Only used at parsing time then goes to the FileSystemExtension
+ const sg_size_t size_; // Only used at parsing time then goes to the FileSystemExtension
/** @brief Storage constructor */
StorageImpl(Model* model, const std::string& name, kernel::lmm::System* maxmin_system, double bread, double bwrite,
const std::string& type_id, const std::string& content_name, sg_size_t size, const std::string& attach);
~StorageImpl() override;
s4u::Storage* get_iface() { return &piface_; }
+ const char* get_type() { return typeId_.c_str(); }
+ lmm::Constraint* get_read_constraint() const { return constraint_read_; }
+ lmm::Constraint* get_write_constraint() const { return constraint_write_; }
/** @brief Check if the Storage is used (if an action currently uses its resources) */
bool is_used() override;
*/
virtual StorageAction* write(sg_size_t size) = 0;
const std::string& get_host() const { return attach_; }
-
- lmm::Constraint* constraint_write_; /* Constraint for maximum write bandwidth*/
- lmm::Constraint* constraint_read_; /* Constraint for maximum write bandwidth*/
-
- std::string typeId_;
- std::string content_name_; // Only used at parsing time then goes to the FileSystemExtension
- sg_size_t size_; // Only used at parsing time then goes to the FileSystemExtension
-
-private:
- bool currently_destroying_ = false;
- // Name of the host to which this storage is attached. Only used at platform parsing time, then the interface stores
- // the Host directly.
- std::string attach_;
};
/**********
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
bool select = config::get_value<bool>("cpu/maxmin-selective-update");
- if (algo == Model::UpdateAlgo::LAZY) {
+ if (is_update_lazy()) {
xbt_assert(select || config::is_default("cpu/maxmin-selective-update"),
"You cannot disable cpu selective update when using the lazy update mechanism");
select = true;
/** @brief take into account changes of speed (either load or max) */
void CpuCas01::on_speed_change()
{
- lmm::Variable* var = nullptr;
+ const lmm::Variable* var;
const lmm::Element* elem = nullptr;
get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(),
get_host()->turn_on();
}
} else {
- lmm::Constraint* cnst = get_constraint();
- lmm::Variable* var = nullptr;
+ const lmm::Constraint* cnst = get_constraint();
+ const lmm::Variable* var;
const lmm::Element* elem = nullptr;
double date = surf_get_clock();
action->set_state(Action::State::IGNORED);
get_model()->get_maxmin_system()->update_variable_penalty(action->get_variable(), 0.0);
- if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) { // remove action from the heap
+ if (get_model()->is_update_lazy()) { // remove action from the heap
get_model()->get_action_heap().remove(action);
// this is necessary for a variable with weight 0 since such variables are ignored in lmm and we need to set its
// max_duration correctly at the next call to share_resources
model->get_maxmin_system()->variable_new(this, 1.0 / requested_core, requested_core * speed, 1))
, requested_core_(requested_core)
{
- if (model->get_update_algorithm() == Model::UpdateAlgo::LAZY)
+ if (model->is_update_lazy())
set_last_update();
model->get_maxmin_system()->expand(constraint, get_variable(), 1.0);
}
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
void CpuModel::update_actions_state_lazy(double now, double /*delta*/)
{
while (not get_action_heap().empty() && double_equals(get_action_heap().top_date(), now, sg_surf_precision)) {
-
auto* action = static_cast<CpuAction*>(get_action_heap().pop());
XBT_CDEBUG(surf_kernel, "Something happened to action %p", action);
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
* Trace *
*********/
-CpuTiProfile::CpuTiProfile(profile::Profile* profile)
+CpuTiProfile::CpuTiProfile(const profile::Profile* profile)
{
double integral = 0;
double time = 0;
/* no availability file, fixed trace */
if (not speed_profile) {
- type_ = Type::FIXED;
value_ = value;
XBT_DEBUG("No availability trace. Constant value = %f", value);
return;
/* only one point available, fixed trace */
if (speed_profile->event_list.size() == 1) {
- type_ = Type::FIXED;
value_ = speed_profile->event_list.front().value_;
return;
}
xbt_assert(surf_cpu_model_pm == nullptr, "CPU model already initialized. This should not happen.");
xbt_assert(surf_cpu_model_vm == nullptr, "CPU model already initialized. This should not happen.");
- surf_cpu_model_pm = new simgrid::kernel::resource::CpuTiModel();
- surf_cpu_model_vm = new simgrid::kernel::resource::CpuTiModel();
+ surf_cpu_model_pm = new CpuTiModel();
+ surf_cpu_model_vm = new CpuTiModel();
}
CpuTiModel::CpuTiModel() : CpuModel(Model::UpdateAlgo::FULL)
surf_cpu_model_pm = nullptr;
}
-kernel::resource::Cpu* CpuTiModel::create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate, int core)
+Cpu* CpuTiModel::create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate, int core)
{
return new CpuTi(this, host, speed_per_pstate, core);
}
while (not get_action_heap().empty() && double_equals(get_action_heap().top_date(), now, sg_surf_precision)) {
auto* action = static_cast<CpuTiAction*>(get_action_heap().pop());
XBT_DEBUG("Action %p: finish", action);
- action->finish(kernel::resource::Action::State::FINISHED);
+ action->finish(Action::State::FINISHED);
/* update remaining amount of all actions */
action->cpu_->update_remaining_amount(surf_get_clock());
}
/************
* Resource *
************/
-CpuTi::CpuTi(CpuTiModel* model, simgrid::s4u::Host* host, const std::vector<double>& speed_per_pstate, int core)
+CpuTi::CpuTi(CpuTiModel* model, s4u::Host* host, const std::vector<double>& speed_per_pstate, int core)
: Cpu(model, host, speed_per_pstate, core)
{
xbt_assert(core == 1, "Multi-core not handled by this model yet");
set_modified(false);
delete speed_integrated_trace_;
}
+
void CpuTi::set_speed_profile(kernel::profile::Profile* profile)
{
delete speed_integrated_trace_;
if (profile && profile->event_list.size() > 1) {
kernel::profile::DatedValue val = profile->event_list.back();
if (val.date_ < 1e-12) {
- auto* prof = new simgrid::kernel::profile::Profile();
+ auto* prof = new kernel::profile::Profile();
speed_.event = prof->schedule(&profile::future_evt_set, this);
}
}
/* put all action running on cpu to failed */
for (CpuTiAction& action : action_set_) {
- if (action.get_state() == kernel::resource::Action::State::INITED ||
- action.get_state() == kernel::resource::Action::State::STARTED ||
- action.get_state() == kernel::resource::Action::State::IGNORED) {
+ if (action.get_state() == Action::State::INITED || action.get_state() == Action::State::STARTED ||
+ action.get_state() == Action::State::IGNORED) {
action.set_finish_time(date);
- action.set_state(kernel::resource::Action::State::FAILED);
+ action.set_state(Action::State::FAILED);
get_model()->get_action_heap().remove(&action);
}
}
}
/* add in action heap */
if (min_finish != NO_MAX_DURATION)
- get_model()->get_action_heap().update(&action, min_finish, kernel::resource::ActionHeap::Type::unset);
+ get_model()->get_action_heap().update(&action, min_finish, ActionHeap::Type::unset);
else
get_model()->get_action_heap().remove(&action);
last_update_ = now;
}
-kernel::resource::CpuAction* CpuTi::execution_start(double size)
+CpuAction* CpuTi::execution_start(double size)
{
XBT_IN("(%s,%g)", get_cname(), size);
auto* action = new CpuTiAction(this, size);
return action;
}
-kernel::resource::CpuAction* CpuTi::sleep(double duration)
+CpuAction* CpuTi::sleep(double duration)
{
if (duration > 0)
duration = std::max(duration, sg_surf_precision);
auto* action = new CpuTiAction(this, 1.0);
action->set_max_duration(duration);
- action->set_suspend_state(kernel::resource::Action::SuspendStates::SLEEPING);
+ action->set_suspend_state(Action::SuspendStates::SLEEPING);
if (duration == NO_MAX_DURATION)
- action->set_state(simgrid::kernel::resource::Action::State::IGNORED);
+ action->set_state(Action::State::IGNORED);
action_set_.push_back(*action);
}
} else {
if (cpu_ti_hook.is_linked())
- simgrid::xbt::intrusive_erase(modified_cpus, *this);
+ xbt::intrusive_erase(modified_cpus, *this);
}
}
{
/* remove from action_set */
if (action_ti_hook.is_linked())
- simgrid::xbt::intrusive_erase(cpu_->action_set_, *this);
+ xbt::intrusive_erase(cpu_->action_set_, *this);
/* remove from heap */
get_model()->get_action_heap().remove(this);
cpu_->set_modified(true);
min_finish = get_finish_time();
/* add in action heap */
- get_model()->get_action_heap().update(this, min_finish, kernel::resource::ActionHeap::Type::unset);
+ get_model()->get_action_heap().update(this, min_finish, ActionHeap::Type::unset);
XBT_OUT();
}
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
*********/
class CpuTiProfile {
public:
- explicit CpuTiProfile(profile::Profile* profile);
+ explicit CpuTiProfile(const profile::Profile* profile);
double integrate_simple(double a, double b);
double integrate_simple_point(double a);
};
public:
- explicit CpuTiTmgr(double value) : type_(Type::FIXED), value_(value){};
+ explicit CpuTiTmgr(double value) : value_(value){};
CpuTiTmgr(profile::Profile* speed_profile, double value);
CpuTiTmgr(const CpuTiTmgr&) = delete;
CpuTiTmgr& operator=(const CpuTiTmgr&) = delete;
double get_power_scale(double a);
private:
- Type type_;
+ Type type_ = Type::FIXED;
double value_; /*< Percentage of cpu speed available. Value fixed between 0 and 1 */
/* Dynamic */
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
void NetworkCm02Model::update_actions_state_lazy(double now, double /*delta*/)
{
while (not get_action_heap().empty() && double_equals(get_action_heap().top_date(), now, sg_surf_precision)) {
-
auto* action = static_cast<NetworkCm02Action*>(get_action_heap().pop());
XBT_DEBUG("Something happened to action %p", action);
action->latency_ = latency;
action->rate_ = rate;
- if (get_update_algorithm() == Model::UpdateAlgo::LAZY) {
+ if (is_update_lazy()) {
action->set_last_update();
}
if (action->latency_ > 0) {
action->set_variable(get_maxmin_system()->variable_new(action, 0.0, -1.0, constraints_per_variable));
- if (get_update_algorithm() == Model::UpdateAlgo::LAZY) {
+ if (is_update_lazy()) {
// add to the heap the event when the latency is payed
double date = action->latency_ + action->get_last_update();
if (sg_weight_S_parameter > 0) {
double delta = sg_weight_S_parameter / value - sg_weight_S_parameter / (bandwidth_.peak * bandwidth_.scale);
- kernel::lmm::Variable* var;
+ const kernel::lmm::Variable* var;
const kernel::lmm::Element* elem = nullptr;
const kernel::lmm::Element* nextelem = nullptr;
int numelem = 0;
void NetworkCm02Link::set_latency(double value)
{
double delta = value - latency_.peak;
- kernel::lmm::Variable* var = nullptr;
+ const kernel::lmm::Variable* var;
const kernel::lmm::Element* elem = nullptr;
const kernel::lmm::Element* nextelem = nullptr;
int numelem = 0;
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
LinkImpl* NetworkConstantModel::create_link(const std::string& name, const std::vector<double>& /*bandwidth*/,
double /*latency*/, s4u::Link::SharingPolicy)
{
-
xbt_die("Refusing to create the link %s: there is no link in the Constant network model. "
"Please remove any link from your platform (and switch to routing='None')",
name.c_str());
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
((NetworkIBModel*)surf_network_model)->active_comms.erase(&action);
}
-static void IB_action_init_callback(simgrid::kernel::resource::NetworkAction& action, simgrid::s4u::Host* src,
- simgrid::s4u::Host* dst)
+static void IB_action_init_callback(simgrid::kernel::resource::NetworkAction& action, const simgrid::s4u::Host* src,
+ const simgrid::s4u::Host* dst)
{
simgrid::kernel::resource::NetworkIBModel* ibModel = (simgrid::kernel::resource::NetworkIBModel*)surf_network_model;
simgrid::kernel::resource::IBNode* act_src = &ibModel->active_nodes.at(src->get_name());
try {
Be = std::stod(radical_elements.front());
- } catch (std::invalid_argument& ia) {
+ } catch (const std::invalid_argument& ia) {
throw std::invalid_argument(std::string("First part of smpi/IB-penalty-factors is not numerical:") + ia.what());
}
try {
Bs = std::stod(radical_elements.at(1));
- } catch (std::invalid_argument& ia) {
+ } catch (const std::invalid_argument& ia) {
throw std::invalid_argument(std::string("Second part of smpi/IB-penalty-factors is not numerical:") + ia.what());
}
try {
ys = std::stod(radical_elements.back());
- } catch (std::invalid_argument& ia) {
+ } catch (const std::invalid_argument& ia) {
throw std::invalid_argument(std::string("Third part of smpi/IB-penalty-factors is not numerical:") + ia.what());
}
}
-/* Copyright (c) 2014-2019. The SimGrid Team.
+/* Copyright (c) 2014-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
class XBT_PRIVATE IBNode;
-class XBT_PRIVATE ActiveComm {
-public:
- IBNode* destination;
- NetworkAction* action;
- double init_rate;
- ActiveComm() : destination(nullptr), action(nullptr), init_rate(-1){};
- virtual ~ActiveComm() = default;
+struct XBT_PRIVATE ActiveComm {
+ IBNode* destination = nullptr;
+ NetworkAction* action = nullptr;
+ double init_rate = -1;
};
class IBNode {
// store the number of comms received from each node
std::map<IBNode*, int> ActiveCommsDown;
// number of comms the node is receiving
- int nbActiveCommsDown;
- explicit IBNode(int id) : id(id), nbActiveCommsDown(0){};
+ int nbActiveCommsDown = 0;
+ explicit IBNode(int id) : id(id){};
virtual ~IBNode() = default;
};
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
LinkImpl::LinkImpl(NetworkModel* model, const std::string& name, lmm::Constraint* constraint)
: Resource(model, name, constraint), piface_(this)
{
-
if (name != "__loopback__")
xbt_assert(not s4u::Link::by_name_or_null(name), "Link '%s' declared several times in the platform.", name.c_str());
Resource::turn_off();
s4u::Link::on_state_change(this->piface_);
- kernel::lmm::Variable* var = nullptr;
+ const kernel::lmm::Variable* var;
const kernel::lmm::Element* elem = nullptr;
double now = surf_get_clock();
while ((var = get_constraint()->get_variable(&elem))) {
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
Metric latency_ = {0.0, 0, nullptr};
Metric bandwidth_ = {1.0, 0, nullptr};
-
};
/**********
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
pt.extension_set<NetPointNs3>(new NetPointNs3());
XBT_VERB("SimGrid's %s is known as node %d within ns-3", pt.get_cname(), pt.extension<NetPointNs3>()->node_num);
});
- surf::on_cluster.connect(&clusterCreation_cb);
+ routing::on_cluster_creation.connect(&clusterCreation_cb);
s4u::Engine::on_platform_created.connect(&postparse_cb);
s4u::NetZone::on_route_creation.connect(&routeCreation_cb);
NetworkNS3Action::NetworkNS3Action(Model* model, double totalBytes, s4u::Host* src, s4u::Host* dst)
: NetworkAction(model, totalBytes, false), src_(src), dst_(dst)
{
-
// If there is no other started actions, we need to move NS-3 forward to be sync with SimGrid
if (model->get_started_action_set()->size()==1){
while(double_positive(surf_get_clock() - ns3::Simulator::Now().GetSeconds(), sg_surf_precision)){
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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. */
simgrid::s4u::Link::on_creation(*get_iface());
}
-void NetworkWifiLink::set_host_rate(s4u::Host* host, int rate_level)
+void NetworkWifiLink::set_host_rate(const s4u::Host* host, int rate_level)
{
auto insert_done = host_rates_.insert(std::make_pair(host->get_name(), rate_level));
if (insert_done.second == false)
insert_done.first->second = rate_level;
}
-double NetworkWifiLink::get_host_rate(sg_host_t host)
+double NetworkWifiLink::get_host_rate(const s4u::Host* host)
{
std::map<xbt::string, int>::iterator host_rates_it;
host_rates_it = host_rates_.find(host->get_name());
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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. */
NetworkWifiLink(NetworkCm02Model* model, const std::string& name, std::vector<double> bandwidths,
lmm::System* system);
- void set_host_rate(s4u::Host* host, int rate_level);
+ void set_host_rate(const s4u::Host* host, int rate_level);
/** @brief Get the AP rate associated to the host (or -1 if not associated to the AP) */
- double get_host_rate(s4u::Host* host);
+ double get_host_rate(const s4u::Host* host);
s4u::Link::SharingPolicy get_sharing_policy() override;
void apply_event(kernel::profile::Event*, double) override { THROW_UNIMPLEMENTED; }
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
double min = HostModel::next_occurring_event_full(now);
for (kernel::resource::Action const& action : *get_started_action_set()) {
const L07Action& net_action = static_cast<const L07Action&>(action);
- if (net_action.latency_ > 0 && (min < 0 || net_action.latency_ < min)) {
- min = net_action.latency_;
+ if (net_action.get_latency() > 0 && (min < 0 || net_action.get_latency() < min)) {
+ min = net_action.get_latency();
XBT_DEBUG("Updating min with %p (start %f): %f", &net_action, net_action.get_start_time(), min);
}
}
for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) {
L07Action& action = static_cast<L07Action&>(*it);
++it; // increment iterator here since the following calls to action.finish() may invalidate it
- if (action.latency_ > 0) {
- if (action.latency_ > delta) {
- double_update(&(action.latency_), delta, sg_surf_precision);
+ if (action.get_latency() > 0) {
+ if (action.get_latency() > delta) {
+ action.update_latency(delta, sg_surf_precision);
} else {
- action.latency_ = 0.0;
+ action.set_latency(0.0);
}
- if ((action.latency_ <= 0.0) && (action.is_suspended() == 0)) {
+ if ((action.get_latency() <= 0.0) && (action.is_suspended() == 0)) {
action.updateBound();
get_maxmin_system()->update_variable_penalty(action.get_variable(), 1.0);
action.set_last_update();
/* Need to check that none of the model has failed */
int i = 0;
- kernel::lmm::Constraint* cnst = action.get_variable()->get_constraint(i);
+ const kernel::lmm::Constraint* cnst = action.get_variable()->get_constraint(i);
while (cnst != nullptr) {
i++;
- kernel::resource::Resource* constraint_id = cnst->get_id();
+ const kernel::resource::Resource* constraint_id = cnst->get_id();
if (not constraint_id->is_on()) {
XBT_DEBUG("Action (%p) Failed!!", &action);
action.finish(kernel::resource::Action::State::FAILED);
kernel::resource::Action* NetworkL07Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
{
std::vector<s4u::Host*> host_list = {src, dst};
- double* flops_amount = new double[2]();
+ const double* flops_amount = new double[2]();
double* bytes_amount = new double[4]();
bytes_amount[1] = size;
/** @brief take into account changes of speed (either load or max) */
void CpuL07::on_speed_change()
{
- kernel::lmm::Variable* var = nullptr;
+ const kernel::lmm::Variable* var;
const kernel::lmm::Element* elem = nullptr;
get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(), speed_.peak * speed_.scale);
while ((var = get_constraint()->get_variable(&elem))) {
- kernel::resource::Action* action = static_cast<kernel::resource::Action*>(var->get_id());
+ const kernel::resource::Action* action = static_cast<kernel::resource::Action*>(var->get_id());
get_model()->get_maxmin_system()->update_variable_bound(action->get_variable(), speed_.scale * speed_.peak);
}
void LinkL07::set_latency(double value)
{
- kernel::lmm::Variable* var = nullptr;
+ const kernel::lmm::Variable* var;
L07Action *action;
const kernel::lmm::Element* elem = nullptr;
if (communicationAmount_ != nullptr) {
for (size_t i = 0; i < host_count; i++) {
for (size_t j = 0; j < host_count; j++) {
-
if (communicationAmount_[i * host_count + j] > 0) {
double lat = 0.0;
std::vector<kernel::resource::LinkImpl*> route;
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
* Action *
**********/
class L07Action : public kernel::resource::CpuAction {
+ std::vector<s4u::Host*> hostList_;
+ bool free_arrays_ = false; // By default, computationAmount_ and friends are freed by caller. But not for sequential
+ // exec and regular comms
+ const double* computationAmount_; /* pointer to the data that lives in s4u action -- do not free unless if
+ * free_arrays */
+ const double* communicationAmount_; /* pointer to the data that lives in s4u action -- do not free unless if
+ * free_arrays */
+ double latency_;
+ double rate_;
+
friend CpuAction* CpuL07::execution_start(double size);
friend CpuAction* CpuL07::sleep(double duration);
friend CpuAction* HostL07Model::execute_parallel(const std::vector<s4u::Host*>& host_list, const double* flops_amount,
~L07Action();
void updateBound();
-
- std::vector<s4u::Host*> hostList_;
- const double* computationAmount_; /* pointer to the data that lives in s4u action -- do not free unless if
- * free_arrays */
- const double* communicationAmount_; /* pointer to the data that lives in s4u action -- do not free unless if
- * free_arrays */
- double latency_;
- double rate_;
-
-private:
- bool free_arrays_ = false; // By default, computationAmount_ and friends are freed by caller. But not for sequential
- // exec and regular comms
+ double get_latency() const { return latency_; }
+ void set_latency(double latency) { latency_ = latency; }
+ void update_latency(double delta, double precision) { double_update(&latency_, delta, precision); }
};
} // namespace surf
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
XBT_PRIVATE std::vector<std::string> known_storages;
namespace simgrid {
-namespace surf {
-
-simgrid::xbt::signal<void(kernel::routing::ClusterCreationArgs const&)> on_cluster;
-}
-}
+namespace kernel {
+namespace routing {
+xbt::signal<void(ClusterCreationArgs const&)> on_cluster_creation;
+} // namespace routing
+} // namespace kernel
+} // namespace simgrid
static int surf_parse_models_setup_already_called = 0;
std::map<std::string, simgrid::kernel::resource::StorageType*> storage_types;
/** Module management function: frees all internal data structures */
void sg_platf_exit() {
- simgrid::surf::on_cluster.disconnect_slots();
+ simgrid::kernel::routing::on_cluster_creation.disconnect_slots();
simgrid::s4u::Engine::on_platform_created.disconnect_slots();
/* make sure that we will reinit the models while loading the platf once reinited */
}
/** @brief Add a host to the current AS */
-void sg_platf_new_host(simgrid::kernel::routing::HostCreationArgs* args)
+void sg_platf_new_host(const simgrid::kernel::routing::HostCreationArgs* args)
{
std::map<std::string, std::string> props;
if (args->properties) {
simgrid::s4u::Host* host =
routing_get_current()->create_host(args->id, args->speed_per_pstate, args->core_amount, &props);
- host->pimpl_->storage_ = mount_list;
+ host->pimpl_->set_storages(mount_list);
mount_list.clear();
- host->pimpl_->disks_ = std::move(args->disks);
- for (auto d : host->pimpl_->disks_)
- d->set_host(host);
+ host->pimpl_->set_disks(args->disks, host);
/* Change from the defaults */
if (args->state_trace)
return netpoint;
}
-static void sg_platf_new_link(simgrid::kernel::routing::LinkCreationArgs* link, const std::string& link_name)
+static void sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link, const std::string& link_name)
{
simgrid::kernel::resource::LinkImpl* l =
surf_network_model->create_link(link_name, link->bandwidths, link->latency, link->policy);
l->set_state_profile(link->state_trace);
}
-void sg_platf_new_link(simgrid::kernel::routing::LinkCreationArgs* link)
+void sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link)
{
if (link->policy == simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX) {
sg_platf_new_link(link, link->id + "_UP");
simgrid::kernel::routing::HostCreationArgs host;
host.id = host_id;
if ((cluster->properties != nullptr) && (not cluster->properties->empty())) {
- host.properties = new std::unordered_map<std::string, std::string>;
+ host.properties = new std::unordered_map<std::string, std::string>();
for (auto const& elm : *cluster->properties)
host.properties->insert({elm.first, elm.second});
// other columns are to store one or more link for the node
//add a loopback link
- simgrid::s4u::Link* linkUp = nullptr;
- simgrid::s4u::Link* linkDown = nullptr;
+ const simgrid::s4u::Link* linkUp = nullptr;
+ const simgrid::s4u::Link* linkDown = nullptr;
if(cluster->loopback_bw > 0 || cluster->loopback_lat > 0){
std::string tmp_link = link_id + "_loopback";
XBT_DEBUG("<loopback\tid=\"%s\"\tbw=\"%f\"/>", tmp_link.c_str(), cluster->loopback_bw);
//Make the backbone
if ((cluster->bb_bw > 0) || (cluster->bb_lat > 0)) {
-
simgrid::kernel::routing::LinkCreationArgs link;
link.id = std::string(cluster->id)+ "_backbone";
link.bandwidths.push_back(cluster->bb_bw);
XBT_DEBUG("</AS>");
sg_platf_new_Zone_seal();
- simgrid::surf::on_cluster(*cluster);
+ simgrid::kernel::routing::on_cluster_creation(*cluster);
delete cluster->radicals;
}
XBT_DEBUG("Add a backbone to AS '%s'", current_routing->get_cname());
}
-void sg_platf_new_cabinet(simgrid::kernel::routing::CabinetCreationArgs* cabinet)
+void sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet)
{
for (int const& radical : *cabinet->radicals) {
std::string hostname = cabinet->prefix + std::to_string(radical) + cabinet->suffix;
delete cabinet->radicals;
}
-simgrid::kernel::resource::DiskImpl* sg_platf_new_disk(simgrid::kernel::routing::DiskCreationArgs* disk)
+simgrid::kernel::resource::DiskImpl* sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk)
{
simgrid::kernel::resource::DiskImpl* d = surf_disk_model->createDisk(disk->id, disk->read_bw, disk->write_bw);
if (disk->properties) {
xbt_assert(std::find(known_storages.begin(), known_storages.end(), storage->id) == known_storages.end(),
"Refusing to add a second storage named \"%s\"", storage->id.c_str());
- simgrid::kernel::resource::StorageType* stype;
+ const simgrid::kernel::resource::StorageType* stype;
auto st = storage_types.find(storage->type_id);
if (st != storage_types.end()) {
stype = st->second;
}
}
-void sg_platf_new_storage_type(simgrid::kernel::routing::StorageTypeCreationArgs* storage_type)
+void sg_platf_new_storage_type(const simgrid::kernel::routing::StorageTypeCreationArgs* storage_type)
{
xbt_assert(storage_types.find(storage_type->id) == storage_types.end(),
"Reading a storage type, processing unit \"%s\" already exists", storage_type->id.c_str());
}
xbt_die("%s", msg.c_str());
}
- simgrid::simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(actor->function);
+ const simgrid::simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(actor->function);
xbt_assert(factory, "Error while creating an actor from the XML file: Function '%s' not registered", actor->function);
double start_time = actor->start_time;
host->pimpl_->add_actor_at_boot(arg);
if (start_time > SIMIX_get_clock()) {
-
arg = new simgrid::kernel::actor::ProcessArg(actor_name, code, nullptr, host, kill_time, properties, auto_restart);
XBT_DEBUG("Process %s@%s will be started at time %f", arg->name.c_str(), arg->host->get_cname(), start_time);
}
}
-void sg_platf_new_peer(simgrid::kernel::routing::PeerCreationArgs* peer)
+void sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer)
{
simgrid::kernel::routing::VivaldiZone* as = dynamic_cast<simgrid::kernel::routing::VivaldiZone*>(current_routing);
xbt_assert(as, "<peer> tag can only be used in Vivaldi netzones.");
*
* @param zone the parameters defining the Zone to build.
*/
-simgrid::kernel::routing::NetZoneImpl* sg_platf_new_Zone_begin(simgrid::kernel::routing::ZoneCreationArgs* zone)
+simgrid::kernel::routing::NetZoneImpl* sg_platf_new_Zone_begin(const simgrid::kernel::routing::ZoneCreationArgs* zone)
{
if (not surf_parse_models_setup_already_called) {
simgrid::s4u::Engine::on_platform_creation();
return new_zone;
}
-void sg_platf_new_Zone_set_properties(std::unordered_map<std::string, std::string>* props)
+void sg_platf_new_Zone_set_properties(const std::unordered_map<std::string, std::string>* props)
{
xbt_assert(current_routing, "Cannot set properties of the current Zone: none under construction");
}
/** @brief Add a link connecting a host to the rest of its AS (which must be cluster or vivaldi) */
-void sg_platf_new_hostlink(simgrid::kernel::routing::HostLinkCreationArgs* hostlink)
+void sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* hostlink)
{
simgrid::kernel::routing::NetPoint* netpoint = simgrid::s4u::Host::by_name(hostlink->id)->get_netpoint();
xbt_assert(netpoint, "Host '%s' not found!", hostlink->id.c_str());
xbt_assert(dynamic_cast<simgrid::kernel::routing::ClusterZone*>(current_routing),
"Only hosts from Cluster and Vivaldi ASes can get a host_link.");
- simgrid::s4u::Link* linkUp = simgrid::s4u::Link::by_name_or_null(hostlink->link_up);
- simgrid::s4u::Link* linkDown = simgrid::s4u::Link::by_name_or_null(hostlink->link_down);
+ const simgrid::s4u::Link* linkUp = simgrid::s4u::Link::by_name_or_null(hostlink->link_up);
+ const simgrid::s4u::Link* linkDown = simgrid::s4u::Link::by_name_or_null(hostlink->link_down);
xbt_assert(linkUp, "Link '%s' not found!", hostlink->link_up.c_str());
xbt_assert(linkDown, "Link '%s' not found!", hostlink->link_down.c_str());
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
void check_disk_attachment()
{
for (auto const& s : simgrid::s4u::Engine::get_instance()->get_all_storages()) {
- simgrid::kernel::routing::NetPoint* host_elm =
+ const simgrid::kernel::routing::NetPoint* host_elm =
simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(s->get_impl()->get_host());
if (not host_elm)
surf_parse_error(std::string("Unable to attach storage ") + s->get_cname() + ": host " +
StorageImpl* StorageN11Model::createStorage(const std::string& id, const std::string& type_id,
const std::string& content_name, const std::string& attach)
{
- StorageType* storage_type = storage_types.at(type_id);
+ const StorageType* storage_type = storage_types.at(type_id);
double Bread =
surf_parse_get_bandwidth(storage_type->model_properties->at("Bread").c_str(), "property Bread, storage", type_id);
model->get_maxmin_system()->expand(storage->get_constraint(), get_variable(), 1.0);
switch(type) {
case s4u::Io::OpType::READ:
- model->get_maxmin_system()->expand(storage->constraint_read_, get_variable(), 1.0);
+ model->get_maxmin_system()->expand(storage->get_read_constraint(), get_variable(), 1.0);
break;
case s4u::Io::OpType::WRITE:
- model->get_maxmin_system()->expand(storage->constraint_write_, get_variable(), 1.0);
+ model->get_maxmin_system()->expand(storage->get_write_constraint(), get_variable(), 1.0);
break;
default:
THROW_UNIMPLEMENTED;
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
XBT_PUBLIC void simgrid_add_plugin_description(const char* name, const char* description, void_f_void_t init_fun)
{
if (not surf_plugin_description)
- surf_plugin_description = new std::vector<surf_model_description_t>;
+ surf_plugin_description = new std::vector<surf_model_description_t>();
surf_plugin_description->emplace_back(surf_model_description_t{name, description, init_fun});
}
{
simgrid::s4u::Engine::shutdown();
for (auto const& e : storage_types) {
- simgrid::kernel::resource::StorageType* stype = e.second;
+ const simgrid::kernel::resource::StorageType* stype = e.second;
delete stype->properties;
delete stype->model_properties;
delete stype;
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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 "src/internal_config.h"
#include "src/surf/surf_private.hpp"
+#include "xbt/function_types.h"
#include <cmath>
#include <set>
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
/* platf_private.h - Interface to the SimGrid platforms which visibility should be limited to this directory */
-/* Copyright (c) 2004-2019. The SimGrid Team.
+/* Copyright (c) 2004-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
std::string id;
int routing;
};
-}}}
+
+extern XBT_PRIVATE xbt::signal<void(ClusterCreationArgs const&)> on_cluster_creation;
+
+} // namespace routing
+} // namespace kernel
+} // namespace simgrid
/********** Routing **********/
void routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl* bb);
/*** END of the parsing cruft ***/
XBT_PUBLIC simgrid::kernel::routing::NetZoneImpl*
-sg_platf_new_Zone_begin(simgrid::kernel::routing::ZoneCreationArgs* zone); // Begin description of new Zone
-XBT_PUBLIC void sg_platf_new_Zone_set_properties(std::unordered_map<std::string, std::string>* props);
+sg_platf_new_Zone_begin(const simgrid::kernel::routing::ZoneCreationArgs* zone); // Begin description of new Zone
+XBT_PUBLIC void sg_platf_new_Zone_set_properties(const std::unordered_map<std::string, std::string>* props);
XBT_PUBLIC void sg_platf_new_Zone_seal(); // That Zone is fully described
-XBT_PUBLIC void sg_platf_new_host(simgrid::kernel::routing::HostCreationArgs* host); // Add a host to the current Zone
-XBT_PUBLIC void sg_platf_new_hostlink(simgrid::kernel::routing::HostLinkCreationArgs* h); // Add a host_link to the current Zone
-XBT_PUBLIC void sg_platf_new_link(simgrid::kernel::routing::LinkCreationArgs* link); // Add a link to the current Zone
-XBT_PUBLIC void sg_platf_new_peer(simgrid::kernel::routing::PeerCreationArgs* peer); // Add a peer to the current Zone
+XBT_PUBLIC void
+sg_platf_new_host(const simgrid::kernel::routing::HostCreationArgs* host); // Add a host to the current Zone
+XBT_PUBLIC void
+sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* h); // Add a host_link to the current Zone
+XBT_PUBLIC void
+sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link); // Add a link to the current Zone
+XBT_PUBLIC void
+sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer); // Add a peer to the current Zone
XBT_PUBLIC void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* clust); // Add a cluster to the current Zone
-XBT_PUBLIC void sg_platf_new_cabinet(simgrid::kernel::routing::CabinetCreationArgs* cabinet); // Add a cabinet to the current Zone
+XBT_PUBLIC void
+sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet); // Add a cabinet to the current Zone
XBT_PUBLIC simgrid::kernel::routing::NetPoint* // Add a router to the current Zone
sg_platf_new_router(const std::string&, const char* coords);
XBT_PUBLIC void sg_platf_new_trace(simgrid::kernel::routing::ProfileCreationArgs* trace);
XBT_PUBLIC simgrid::kernel::resource::DiskImpl*
-sg_platf_new_disk(simgrid::kernel::routing::DiskCreationArgs* disk); // Add a disk to the current host
+sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk); // Add a disk to the current host
XBT_PUBLIC void sg_platf_new_storage(simgrid::kernel::routing::StorageCreationArgs* storage); // Add a storage to the current Zone
-XBT_PUBLIC void sg_platf_new_storage_type(simgrid::kernel::routing::StorageTypeCreationArgs* storage_type);
+XBT_PUBLIC void sg_platf_new_storage_type(const simgrid::kernel::routing::StorageTypeCreationArgs* storage_type);
XBT_PUBLIC void sg_platf_new_mount(simgrid::kernel::routing::MountCreationArgs* mount);
XBT_PUBLIC void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor);
XBT_PUBLIC void surf_parse_set_debug(int bdebug);
XBT_PUBLIC int surf_parse_lex_destroy();
-namespace simgrid {
-namespace surf {
-
-extern XBT_PRIVATE simgrid::xbt::signal<void(kernel::routing::ClusterCreationArgs const&)> on_cluster;
-}
-}
-
#endif /* SG_PLATF_H */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
{
const char* cfile = file.c_str();
int len = strlen(cfile);
- int is_lua = len > 3 && file[len - 3] == 'l' && file[len - 2] == 'u' && file[len - 1] == 'a';
+ bool is_lua = len > 3 && file[len - 3] == 'l' && file[len - 2] == 'u' && file[len - 1] == 'a';
sg_platf_init();
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
std::vector<simgrid::kernel::routing::NetPoint*> netpoints =
simgrid::s4u::Engine::get_instance()->get_all_netpoints();
std::sort(netpoints.begin(), netpoints.end(),
- [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) {
+ [](const simgrid::kernel::routing::NetPoint* a, const simgrid::kernel::routing::NetPoint* b) {
return a->get_name() < b->get_name();
});
bool first = true;
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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. */
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
/* automaton - representation of büchi automaton */
-/* Copyright (c) 2011-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2011-2020. 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. */
return automaton;
}
-xbt_automaton_state_t xbt_automaton_state_new(xbt_automaton_t a, int type, char* id){
+xbt_automaton_state_t xbt_automaton_state_new(const_xbt_automaton_t a, int type, const char* id)
+{
xbt_automaton_state_t state = xbt_new0(struct xbt_automaton_state, 1);
state->type = type;
state->id = xbt_strdup(id);
return state;
}
-xbt_automaton_transition_t xbt_automaton_transition_new(xbt_automaton_t a, xbt_automaton_state_t src, xbt_automaton_state_t dst, xbt_automaton_exp_label_t label){
+xbt_automaton_transition_t xbt_automaton_transition_new(const_xbt_automaton_t a, xbt_automaton_state_t src,
+ xbt_automaton_state_t dst, xbt_automaton_exp_label_t label)
+{
xbt_automaton_transition_t transition = xbt_new0(struct xbt_automaton_transition, 1);
if(src != NULL){
xbt_dynar_push(src->out, &transition);
return label;
}
-xbt_automaton_exp_label_t xbt_automaton_exp_label_new_predicat(char* p)
+xbt_automaton_exp_label_t xbt_automaton_exp_label_new_predicat(const char* p)
{
xbt_automaton_exp_label_t label = xbt_new0(struct xbt_automaton_exp_label, 1);
label->type = AUT_PREDICAT;
return label;
}
-xbt_dynar_t xbt_automaton_get_states(xbt_automaton_t a){
+xbt_dynar_t xbt_automaton_get_states(const_xbt_automaton_t a)
+{
return a->states;
}
-xbt_dynar_t xbt_automaton_get_transitions(xbt_automaton_t a){
+xbt_dynar_t xbt_automaton_get_transitions(const_xbt_automaton_t a)
+{
return a->transitions;
}
-xbt_automaton_transition_t xbt_automaton_get_transition(XBT_ATTRIB_UNUSED xbt_automaton_t a, xbt_automaton_state_t src,
- xbt_automaton_state_t dst)
+xbt_automaton_transition_t xbt_automaton_get_transition(XBT_ATTRIB_UNUSED const_xbt_automaton_t a,
+ const_xbt_automaton_state_t src,
+ const_xbt_automaton_state_t dst)
{
xbt_automaton_transition_t transition;
unsigned int cursor;
return NULL;
}
-xbt_automaton_state_t xbt_automaton_transition_get_source(xbt_automaton_transition_t t){
+xbt_automaton_state_t xbt_automaton_transition_get_source(const_xbt_automaton_transition_t t)
+{
return t->src;
}
-xbt_automaton_state_t xbt_automaton_transition_get_destination(xbt_automaton_transition_t t){
+xbt_automaton_state_t xbt_automaton_transition_get_destination(const_xbt_automaton_transition_t t)
+{
return t->dst;
}
xbt_dynar_push(dst->in,&t);
}
-xbt_dynar_t xbt_automaton_state_get_out_transitions(xbt_automaton_state_t s){
+xbt_dynar_t xbt_automaton_state_get_out_transitions(const_xbt_automaton_state_t s)
+{
return s->out;
}
-xbt_dynar_t xbt_automaton_state_get_in_transitions(xbt_automaton_state_t s){
+xbt_dynar_t xbt_automaton_state_get_in_transitions(const_xbt_automaton_state_t s)
+{
return s->in;
}
-xbt_automaton_state_t xbt_automaton_state_exists(xbt_automaton_t a, char *id){
+xbt_automaton_state_t xbt_automaton_state_exists(const_xbt_automaton_t a, const char* id)
+{
xbt_automaton_state_t state = NULL;
unsigned int cursor = 0;
xbt_dynar_foreach(a->states, cursor, state){
return NULL;
}
-void xbt_automaton_display(xbt_automaton_t a){
+void xbt_automaton_display(const_xbt_automaton_t a)
+{
unsigned int cursor;
xbt_automaton_state_t state = NULL;
}
}
-void xbt_automaton_exp_label_display(xbt_automaton_exp_label_t label){
+void xbt_automaton_exp_label_display(const_xbt_automaton_exp_label_t label)
+{
printf("(");
switch(label->type){
case 0:
printf(")");
}
-xbt_automaton_state_t xbt_automaton_get_current_state(xbt_automaton_t a){
+xbt_automaton_state_t xbt_automaton_get_current_state(const_xbt_automaton_t a)
+{
return a->current_state;
}
return function();
}
-xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new(xbt_automaton_t a, const char* id,
+xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new(const_xbt_automaton_t a, const char* id,
int (*fct)(void))
{
xbt_automaton_propositional_symbol_t prop_symb = xbt_new0(struct xbt_automaton_propositional_symbol, 1);
return prop_symb;
}
-XBT_PUBLIC xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new_pointer(xbt_automaton_t a,
+XBT_PUBLIC xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new_pointer(const_xbt_automaton_t a,
const char* id,
int* value)
{
}
XBT_PUBLIC xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new_callback(
- xbt_automaton_t a, const char* id, xbt_automaton_propositional_symbol_callback_type callback, void* data,
+ const_xbt_automaton_t a, const char* id, xbt_automaton_propositional_symbol_callback_type callback, void* data,
xbt_automaton_propositional_symbol_free_function_type free_function)
{
xbt_automaton_propositional_symbol_t prop_symb = xbt_new0(struct xbt_automaton_propositional_symbol, 1);
return prop_symb;
}
-XBT_PUBLIC int xbt_automaton_propositional_symbol_evaluate(xbt_automaton_propositional_symbol_t symbol)
+XBT_PUBLIC int xbt_automaton_propositional_symbol_evaluate(const_xbt_automaton_propositional_symbol_t symbol)
{
if (symbol->callback)
return (symbol->callback)(symbol->data);
}
XBT_PUBLIC xbt_automaton_propositional_symbol_callback_type
-xbt_automaton_propositional_symbol_get_callback(xbt_automaton_propositional_symbol_t symbol)
+xbt_automaton_propositional_symbol_get_callback(const_xbt_automaton_propositional_symbol_t symbol)
{
return symbol->callback;
}
-XBT_PUBLIC void* xbt_automaton_propositional_symbol_get_data(xbt_automaton_propositional_symbol_t symbol)
+XBT_PUBLIC void* xbt_automaton_propositional_symbol_get_data(const_xbt_automaton_propositional_symbol_t symbol)
{
return symbol->data;
}
-XBT_PUBLIC const char* xbt_automaton_propositional_symbol_get_name(xbt_automaton_propositional_symbol_t symbol)
+XBT_PUBLIC const char* xbt_automaton_propositional_symbol_get_name(const_xbt_automaton_propositional_symbol_t symbol)
{
return symbol->pred;
}
-int xbt_automaton_state_compare(xbt_automaton_state_t s1, xbt_automaton_state_t s2){
-
+int xbt_automaton_state_compare(const_xbt_automaton_state_t s1, const_xbt_automaton_state_t s2)
+{
/* single id for each state, id and type sufficient for comparison*/
-
- if(strcmp(s1->id, s2->id))
- return 1;
-
- if(s1->type != s2->type)
- return 1;
-
- return 0;
-
+ return (strcmp(s1->id, s2->id) != 0) || (s1->type != s2->type);
}
-int xbt_automaton_transition_compare(const void *t1, const void *t2){
-
- if(xbt_automaton_state_compare(((xbt_automaton_transition_t)t1)->src, ((xbt_automaton_transition_t)t2)->src))
- return 1;
-
- if(xbt_automaton_state_compare(((xbt_automaton_transition_t)t1)->dst, ((xbt_automaton_transition_t)t2)->dst))
- return 1;
-
- if(xbt_automaton_exp_label_compare(((xbt_automaton_transition_t)t1)->label,((xbt_automaton_transition_t)t2)->label))
- return 1;
-
- return 0;
-
+int xbt_automaton_transition_compare(const_xbt_automaton_transition_t t1, const_xbt_automaton_transition_t t2)
+{
+ return xbt_automaton_state_compare(t1->src, t2->src) || xbt_automaton_state_compare(t1->dst, t2->dst) ||
+ xbt_automaton_exp_label_compare(t1->label, t2->label);
}
-int xbt_automaton_exp_label_compare(xbt_automaton_exp_label_t l1, xbt_automaton_exp_label_t l2){
-
+int xbt_automaton_exp_label_compare(const_xbt_automaton_exp_label_t l1, const_xbt_automaton_exp_label_t l2)
+{
if(l1->type != l2->type)
return 1;
switch(l1->type){
case 0 : // OR
case 1 : // AND
- if(xbt_automaton_exp_label_compare(l1->u.or_and.left_exp, l2->u.or_and.left_exp))
- res = 1;
- else
- res = xbt_automaton_exp_label_compare(l1->u.or_and.right_exp, l2->u.or_and.right_exp);
+ res = xbt_automaton_exp_label_compare(l1->u.or_and.left_exp, l2->u.or_and.left_exp) ||
+ xbt_automaton_exp_label_compare(l1->u.or_and.right_exp, l2->u.or_and.right_exp);
break;
case 2 : // NOT
res = xbt_automaton_exp_label_compare(l1->u.exp_not, l2->u.exp_not);
break;
case 3 : // predicat
- res = strcmp(l1->u.predicat, l2->u.predicat);
+ res = strcmp(l1->u.predicat, l2->u.predicat) != 0;
break;
case 4 : // 1
res = 0;
return res;
}
-int xbt_automaton_propositional_symbols_compare_value(xbt_dynar_t s1, xbt_dynar_t s2){
+int xbt_automaton_propositional_symbols_compare_value(const_xbt_dynar_t s1, const_xbt_dynar_t s2)
+{
unsigned int nb_elem = xbt_dynar_length(s1);
for (unsigned int cursor = 0; cursor < nb_elem; cursor++) {
- int* iptr1 = xbt_dynar_get_ptr(s1, cursor);
- int* iptr2 = xbt_dynar_get_ptr(s2, cursor);
+ const int* iptr1 = xbt_dynar_get_ptr(s1, cursor);
+ const int* iptr2 = xbt_dynar_get_ptr(s2, cursor);
if(*iptr1 != *iptr2)
return 1;
}
#define YY_RESTORE_YY_MORE_OFFSET
char *yytext;
#line 1 "parserPromela.lex"
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. 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. */
/* methods for implementation of automaton from promela description */
-/* Copyright (c) 2011-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2011-2020. 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. */
static xbt_automaton_t parsed_automaton;
char* state_id_src;
-static void new_state(char* id, int src){
+static void new_state(const char* id, int src)
+{
char* saveptr = NULL; // for strtok_r()
char* id_copy = xbt_strdup(id);
- char* first_part = strtok_r(id_copy, "_", &saveptr);
+ const char* first_part = strtok_r(id_copy, "_", &saveptr);
int type = 0 ; // -1=initial state; 0=intermediate state; 1=final state
if(strcmp(first_part,"accept")==0){
type = 1;
}else{
- char* second_part = strtok_r(NULL, "_", &saveptr);
+ const char* second_part = strtok_r(NULL, "_", &saveptr);
if(strcmp(second_part,"init")==0){
type = -1;
}
}
}
-static void new_transition(char* id, xbt_automaton_exp_label_t label)
+static void new_transition(const char* id, xbt_automaton_exp_label_t label)
{
new_state(id, 0);
xbt_automaton_state_t state_dst = xbt_automaton_state_exists(parsed_automaton, id);
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
void yyerror(const char *s);
-static void new_state(char* id, int src);
-static void new_transition(char* id, xbt_automaton_exp_label_t label);
+static void new_state(const char* id, int src);
+static void new_transition(const char* id, xbt_automaton_exp_label_t label);
#line 94 "parserPromela.tab.cacc"
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
void yyerror(const char *s);
-static void new_state(char* id, int src);
-static void new_transition(char* id, xbt_automaton_exp_label_t label);
+static void new_state(const char* id, int src);
+static void new_transition(const char* id, xbt_automaton_exp_label_t label);
%}
-/* Copyright (c) 2005-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2005-2020. 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/virtu.h>
-#include <cstddef>
+#include <cstdio>
#include <cstdlib>
-#include <cstring>
-#include <fstream>
#include <sstream>
-#include <sys/stat.h>
-#include <vector>
-
-#include <boost/algorithm/string.hpp>
// Try to detect and use the C++ itanium ABI for name demangling:
#ifdef __GXX_ABI_VERSION
}
class BacktraceImpl {
- short refcount_ = 1;
-
+#if HAVE_BOOST_STACKTRACE_BACKTRACE || HAVE_BOOST_STACKTRACE_ADDR2LINE
+ const boost::stacktrace::stacktrace st = boost::stacktrace::stacktrace();
+#else
+ const char st[1] = ""; // fallback value
+#endif
public:
- void ref() { refcount_++; }
- bool unref()
+ std::string resolve() const
{
- refcount_--;
- if (refcount_ == 0) {
- delete this;
- return true;
- } else {
- return false;
- }
+ std::stringstream ss;
+ ss << st;
+ return ss.str();
}
-#if HAVE_BOOST_STACKTRACE_BACKTRACE || HAVE_BOOST_STACKTRACE_ADDR2LINE
- boost::stacktrace::stacktrace st;
-#endif
};
-Backtrace::Backtrace()
-{
-#if HAVE_BOOST_STACKTRACE_BACKTRACE || HAVE_BOOST_STACKTRACE_ADDR2LINE
- impl_ = new BacktraceImpl();
- impl_->st = boost::stacktrace::stacktrace();
-#endif
-}
-Backtrace::Backtrace(const Backtrace& bt)
-{
- impl_ = bt.impl_;
- if (impl_)
- impl_->ref();
-}
-
-Backtrace::Backtrace(Backtrace&& bt)
-{
- impl_ = bt.impl_;
- bt.impl_ = nullptr;
-}
-
-Backtrace& Backtrace::operator=(const Backtrace& rhs)
-{
- if (this != &rhs) {
- if (impl_)
- impl_->unref();
- impl_ = rhs.impl_;
- if (impl_)
- impl_->ref();
- }
- return *this;
-}
-
-Backtrace& Backtrace::operator=(Backtrace&& rhs)
-{
- if (this != &rhs) {
- if (impl_)
- impl_->unref();
- impl_ = rhs.impl_;
- rhs.impl_ = nullptr;
- }
- return *this;
-}
+Backtrace::Backtrace() : impl_(std::make_shared<BacktraceImpl>()) {}
-Backtrace::~Backtrace()
+std::string Backtrace::resolve() const
{
- if (impl_)
- impl_->unref();
-}
-
-std::string const Backtrace::resolve() const
-{
- std::string result("");
-
-#if HAVE_BOOST_STACKTRACE_BACKTRACE || HAVE_BOOST_STACKTRACE_ADDR2LINE
- std::stringstream ss;
- ss << impl_->st;
- result.append(ss.str());
-#endif
- return result;
+ return impl_->resolve();
}
void Backtrace::display() const
{
std::string backtrace = resolve();
- if (backtrace.empty()) {
- fprintf(stderr, "(backtrace not set -- did you install Boost.Stacktrace?)\n");
- return;
- }
- fprintf(stderr, "Backtrace (displayed in actor %s):\n", xbt_procname());
- std::fprintf(stderr, "%s\n", backtrace.c_str());
+ std::fprintf(stderr, "Backtrace (displayed in actor %s):\n%s\n", xbt_procname(),
+ backtrace.empty() ? "(backtrace not set -- did you install Boost.Stacktrace?)" : backtrace.c_str());
}
} // namespace xbt
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
bool isdefault = true;
public:
- /* Callback */
- xbt_cfg_cb_t old_callback = nullptr;
-
ConfigurationElement(const std::string& key, const std::string& desc) : key(key), desc(desc) {}
- ConfigurationElement(const std::string& key, const std::string& desc, xbt_cfg_cb_t cb)
- : key(key), desc(desc), old_callback(cb)
- {
- }
virtual ~ConfigurationElement() = default;
TypedConfigurationElement(const std::string& key, const std::string& desc, T value = T())
: ConfigurationElement(key, desc), content(std::move(value))
{}
- TypedConfigurationElement(const std::string& key, const std::string& desc, T value, xbt_cfg_cb_t cb)
- : ConfigurationElement(key, desc, cb), content(std::move(value))
- {}
TypedConfigurationElement(const std::string& key, const std::string& desc, T value, std::function<void(T&)> callback)
: ConfigurationElement(key, desc), content(std::move(value)), callback(std::move(callback))
{}
void update()
{
- if (old_callback)
- this->old_callback(get_key().c_str());
if (this->callback)
this->callback(this->content);
}
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
/* dict - a generic dictionary, variation over hash table */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
*/
xbt_dict_t xbt_dict_new_homogeneous(void_f_pvoid_t free_ctn)
{
- if (dict_elm_mallocator == nullptr)
- xbt_dict_preinit();
+ xbt_dict_preinit();
xbt_dict_t dict;
}
/** Returns the amount of elements in the dict */
-unsigned int xbt_dict_size(xbt_dict_t dict)
+unsigned int xbt_dict_size(const_xbt_dict_t dict)
{
return (dict != nullptr ? static_cast<unsigned int>(dict->count) : static_cast<unsigned int>(0));
}
* @param key_len the size of the @a key
* @return the data that we are looking for
*
- * Search the given @a key. Throws std::out_of_range when not found.
+ * Search the given @a key. Returns nullptr when not found.
*/
-void *xbt_dict_get_ext(xbt_dict_t dict, const char *key, int key_len)
+void* xbt_dict_get_or_null_ext(const_xbt_dict_t dict, const char* key, int key_len)
{
unsigned int hash_code = xbt_str_hash_ext(key, key_len);
- xbt_dictelm_t current = dict->table[hash_code & dict->table_size];
-
- while (current != nullptr && (hash_code != current->hash_code || key_len != current->key_len
- || memcmp(key, current->key, key_len))) {
- current = current->next;
- }
-
- if (current == nullptr)
- throw std::out_of_range(simgrid::xbt::string_printf("key %.*s not found", key_len, key));
-
- return current->content;
-}
-
-/** @brief like xbt_dict_get_ext(), but returning nullptr when not found */
-void *xbt_dict_get_or_null_ext(xbt_dict_t dict, const char *key, int key_len)
-{
- unsigned int hash_code = xbt_str_hash_ext(key, key_len);
- xbt_dictelm_t current = dict->table[hash_code & dict->table_size];
+ const s_xbt_dictelm* current = dict->table[hash_code & dict->table_size];
while (current != nullptr && (hash_code != current->hash_code || key_len != current->key_len
|| memcmp(key, current->key, key_len))) {
return current->content;
}
-/**
- * @brief retrieve the key associated to that object. Warning, that's a linear search
- *
- * Returns nullptr if the object cannot be found
- */
-char *xbt_dict_get_key(xbt_dict_t dict, const void *data)
-{
- for (int i = 0; i <= dict->table_size; i++) {
- xbt_dictelm_t current = dict->table[i];
- while (current != nullptr) {
- if (current->content == data)
- return current->key;
- current = current->next;
- }
- }
- return nullptr;
-}
-
/**
* @brief Retrieve data from the dict (null-terminated key)
*
* @param key the key to find data
* @return the data that we are looking for
*
- * Search the given @a key. Throws std::out_of_range when not found.
- * Check xbt_dict_get_or_null() for a version returning nullptr without exception when not found.
+ * Search the given @a key. Returns nullptr when not found.
*/
-void *xbt_dict_get(xbt_dict_t dict, const char *key)
+void* xbt_dict_get_or_null(const_xbt_dict_t dict, const char* key)
{
- return xbt_dict_get_elm(dict, key)->content;
+ const s_xbt_dictelm* current = xbt_dict_get_elm_or_null(dict, key);
+
+ if (current == nullptr)
+ return nullptr;
+
+ return current->content;
}
/**
* @param key the key to find data
* @return the s_xbt_dictelm_t that we are looking for
*
- * Search the given @a key. Throws std::out_of_range when not found.
- * Check xbt_dict_get_or_null() for a version returning nullptr without exception when not found.
- */
-xbt_dictelm_t xbt_dict_get_elm(xbt_dict_t dict, const char *key)
-{
- xbt_dictelm_t current = xbt_dict_get_elm_or_null(dict, key);
-
- if (current == nullptr)
- throw std::out_of_range(simgrid::xbt::string_printf("key %s not found", key));
-
- return current;
-}
-
-/**
- * @brief like xbt_dict_get(), but returning nullptr when not found
+ * Search the given @a key. Returns nullptr when not found.
*/
-void *xbt_dict_get_or_null(xbt_dict_t dict, const char *key)
-{
- xbt_dictelm_t current = xbt_dict_get_elm_or_null(dict, key);
-
- if (current == nullptr)
- return nullptr;
-
- return current->content;
-}
-
-/**
- * @brief like xbt_dict_get_elm(), but returning nullptr when not found
- */
-xbt_dictelm_t xbt_dict_get_elm_or_null(xbt_dict_t dict, const char *key)
+xbt_dictelm_t xbt_dict_get_elm_or_null(const_xbt_dict_t dict, const char* key)
{
unsigned int hash_code = xbt_str_hash(key);
xbt_dictelm_t current = dict->table[hash_code & dict->table_size];
dict->count--;
}
-/**
- * @brief Remove data from the dict (null-terminated key)
- *
- * @param dict the dict
- * @param key the key of the data to be removed
- *
- * Remove the entry associated with the given @a key
- */
-void xbt_dict_remove(xbt_dict_t dict, const char *key)
-{
- xbt_dict_remove_ext(dict, key, strlen(key));
-}
-
-/** @brief Remove all data from the dict */
-void xbt_dict_reset(xbt_dict_t dict)
-{
- if (dict->count == 0)
- return;
-
- for (int i = 0; i <= dict->table_size; i++) {
- xbt_dictelm_t previous = nullptr;
- xbt_dictelm_t current = dict->table[i];
- while (current != nullptr) {
- previous = current;
- current = current->next;
- xbt_dictelm_free(dict, previous);
- }
- dict->table[i] = nullptr;
- }
-
- dict->count = 0;
- dict->fill = 0;
-}
-
/**
* @brief Return the number of elements in the dict.
* @param dict a dictionary
*/
-int xbt_dict_length(xbt_dict_t dict)
+int xbt_dict_length(const_xbt_dict_t dict)
{
return dict->count;
}
/**
* @brief test if the dict is empty or not
*/
-int xbt_dict_is_empty(xbt_dict_t dict)
+int xbt_dict_is_empty(const_xbt_dict_t dict)
{
return not dict || (xbt_dict_length(dict) == 0);
}
/* dict_cursor - iterators over dictionaries */
-/* Copyright (c) 2004-2019. The SimGrid Team.
+/* Copyright (c) 2004-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/** @brief Creator
* @param dict the dict
*/
-inline xbt_dict_cursor_t xbt_dict_cursor_new(const xbt_dict_t dict)
+inline xbt_dict_cursor_t xbt_dict_cursor_new(const_xbt_dict_t dict)
{
xbt_dict_cursor_t res = xbt_new(struct s_xbt_dict_cursor, 1);
res->dict = dict;
/*
* Sanity check to see if the head contains something
*/
-static inline void __cursor_not_null(xbt_dict_cursor_t cursor)
+static inline void __cursor_not_null(const_xbt_dict_cursor_t cursor)
{
xbt_assert(cursor, "Null cursor");
}
* @param dict on what to let the cursor iterate
* @param[out] cursor dest address
*/
-inline void xbt_dict_cursor_first(const xbt_dict_t dict, xbt_dict_cursor_t * cursor)
+inline void xbt_dict_cursor_first(const_xbt_dict_t dict, xbt_dict_cursor_t* cursor)
{
XBT_CDEBUG(xbt_dict_cursor, "xbt_dict_cursor_first");
if (!*cursor) {
*/
inline int xbt_dict_cursor_get_or_free(xbt_dict_cursor_t * cursor, char **key, void **data)
{
- xbt_dictelm_t current;
+ const struct s_xbt_dictelm* current;
XBT_CDEBUG(xbt_dict_cursor, "xbt_dict_get_or_free");
* @param cursor: the cursor
* @returns the current key
*/
-inline char *xbt_dict_cursor_get_key(xbt_dict_cursor_t cursor)
+inline char* xbt_dict_cursor_get_key(const_xbt_dict_cursor_t cursor)
{
__cursor_not_null(cursor);
* @param cursor the cursor
* @returns the current data
*/
-inline void *xbt_dict_cursor_get_data(xbt_dict_cursor_t cursor)
+inline void* xbt_dict_cursor_get_data(const_xbt_dict_cursor_t cursor)
{
__cursor_not_null(cursor);
/* dict - a generic dictionary, variation over hash table */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
return element;
}
-void xbt_dictelm_free(xbt_dict_t dict, xbt_dictelm_t element)
+void xbt_dictelm_free(const_xbt_dict_t dict, xbt_dictelm_t element)
{
if (element) {
char *key = element->key;
}
}
-void xbt_dictelm_set_data(xbt_dict_t dict, xbt_dictelm_t element, void* data)
+void xbt_dictelm_set_data(const_xbt_dict_t dict, xbt_dictelm_t element, void* data)
{
void_f_pvoid_t free_f = dict->free_f;
if (free_f && element->content)
/* dict_elm - elements of generic dictionaries */
/* This file is not to be loaded from anywhere but dict.cpp */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
/*####[ Function prototypes ]################################################*/
XBT_PRIVATE xbt_dictelm_t xbt_dictelm_new(const char* key, int key_len, unsigned int hash_code, void* content);
-XBT_PRIVATE void xbt_dictelm_free(xbt_dict_t dict, xbt_dictelm_t element);
-XBT_PRIVATE void xbt_dictelm_set_data(xbt_dict_t dict, xbt_dictelm_t element, void* data);
+XBT_PRIVATE void xbt_dictelm_free(const_xbt_dict_t dict, xbt_dictelm_t element);
+XBT_PRIVATE void xbt_dictelm_set_data(const_xbt_dict_t dict, xbt_dictelm_t element, void* data);
SG_END_DECL
/* dict - a generic dictionary, variation over hash table */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
return head;
}
-static void search_ext(xbt_dict_t head, const char* key, const char* data)
+static void search_ext(const_xbt_dict_t head, const char* key, const char* data)
{
INFO("Search " << STR(key));
- char* found = (char*)xbt_dict_get(head, key);
+ char* found = (char*)xbt_dict_get_or_null(head, key);
INFO("Found " << STR(found));
if (data) {
REQUIRE(found); // data do not match expectations: found null while searching for data
}
}
-static void search(xbt_dict_t head, const char* key)
+static void search(const_xbt_dict_t head, const char* key)
{
search_ext(head, key, key);
}
static void debugged_remove(xbt_dict_t head, const char* key)
{
INFO("Remove '" << STR(key) << "'");
- xbt_dict_remove(head, key);
+ xbt_dict_remove_ext(head, key, strlen(key));
}
-static void traverse(xbt_dict_t head)
+static void traverse(const_xbt_dict_t head)
{
xbt_dict_cursor_t cursor = nullptr;
char* key;
}
}
-static void search_not_found(xbt_dict_t head, const char* data)
+static void search_not_found(const_xbt_dict_t head, const char* data)
{
INFO("Search " << STR(data) << " (expected not to be found)");
- REQUIRE_THROWS_AS(xbt_dict_get(head, data), std::out_of_range);
+ REQUIRE(xbt_dict_get_or_null(head, data) == nullptr);
}
-static void count(xbt_dict_t dict, int length)
+static void count(const_xbt_dict_t dict, int length)
{
INFO("Count elements (expecting " << length << ")");
REQUIRE(xbt_dict_length(dict) == length); // Announced length differs
REQUIRE(effective == length); // Effective length differs
}
-static void count_check_get_key(xbt_dict_t dict, int length)
-{
- xbt_dict_cursor_t cursor;
- char* key;
- void* data;
- int effective = 0;
-
- INFO("Count elements (expecting " << length << "), and test the getkey function");
- REQUIRE(xbt_dict_length(dict) == length); // Announced length differs
-
- xbt_dict_foreach (dict, cursor, key, data) {
- effective++;
- char* key2 = xbt_dict_get_key(dict, data);
- xbt_assert(not strcmp(key, key2), "The data was registered under %s instead of %s as expected", key2, key);
- }
-
- REQUIRE(effective == length); // Effective length differs
-}
-
-static int countelems(xbt_dict_t head)
+static int countelems(const_xbt_dict_t head)
{
xbt_dict_cursor_t cursor;
char* key;
TEST_CASE("xbt::dict: dict data container", "dict")
{
-
SECTION("Basic usage: change, retrieve and traverse homogeneous dicts")
{
INFO("Traversal the null dictionary");
INFO("Traverse the full dictionary");
head = new_fixture();
- count_check_get_key(head, 7);
+ count(head, 7);
debugged_add_ext(head, "toto", "tutu");
search_ext(head, "toto", "tutu");
/* CHANGING */
head = new_fixture();
- count_check_get_key(head, 7);
+ count(head, 7);
INFO("Change 123 to 'Changed 123'");
xbt_dict_set(head, "123", xbt_strdup("Changed 123"));
- count_check_get_key(head, 7);
+ count(head, 7);
INFO("Change 123 back to '123'");
xbt_dict_set(head, "123", xbt_strdup("123"));
- count_check_get_key(head, 7);
+ count(head, 7);
INFO("Change 12a to 'Dummy 12a'");
xbt_dict_set(head, "12a", xbt_strdup("Dummy 12a"));
- count_check_get_key(head, 7);
+ count(head, 7);
INFO("Change 12a to '12a'");
xbt_dict_set(head, "12a", xbt_strdup("12a"));
- count_check_get_key(head, 7);
+ count(head, 7);
INFO("Traverse the resulting dictionary");
traverse(head);
/* RETRIEVE */
INFO("Search 123");
- char* data = (char*)xbt_dict_get(head, "123");
+ const char* data = (char*)xbt_dict_get_or_null(head, "123");
REQUIRE((data && strcmp("123", data) == 0));
search_not_found(head, "Can't be found");
REQUIRE_THROWS_AS(debugged_remove(head, "12346"), std::out_of_range);
traverse(head);
- INFO("Free dict, create new fresh one, and then reset the dict");
- xbt_dict_free(&head);
- head = new_fixture();
- xbt_dict_reset(head);
- count(head, 0);
- traverse(head);
-
INFO("Free the dictionary twice");
xbt_dict_free(&head);
xbt_dict_free(&head);
INFO("using 1000 elements with " << SIZEOFKEY << " chars long randomized keys.");
xbt_dict_t head = xbt_dict_new_homogeneous(free);
for (int j = 0; j < 1000; j++) {
- char* data = nullptr;
+ const char* data = nullptr;
char* key = (char*)xbt_malloc(SIZEOFKEY);
do {
} while (data != nullptr);
xbt_dict_set(head, key, key);
- data = (char*)xbt_dict_get(head, key);
- REQUIRE(not strcmp(key, data)); // Retrieved value != Injected value
+ data = (char*)xbt_dict_get_or_null(head, key);
+ REQUIRE((data && not strcmp(key, data))); // Retrieved value != Injected value
count(head, j + 1);
}
for (int i = 0; i < 20; i++) {
for (int j = 0; j < NB_ELM; j++) {
snprintf(key, 10, "%d", j);
- void* data = xbt_dict_get(head, key);
- REQUIRE(not strcmp(key, (char*)data)); // with get, key != data
- data = xbt_dict_get_ext(head, key, strlen(key));
- REQUIRE(not strcmp(key, (char*)data)); // with get_ext, key != data
+ void* data = xbt_dict_get_or_null(head, key);
+ REQUIRE((data && not strcmp(key, (char*)data))); // with get, key != data
+ data = xbt_dict_get_or_null_ext(head, key, strlen(key));
+ REQUIRE((data && not strcmp(key, (char*)data))); // with get_ext, key != data
}
}
xbt_free(key);
key = (char*)xbt_malloc(10);
for (int j = 0; j < NB_ELM; j++) {
snprintf(key, 10, "%d", j);
- xbt_dict_remove(head, key);
+ xbt_dict_remove_ext(head, key, strlen(key));
}
xbt_free(key);
INFO("Check elements");
for (int i = 0; i < count; ++i) {
- xbt_dict_get_ext(dict, (char*)&i, sizeof(i));
- REQUIRE(xbt_dict_size(dict) == (unsigned)count); // Unexpected value at index i
+ void* data = xbt_dict_get_or_null_ext(dict, (char*)&i, sizeof(i));
+ REQUIRE((intptr_t)data == i); // Unexpected value at index i
}
INFO("Free the array");
/* a generic DYNamic ARray implementation. */
-/* Copyright (c) 2004-2019. The SimGrid Team.
+/* Copyright (c) 2004-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_dyn, xbt, "Dynamic arrays");
-static inline void _sanity_check_dynar(xbt_dynar_t dynar)
+static inline void _sanity_check_dynar(const_xbt_dynar_t dynar)
{
xbt_assert(dynar, "dynar is nullptr");
}
xbt_assert(idx >= 0, "dynar idx(=%d) < 0", idx);
}
-static inline void _check_inbound_idx(xbt_dynar_t dynar, int idx)
+static inline void _check_inbound_idx(const_xbt_dynar_t dynar, int idx)
{
- if (idx < 0 || idx >= static_cast<int>(dynar->used)) {
- throw std::out_of_range(simgrid::xbt::string_printf("dynar is not that long. You asked %d, but it's only %lu long",
- idx, static_cast<unsigned long>(dynar->used)));
- }
+ xbt_assert(idx >= 0 && idx < static_cast<int>(dynar->used),
+ "dynar is not that long. You asked %d, but it's only %lu long", idx, dynar->used);
}
-static inline void _check_populated_dynar(xbt_dynar_t dynar)
+static inline void _check_populated_dynar(const_xbt_dynar_t dynar)
{
- if (dynar->used == 0) {
- throw std::out_of_range(simgrid::xbt::string_printf("dynar %p is empty", dynar));
- }
+ xbt_assert(dynar->used > 0, "dynar %p is empty", dynar);
}
static inline void _xbt_dynar_resize(xbt_dynar_t dynar, unsigned long new_size)
}
}
-static inline void _xbt_dynar_expand(xbt_dynar_t const dynar, const unsigned long nb)
+static inline void _xbt_dynar_expand(xbt_dynar_t dynar, unsigned long nb)
{
const unsigned long old_size = dynar->size;
}
}
-static inline void *_xbt_dynar_elm(const xbt_dynar_t dynar, const unsigned long idx)
+static inline void* _xbt_dynar_elm(const_xbt_dynar_t dynar, unsigned long idx)
{
char *const data = (char *) dynar->data;
const unsigned long elmsize = dynar->elmsize;
return data + idx * elmsize;
}
-static inline void _xbt_dynar_get_elm(void *const dst, const xbt_dynar_t dynar, const unsigned long idx)
+static inline void _xbt_dynar_get_elm(void* dst, const_xbt_dynar_t dynar, unsigned long idx)
{
- void *const elm = _xbt_dynar_elm(dynar, idx);
-
+ const void* const elm = _xbt_dynar_elm(dynar, idx);
memcpy(dst, elm, dynar->elmsize);
}
-void xbt_dynar_dump(xbt_dynar_t dynar)
-{
- XBT_INFO("Dynar dump: size=%lu; used=%lu; elmsize=%lu; data=%p; free_f=%p",
- dynar->size, dynar->used, dynar->elmsize, dynar->data, dynar->free_f);
-}
-
/** @brief Constructor
*
* @param elmsize size of each element in the dynar
* Creates a new dynar. If a free_func is provided, the elements have to be pointer of pointer. That is to say that
* dynars can contain either base types (int, char, double, etc) or pointer of pointers (struct **).
*/
-xbt_dynar_t xbt_dynar_new(const unsigned long elmsize, void_f_pvoid_t const free_f)
+xbt_dynar_t xbt_dynar_new(const unsigned long elmsize, void_f_pvoid_t free_f)
{
xbt_dynar_t dynar = xbt_new0(s_xbt_dynar_t, 1);
return dynar;
}
-/** @brief Initialize a dynar structure that was not malloc'ed
- * This can be useful to keep temporary dynars on the stack
- */
-void xbt_dynar_init(xbt_dynar_t dynar, const unsigned long elmsize, void_f_pvoid_t const free_f)
-{
- dynar->size = 0;
- dynar->used = 0;
- dynar->elmsize = elmsize;
- dynar->data = nullptr;
- dynar->free_f = free_f;
-}
-
-/** @brief Destroy a dynar that was created with xbt_dynar_init */
-void xbt_dynar_free_data(xbt_dynar_t dynar)
-{
- xbt_dynar_reset(dynar);
- if (dynar)
- xbt_free(dynar->data);
-}
-
/** @brief Destructor of the structure not touching to the content
*
* @param dynar poor victim
*
* @param dynar who to squeeze
*/
-void xbt_dynar_reset(xbt_dynar_t const dynar)
+void xbt_dynar_reset(xbt_dynar_t dynar)
{
_sanity_check_dynar(dynar);
dynar->used = 0;
}
-/** @brief Merge dynar d2 into d1
- *
- * @param d1 dynar to keep
- * @param d2 dynar to merge into d1. This dynar is free at end.
- */
-void xbt_dynar_merge(xbt_dynar_t* d1, xbt_dynar_t* d2)
-{
- if((*d1)->elmsize != (*d2)->elmsize)
- xbt_die("Element size must are not equal");
-
- const unsigned long elmsize = (*d1)->elmsize;
-
- void *ptr = _xbt_dynar_elm((*d2), 0);
- _xbt_dynar_resize(*d1, (*d1)->size + (*d2)->size);
- void *elm = _xbt_dynar_elm((*d1), (*d1)->used);
-
- memcpy(elm, ptr, ((*d2)->size)*elmsize);
- (*d1)->used += (*d2)->used;
- (*d2)->used = 0;
- xbt_dynar_free(d2);
-}
-
/**
* @brief Shrink the dynar by removing empty slots at the end of the internal array
* @param dynar a dynar
}
}
-/** @brief free a dynar passed as void* (handy to store dynar in dynars or dict) */
-void xbt_dynar_free_voidp(void* d)
-{
- xbt_dynar_t dynar = (xbt_dynar_t)d;
- xbt_dynar_free(&dynar);
-}
-
/** @brief Count of dynar's elements
*
* @param dynar the dynar we want to measure
*/
-unsigned long xbt_dynar_length(const xbt_dynar_t dynar)
+unsigned long xbt_dynar_length(const_xbt_dynar_t dynar)
{
return (dynar ? (unsigned long) dynar->used : (unsigned long) 0);
}
*
*@param dynar the dynat we want to check
*/
-int xbt_dynar_is_empty(const xbt_dynar_t dynar)
+int xbt_dynar_is_empty(const_xbt_dynar_t dynar)
{
return (xbt_dynar_length(dynar) == 0);
}
* @param idx index of the slot we want to retrieve
* @param[out] dst where to put the result to.
*/
-void xbt_dynar_get_cpy(const xbt_dynar_t dynar, const unsigned long idx, void* const dst)
+void xbt_dynar_get_cpy(const_xbt_dynar_t dynar, unsigned long idx, void* dst)
{
_sanity_check_dynar(dynar);
_check_inbound_idx(dynar, idx);
* @warning The returned value is the actual content of the dynar.
* Make a copy before fooling with it.
*/
-void* xbt_dynar_get_ptr(const xbt_dynar_t dynar, const unsigned long idx)
+void* xbt_dynar_get_ptr(const_xbt_dynar_t dynar, unsigned long idx)
{
void *res;
_sanity_check_dynar(dynar);
return res;
}
-void* xbt_dynar_set_at_ptr(const xbt_dynar_t dynar, const unsigned long idx)
+void* xbt_dynar_set_at_ptr(const xbt_dynar_t dynar, unsigned long idx)
{
_sanity_check_dynar(dynar);
return _xbt_dynar_elm(dynar, idx);
}
-/** @brief Set the Nth element of a dynar (expanded if needed). Previous value at this position is NOT freed
- *
- * @param dynar information dealer
- * @param idx index of the slot we want to modify
- * @param src What will be feeded to the dynar
- *
- * If you want to free the previous content, use xbt_dynar_replace().
- */
-void xbt_dynar_set(xbt_dynar_t dynar, const int idx, const void* const src)
-{
- memcpy(xbt_dynar_set_at_ptr(dynar, idx), src, dynar->elmsize);
-}
-
-/** @brief Set the Nth element of a dynar (expanded if needed). Previous value is freed
- *
- * @param dynar
- * @param idx
- * @param object
- *
- * Set the Nth element of a dynar, expanding the dynar if needed, AND DO free the previous value at this position. If
- * you don't want to free the previous content, use xbt_dynar_set().
- */
-void xbt_dynar_replace(xbt_dynar_t dynar, const unsigned long idx, const void* const object)
-{
- _sanity_check_dynar(dynar);
-
- if (idx < dynar->used && dynar->free_f) {
- void *const old_object = _xbt_dynar_elm(dynar, idx);
-
- dynar->free_f(old_object);
- }
-
- xbt_dynar_set(dynar, idx, object);
-}
-
/** @brief Make room for a new element, and return a pointer to it
*
* You can then use regular affectation to set its value instead of relying on the slow memcpy. This is what
* xbt_dynar_insert_at_as() does.
*/
-void* xbt_dynar_insert_at_ptr(xbt_dynar_t const dynar, const int idx)
+void* xbt_dynar_insert_at_ptr(xbt_dynar_t dynar, int idx)
{
void *res;
unsigned long old_used;
* Set the Nth element of a dynar, expanding the dynar if needed, and moving the previously existing value and all
* subsequent ones to one position right in the dynar.
*/
-void xbt_dynar_insert_at(xbt_dynar_t const dynar, const int idx, const void* const src)
+void xbt_dynar_insert_at(xbt_dynar_t dynar, int idx, const void* src)
{
/* checks done in xbt_dynar_insert_at_ptr */
memcpy(xbt_dynar_insert_at_ptr(dynar, idx), src, dynar->elmsize);
* If the object argument of this function is a non-null pointer, the removed element is copied to this address. If not,
* the element is freed using the free_f function passed at dynar creation.
*/
-void xbt_dynar_remove_at(xbt_dynar_t const dynar, const int idx, void* const object)
+void xbt_dynar_remove_at(xbt_dynar_t dynar, int idx, void* object)
{
_sanity_check_dynar(dynar);
_check_inbound_idx(dynar, idx);
dynar->used--;
}
-/** @brief Remove a slice of the dynar, sliding the rest of the values to the left
- *
- * This function removes an n-sized slice that starts at element idx. It is equivalent to xbt_dynar_remove_at with a
- * nullptr object argument if n equals to 1.
- *
- * Each of the removed elements is freed using the free_f function passed at dynar creation.
- */
-void xbt_dynar_remove_n_at(xbt_dynar_t const dynar, const unsigned int n, const int idx)
-{
- if (not n)
- return;
-
- _sanity_check_dynar(dynar);
- _check_inbound_idx(dynar, idx);
- _check_inbound_idx(dynar, idx + n - 1);
-
- if (dynar->free_f) {
- for (unsigned long cur = idx; cur < idx + n; cur++) {
- dynar->free_f(_xbt_dynar_elm(dynar, cur));
- }
- }
-
- unsigned long nb_shift = dynar->used - n - idx;
-
- if (nb_shift) {
- unsigned long offset = nb_shift * dynar->elmsize;
- memmove(_xbt_dynar_elm(dynar, idx), _xbt_dynar_elm(dynar, idx + n), offset);
- }
-
- dynar->used -= n;
-}
-
-/** @brief Returns the position of the element in the dynar
- *
- * Beware that if your dynar contains pointed values (such as strings) instead of scalar, this function compares the
- * pointer value, not what's pointed. The only solution to search for a pointed value is then to write the foreach loop
- * yourself:
- * @code
- * signed int position = -1;
- * xbt_dynar_foreach(dynar, iter, elem) {
- * if (not memcmp(elem, searched_element, sizeof(*elem))) {
- * position = iter;
- * break;
- * }
- * }
- * @endcode
- *
- * Raises std::out_of_range if not found. If you have less than 2 millions elements, you probably want to use
- * #xbt_dynar_search_or_negative() instead, so that you don't have to try/catch on element not found.
- */
-unsigned int xbt_dynar_search(xbt_dynar_t const dynar, void* const elem)
-{
- unsigned long it;
-
- for (it = 0; it < dynar->used; it++)
- if (not memcmp(_xbt_dynar_elm(dynar, it), elem, dynar->elmsize)) {
- return it;
- }
-
- throw std::out_of_range(simgrid::xbt::string_printf("Element %p not part of dynar %p", elem, dynar));
-}
-
/** @brief Returns the position of the element in the dynar (or -1 if not found)
*
* Beware that if your dynar contains pointed values (such as strings) instead of scalar, this function is probably not
* Note that usually, the dynar indices are unsigned integers. If you have more than 2 million elements in your dynar,
* this very function will not work (but the other will).
*/
-signed int xbt_dynar_search_or_negative(xbt_dynar_t const dynar, void* const elem)
+signed int xbt_dynar_search_or_negative(const_xbt_dynar_t dynar, const void* elem)
{
unsigned long it;
* Beware that if your dynar contains pointed values (such as strings) instead of scalar, this function is probably not
* what you want. Check the documentation of xbt_dynar_search() for more info.
*/
-int xbt_dynar_member(xbt_dynar_t const dynar, void* const elem)
+int xbt_dynar_member(const_xbt_dynar_t dynar, const void* elem)
{
unsigned long it;
* You can then use regular affectation to set its value instead of relying on the slow memcpy. This is what
* xbt_dynar_push_as() does.
*/
-void* xbt_dynar_push_ptr(xbt_dynar_t const dynar)
+void* xbt_dynar_push_ptr(xbt_dynar_t dynar)
{
return xbt_dynar_insert_at_ptr(dynar, dynar->used);
}
/** @brief Add an element at the end of the dynar */
-void xbt_dynar_push(xbt_dynar_t const dynar, const void* const src)
+void xbt_dynar_push(xbt_dynar_t dynar, const void* src)
{
/* checks done in xbt_dynar_insert_at_ptr */
memcpy(xbt_dynar_insert_at_ptr(dynar, dynar->used), src, dynar->elmsize);
* You can then use regular affectation to set its value instead of relying on the slow memcpy. This is what
* xbt_dynar_pop_as() does.
*/
-void* xbt_dynar_pop_ptr(xbt_dynar_t const dynar)
+void* xbt_dynar_pop_ptr(xbt_dynar_t dynar)
{
_check_populated_dynar(dynar);
XBT_CDEBUG(xbt_dyn, "Pop %p", (void *) dynar);
}
/** @brief Get and remove the last element of the dynar */
-void xbt_dynar_pop(xbt_dynar_t const dynar, void* const dst)
+void xbt_dynar_pop(xbt_dynar_t dynar, void* dst)
{
/* sanity checks done by remove_at */
XBT_CDEBUG(xbt_dyn, "Pop %p", (void *) dynar);
*
* This is less efficient than xbt_dynar_push()
*/
-void xbt_dynar_unshift(xbt_dynar_t const dynar, const void* const src)
+void xbt_dynar_unshift(xbt_dynar_t dynar, const void* src)
{
/* sanity checks done by insert_at */
xbt_dynar_insert_at(dynar, 0, src);
*
* This is less efficient than xbt_dynar_pop()
*/
-void xbt_dynar_shift(xbt_dynar_t const dynar, void* const dst)
+void xbt_dynar_shift(xbt_dynar_t dynar, void* dst)
{
/* sanity checks done by remove_at */
xbt_dynar_remove_at(dynar, 0, dst);
*
* The mapped function may change the value of the element itself, but should not mess with the structure of the dynar.
*/
-void xbt_dynar_map(const xbt_dynar_t dynar, void_f_pvoid_t const op)
+void xbt_dynar_map(const_xbt_dynar_t dynar, void_f_pvoid_t op)
{
char *const data = (char *) dynar->data;
const unsigned long elmsize = dynar->elmsize;
*
* This function can be used while traversing without problem.
*/
-void xbt_dynar_cursor_rm(xbt_dynar_t dynar, unsigned int* const cursor)
+void xbt_dynar_cursor_rm(xbt_dynar_t dynar, unsigned int* cursor)
{
xbt_dynar_remove_at(dynar, *cursor, nullptr);
*cursor -= 1;
* @param dynar the dynar to sort
* @param compar_fn comparison function of type (int (compar_fn*) (const void*) (const void*)).
*/
-void xbt_dynar_sort(xbt_dynar_t dynar, int_f_cpvoid_cpvoid_t compar_fn)
+void xbt_dynar_sort(const_xbt_dynar_t dynar, int_f_cpvoid_cpvoid_t compar_fn)
{
if (dynar->data != nullptr)
qsort(dynar->data, dynar->used, dynar->elmsize, compar_fn);
xbt_free(dynar);
return res;
}
-
-/** @brief Compare two dynars
- *
- * @param d1 first dynar to compare
- * @param d2 second dynar to compare
- * @param compar function to use to compare elements
- * @return 0 if d1 and d2 are equal and 1 if not equal
- *
- * d1 and d2 should be dynars of pointers. The compar function takes two elements and returns 0 when they are
- * considered equal, and a value different of zero when they are considered different. Finally, d2 is destroyed
- * afterwards.
- */
-int xbt_dynar_compare(xbt_dynar_t d1, xbt_dynar_t d2, int (*compar)(const void*, const void*))
-{
- int i ;
- int size;
- if ((not d1) && (not d2))
- return 0;
- if ((not d1) || (not d2)) {
- XBT_DEBUG("nullptr dynar d1=%p d2=%p",d1,d2);
- xbt_dynar_free(&d2);
- return 1;
- }
- if((d1->elmsize)!=(d2->elmsize)) {
- XBT_DEBUG("Size of elmsize d1=%lu d2=%lu",d1->elmsize,d2->elmsize);
- xbt_dynar_free(&d2);
- return 1; // xbt_die
- }
- if(xbt_dynar_length(d1) != xbt_dynar_length(d2)) {
- XBT_DEBUG("Size of dynar d1=%lu d2=%lu",xbt_dynar_length(d1),xbt_dynar_length(d2));
- xbt_dynar_free(&d2);
- return 1;
- }
-
- size = xbt_dynar_length(d1);
- for(i=0;i<size;i++) {
- void *data1 = xbt_dynar_get_as(d1, i, void *);
- void *data2 = xbt_dynar_get_as(d2, i, void *);
- XBT_DEBUG("link[%d] d1=%p d2=%p",i,data1,data2);
- if(compar(data1,data2)){
- xbt_dynar_free(&d2);
- return 1;
- }
- }
- xbt_dynar_free(&d2);
- return 0;
-}
/* a generic DYNamic ARray implementation. */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
TEST_CASE("xbt::dynar: generic C vector", "dynar")
{
-
SECTION("Dynars of integers")
{
/* Vars_decl [doxygen cruft] */
/* 2. Traverse manually the dynar */
for (int i = 0; i < NB_ELEM; i++) {
- int* iptr = (int*)xbt_dynar_get_ptr(d, i);
+ const int* iptr = (int*)xbt_dynar_get_ptr(d, i);
REQUIRE(i == *iptr); // The retrieved value is not the same than the injected one
}
}
REQUIRE(xbt_dynar_is_empty(d));
- for (int i = 0; i < NB_ELEM; i++) {
- xbt_dynar_push_as(d, int, -1);
- }
- int* pi;
- xbt_dynar_foreach_ptr(d, cursor, pi) { *pi = 0; }
- xbt_dynar_foreach (d, cursor, cpt) {
- REQUIRE(cpt == 0); // The value is not the same as the expected one.
- }
- xbt_dynar_foreach_ptr(d, cursor, pi) { *pi = 1; }
- xbt_dynar_foreach (d, cursor, cpt) {
- REQUIRE(cpt == 1); // The value is not the same as the expected one
- }
-
/* 5. Free the resources */
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 */
for (int i = 0; i < NB_ELEM; i++) {
xbt_dynar_push_as(d, int, i);
}
- for (int i = 0; i < NB_ELEM / 5; i++) {
- xbt_dynar_insert_at_as(d, NB_ELEM / 2, int, i);
- }
- for (int i = 0; i < NB_ELEM / 2; i++) {
+ for (int i = 0; i < NB_ELEM; i++) {
int val;
xbt_dynar_shift(d, &val);
REQUIRE(val == i); // The retrieved value is not the same than the injected one at the beginning
}
- for (int i = 999; i >= 0; i--) {
- int val;
- xbt_dynar_shift(d, &val);
- REQUIRE(val == i); // The retrieved value is not the same than the injected one in the middle
- }
- for (int i = 2500; i < NB_ELEM; i++) {
- int val;
- xbt_dynar_shift(d, &val);
- REQUIRE(val == i); // The retrieved value is not the same than the injected one at the end
- }
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 */
/* in your code is naturally the way to go outside a regression test */
}
REQUIRE(xbt_dynar_is_empty(d));
xbt_dynar_free(&d);
-
- /* ********************* */
- INFO("==== Insert " << NB_ELEM << " int in reverse order, traverse them, remove them");
- d = xbt_dynar_new(sizeof(int), nullptr);
- for (int i = NB_ELEM - 1; i >= 0; i--) {
- xbt_dynar_replace(d, i, &i);
- }
-
- /* 3. Traverse the dynar */
- xbt_dynar_foreach (d, cursor, cpt) {
- REQUIRE(cursor == (unsigned)cpt); // The retrieved value is not the same than the injected one
- }
- /* end_of_traversal */
-
- for (int i = NB_ELEM - 1; i >= 0; i--) {
- int val;
- xbt_dynar_remove_at(d, xbt_dynar_length(d) - 1, &val);
- REQUIRE(val == i); // The retrieved value is not the same than the injected one
- }
- REQUIRE(xbt_dynar_is_empty(d));
- xbt_dynar_free(&d);
}
/*******************************************************************************/
s1 = xbt_strdup(buf);
xbt_dynar_push(d, &s1);
}
- for (int k = 0; k < 3; k++) {
- for (int i = 0; i < NB_ELEM; i++) {
- snprintf(buf, 1023, "%d", i);
- s1 = xbt_strdup(buf);
- xbt_dynar_replace(d, i, &s1);
- }
- }
for (int i = 0; i < NB_ELEM; i++) {
snprintf(buf, 1023, "%d", i);
xbt_dynar_shift(d, &s2);
-/* Copyright (c) 2005-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2005-2020. 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. */
return;
try {
with_nested->rethrow_nested();
- }
- catch (std::exception& nested_exception) {
+ } catch (const std::exception& nested_exception) {
log_exception(prio, "Caused by", nested_exception);
}
// We could catch nested_exception or WithContextException but we don't bother:
}
// Parse error are handled differently, as the call stack does not matter, only the file location
- catch (simgrid::ParseError& e) {
+ catch (const simgrid::ParseError& e) {
XBT_ERROR("%s", e.what());
XBT_ERROR("Exiting now.");
std::abort();
}
// We manage C++ exception ourselves
- catch (std::exception& e) {
+ catch (const std::exception& e) {
log_exception(xbt_log_priority_critical, "Uncaught exception", e);
show_backtrace(bt);
std::abort();
/* a generic graph library. */
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
}
/** @brief add a node to the given graph */
-xbt_node_t xbt_graph_new_node(xbt_graph_t g, void *data)
+xbt_node_t xbt_graph_new_node(const s_xbt_graph_t* g, void* data)
{
xbt_node_t node= xbt_new0(struct xbt_node, 1);
node->data = data;
}
/** @brief add an edge to the given graph */
-xbt_edge_t xbt_graph_new_edge(xbt_graph_t g, xbt_node_t src, xbt_node_t dst, void *data)
+xbt_edge_t xbt_graph_new_edge(const s_xbt_graph_t* g, xbt_node_t src, xbt_node_t dst, void* data)
{
xbt_edge_t edge = xbt_new0(struct xbt_edge, 1);
xbt_dynar_push(src->out, &edge);
}
/** @brief Get the edge connecting src and dst */
-xbt_edge_t xbt_graph_get_edge(xbt_graph_t g, xbt_node_t src, xbt_node_t dst)
+xbt_edge_t xbt_graph_get_edge(const s_xbt_graph_t* g, const s_xbt_node_t* src, const s_xbt_node_t* dst)
{
xbt_edge_t edge;
unsigned int cursor;
}
/** @brief Get the user data associated to a node */
-void *xbt_graph_node_get_data(xbt_node_t node)
+void* xbt_graph_node_get_data(const s_xbt_node_t* node)
{
return node->data;
}
}
/** @brief Get the user data associated to a edge */
-void *xbt_graph_edge_get_data(xbt_edge_t edge)
+void* xbt_graph_edge_get_data(const s_xbt_edge_t* edge)
{
return edge->data;
}
}
/** @brief Retrieve the graph's nodes as a dynar */
-xbt_dynar_t xbt_graph_get_nodes(xbt_graph_t g)
+xbt_dynar_t xbt_graph_get_nodes(const s_xbt_graph_t* g)
{
return g->nodes;
}
/** @brief Retrieve the graph's edges as a dynar */
-xbt_dynar_t xbt_graph_get_edges(xbt_graph_t g)
+xbt_dynar_t xbt_graph_get_edges(const s_xbt_graph_t* g)
{
return g->edges;
}
/** @brief Retrieve the node at the source of the given edge */
-xbt_node_t xbt_graph_edge_get_source(xbt_edge_t e)
+xbt_node_t xbt_graph_edge_get_source(const s_xbt_edge_t* e)
{
return e->src;
}
/** @brief Retrieve the node being the target of the given edge */
-xbt_node_t xbt_graph_edge_get_target(xbt_edge_t e)
+xbt_node_t xbt_graph_edge_get_target(const s_xbt_edge_t* e)
{
return e->dst;
}
/** @brief Retrieve the outgoing edges of the given node */
-xbt_dynar_t xbt_graph_node_get_outedges(xbt_node_t n)
+xbt_dynar_t xbt_graph_node_get_outedges(const s_xbt_node_t* n)
{
return n->out;
}
/* log - a generic logging facility in the spirit of log4j */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
}
}
-static void log_cat_exit(xbt_log_category_t cat)
+static void log_cat_exit(const s_xbt_log_category_t* cat)
{
- xbt_log_category_t child;
-
if (cat->appender) {
if (cat->appender->free_)
cat->appender->free_(cat->appender);
xbt_free(cat->layout);
}
- for (child = cat->firstChild; child != nullptr; child = child->nextSibling)
+ for (auto const* child = cat->firstChild; child != nullptr; child = child->nextSibling)
log_cat_exit(child);
}
void _xbt_log_event_log(xbt_log_event_t ev, const char *fmt, ...)
{
- xbt_log_category_t cat = ev->cat;
+ const xbt_log_category_s* cat = ev->cat;
xbt_assert(ev->priority >= 0, "Negative logging priority naturally forbidden");
xbt_assert(static_cast<size_t>(ev->priority) < sizeof(xbt_log_priority_names)/sizeof(xbt_log_priority_names[0]),
"Priority %d is greater than the biggest allowed value", ev->priority);
while (1) {
- xbt_log_appender_t appender = cat->appender;
+ const s_xbt_log_appender_t* appender = cat->appender;
if (appender != nullptr) {
xbt_assert(cat->layout, "No valid layout for the appender of category %s", cat->name);
if (done) {
appender->do_append(appender, buff);
} else {
-
/* The static buffer was too small, use a dynamically expanded one */
ev->buffer_size = XBT_LOG_DYNAMIC_BUFFER_SIZE;
ev->buffer = static_cast<char*>(xbt_malloc(ev->buffer_size));
if (XBT_LOG_ISENABLED(log, xbt_log_priority_debug)) {
std::string res;
- xbt_log_category_t cpp = category->parent->firstChild;
+ const xbt_log_category_s* cpp = category->parent->firstChild;
while (cpp) {
res += std::string(" ") + cpp->name;
cpp = cpp->nextSibling;
cat->isThreshInherited = 1;
}
-static void _set_inherited_thresholds(xbt_log_category_t cat)
+static void _set_inherited_thresholds(const s_xbt_log_category_t* cat)
{
xbt_log_category_t child = cat->firstChild;
cats.push_back(cat);
std::sort(begin(cats), end(cats),
- [](xbt_log_category_t a, xbt_log_category_t b) { return strcmp(a->name, b->name) < 0; });
+ [](const s_xbt_log_category_t* a, const s_xbt_log_category_t* b) { return strcmp(a->name, b->name) < 0; });
for (auto const& cat : cats) {
XBT_HELP("%s%s: %s", this_prefix.c_str(), cat->name, cat->description);
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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/log.h"
struct xbt_log_appender_s {
- void (*do_append) (xbt_log_appender_t this_appender, char *event);
- void (*free_) (xbt_log_appender_t this_);
+ void (*do_append)(const s_xbt_log_appender_t* this_appender, const char* event);
+ void (*free_)(const s_xbt_log_appender_t* this_);
void *data;
};
struct xbt_log_layout_s {
- int (*do_layout) (xbt_log_layout_t l, xbt_log_event_t event, const char *fmt);
- void (*free_) (xbt_log_layout_t l);
+ int (*do_layout)(const s_xbt_log_layout_t* l, xbt_log_event_t event, const char* fmt);
+ void (*free_)(const s_xbt_log_layout_t* l);
void *data;
};
/* mallocator - recycle objects to avoid malloc() / free() */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
/* mallocator - recycle objects to avoid malloc() / free() */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
/* Ok we are good enough to try to get the info we need */
/* First get the start and the end address of the map */
- char* tok = strtok_r(lfields[0], "-", &saveptr);
+ const char* tok = strtok_r(lfields[0], "-", &saveptr);
if (tok == nullptr) {
std::fprintf(stderr,
"Start and end address of the map are not concatenated by a hyphen (-). Recovery impossible.\n");
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* Free a block of memory allocated by `mmalloc'. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
behavior. It should also still be possible to build the library
as a standard library with multiple objects. */
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* Initialization for access to a mmap'd malloc managed region. */
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* Memory allocator `malloc'. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
/** Initialize heapinfo about the heapinfo pages :)
*
*/
-static void initialize_heapinfo_heapinfo(xbt_mheap_t mdp)
+static void initialize_heapinfo_heapinfo(const s_xbt_mheap_t* mdp)
{
// Update heapinfo about the heapinfo pages (!):
xbt_assert((uintptr_t) mdp->heapinfo % BLOCKSIZE == 0);
/* Support for an sbrk-like function that uses mmap. */
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
return (result);
}
-void *__mmalloc_remap_core(xbt_mheap_t mdp)
+void* __mmalloc_remap_core(const s_xbt_mheap_t* mdp)
{
/* FIXME: Quick hack, needs error checking and other attention. */
/* Declarations for `mmalloc' and friends. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
/* Remap a mmalloc region that was previously mapped. */
-XBT_PUBLIC void* __mmalloc_remap_core(xbt_mheap_t mdp);
+XBT_PUBLIC void* __mmalloc_remap_core(const s_xbt_mheap_t* mdp);
XBT_PUBLIC void* mmorecore(struct mdesc* mdp, ssize_t size);
/* Change the size of a block allocated by `mmalloc'. */
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2004-2019. The SimGrid Team.
+/* Copyright (c) 2004-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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. */
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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. */
-/* Copyright (c) 2005-2019. The SimGrid Team.
+/* Copyright (c) 2005-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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. */
/* file_appender - a dumb log appender which simply prints to a file */
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#include <cstdio>
#include <cstring>
-static void append_file(xbt_log_appender_t this_, char *str) {
+static void append_file(const s_xbt_log_appender_t* this_, const char* str)
+{
fputs(str, (FILE *) this_->data);
}
-static void free_(xbt_log_appender_t this_)
+static void free_(const s_xbt_log_appender_t* this_)
{
fclose(static_cast<FILE*>(this_->data));
}
}
}
-static void append2_file(xbt_log_appender_t this_, char *str) {
- xbt_log_append2_file_t d=(xbt_log_append2_file_t) this_->data;
- xbt_assert(d->file);
- if(ftell(d->file)>=d->limit) {
- open_append2_file(d);
- }
- fputs(str, d->file);
- if(d->count<0){
- fputs(APPEND2_END_TOKEN,d->file);
- fseek(d->file,-((signed long)strlen(APPEND2_END_TOKEN)),SEEK_CUR);
- }
+static void append2_file(const s_xbt_log_appender_t* this_, const char* str)
+{
+ xbt_log_append2_file_t d = (xbt_log_append2_file_t)this_->data;
+ xbt_assert(d->file);
+ if (ftell(d->file) >= d->limit) {
+ open_append2_file(d);
+ }
+ fputs(str, d->file);
+ if (d->count < 0) {
+ fputs(APPEND2_END_TOKEN, d->file);
+ fseek(d->file, -((signed long)strlen(APPEND2_END_TOKEN)), SEEK_CUR);
+ }
}
-static void free_append2_(xbt_log_appender_t this_)
+static void free_append2_(const s_xbt_log_appender_t* this_)
{
xbt_log_append2_file_t data = static_cast<xbt_log_append2_file_t>(this_->data);
if (data->file)
/* layout_simple - a dumb log layout */
-/* Copyright (c) 2007-2019. The SimGrid Team. */
+/* Copyright (c) 2007-2020. The SimGrid Team. */
/* 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. */
#define show_int(data) show_it((data), "d")
#define show_double(data) show_it((data), "f")
-static int xbt_log_layout_format_doit(xbt_log_layout_t l, xbt_log_event_t ev, const char* msg_fmt)
+static int xbt_log_layout_format_doit(const s_xbt_log_layout_t* l, xbt_log_event_t ev, const char* msg_fmt)
{
char *p = ev->buffer;
int rem_size = ev->buffer_size;
return 1;
}
-static void xbt_log_layout_format_free(xbt_log_layout_t lay)
+static void xbt_log_layout_format_free(const s_xbt_log_layout_t* lay)
{
xbt_free(lay->data);
}
/* layout_simple - a dumb log layout */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
p += (len); \
} while (0)
-static int xbt_log_layout_simple_doit(xbt_log_layout_t, xbt_log_event_t ev, const char* fmt)
+static int xbt_log_layout_simple_doit(const s_xbt_log_layout_t*, xbt_log_event_t ev, const char* fmt)
{
char *p = ev->buffer;
int rem_size = ev->buffer_size;
/* module handling */
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
+#include <string>
+#include <vector>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(module, xbt, "module handling");
XBT_LOG_NEW_CATEGORY(smpi, "All SMPI categories"); /* lives here even if that's a bit odd to solve linking issues: this is used in xbt_log_file_appender to detect whether SMPI is used (and thus whether we should unbench the writing to disk) */
-char *xbt_binary_name = NULL; /* Name of the system process containing us (mandatory to retrieve neat backtraces) */
-xbt_dynar_t xbt_cmdline = NULL; /* all we got in argv */
+namespace simgrid {
+namespace xbt {
+std::string binary_name; /* Name of the system process containing us (mandatory to retrieve neat backtraces) */
+std::vector<std::string> cmdline; /* all we got in argv */
+} // namespace xbt
+} // namespace simgrid
int xbt_initialized = 0;
simgrid::config::Flag<bool> cfg_dbg_clean_atexit{
#ifndef __GNUC__
/* Should not be necessary but for some reason, DllMain is called twice at attachment and at detachment.*/
-static int xbt_dll_process_is_attached = 0;
-
/* see also http://msdn.microsoft.com/en-us/library/ms682583%28VS.85%29.aspx */
/* and http://www.microsoft.com/whdc/driver/kernel/DLL_bestprac.mspx */
static BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
- if (fdwReason == DLL_PROCESS_ATTACH
- && xbt_dll_process_is_attached == 0) {
- xbt_dll_process_is_attached = 1;
+ static bool xbt_dll_process_is_attached = false;
+ if (fdwReason == DLL_PROCESS_ATTACH && not xbt_dll_process_is_attached) {
+ xbt_dll_process_is_attached = true;
xbt_preinit();
- } else if (fdwReason == DLL_PROCESS_DETACH
- && xbt_dll_process_is_attached == 1) {
- xbt_dll_process_is_attached = 0;
+ } else if (fdwReason == DLL_PROCESS_DETACH && xbt_dll_process_is_attached) {
+ xbt_dll_process_is_attached = false;
}
return 1;
}
return;
xbt_initialized--;
xbt_dict_postexit();
- xbt_dynar_free(&xbt_cmdline);
xbt_log_postexit();
#if SIMGRID_HAVE_MC
mmalloc_postexit();
simgrid::xbt::install_exception_handler();
- xbt_binary_name = argv[0];
- xbt_cmdline = xbt_dynar_new(sizeof(char*), NULL);
+ simgrid::xbt::binary_name = argv[0];
for (int i = 0; i < *argc; i++)
- xbt_dynar_push(xbt_cmdline,&(argv[i]));
+ simgrid::xbt::cmdline.push_back(argv[i]);
xbt_log_init(argc, argv);
}
/* xbt_os_file.cpp -- portable interface to file-related functions */
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
{
#if HAVE_UNISTD_H
char buffer[2048];
- char* ret = getcwd(buffer, 2048);
+ const char* ret = getcwd(buffer, 2048);
xbt_assert(ret == buffer, "Error during getcwd: %s", strerror(errno));
path_ = std::string(buffer);
#else
std::string simgrid::xbt::Path::get_dir_name()
{
std::string p(path_);
- char *res = dirname(&p[0]);
+ const char* res = dirname(&p[0]);
return std::string(res, strlen(res));
}
std::string simgrid::xbt::Path::get_base_name()
{
std::string p(path_);
- char *res = basename(&p[0]);
+ const char* res = basename(&p[0]);
return std::string(res, strlen(res));
}
/* Classical synchro schema, implemented on top of SimGrid */
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
void xbt_cond_signal(xbt_cond_t cond)
{
- cond->cond_.notify_one();
+ cond->get_iface()->notify_one();
}
void xbt_cond_broadcast(xbt_cond_t cond)
{
- cond->cond_.notify_all();
+ cond->get_iface()->notify_all();
}
void xbt_cond_destroy(xbt_cond_t cond)
/* xbt_os_time.c -- portable interface to time-related functions */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
free(timer);
}
-double xbt_os_timer_elapsed(xbt_os_timer_t timer)
+double xbt_os_timer_elapsed(const_xbt_os_timer_t timer)
{
#if HAVE_POSIX_GETTIME && defined (_POSIX_THREAD_CPUTIME)
return ((double) timer->stop.tv_sec) - ((double) timer->start.tv_sec) + ((double) timer->elapse.tv_sec ) +
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
delete evt;
}
if (action_queues.find(actor_name_string) != action_queues.end()) {
- std::queue<ReplayAction*>* myqueue = action_queues.at(actor_name_string);
- delete myqueue;
+ delete action_queues.at(actor_name_string);
action_queues.erase(actor_name_string);
}
} else { // Should have got my trace file in argument
/* xbt_str.cpp - various helping functions to deal with strings */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
/* xbt_str.cpp - various helping functions to deal with strings */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
/* virtualization layer for XBT */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
int xbt_getpid()
{
- smx_actor_t self = SIMIX_process_self();
+ const simgrid::kernel::actor::ActorImpl* self = SIMIX_process_self();
return self == nullptr ? 0 : self->get_pid();
}
/* xbt_modinter - How to init/exit the XBT modules */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
static simgrid::mc::RemoteClient* process;
-static
-uintptr_t eval_binary_operation(
- simgrid::dwarf::ExpressionContext& state, int op, uintptr_t a, uintptr_t b) {
-
+static uintptr_t eval_binary_operation(simgrid::dwarf::ExpressionContext const& state, int op, uintptr_t a, uintptr_t b)
+{
Dwarf_Op ops[15];
ops[0].atom = DW_OP_const8u;
ops[0].number = a;
return stack.top();
}
-static
-void basic_test(simgrid::dwarf::ExpressionContext const& state) {
+static void basic_test(simgrid::dwarf::ExpressionContext const& state)
+{
try {
+ Dwarf_Op ops[60];
- Dwarf_Op ops[60];
+ uintptr_t a = rnd_engine();
+ uintptr_t b = rnd_engine();
- uintptr_t a = rnd_engine();
- uintptr_t b = rnd_engine();
+ simgrid::dwarf::ExpressionStack stack;
- simgrid::dwarf::ExpressionStack stack;
+ bool caught_ex = false;
+ try {
+ ops[0].atom = DW_OP_drop;
+ simgrid::dwarf::execute(ops, 1, state, stack);
+ } catch (const simgrid::dwarf::evaluation_error&) {
+ caught_ex = true;
+ }
+ if (not caught_ex)
+ fprintf(stderr, "Exception expected");
- bool caught_ex = false;
- try {
- ops[0].atom = DW_OP_drop;
+ ops[0].atom = DW_OP_lit21;
simgrid::dwarf::execute(ops, 1, state, stack);
- } catch (const simgrid::dwarf::evaluation_error&) {
- caught_ex = true;
- }
- if (not caught_ex)
- fprintf(stderr, "Exception expected");
-
- ops[0].atom = DW_OP_lit21;
- simgrid::dwarf::execute(ops, 1, state, stack);
- assert(stack.size() == 1);
- assert(stack.top() == 21);
-
- ops[0].atom = DW_OP_const8u;
- ops[0].number = a;
- simgrid::dwarf::execute(ops, 1, state, stack);
- assert(stack.size() == 2);
- assert(stack.top() == a);
-
- ops[0].atom = DW_OP_drop;
- ops[1].atom = DW_OP_drop;
- simgrid::dwarf::execute(ops, 2, state, stack);
- assert(stack.empty());
-
- stack.clear();
- ops[0].atom = DW_OP_lit21;
- ops[1].atom = DW_OP_plus_uconst;
- ops[1].number = a;
- simgrid::dwarf::execute(ops, 2, state, stack);
- assert(stack.size() == 1);
- assert(stack.top() == a + 21);
-
- stack.clear();
- ops[0].atom = DW_OP_const8u;
- ops[0].number = a;
- ops[1].atom = DW_OP_dup;
- ops[2].atom = DW_OP_plus;
- simgrid::dwarf::execute(ops, 3, state, stack);
- assert(stack.size() == 1);
- assert(stack.top() == a + a);
+ assert(stack.size() == 1);
+ assert(stack.top() == 21);
- stack.clear();
- ops[0].atom = DW_OP_const8u;
- ops[0].number = a;
- ops[1].atom = DW_OP_const8u;
- ops[1].number = b;
- ops[2].atom = DW_OP_over;
- simgrid::dwarf::execute(ops, 3, state, stack);
- assert(stack.size() == 3);
- assert(stack.top() == a);
- assert(stack.top(1) == b);
- assert(stack.top(2) == a);
-
- stack.clear();
- ops[0].atom = DW_OP_const8u;
- ops[0].number = a;
- ops[1].atom = DW_OP_const8u;
- ops[1].number = b;
- ops[2].atom = DW_OP_swap;
- simgrid::dwarf::execute(ops, 3, state, stack);
- assert(stack.size() == 2);
- assert(stack.top() == a);
- assert(stack.top(1) == b);
+ ops[0].atom = DW_OP_const8u;
+ ops[0].number = a;
+ simgrid::dwarf::execute(ops, 1, state, stack);
+ assert(stack.size() == 2);
+ assert(stack.top() == a);
+ ops[0].atom = DW_OP_drop;
+ ops[1].atom = DW_OP_drop;
+ simgrid::dwarf::execute(ops, 2, state, stack);
+ assert(stack.empty());
+
+ stack.clear();
+ ops[0].atom = DW_OP_lit21;
+ ops[1].atom = DW_OP_plus_uconst;
+ ops[1].number = a;
+ simgrid::dwarf::execute(ops, 2, state, stack);
+ assert(stack.size() == 1);
+ assert(stack.top() == a + 21);
+
+ stack.clear();
+ ops[0].atom = DW_OP_const8u;
+ ops[0].number = a;
+ ops[1].atom = DW_OP_dup;
+ ops[2].atom = DW_OP_plus;
+ simgrid::dwarf::execute(ops, 3, state, stack);
+ assert(stack.size() == 1);
+ assert(stack.top() == a + a);
+
+ stack.clear();
+ ops[0].atom = DW_OP_const8u;
+ ops[0].number = a;
+ ops[1].atom = DW_OP_const8u;
+ ops[1].number = b;
+ ops[2].atom = DW_OP_over;
+ simgrid::dwarf::execute(ops, 3, state, stack);
+ assert(stack.size() == 3);
+ assert(stack.top() == a);
+ assert(stack.top(1) == b);
+ assert(stack.top(2) == a);
+
+ stack.clear();
+ ops[0].atom = DW_OP_const8u;
+ ops[0].number = a;
+ ops[1].atom = DW_OP_const8u;
+ ops[1].number = b;
+ ops[2].atom = DW_OP_swap;
+ simgrid::dwarf::execute(ops, 3, state, stack);
+ assert(stack.size() == 2);
+ assert(stack.top() == a);
+ assert(stack.top(1) == b);
} catch (const simgrid::dwarf::evaluation_error&) {
fprintf(stderr,"Expression evaluation error");
}
}
-static
-void test_deref(simgrid::dwarf::ExpressionContext const& state) {
+static void test_deref(simgrid::dwarf::ExpressionContext const& state)
+{
try {
+ uintptr_t foo = 42;
- uintptr_t foo = 42;
+ Dwarf_Op ops[60];
+ ops[0].atom = DW_OP_const8u;
+ ops[0].number = (uintptr_t)&foo;
+ ops[1].atom = DW_OP_deref;
- Dwarf_Op ops[60];
- ops[0].atom = DW_OP_const8u;
- ops[0].number = (uintptr_t) &foo;
- ops[1].atom = DW_OP_deref;
-
- simgrid::dwarf::ExpressionStack stack;
-
- simgrid::dwarf::execute(ops, 2, state, stack);
- assert(stack.size() == 1);
- assert(stack.top() == foo);
+ simgrid::dwarf::ExpressionStack stack;
+ simgrid::dwarf::execute(ops, 2, state, stack);
+ assert(stack.size() == 1);
+ assert(stack.top() == foo);
} catch (const simgrid::dwarf::evaluation_error&) {
fprintf(stderr,"Expression evaluation error");
}
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
return nullptr;
}
-static void test_local_variable(simgrid::mc::ObjectInformation* info, const char* function, const char* variable, void* address, unw_cursor_t* cursor) {
+static void test_local_variable(simgrid::mc::ObjectInformation* info, const char* function, const char* variable,
+ const void* address, unw_cursor_t* cursor)
+{
simgrid::mc::Frame* subprogram = find_function_by_name(info, function);
assert(subprogram);
// TODO, Lookup frame by IP and test against name instead
- simgrid::mc::Variable* var = find_local_variable(subprogram, variable);
+ const simgrid::mc::Variable* var = find_local_variable(subprogram, variable);
assert(var);
void* frame_base = subprogram->frame_base(*cursor);
xbt_assert(location.address() == address, "Bad resolution of local variable %s of %s", variable, function);
}
-static const simgrid::mc::Variable* test_global_variable(simgrid::mc::RemoteClient& process,
- simgrid::mc::ObjectInformation* info, const char* name,
+static const simgrid::mc::Variable* test_global_variable(const simgrid::mc::RemoteClient& process,
+ const simgrid::mc::ObjectInformation* info, const char* name,
void* address, long byte_size)
{
const simgrid::mc::Variable* variable = info->find_variable(name);
auto i = process.binary_info->types.find(variable->type_id);
xbt_assert(i != process.binary_info->types.end(), "Missing type for %s", name);
- simgrid::mc::Type* type = &i->second;
+ const simgrid::mc::Type* type = &i->second;
xbt_assert(type->byte_size == byte_size, "Byte size mismatch for %s", name);
return variable;
}
int i;
};
-static void test_type_by_name(simgrid::mc::RemoteClient& process, s_foo /*my_foo*/)
+static void test_type_by_name(const 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());
}
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. 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. */
static int sender(int argc, char *argv[])
{
xbt_assert(argc == 2);
- char* message_name = argv[1];
+ const char* message_name = argv[1];
#ifndef DISABLE_THE_MUTEX
sg_mutex_lock(mutex);
#endif
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
return count;
}
-int peer_has_not_piece(peer_t peer, unsigned int piece)
+int peer_has_not_piece(const s_peer_t* peer, unsigned int piece)
{
return !(peer->bitfield & 1U << piece);
}
/** Check that a piece is not currently being download by the peer. */
-int peer_is_not_downloading_piece(peer_t peer, unsigned int piece)
+int peer_is_not_downloading_piece(const s_peer_t* peer, unsigned int piece)
{
return !(peer->current_pieces & 1U << piece);
}
/** @brief Retrieves the peer list from the tracker
* @param peer current peer data
*/
-int get_peers_data(peer_t peer)
+int get_peers_data(const s_peer_t* peer)
{
int success = 0;
double timeout = MSG_get_clock() + GET_PEERS_TIMEOUT;
return bitfield == (1U << FILE_PIECES) - 1U;
}
-int nb_interested_peers(peer_t peer)
+int nb_interested_peers(const s_peer_t* peer)
{
xbt_dict_cursor_t cursor = NULL;
char* key;
return nb;
}
-void update_active_peers_set(peer_t peer, connection_t remote_peer)
+void update_active_peers_set(const s_peer_t* peer, connection_t remote_peer)
{
if ((remote_peer->interested != 0) && (remote_peer->choked_upload == 0)) {
// add in the active peers set
* @param peer peer we want to update the list
* @param bitfield bitfield
*/
-void update_pieces_count_from_bitfield(peer_t peer, unsigned int bitfield)
+void update_pieces_count_from_bitfield(const s_peer_t* peer, unsigned int bitfield)
{
for (int i = 0; i < FILE_PIECES; i++) {
if (bitfield & (1U << i)) {
* @param remote_peer: information about the connection
* @return the piece to download if possible. -1 otherwise
*/
-int select_piece_to_download(peer_t peer, connection_t remote_peer)
+int select_piece_to_download(const s_peer_t* peer, const s_connection_t* remote_peer)
{
int piece = partially_downloaded_piece(peer, remote_peer);
// strict priority policy
/** @brief Update "interested" state of peers: send "not interested" to peers that don't have any more pieces we want.
* @param peer our peer data
*/
-void update_interested_after_receive(peer_t peer)
+void update_interested_after_receive(const s_peer_t* peer)
{
char* key;
xbt_dict_cursor_t cursor;
}
/** Returns if a peer has completed the download of a piece */
-int piece_complete(peer_t peer, int index)
+int piece_complete(const s_peer_t* peer, int index)
{
for (int i = 0; i < PIECES_BLOCKS; i++) {
if (!(peer->bitfield_blocks & 1ULL << (index * PIECES_BLOCKS + i))) {
}
/** Returns the first block that a peer doesn't have in a piece. If the peer has all blocks of the piece, returns -1. */
-int get_first_block(peer_t peer, int piece)
+int get_first_block(const s_peer_t* peer, int piece)
{
for (int i = 0; i < PIECES_BLOCKS; i++) {
if (!(peer->bitfield_blocks & 1ULL << (piece * PIECES_BLOCKS + i))) {
}
/** Indicates if the remote peer has a piece not stored by the local peer */
-int is_interested(peer_t peer, connection_t remote_peer)
+int is_interested(const s_peer_t* peer, const s_connection_t* remote_peer)
{
return remote_peer->bitfield & (peer->bitfield ^ ((1 << FILE_PIECES) - 1));
}
/** Indicates if the remote peer has a piece not stored by the local peer nor requested by the local peer */
-int is_interested_and_free(peer_t peer, connection_t remote_peer)
+int is_interested_and_free(const s_peer_t* peer, const s_connection_t* remote_peer)
{
for (int i = 0; i < FILE_PIECES; i++) {
if (peer_has_not_piece(peer, i) && connection_has_piece(remote_peer, i) && peer_is_not_downloading_piece(peer, i)) {
}
/** Returns a piece that is partially downloaded and stored by the remote peer if any -1 otherwise. */
-int partially_downloaded_piece(peer_t peer, connection_t remote_peer)
+int partially_downloaded_piece(const s_peer_t* peer, const s_connection_t* remote_peer)
{
for (int i = 0; i < FILE_PIECES; i++) {
if (peer_has_not_piece(peer, i) && connection_has_piece(remote_peer, i) && peer_is_not_downloading_piece(peer, i) &&
* @param peer peer
* @param remote_peer peer data to the peer we want to send the request
*/
-void send_request_to_peer(peer_t peer, connection_t remote_peer, int piece)
+void send_request_to_peer(const s_peer_t* peer, connection_t remote_peer, int piece)
{
remote_peer->current_piece = piece;
xbt_assert(connection_has_piece(remote_peer, piece));
* @param peer peer data
* @param mailbox destination mailbox
*/
-void send_interested(peer_t peer, const char* mailbox)
+void send_interested(const s_peer_t* peer, const char* mailbox)
{
msg_task_t task = task_message_new(MESSAGE_INTERESTED, peer->hostname, peer->mailbox, peer->id,
task_message_size(MESSAGE_INTERESTED));
* @param peer peer data
* @param mailbox destination mailbox
*/
-void send_notinterested(peer_t peer, const char* mailbox)
+void send_notinterested(const s_peer_t* peer, const char* mailbox)
{
msg_task_t task = task_message_new(MESSAGE_NOTINTERESTED, peer->hostname, peer->mailbox, peer->id,
task_message_size(MESSAGE_NOTINTERESTED));
/** @brief Send a handshake message to all the peers the peer has.
* @param peer peer data
*/
-void send_handshake_all(peer_t peer)
+void send_handshake_all(const s_peer_t* peer)
{
connection_t remote_peer;
xbt_dict_cursor_t cursor = NULL;
* @param peer peer data
* @param mailbox mailbox where to we send the message
*/
-void send_handshake(peer_t peer, const char* mailbox)
+void send_handshake(const s_peer_t* peer, const char* mailbox)
{
XBT_DEBUG("Sending a HANDSHAKE to %s", mailbox);
msg_task_t task = task_message_new(MESSAGE_HANDSHAKE, peer->hostname, peer->mailbox, peer->id,
}
/** Send a "choked" message to a peer. */
-void send_choked(peer_t peer, const char* mailbox)
+void send_choked(const s_peer_t* peer, const char* mailbox)
{
XBT_DEBUG("Sending a CHOKE to %s", mailbox);
msg_task_t task =
}
/** Send a "unchoked" message to a peer */
-void send_unchoked(peer_t peer, const char* mailbox)
+void send_unchoked(const s_peer_t* peer, const char* mailbox)
{
XBT_DEBUG("Sending a UNCHOKE to %s", mailbox);
msg_task_t task =
}
/** Send a "HAVE" message to all peers we are connected to */
-void send_have(peer_t peer, int piece)
+void send_have(const s_peer_t* peer, int piece)
{
XBT_DEBUG("Sending HAVE message to all my peers");
connection_t remote_peer;
/** @brief Send a bitfield message to all the peers the peer has.
* @param peer peer data
*/
-void send_bitfield(peer_t peer, const char* mailbox)
+void send_bitfield(const s_peer_t* peer, const char* mailbox)
{
XBT_DEBUG("Sending a BITFIELD to %s", mailbox);
msg_task_t task = task_message_bitfield_new(peer->hostname, peer->mailbox, peer->id, peer->bitfield, FILE_PIECES);
}
/** Send a "request" message to a pair, containing a request for a piece */
-void send_request(peer_t peer, const char* mailbox, int piece, int block_index, int block_length)
+void send_request(const s_peer_t* peer, const char* mailbox, int piece, int block_index, int block_length)
{
XBT_DEBUG("Sending a REQUEST to %s for piece %d (%d,%d)", mailbox, piece, block_index, block_length);
msg_task_t task = task_message_request_new(peer->hostname, peer->mailbox, peer->id, piece, block_index, block_length);
}
/** Send a "piece" message to a pair, containing a piece of the file */
-void send_piece(peer_t peer, const char* mailbox, int piece, int block_index, int block_length)
+void send_piece(const s_peer_t* peer, const char* mailbox, int piece, int block_index, int block_length)
{
XBT_DEBUG("Sending the PIECE %d (%d,%d) to %s", piece, block_index, block_length, mailbox);
xbt_assert(piece >= 0, "Tried to send a piece that doesn't exist.");
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
int peer(int argc, char* argv[]);
void get_status(char** status, unsigned int bitfield);
-int get_peers_data(peer_t peer);
+int get_peers_data(const s_peer_t* peer);
void leech_loop(peer_t peer, double deadline);
void seed_loop(peer_t peer, double deadline);
void handle_message(peer_t peer, msg_task_t task);
-void update_pieces_count_from_bitfield(peer_t peer, unsigned int bitfield);
+void update_pieces_count_from_bitfield(const s_peer_t* peer, unsigned int bitfield);
void update_choked_peers(peer_t peer);
-void update_interested_after_receive(peer_t peer);
+void update_interested_after_receive(const s_peer_t* peer);
void update_bitfield_blocks(peer_t peer, int index, int block_index, int block_length);
-int piece_complete(peer_t peer, int index);
-int get_first_block(peer_t peer, int piece);
+int piece_complete(const s_peer_t* peer, int index);
+int get_first_block(const s_peer_t* peer, int piece);
-int peer_has_not_piece(peer_t peer, unsigned int piece);
-int peer_is_not_downloading_piece(peer_t peer, unsigned int piece);
+int peer_has_not_piece(const s_peer_t* peer, unsigned int piece);
+int peer_is_not_downloading_piece(const s_peer_t* peer, unsigned int piece);
int count_pieces(unsigned int bitfield);
-int nb_interested_peers(peer_t peer);
-int is_interested(peer_t peer, connection_t remote_peer);
-int is_interested_and_free(peer_t peer, connection_t remote_peer);
-int partially_downloaded_piece(peer_t peer, connection_t remote_peer);
+int nb_interested_peers(const s_peer_t* peer);
+int is_interested(const s_peer_t* peer, const s_connection_t* remote_peer);
+int is_interested_and_free(const s_peer_t* peer, const s_connection_t* remote_peer);
+int partially_downloaded_piece(const s_peer_t* peer, const s_connection_t* remote_peer);
void request_new_piece_to_peer(peer_t peer, connection_t remote_peer);
-void send_request_to_peer(peer_t peer, connection_t remote_peer, int piece);
+void send_request_to_peer(const s_peer_t* peer, connection_t remote_peer, int piece);
void remove_current_piece(peer_t peer, connection_t remote_peer, unsigned int current_piece);
-void update_active_peers_set(peer_t peer, connection_t remote_peer);
-int select_piece_to_download(peer_t peer, connection_t remote_peer);
+void update_active_peers_set(const s_peer_t* peer, connection_t remote_peer);
+int select_piece_to_download(const s_peer_t* peer, const s_connection_t* remote_peer);
-void send_handshake_all(peer_t peer);
+void send_handshake_all(const s_peer_t* peer);
-void send_interested(peer_t peer, const char* mailbox);
+void send_interested(const s_peer_t* peer, const char* mailbox);
-void send_notinterested(peer_t peer, const char* mailbox);
-void send_handshake(peer_t peer, const char* mailbox);
-void send_bitfield(peer_t peer, const char* mailbox);
-void send_choked(peer_t peer, const char* mailbox);
-void send_unchoked(peer_t peer, const char* mailbox);
-void send_have(peer_t peer, int piece);
+void send_notinterested(const s_peer_t* peer, const char* mailbox);
+void send_handshake(const s_peer_t* peer, const char* mailbox);
+void send_bitfield(const s_peer_t* peer, const char* mailbox);
+void send_choked(const s_peer_t* peer, const char* mailbox);
+void send_unchoked(const s_peer_t* peer, const char* mailbox);
+void send_have(const s_peer_t* peer, int piece);
-void send_request(peer_t peer, const char* mailbox, int piece, int block_index, int block_length);
-void send_piece(peer_t peer, const char* mailbox, int piece, int block_index, int block_length);
+void send_request(const s_peer_t* peer, const char* mailbox, int piece, int block_index, int block_length);
+void send_piece(const s_peer_t* peer, const char* mailbox, int piece, int block_index, int block_length);
#endif /* BITTORRENT_PEER_H */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
xbt_free(co);
}
-int connection_has_piece(connection_t connection, unsigned int piece)
+int connection_has_piece(const s_connection_t* connection, unsigned int piece)
{
return (connection->bitfield & 1U << piece);
}
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
void connection_add_speed_value(connection_t connection, double speed);
/** Frees a connection object */
void connection_free(void* data);
-int connection_has_piece(connection_t connection, unsigned int piece);
+int connection_has_piece(const s_connection_t* connection, unsigned int piece);
#endif /* BITTORRENT_CONNECTION_H_ */
#!/usr/bin/env python
-# Copyright (c) 2012-2019. The SimGrid Team.
+# Copyright (c) 2012-2020. The SimGrid Team.
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
// Retrieve the data sent by the peer.
tracker_task_data_t data = MSG_task_get_data(task_received);
// Add the peer to our peer list.
- if (is_in_list(peers_list, data->peer_id) == 0) {
+ if (!is_in_list(peers_list, data->peer_id)) {
xbt_dynar_push_as(peers_list, int, data->peer_id);
}
// Sending peers to the peer
* @param peers dynar containing the peers
* @param id identifier of the peer to test
*/
-int is_in_list(xbt_dynar_t peers, int id)
+int is_in_list(const_xbt_dynar_t peers, int id)
{
return xbt_dynar_member(peers, &id);
}
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. 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 BITTORRENT_TRACKER_H_
-#define BITTORRENT_TRACKER_H_
+#ifndef BITTORRENT_TRACKER_H
+#define BITTORRENT_TRACKER_H
#include "bittorrent.h"
#include <xbt/dynar.h>
/**
int downloaded, int left);
void tracker_task_data_free(tracker_task_data_t task);
-int is_in_list(xbt_dynar_t peers, int id);
+int is_in_list(const_xbt_dynar_t peers, int id);
#endif /* BITTORRENT_TRACKER_H */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
if (it->current >= it->length) {
return NULL;
} else {
- int* next = xbt_dynar_get_ptr(it->indices_list, it->current);
+ const int* next = xbt_dynar_get_ptr(it->indices_list, it->current);
it->current++;
return xbt_dynar_get_ptr(it->list, *next);
}
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_peer, "Messages specific for the peer");
-void peer_init_chain(peer_t peer, message_t msg)
+void peer_init_chain(peer_t peer, const s_message_t* msg)
{
peer->prev = msg->prev_hostname;
peer->next = msg->next_hostname;
peer->init = 1;
}
-static void peer_forward_msg(peer_t peer, message_t msg)
+static void peer_forward_msg(const s_peer_t* peer, const s_message_t* msg)
{
msg_task_t task = task_message_data_new(NULL, msg->data_length);
XBT_DEBUG("Sending (isend) from %s into mailbox %s", peer->me, peer->next);
int peer_execute_task(peer_t peer, msg_task_t task)
{
int done = 0;
- message_t msg = MSG_task_get_data(task);
+ const s_message_t* msg = MSG_task_get_data(task);
XBT_DEBUG("Peer %s got message of type %u\n", peer->me, msg->type);
if (msg->type == MESSAGE_BUILD_CHAIN)
}
}
-void peer_shutdown(peer_t p)
+void peer_shutdown(const s_peer_t* p)
{
unsigned int size = xbt_dynar_length(p->pending_sends);
unsigned int idx;
xbt_free(p);
}
-void peer_print_stats(peer_t p, float elapsed_time)
+void peer_print_stats(const s_peer_t* p, float elapsed_time)
{
XBT_INFO("### %f %llu bytes (Avg %f MB/s); copy finished (simulated).", elapsed_time, p->bytes,
p->bytes / 1024.0 / 1024.0 / elapsed_time);
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* Peer: helper functions */
msg_error_t peer_wait_for_message(peer_t peer);
int peer_execute_task(peer_t peer, msg_task_t task);
-void peer_init_chain(peer_t peer, message_t msg);
+void peer_init_chain(peer_t peer, const s_message_t* msg);
void peer_delete(peer_t p);
-void peer_shutdown(peer_t p);
+void peer_shutdown(const s_peer_t* p);
void peer_init(peer_t p, int argc, char* argv[]);
-void peer_print_stats(peer_t p, float elapsed_time);
+void peer_print_stats(const s_peer_t* p, float elapsed_time);
int peer(int argc, char* argv[]);
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
static void vm_migrate(msg_vm_t vm, msg_host_t dst_pm)
{
- msg_host_t src_pm = MSG_vm_get_pm(vm);
+ const_sg_host_t src_pm = MSG_vm_get_pm(vm);
double mig_sta = MSG_get_clock();
MSG_vm_migrate(vm, dst_pm);
double mig_end = MSG_get_clock();
static int migration_worker_main(int argc, char* argv[])
{
xbt_assert(argc == 3);
- char* vm_name = argv[1];
- char* dst_pm_name = argv[2];
+ const char* vm_name = argv[1];
+ const char* dst_pm_name = argv[2];
msg_vm_t vm = (msg_vm_t)MSG_host_by_name(vm_name);
msg_host_t dst_pm = MSG_host_by_name(dst_pm_name);
return 0;
}
-static void vm_migrate_async(msg_vm_t vm, msg_host_t dst_pm)
+static void vm_migrate_async(const_sg_vm_t vm, const_sg_host_t dst_pm)
{
const char* vm_name = MSG_vm_get_name(vm);
const char* dst_pm_name = MSG_host_get_name(dst_pm);
{
msg_host_t pm0 = MSG_host_by_name("Fafard");
msg_host_t pm1 = MSG_host_by_name("Tremblay");
- msg_host_t pm2 = MSG_host_by_name("Bourassa");
+ const_sg_host_t pm2 = MSG_host_by_name("Bourassa");
msg_vm_t vm0 = MSG_vm_create_core(pm0, "VM0");
MSG_vm_set_ramsize(vm0, 1e9); // 1Gbytes
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
sg_size_t write = MSG_file_write(file, MSG_file_get_size(file) * 1024);
XBT_INFO("Have written %llu bytes to '%s'.", write, filename);
- msg_host_t src = MSG_host_self();
+ const_sg_host_t src = MSG_host_self();
msg_host_t dest = MSG_host_by_name(argv[3]);
if (xbt_str_parse_int(argv[5], "Argument 5 (move or copy) must be an int, not '%s'")) {
XBT_INFO("Move '%s' (of size %llu) from '%s' to '%s'", filename, MSG_file_get_size(file), MSG_host_get_name(src),
int main(int argc, char** argv)
{
unsigned int cur;
- msg_storage_t st;
+ const_sg_storage_t st;
MSG_init(&argc, argv);
MSG_storage_file_system_init();
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
msg_file_t file = NULL;
sg_size_t read;
sg_size_t write;
- msg_storage_t st;
const char* st_name;
switch (MSG_process_self_PID()) {
const char* filename = MSG_file_get_name(file);
XBT_INFO("\tOpen file '%s'", filename);
- st = MSG_storage_get_by_name(st_name);
+ const_sg_storage_t st = MSG_storage_get_by_name(st_name);
XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu", filename, MSG_storage_get_used_size(st),
MSG_storage_get_size(st));
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
static int bob(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
{
/* this host also tests the properties of the AS*/
- msg_netzone_t root = MSG_zone_get_root();
+ const_sg_netzone_t root = MSG_zone_get_root();
XBT_INFO("== Print the properties of the AS");
XBT_INFO(" Process property: filename -> %s", MSG_zone_get_property_value(root, "filename"));
XBT_INFO(" Process property: date -> %s", MSG_zone_get_property_value(root, "date"));
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
controlled_process = MSG_process_self(); /* - Get controlled at checkpoint */
MSG_barrier_wait(barrier);
MSG_process_suspend(MSG_process_self());
- msg_host_t h = MSG_process_get_host(MSG_process_self());
+ const_sg_host_t h = MSG_process_get_host(MSG_process_self());
XBT_INFO("I've been moved on this new host: %s", MSG_host_get_name(h));
XBT_INFO("Uh, nothing to do here. Stopping now");
return 0;
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
static int tester(int, char**)
{
msg_task_t task = MSG_task_create("name", 0, 10, NULL);
- msg_comm_t comm = MSG_task_isend(task, "mailbox");
+ const_msg_comm_t comm = MSG_task_isend(task, "mailbox");
XBT_INFO("MSG_task_listen_from returns() %d (should return my pid, which is %d)", MSG_task_listen_from("mailbox"),
MSG_process_get_PID(MSG_process_self()));
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
static void vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm)
{
- simgrid::s4u::Host* src_pm = vm->get_pm();
+ const simgrid::s4u::Host* src_pm = vm->get_pm();
double mig_sta = simgrid::s4u::Engine::get_clock();
sg_vm_migrate(vm, dst_pm);
double mig_end = simgrid::s4u::Engine::get_clock();
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
default:
xbt_die("Unknown receiver spec for test %u: '%c'", test, args[0][test - 1]);
}
- std::string* receivedStr = static_cast<std::string*>(received);
+ const std::string* receivedStr = static_cast<std::string*>(received);
xbt_assert(*receivedStr == mboxName);
delete receivedStr;
XBT_INFO("Test %u OK", test);
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
xbt_assert(mailbox->listen()); // True (1)
XBT_INFO("Task listen works on regular mailboxes");
- std::string* res = static_cast<std::string*>(mailbox->get());
+ const std::string* res = static_cast<std::string*>(mailbox->get());
xbt_assert(*res == "Some data", "Data received: %s", res->c_str());
XBT_INFO("Data successfully received from regular mailbox");
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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. */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
{
simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name("mailbox");
for (int i = 0; i < 3; i++) {
- int* pid = static_cast<int*>(mailbox->get());
+ const int* pid = static_cast<int*>(mailbox->get());
XBT_INFO("Killing process \"%d\".", *pid);
simgrid::s4u::Actor::by_pid(*pid)->kill();
}
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2020. 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. */
XBT_LOG_NEW_DEFAULT_CATEGORY(storage, "Messages specific for this simulation");
-static void display_disk_properties(simgrid::s4u::Disk* disk)
+static void display_disk_properties(const simgrid::s4u::Disk* disk)
{
const std::unordered_map<std::string, std::string>* props = disk->get_properties();
if (not props->empty()) {
simgrid::s4u::this_actor::sleep_for(.4);
}
-static void display_disk_content(simgrid::s4u::Disk* disk)
+static void display_disk_content(const simgrid::s4u::Disk* disk)
{
XBT_INFO("*** Dump a disk ***");
XBT_INFO("Print the content of the disk: %s", disk->get_cname());
- std::map<std::string, sg_size_t>* content = disk->extension<simgrid::s4u::FileSystemDiskExt>()->get_content();
+ const std::map<std::string, sg_size_t>* content = disk->extension<simgrid::s4u::FileSystemDiskExt>()->get_content();
if (not content->empty()) {
for (auto const& entry : *content)
XBT_INFO(" %s size: %llu bytes", entry.first.c_str(), entry.second);
{
XBT_INFO("*** GET/SET DATA for disk: %s ***", disk->get_cname());
- std::string* data = static_cast<std::string*>(disk->get_data());
+ const std::string* data = static_cast<std::string*>(disk->get_data());
XBT_INFO("Get data: '%s'", data ? data->c_str() : "No User Data");
disk->set_data(new std::string("Some data"));
data = static_cast<std::string*>(disk->get_data());
static void dump_platform_disks()
{
-
for (auto const& h : simgrid::s4u::Engine::get_instance()->get_all_hosts())
for (auto const& d : h->get_disks()) {
if (h == d->get_host())
}
}
-static void disk_info(simgrid::s4u::Host* host)
+static void disk_info(const simgrid::s4u::Host* host)
{
XBT_INFO("*** Disk info on %s ***", host->get_cname());
XBT_INFO("Server waiting for transfers ...");
while (1) {
- std::string* msg = static_cast<std::string*>(mailbox->get());
+ const std::string* msg = static_cast<std::string*>(mailbox->get());
if (*msg == "finalize") { // Shutdown ...
delete msg;
break;
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
static int name_compare_hosts(const void *n1, const void *n2)
{
- return strcmp(sg_host_get_name(*(sg_host_t *) n1), sg_host_get_name(*(sg_host_t *) n2));
+ return strcmp(sg_host_get_name(*(const sg_host_t*)n1), sg_host_get_name(*(const sg_host_t*)n2));
}
-static void scheduleDAX(xbt_dynar_t dax)
+static void scheduleDAX(const_xbt_dynar_t dax)
{
unsigned int cursor;
SD_task_t task;
-/* Copyright (c) 2008-2019. The SimGrid Team.
+/* Copyright (c) 2008-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(basic_link_test, sd, "SimDag test basic_link_test");
static int cmp_link(const void*a, const void*b) {
- return strcmp(sg_link_name(*(SD_link_t*)a) , sg_link_name(*(SD_link_t*)b));
+ return strcmp(sg_link_name(*(const SD_link_t*)a), sg_link_name(*(const SD_link_t*)b));
}
int main(int argc, char **argv)
{
- const char *user_data = "some user_data";
+ char user_data[] = "some user_data";
/* initialization of SD */
SD_init(&argc, argv);
for (int i=0; i < count; i++){
XBT_INFO("%s: latency = %.5f, bandwidth = %f", sg_link_name(links[i]),
sg_link_latency(links[i]), sg_link_bandwidth(links[i]));
- sg_link_data_set(links[i], (void*) user_data);
+ sg_link_data_set(links[i], user_data);
xbt_assert(!strcmp(user_data, (const char*)sg_link_data(links[i])),"User data was corrupted.");
}
xbt_free(links);
-/* Copyright (c) 2008-2019. The SimGrid Team.
+/* Copyright (c) 2008-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
sg_host_t *hosts = sg_host_list();
if (argc >= 3) {
if (!strcmp(argv[2], "ONE_LINK")) {
- sg_host_t h1 = hosts[0];
- sg_host_t h2 = hosts[1];
+ const_sg_host_t h1 = hosts[0];
+ const_sg_host_t h2 = hosts[1];
const char *name1 = sg_host_get_name(h1);
const char *name2 = sg_host_get_name(h2);
if (!strcmp(argv[2], "FULL_LINK")) {
int list_size = sg_host_count();
for (int i = 0; i < list_size; i++) {
- sg_host_t h1 = hosts[i];
+ const_sg_host_t h1 = hosts[i];
const char *name1 = sg_host_get_name(h1);
for (int j = 0; j < list_size; j++) {
- sg_host_t h2 = hosts[j];
+ const_sg_host_t h2 = hosts[j];
const char *name2 = sg_host_get_name(h2);
fprintf(stderr, "Route between %s and %s\n", name1, name2);
xbt_dynar_t route = xbt_dynar_new(sizeof(SD_link_t), NULL);
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* Latency tests */
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* Latency tests */
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* Latency tests */
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* Latency tests */
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* Latency tests */
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* Latency tests */
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* Latency tests */
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2008-2019. The SimGrid Team.
+/* Copyright (c) 2008-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
j = rand()%host_count;
} while(i==j);
- sg_host_t h1 = hosts[i];
- sg_host_t h2 = hosts[j];
+ const_sg_host_t h1 = hosts[i];
+ const_sg_host_t h2 = hosts[j];
printf("%d\tand\t%d\t\t",i,j);
xbt_dynar_t route = xbt_dynar_new(sizeof(SD_link_t), NULL);
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
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; });
+ [](const_sg_host_t a, const_sg_host_t b) { return strcmp(sg_host_get_name(a), sg_host_get_name(b)) < 0; });
for (unsigned int i = 0; i < totalHosts; i++) {
std::printf(" <host id=\"%s\" speed=\"%.0f\"", hosts[i]->get_cname(), sg_host_speed(hosts[i]));
unsigned int totalLinks = sg_link_count();
simgrid::s4u::Link** links = sg_link_list();
- std::sort(links, links + totalLinks,
- [](simgrid::s4u::Link* a, simgrid::s4u::Link* b) { return strcmp(sg_link_name(a), sg_link_name(b)) < 0; });
+ std::sort(links, links + totalLinks, [](const simgrid::s4u::Link* a, const simgrid::s4u::Link* b) {
+ return strcmp(sg_link_name(a), sg_link_name(b)) < 0;
+ });
for (unsigned int i = 0; i < totalLinks; i++) {
- simgrid::s4u::Link* link = links[i];
+ const simgrid::s4u::Link* link = links[i];
std::printf(" <link id=\"");
std::printf("%s\" bandwidth=\"%.0f\" latency=\"%.9f\"", link->get_cname(), link->get_bandwidth(), link->get_latency());
std::vector<simgrid::kernel::routing::NetPoint*> netpoints =
simgrid::s4u::Engine::get_instance()->get_all_netpoints();
std::sort(netpoints.begin(), netpoints.end(),
- [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) {
+ [](const simgrid::kernel::routing::NetPoint* a, const simgrid::kernel::routing::NetPoint* b) {
return a->get_name() < b->get_name();
});
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; });
+ [](const_sg_host_t a, const_sg_host_t b) { return strcmp(sg_host_get_name(a), sg_host_get_name(b)) < 0; });
std::vector<simgrid::kernel::routing::NetPoint*> netpoints =
simgrid::s4u::Engine::get_instance()->get_all_netpoints();
std::sort(netpoints.begin(), netpoints.end(),
- [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) {
+ [](const simgrid::kernel::routing::NetPoint* a, const simgrid::kernel::routing::NetPoint* b) {
return a->get_name() < b->get_name();
});
for (unsigned int it_src = 0; it_src < totalHosts; it_src++) { // Routes from host
- simgrid::s4u::Host* host1 = hosts[it_src];
+ const simgrid::s4u::Host* host1 = hosts[it_src];
simgrid::kernel::routing::NetPoint* src = host1->get_netpoint();
for (unsigned int it_dst = 0; it_dst < totalHosts; it_dst++) { // Routes to host
- simgrid::s4u::Host* host2 = hosts[it_dst];
+ const simgrid::s4u::Host* host2 = hosts[it_dst];
std::vector<simgrid::kernel::resource::LinkImpl*> route;
simgrid::kernel::routing::NetPoint* dst = host2->get_netpoint();
simgrid::kernel::routing::NetZoneImpl::get_global_route(src, dst, route, nullptr);
}
}
for (unsigned int it_dst = 0; it_dst < totalHosts; it_dst++) { // Routes to host
- simgrid::s4u::Host* host2 = hosts[it_dst];
+ const simgrid::s4u::Host* host2 = hosts[it_dst];
std::printf(" <route src=\"%s\" dst=\"%s\">\n ", value1->get_cname(), host2->get_cname());
std::vector<simgrid::kernel::resource::LinkImpl*> route;
simgrid::kernel::routing::NetPoint* netcardDst = host2->get_netpoint();
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2008-2020. 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. */
std::vector<simgrid::kernel::routing::NetPoint*> netpoints =
simgrid::s4u::Engine::get_instance()->get_all_netpoints();
std::sort(netpoints.begin(), netpoints.end(),
- [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) {
+ [](const simgrid::kernel::routing::NetPoint* a, const simgrid::kernel::routing::NetPoint* b) {
return a->get_name() < b->get_name();
});
int it;
sg_host_t host;
xbt_dynar_foreach(hosts, it, host) {
- simgrid::kernel::routing::NetPoint* nc = host->get_netpoint();
+ const simgrid::kernel::routing::NetPoint* nc = host->get_netpoint();
const char *type = "buggy";
if (nc->is_router())
type = "router";
/* check_defaults -- simple program displaying its context factory */
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2020. 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. */
/* stack_overflow -- simple program generating a stack overflow */
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2020. 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. */
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2014-2019. The SimGrid Team.
+/* Copyright (c) 2014-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2009-2020. 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. */
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2019. The SimGrid Team.
+/* Copyright (c) 2019-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
}
// Return the number of times that an element is equal to (i+value)%256 between buf[start] and buf[stop-1].
-static int count_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
+static int count_all(const uint8_t* buf, size_t start, size_t stop, uint8_t value)
+{
size_t occ = 0;
for(size_t i = start ; i < stop ; i++) {
if(buf[i] == (i+value)%256) {
}
// Return true iff the values from buf[start] to buf[stop-1] are all equal to (i+value)%256.
-static int check_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
+static int check_all(const uint8_t* buf, size_t start, size_t stop, uint8_t value)
+{
size_t occ = count_all(buf, start, stop, value);
return occ == stop-start;
}
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. 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. */
}
// Return the number of times that an element is equal to (i+value)%256 between buf[start] and buf[stop-1].
-static int count_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
+static int count_all(const uint8_t* buf, size_t start, size_t stop, uint8_t value)
+{
size_t occ = 0;
for(size_t i = start ; i < stop ; i++) {
if(buf[i] == (i+value)%256) {
}
// Return true iff the values from buf[start] to buf[stop-1] are all equal to (i+value)%256.
-static int check_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
+static int check_all(const uint8_t* buf, size_t start, size_t stop, uint8_t value)
+{
size_t occ = count_all(buf, start, stop, value);
return occ == stop-start;
}
// Return true iff "enough" elements are equal to (i+value)%256 between buf[start] and buf[stop-1].
-static int check_enough(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
+static int check_enough(const uint8_t* buf, size_t start, size_t stop, uint8_t value)
+{
int page_size = 0x1000;
size_t size = stop-start;
if(size <= 2*page_size) // we are not sure to have a whole page that is shared
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
MPI_Waitall(NUM_LOOPS, req, MPI_STATUSES_IGNORE);
MPI_Barrier(MPI_COMM_WORLD);
+ free(req);
/* test issends */
MPI_Type_create_indexed_block(count, 1, displs, MPI_INT, &newtype);
MPI_Waitall(NUM_LOOPS, req, MPI_STATUSES_IGNORE);
MPI_Barrier(MPI_COMM_WORLD);
+ free(req);
/* test irsends */
MPI_Type_create_indexed_block(count, 1, displs, MPI_INT, &newtype);
MPI_Waitall(NUM_LOOPS, req, MPI_STATUSES_IGNORE);
MPI_Barrier(MPI_COMM_WORLD);
+ free(req);
+ free(displs);
MPI_Finalize();
# Skip FORTRAN STOP
if (/FORTRAN STOP/) { next; }
$inline .= $_;
- if (/^==[0-9]+== ?WARNING: ASan doesn't fully support/) {
+ if (m{^==[0-9]+== ?WARNING: ASan doesn't fully support} ||
+ m{^==[0-9]+== ?WARNING: ASan is ignoring requested __asan_handle_no_return: stack top:} ||
+ m{^False positive error reports may follow$} ||
+ m{^For details see http://code.google.com/p/address-sanitizer/issues/detail\?id=189$} ||
+ m{^For details see https://github.com/google/sanitizers/issues/189$}) {
next;
}
if (/^\s*No [Ee]rrors\s*$/ && $found_noerror == 0) {
static int myvalue = 0;
-static void test_opts(int* argc, char **argv[]){
+static void test_opts(int argc, char* const argv[])
+{
int found = 0;
static struct option long_options[] = {
{(char*)"long", no_argument, 0, 0 },
{0, 0, 0, 0 }
};
while (1) {
- int ret = getopt_long_only(*argc, *argv, "s", long_options, NULL);
+ int ret = getopt_long_only(argc, argv, "s", long_options, NULL);
if(ret==-1)
break;
MPI_Init(&argc, &argv);
/* test getopt_long function */
- test_opts(&argc, &argv);
+ test_opts(argc, argv);
MPI_Comm_rank(MPI_COMM_WORLD, &me);
-/* Copyright (c) 2011-2019. The SimGrid Team.
+/* Copyright (c) 2011-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
XBT_LOG_NEW_DEFAULT_CATEGORY(dsend,"the dsend test");
-static void test_opts(int* argc, char **argv[]){
+static void test_opts(int argc, char* const argv[])
+{
int found = 0;
int option_index = 0;
static struct option long_options[] = {
{0, 0, 0, 0 }
};
while (1) {
- int ret = getopt_long(*argc, *argv, "s", long_options, &option_index);
+ int ret = getopt_long(argc, argv, "s", long_options, &option_index);
if(ret==-1)
break;
MPI_Init(NULL, NULL);
/* test getopt_long function */
- test_opts(&argc, &argv);
+ test_opts(argc, argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Request r;
/* A simple example ping-pong program to test MPI_Send and MPI_Recv */
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#include <stdio.h>
#include <mpi.h>
-static void test_opts(int* argc, char **argv[]){
+static void test_opts(int argc, char* const argv[])
+{
int found = 0;
int ret;
- while ((ret = getopt(*argc, *argv, "s")) >= 0)
- {
+ while ((ret = getopt(argc, argv, "s")) >= 0) {
if (ret == 's')
found = 1;
}
int err = MPI_Init(&argc, &argv); /* Initialize MPI */
/* test getopt function */
- test_opts(&argc, &argv);
+ test_opts(argc, argv);
if (err != MPI_SUCCESS) {
printf("MPI initialization failed!\n");
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* A few tests for the maxmin library */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
/* A few crash tests for the maxmin library */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
/* A few basic tests for the surf library */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
simgrid::s4u::Host* hostB = sg_host_by_name("Cpu B");
/* Let's do something on it */
- simgrid::kernel::resource::Action* actionA = hostA->pimpl_cpu->execution_start(1000.0);
- simgrid::kernel::resource::Action* actionB = hostB->pimpl_cpu->execution_start(1000.0);
- simgrid::kernel::resource::Action* actionC = hostB->pimpl_cpu->sleep(7.32);
+ const simgrid::kernel::resource::Action* actionA = hostA->pimpl_cpu->execution_start(1000.0);
+ const simgrid::kernel::resource::Action* actionB = hostB->pimpl_cpu->execution_start(1000.0);
+ const simgrid::kernel::resource::Action* actionC = hostB->pimpl_cpu->sleep(7.32);
simgrid::kernel::resource::Action::State stateActionA = actionA->get_state();
simgrid::kernel::resource::Action::State stateActionB = actionB->get_state();
/* A few basic tests for the surf library */
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2020. 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. */
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019-2020. 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. */
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2018-2020. 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. */
/* log_large_test -- log a very large string to test the dynamic variants */
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* log_usage - A test of normal usage of the log facilities */
-/* Copyright (c) 2004-2019. The SimGrid Team.
+/* Copyright (c) 2004-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
/* synchro_crashtest -- tries to crash the logging mechanism by doing parallel logs*/
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2020. 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. */
/* parmap_test -- test parmap */
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
#!/usr/bin/env perl
-# Copyright (c) 2005-2019. The SimGrid Team.
+# Copyright (c) 2005-2020. The SimGrid Team.
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it
#!/usr/bin/env perl
-# Copyright (c) 2006-2019. The SimGrid Team.
+# Copyright (c) 2006-2020. The SimGrid Team.
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it
src/kernel/future.cpp
src/simix/libsmx.cpp
src/simix/smx_context.cpp
- src/kernel/context/context_private.hpp
src/kernel/context/Context.cpp
src/kernel/context/Context.hpp
src/kernel/context/ContextRaw.cpp
docs/requirements.txt
docs/source/conf.py
docs/source/Doxyfile
+ docs/find-missing.ignore
docs/find-missing.py
docs/source/_ext/autodoxy.py
docs/source/_ext/showfile.css
docs/source/ns3.rst
docs/source/outcomes.rst
docs/source/platform.rst
- docs/source/platform_howtos.rst
docs/source/Platform_Examples.rst
+ docs/source/platform_howtos.rst
+ docs/source/Platform_Routing.rst
docs/source/Plugins.rst
docs/source/XML_Reference.rst
tools/cmake/test_prog/prog_makecontext.c
tools/cmake/test_prog/prog_stackgrowth.c
tools/cmake/test_prog/prog_stacksetup.c
+ tools/cmake/test_prog/prog_tsan.cpp
tools/cmake/cross-mingw.cmake
tools/smpi/generate_smpi_defines.pl
tools/stack-cleaner/as
message(WARNING "Failed to find relative source directory. Using \".\".")
set(RELATIVE_SOURCE_DIR ".")
endif()
- set(optCFLAGS "${optCFLAGS} -fdebug-prefix-map=${CMAKE_SOURCE_DIR}=${RELATIVE_SOURCE_DIR}")
+ if (CMAKE_C_COMPILER_VERSION VERSION_LESS "8.0")
+ set(optCFLAGS "${optCFLAGS} -fdebug-prefix-map=${CMAKE_SOURCE_DIR}=${RELATIVE_SOURCE_DIR}")
+ else()
+ set(optCFLAGS "${optCFLAGS} -ffile-prefix-map=${CMAKE_SOURCE_DIR}=${RELATIVE_SOURCE_DIR}")
+ endif()
endif()
# Configure LTO
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -fno-omit-frame-pointer -no-pie")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer -no-pie")
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -fsanitize=thread -no-pie")
- set(HAVE_SANITIZER_THREAD TRUE CACHE INTERNAL "")
+ try_compile(HAVE_SANITIZER_THREAD ${CMAKE_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_tsan.cpp)
+ try_compile(HAVE_SANITIZER_THREAD_FIBER_SUPPORT ${CMAKE_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_tsan.cpp
+ COMPILE_DEFINITIONS -DCHECK_FIBER_SUPPORT)
else()
set(HAVE_SANITIZER_THREAD FALSE CACHE INTERNAL "")
+ set(HAVE_SANITIZER_THREAD_FIBER_SUPPORT FALSE CACHE INTERNAL "")
endif()
if(enable_undefined_sanitizer)
## This file is loaded only if the Java option is activated
##
-find_package(Java 1.7 COMPONENTS Runtime Development)
+find_package(Java 1.8 COMPONENTS Runtime Development)
if (NOT ${Java_FOUND})
- message(FATAL_ERROR "Java not found (need at least Java7). Please install the JDK or disable that option")
+ message(FATAL_ERROR "Java not found (need at least Java8). Please install the JDK or disable that option")
endif()
set(Java_FOUND 1)
include(UseJava)
# Search for libunwind and components, both includes and libraries
#
-# Copyright (C) 2003-2019 The SimGrid Team.
+# Copyright (C) 2003-2020 The SimGrid Team.
# This is distributed under the LGPL licence but please contact us for
# relicensing if you need. This is merely free software, no matter the licence.
#
-IF(enable_smpi AND NOT WIN32)
- execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpicc)
- execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpicxx)
- execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpiff)
- execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpif90)
- execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpirun)
-ENDIF()
-
SET(TESH_OPTION "--ignore-jenkins")
SET(TESH_COMMAND "${PYTHON_EXECUTABLE}" ${CMAKE_BINARY_DIR}/bin/tesh)
#!/usr/bin/env perl
-# Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2012-2020. 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.
#!/usr/bin/env perl
-# Copyright (c) 2012-2019. The SimGrid Team.
+# Copyright (c) 2012-2020. The SimGrid Team.
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2017-2019. The SimGrid Team.
+/* Copyright (c) 2017-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2020. 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. */
--- /dev/null
+/* Copyright (c) 2020. 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. */
+
+/* Check availability of ThreadSanitizer */
+
+#if defined(__has_feature)
+#define HAS_FEATURE(x) __has_feature(x)
+#else
+#define HAS_FEATURE(x) 0
+#endif
+
+#if not HAS_FEATURE(thread_sanitizer) && not defined(__SANITIZE_THREAD__)
+#error "TSan feature not found."
+#endif
+
+#if defined(CHECK_FIBER_SUPPORT)
+#include <sanitizer/tsan_interface.h>
+// Verify the existence of the fiber annotation interface, with the expected signature
+void* (*create_fiber)(unsigned) = __tsan_create_fiber;
+void (*destroy_fiber)(void*) = __tsan_destroy_fiber;
+void (*switch_fiber)(void*, unsigned) = __tsan_switch_to_fiber;
+#endif
+
+int main(void) {}
#! /usr/bin/env perl
-# Copyright (c) 2010-2019. The SimGrid Team.
+# Copyright (c) 2010-2020. The SimGrid Team.
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it
#!/usr/bin/env perl
-# Copyright (c) 2008-2019. The SimGrid Team.
+# Copyright (c) 2008-2020. The SimGrid Team.
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it
#!/usr/bin/env bash
-# Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2010-2020. 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.
#!/usr/bin/env bash
# Copyright (c) 2015, David Martin. All rights reserved.
-# Copyright (c) 2017-2019. The SimGrid team. All rights reserved.
+# Copyright (c) 2017-2020. The SimGrid team. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
-/* Copyright (c) 2008-2019. The SimGrid Team.
+/* Copyright (c) 2008-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#!/usr/bin/env bash
-# Copyright (c) 2013-2019. The SimGrid Team.
+# Copyright (c) 2013-2020. The SimGrid Team.
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it
#!/usr/bin/env bash
-# Copyright (c) 2011-2019. The SimGrid Team.
+# Copyright (c) 2011-2020. The SimGrid Team.
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it
#!/usr/bin/env perl
-# Copyright (c) 2013-2019. The SimGrid Team.
+# Copyright (c) 2013-2020. The SimGrid Team.
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it
#!/usr/bin/env bash
-# Copyright (c) 2014-2019. The SimGrid Team.
+# Copyright (c) 2014-2020. The SimGrid Team.
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it
fi
}
-# Check that we have what we need, or die quickly.
-# The paths are not the same on all platforms, unfortunately.
-#test -e /bin/tar || die 1 "I need tar to compile. Please fix your slave."
-#test -e /bin/gzip || die 1 "I need gzip to compile. Please fix your slave."
-#test -e /usr/include/libunwind.h || die 1 "I need libunwind to compile. Please fix your slave."
-#test -e /usr/include/valgrind/valgrind.h || die 1 "I need valgrind to compile. Please fix your slave."
-
-if type lsb_release >/dev/null 2>&1; then
- if [ -f /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ]; then
- #To identify the windows underneath the winbuntu
- PATH="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:$PATH"
- major=$(powershell.exe -command "[environment]::OSVersion.Version.Major" | sed 's/\r//g')
- build=$(powershell.exe -command "[environment]::OSVersion.Version.Build"| sed 's/\r//g')
- os=Windows
- ver="$major v$build - WSL $(lsb_release -sd)"
- else
+if type lsb_release >/dev/null 2>&1; then # recent versions of Debian/Ubuntu
# linuxbase.org
os=$(lsb_release -si)
ver="$(lsb_release -sr) ($(lsb_release -sc))"
- fi
-elif [ -f /etc/lsb-release ]; then
- # For some versions of Debian/Ubuntu without lsb_release command
+elif [ -f /etc/lsb-release ]; then # For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
os=$DISTRIB_ID
ver=$DISTRIB_RELEASE
-elif [ -f /etc/debian_version ]; then
- # Older Debian/Ubuntu/etc.
+elif [ -f /etc/debian_version ]; then # Older Debian/Ubuntu/etc.
os=Debian
ver=$(cat /etc/debian_version)
-elif [ -f /etc/redhat-release ]; then
+elif [ -f /etc/redhat-release ]; then #RH, Fedora, Centos
read -r os ver < /etc/redhat-release
-elif [ -f /usr/bin/sw_vers ]; then
+elif [ -f /usr/bin/sw_vers ]; then #osx
os=$(sw_vers -productName)
ver=$(sw_vers -productVersion)
-elif [ -f /bin/freebsd-version ]; then
+elif [ -f /bin/freebsd-version ]; then #freebsd
os=$(uname -s)
ver=$(freebsd-version -u)
-elif [ -f /etc/version ]; then
+elif [ -f /etc/release ]; then #openindiana
read -r os ver < /etc/release
-elif [ -f /etc/os-release ]; then
- # freedesktop.org and systemd, put last as usually missing useful info
+elif [ -f /etc/os-release ]; then # freedesktop.org and systemd, put last as usually missing useful info
. /etc/os-release
os=$NAME
ver=$VERSION_ID
os=$(uname -s)
ver=$(uname -r)
fi
+
+# Are we running on wsl ?
+if [ -f /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ]; then
+ #To identify the windows underneath the linux
+ PATH="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:$PATH"
+ major=$(powershell.exe -command "[environment]::OSVersion.Version.Major" | sed 's/\r//g')
+ build=$(powershell.exe -command "[environment]::OSVersion.Version.Build"| sed 's/\r//g')
+ ver="$major v$build - WSL $os $ver"
+ os=Windows
+fi
+
case $(uname -m) in
x86_64)
bits="64 bits"
echo "XX"
ctest -T test --output-on-failure --no-compress-output || true
-if [ -f Testing/TAG ] ; then
- xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/$( head -n 1 < Testing/TAG )/Test.xml > CTestResults.xml
- mv CTestResults.xml $WORKSPACE
-fi
if test -n "$INSTALL" && [ ${branch_name} = "origin/master" ] ; then
echo "XX"
#!/usr/bin/env python
-# Copyright (c) 2013-2019. The SimGrid Team.
+# Copyright (c) 2013-2020. The SimGrid Team.
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (c) 2013-2019. The SimGrid Team.
+# Copyright (c) 2013-2020. The SimGrid Team.
# All rights reserved.
# This program is free software; you can redistribute it and/or modify it
fun:_dl_init
}
-# There's a constant leak of 56 bytes in the depths of libc which
-# manifests, for example, when using backtrace()
-{
- Memory leak in libc/dlopen with -pthread
- Memcheck:Leak
- fun:malloc
- fun:_dl_map_object_deps
- fun:dl_open_worker
- fun:_dl_catch_error
- fun:_dl_open
- fun:do_dlopen
- fun:_dl_catch_error
- fun:dlerror_run
- fun:__libc_dlopen_mode
-}
-
-# Another problem in glibc, where makecontext does not reset the EBP register,
+# There's problem in glibc, where makecontext does not reset the EBP register,
# and backtrace goes too far when walking up the stack frames
{
Invalid read in backtrace, called after makecontext
fun:_dl_start
}
+# There are memory leaks when using dlopen
+{
+ Memory leak in libc/dlopen
+ Memcheck:Leak
+ ...
+ fun:_dlerror_run
+}
+
# 72704 bytes leak from GCC >5.1 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64535
{
Memory leak in dl_init
fun:smpi_simulated_main_
}
-#SMPI leaks the dlopen handle used to load the program
-{
- dlopen handle leaks (1/3)
- Memcheck:Leak
- match-leak-kinds:reachable
- fun:malloc
- ...
- fun:dlopen@@GLIBC_*
-}
-
-{
- dlopen handle leaks (2/3)
- Memcheck:Leak
- match-leak-kinds:reachable
- fun:calloc
- ...
- fun:dlopen@@GLIBC_*
-}
-
-{
- dlopen handle leaks (3/3)
- Memcheck:Leak
- match-leak-kinds:reachable
- fun:realloc
- ...
- fun:dlopen@@GLIBC_*
-}
-
# Memory leaks appearing to be in libcgraph. They can be seen with the
# following simple program:
# ,----
# This script updates the simgrid XML file passed as argument (modification in place)
# It is built to do the conversion incrementally.
-# Copyright (c) 2006-2019. The SimGrid Team.
+# Copyright (c) 2006-2020. The SimGrid Team.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
=head1 COPYRIGHT AND LICENSE
-Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.
+Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.
This program is free software; you may redistribute it and/or modify it
under the terms of GNU LGPL (v2.1) license.
tesh -- testing shell
========================
-Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.
+Copyright (c) 2012-2020. 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.
-
#TODO: child of child of child that printfs. Does it work?
#TODO: a child dies after its parent. What happen?
"""
-
import sys
import os
import shlex
#
#
-
def isWindows():
return sys.platform.startswith('win')
# Singleton metaclass that works in Python 2 & 3
# http://stackoverflow.com/questions/6760685/creating-a-singleton-in-python
-
class _Singleton(type):
""" A metaclass that creates a Singleton base class when called. """
_instances = {}
cls._instances[cls] = super(_Singleton, cls).__call__(*args, **kwargs)
return cls._instances[cls]
-
class Singleton(_Singleton('SingletonMeta', (object,), {})):
pass
-
SIGNALS_TO_NAMES_DICT = dict((getattr(signal, n), n)
for n in dir(signal) if n.startswith('SIG') and '_' not in n)
vdefault = m.group(2)
if vname in os.environ:
return "$" + vname
- else:
- return vdefault
+ return vdefault
+
self.args = re.sub(r"\${(\w+):=([^}]*)}", replace_perl_variables, self.args)
# replace bash environment variables ($THINGS) to their values
logs.append("(ignoring the output of <{cmd}> as requested)".format(cmd=cmdName))
else:
stdouta = stdout_data.split("\n")
- while len(stdouta) > 0 and stdouta[-1] == "":
+ while stdouta and stdouta[-1] == "":
del stdouta[-1]
stdouta = self.remove_ignored_lines(stdouta)
stdcpy = stdouta[:]
lineterm="",
fromfile='expected',
tofile='obtained'))
- if len(diff) > 0:
+ if diff:
logs.append("Output of <{cmd}> mismatch:".format(cmd=cmdName))
if self.sort >= 0: # If sorted, truncate the diff output and show the unsorted version
difflen = 0
if TeshState().keep:
f = open('obtained', 'w')
obtained = stdout_data.split("\n")
- while len(obtained) > 0 and obtained[-1] == "":
+ while obtained and obtained[-1] == "":
del obtained[-1]
obtained = self.remove_ignored_lines(obtained)
for line in obtained:
def can_run(self):
return self.args is not None
-
##############
#
# Main
#
#
-
if __name__ == '__main__':
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
line = f.readfullline()
while line is not None:
# print(">>============="+line+"==<<")
- if len(line) == 0:
+ if not line:
#print ("END CMD block")
if cmd.run_if_possible():
cmd = Cmd()