# This package is so outdated and broken that we cannot use it anymore. So we build without perl
# - choco install --limit-output strawberryperl --version 5.20.1.1
# - SET PATH=C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;%PATH%
-# Lua
+# Lua
#- choco install lua53
# We need python v3
- cmd: SET PATH=C:\Python37-x64;%PATH% # We need python v3
# Work around a bug on appveyor where the default sh is not the one I expect
- rename "C:\Program Files\Git\usr\bin\sh.exe" "sh-ignored.exe"
# We need pybind11. SimGrid will pick it automatically if the subdir is here
-#- cmd: git clone --depth=1 https://github.com/pybind/pybind11.git
+- cmd: git clone --depth=1 https://github.com/pybind/pybind11.git
build_script:
-- cmake -G "MinGW Makefiles" -Denable_lua=OFF -Denable_documentation=OFF -Denable_java=ON -Denable_smpi=OFF -Denable_mallocators=OFF -Denable_lto=OFF .
-- mingw32-make.exe VERBOSE=1 java-all # python-bindings # Only the Java and Python parts
+- cmake -G "MinGW Makefiles" -Denable_lua=OFF -Denable_documentation=OFF -Denable_java=ON -Denable_msg=ON -Denable_smpi=OFF -Denable_mallocators=OFF -Denable_lto=OFF .
+- mingw32-make.exe VERBOSE=1 java-all python-bindings # Only the Java and Python parts
- ctest --output-on-failure -R java
-# Don't test python, as pybind11 seems too complex for mingw for now (mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1)
-# The observed failure is around the ForcefulKill exception, that seems badly caught somehow.
-# - ctest --output-on-failure -R python
+- ctest --output-on-failure -R python
artifacts:
- path: simgrid.jar
# 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.
name: Configure, build and test da stuff
command: |
mkdir _build && cd _build
- cmake -Denable_documentation=OFF -Denable_coverage=ON -Denable_java=ON -Denable_model-checking=OFF -Denable_lua=OFF -Denable_compile_optimizations=OFF -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=OFF -Denable_compile_warnings=ON ..
+ cmake -Denable_documentation=OFF -Denable_coverage=ON -Denable_java=ON -Denable_msg=ON -Denable_model-checking=OFF -Denable_lua=OFF -Denable_compile_optimizations=OFF -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=OFF -Denable_compile_warnings=ON ..
make -j4 tests && ctest -j4 --output-on-failure
### Generated files
_*.c
include/simgrid/config.h
+include/simgrid/version.h
include/smpi/smpif.h
src/internal_config.h
-src/simgrid/version.h
testprog
### Cmake files
CPackConfig.cmake
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.
except:
- stable
script:
- - cmake -Denable_model-checking=OFF -Denable_documentation=OFF -Denable_coverage=OFF -Denable_java=ON -Denable_lua=OFF -Denable_compile_optimizations=ON -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=ON -Denable_compile_warnings=ON .
+ - cmake -Denable_model-checking=OFF -Denable_documentation=OFF -Denable_coverage=OFF -Denable_lua=OFF -Denable_compile_optimizations=ON -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=ON -Denable_compile_warnings=ON .
- make VERBOSE=1 all tests && ctest --output-on-failure
pip:
script:
- apt-get --allow-releaseinfo-change update && apt install -y binutils-x86-64-linux-gnu wget unzip zip
# Build the linux version of the jarfile without the boost dependency
- - cmake -Denable_documentation=OFF -Denable_java=ON -Denable_lib_in_jar=ON -Dminimal-bindings=ON -Denable_compile_optimizations=ON -Denable_smpi=OFF .
+ - cmake -Denable_documentation=OFF -Denable_java=ON -Denable_msg=ON -Denable_lib_in_jar=ON -Dminimal-bindings=ON -Denable_compile_optimizations=ON -Denable_smpi=OFF .
- make VERBOSE=1 dist simgrid simgrid-java_jar
# Get the foreign architectures
- wget https://ci.appveyor.com/api/projects/mquinson/simgrid/artifacts/simgrid.jar -O simgrid-windows.jar
# Path to the pip requirements file
requirements_file: docs/requirements.txt
-
+
# Don't build any extra formats
formats: []
\ No newline at end of file
-# NS3 is disabled because the version in ubuntu precise does not lead
+# NS3 is disabled because the version in ubuntu precise does not lead
# to the same timings (precision error?)
-# Reenable with
+# Reenable with
# cmake -Denable_ns3
# apt-get libns3-dev ns3
#
language: cpp
compiler:
- gcc
-# - clang
+# - clang
jdk:
- openjdk11
addons:
script:
- 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
+ - (cmake -Denable_model-checking=ON -Denable_documentation=OFF -Denable_coverage=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 && make -j2 tests && ctest -j2 --output-on-failure
- os: windows
script:
- mv "C:/Program Files/Git/usr/bin/sh.exe" "sh-ignored.exe"
- - df -h
- - du -hs /tmp || true
- - choco install boost-msvc-12 python jdk8
- - export CC=gcc
- - export CXX=g++
- - export PATH='C:\Python38':'C:\local\boost_1_58_0':$PATH
- - export BOOST_LIBRARYDIR='C:/local/boost_1_58_0/lib64-msvc-12.0'
- - export BOOST_INCLUDEDIR='C:/local/boost_1_58_0/include'
- - export JAVA_HOME='C:/Program Files/Java/jdk1.8.0_211'
- - cmake -G "MinGW Makefiles" -Denable_lua=OFF -Denable_documentation=OFF -Denable_java=ON -Denable_smpi=OFF -Denable_mallocators=OFF -Denable_lto=OFF .
- - df -h
- - du -hs /tmp || true
- - mingw32-make.exe VERBOSE=1 java-all && ctest --output-on-failure -R java
- - df -h
- - du -hc /tmp || true
+ - df -h
+ - du -hs /tmp || true
+ - choco install boost-msvc-12 python jdk8
+ - export CC=gcc
+ - export CXX=g++
+ - export PATH='C:\Python38':'C:\local\boost_1_58_0':$PATH
+ - export BOOST_LIBRARYDIR='C:/local/boost_1_58_0/lib64-msvc-12.0'
+ - export BOOST_INCLUDEDIR='C:/local/boost_1_58_0/include'
+ - export JAVA_HOME='C:/Program Files/Java/jdk1.8.0_211'
+ # We need pybind11. SimGrid will pick it automatically if the subdir is here
+ # - git clone --depth=1 https://github.com/pybind/pybind11.git
+ - cmake -G "MinGW Makefiles" -Denable_java=ON -Denable_msg=ON -Denable_lua=OFF -Denable_documentation=OFF -Denable_smpi=OFF -Denable_mallocators=OFF -Denable_lto=OFF .
+ - df -h
+ - du -hs /tmp || true
+ - mingw32-make.exe VERBOSE=1 java-all && ctest --output-on-failure -R java
+ # - mingw32-make.exe VERBOSE=1 python-bindings && ctest --output-on-failure -R python
+ - df -h
+ - du -hc /tmp || true
- os: osx
osx_image: xcode11
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
+ - cmake -Denable_model-checking=OFF -Denable_documentation=OFF -Denable_coverage=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 && 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 Makefile ] ; then
if [ -e build/default/Makefile ] ; then
cd build/default
else
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} -a -d ${install_path} -a -x ${install_path} -a -w ${install_path} ] ; then
+if [ -e ${install_path} ] && [ -d ${install_path} ] && [ -x ${install_path} ] && [ -w ${install_path} ] ; then
target=install
fi
(
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
# Build the version number
set(SIMGRID_VERSION_MAJOR "3")
-set(SIMGRID_VERSION_MINOR "24")
+set(SIMGRID_VERSION_MINOR "25")
set(SIMGRID_VERSION_PATCH "1") # odd => git branch; even => stable release or released snapshot
-set(SIMGRID_VERSION_DATE "2019") # Year for copyright information
-
if(${SIMGRID_VERSION_PATCH} EQUAL "0")
set(release_version "${SIMGRID_VERSION_MAJOR}.${SIMGRID_VERSION_MINOR}")
else()
## 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")
endif()
endif()
+set(SIMGRID_HAVE_MSG 0)
+if(enable_msg)
+ set(SIMGRID_HAVE_MSG 1)
+endif()
+
if(WIN32)
set(Boost_USE_STATIC_LIBS 1)
endif()
CHECK_INCLUDE_FILE("signal.h" HAVE_SIGNAL_H)
CHECK_INCLUDE_FILE("sys/param.h" HAVE_SYS_PARAM_H)
CHECK_INCLUDE_FILE("sys/sysctl.h" HAVE_SYS_SYSCTL_H)
-CHECK_INCLUDE_FILE("ucontext.h" HAVE_UCONTEXT_H)
CHECK_INCLUDE_FILE("linux/futex.h" HAVE_FUTEX_H)
CHECK_FUNCTION_EXISTS(dlfunc HAVE_DLFUNC)
mark_as_advanced(PATH_LIBDW_H)
mark_as_advanced(PATH_LIBDW_LIB)
+if(enable_java AND NOT enable_msg)
+ message(FATAL_ERROR "Cannot activate the Java bindings without the MSG module. Either add -Denable_msg=ON or -Denable_java=OFF")
+endif()
+
if (enable_model-checking AND enable_ns3)
- message(FATAL_ERROR "Cannot activate both model-checking and ns-3 bindings: ns-3 pull too much dependencies for the MC to work")
+ message(FATAL_ERROR "Cannot activate both model-checking and ns-3 bindings: ns-3 pulls too much dependencies for the MC to work")
endif()
get_property(known_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES)
if(enable_smpi)
SET(HAVE_SMPI 1)
- if(NOT WIN32)
- SET(HAVE_PRIVATIZATION 1)
- else()
- message (STATUS "Warning: no support for SMPI automatic privatization on this platform")
+ if(WIN32)
+ message (STATUS "Warning: no support for SMPI automatic privatization on Windows.")
SET(HAVE_PRIVATIZATION 0)
+ else()
+ SET(HAVE_PRIVATIZATION 1)
endif()
else()
SET(HAVE_SMPI 0)
### Check what context backends are available
set(HAVE_UCONTEXT_CONTEXTS 0)
+CHECK_INCLUDE_FILE("ucontext.h" HAVE_UCONTEXT_H)
if(NOT HAVE_UCONTEXT_H)
message(STATUS "No ucontext factory: <ucontext.h> not found.")
elseif(APPLE)
# Avoid triggering a (full) rebuild by touching the files if they did not really change
configure_file("${CMAKE_HOME_DIRECTORY}/src/internal_config.h.in" "${CMAKE_BINARY_DIR}/src/internal_config.h.generated" @ONLY IMMEDIATE)
-configure_file("${CMAKE_HOME_DIRECTORY}/src/simgrid/version.h.in" "${CMAKE_BINARY_DIR}/src/simgrid/version.h.generated" @ONLY IMMEDIATE)
+configure_file("${CMAKE_HOME_DIRECTORY}/include/simgrid/version.h.in" "${CMAKE_BINARY_DIR}/include/simgrid/version.h.generated" @ONLY IMMEDIATE)
configure_file("${CMAKE_HOME_DIRECTORY}/include/simgrid/config.h.in" "${CMAKE_BINARY_DIR}/include/simgrid/config.h.generated" @ONLY IMMEDIATE)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/src/internal_config.h.generated ${CMAKE_BINARY_DIR}/src/internal_config.h)
-execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/src/simgrid/version.h.generated ${CMAKE_BINARY_DIR}/src/simgrid/version.h)
+execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/include/simgrid/version.h.generated ${CMAKE_BINARY_DIR}/include/simgrid/version.h)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/include/simgrid/config.h.generated ${CMAKE_BINARY_DIR}/include/simgrid/config.h)
file(REMOVE ${CMAKE_BINARY_DIR}/src/internal_config.h.generated)
file(REMOVE ${CMAKE_BINARY_DIR}/include/simgrid/config.h.generated)
-file(REMOVE ${CMAKE_BINARY_DIR}/src/simgrid/version.h.generated)
+file(REMOVE ${CMAKE_BINARY_DIR}/include/simgrid/version.h.generated)
# We need two versions of the SMPI scripts because they contain the path to the library
# so, it depends of whether SimGrid is installed, or run from the sources (during the build)
set(generated_headers_to_install
${CMAKE_CURRENT_BINARY_DIR}/include/smpi/mpif.h
${CMAKE_CURRENT_BINARY_DIR}/include/simgrid/config.h
+ ${CMAKE_CURRENT_BINARY_DIR}/include/simgrid/version.h
)
set(generated_headers ${CMAKE_CURRENT_BINARY_DIR}/src/internal_config.h )
else()
find_package(pybind11 CONFIG)
- if (pybind11_VERSION VERSION_LESS 2.2)
- message(STATUS "SimGrid needs at least v2.2 of pybind11. Disabling the Python bindings (found version: ${pybind11_VERSION}).")
+ message(STATUS "Pybind11 version: ${pybind11_VERSION}")
+ if (pybind11_VERSION VERSION_LESS 2.4)
+ message(STATUS "SimGrid needs at least v2.4 of pybind11. Disabling the Python bindings.")
set(pybind11_FOUND OFF)
endif()
endif()
message(" with LTO ....................: ${enable_lto}")
message("")
+if (SIMGRID_HAVE_MSG)
+ message(" Compile MSG .................: ON")
+else()
+ message(" Compile MSG .................: OFF")
+endif()
+
if (SIMGRID_HAVE_NS3)
- message(" Compile ns-3 ................: yes (path: ${NS3_PATH})")
+ message(" Compile ns-3 ................: ON (path: ${NS3_PATH})")
else()
- message(" Compile ns-3 ................: NO (hint: ${NS3_HINT})")
+ message(" Compile ns-3 ................: OFF (hint: ${NS3_HINT})")
endif()
if (${Java_FOUND})
- message(" Compile Java ................: yes")
+ message(" Compile Java ................: ON")
message(" Native lib in jar .........: ${enable_lib_in_jar}")
else()
- message(" Compile Java ................: NO")
+ message(" Compile Java ................: OFF")
endif()
if(pybind11_FOUND)
message(" Compile Python bindings .....: ${enable_python}")
message(" module ....................: ${PYTHON_MODULE_PREFIX}simgrid${PYTHON_MODULE_EXTENSION}")
else()
- message(" Compile Python bindings .....: NO (disabled, or pybind11 not found)")
+ message(" Compile Python bindings .....: OFF (disabled, or pybind11 not found)")
endif()
message(" Compile Lua .................: ${SIMGRID_HAVE_LUA}")
message(" Compile Smpi ................: ${HAVE_SMPI}")
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)
+SimGrid (3.25.1) UNRELEASED (target: March 20 2020 or v3.26 on 3/26/20)
+
+
+----------------------------------------------------------------------------
+
+SimGrid (3.25) February 2. 2020 (aka 02 02 2020)
+
+The Palindrom Day Release.
+
+Important user-visible changes:
+- Improve the Python usability (stability and documentation).
+ - A nasty synchronization bug was ironed out, see also below.
+ - Python's doc was organized as a separate tree, now integrated with C++.
+ - C bindings of S4U were not part of the doc.
+ - The C++ doc was also improved as methods are now split by theme.
+- Further deprecate MSG: you now have to pass -Denable_msg=ON to cmake.
+ - This is mandatory to use the Java bindings.
+ - OFF by default; The plan is to completely remove MSG by 2020Q4 or 2021Q1.
+- SimDAG++: Automatic dependencies on S4U activities (experimental)
+ - Some features are already implemented but not all of them
+ - Cannot block an activity until it's scheduled on a resource
+ - No heterogeneous wait_any() that would mix Exec/Comm/Io activities.
+ - See examples/s4u/{io,exec,comm}-dependent for what's already there.
+
+
+
+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.
+
+Python:
+- Require pybind11 version 2.4.
+- Greatly improve locking during context switches with Python.
+ - Declaring Python callbacks to this_actor::on_exit is now working.
+ - No more tests are failing currently, even on win32.
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#9: Python bindings crashing
+ - 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.
----------------------------------------------------------------------------
- #230: segfaults when exit() without run()
- #225: s4u::Actor::kill() doesn not really kill victims in a join()
- #223: MSG_task_get_flops_amount() not working with parallel tasks
- - #222: Actor::kill() doesn't really kill and segfaults
+ - #222: Actor::kill() doesn't really kill and segfaults
- #221: odd LMM warning when killing an actor
- #120: Memory leak when the processes are forcefully killed
# 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.
find_path(SimGrid_INCLUDE_DIR
NAMES simgrid/config.h
+ NAMES simgrid/version.h
PATHS ${SimGrid_PATH}/include /opt/simgrid/include
)
if (NOT SimGrid_INCLUDE_DIR)
if (SimGrid_INCLUDE_DIR)
set(SimGrid_VERSION_REGEX "^#define SIMGRID_VERSION_(MAJOR|MINOR|PATCH) ([0-9]+)$")
- if (EXISTS "${SimGrid_INCLUDE_DIR}/simgrid/config.h")
- file(STRINGS "${SimGrid_INCLUDE_DIR}/simgrid/config.h" SimGrid_VERSION_STRING REGEX ${SimGrid_VERSION_REGEX})
+ if (EXISTS "${SimGrid_INCLUDE_DIR}/simgrid/version.h")
+ file(STRINGS "${SimGrid_INCLUDE_DIR}/simgrid/version.h" SimGrid_VERSION_STRING REGEX ${SimGrid_VERSION_REGEX})
else()
file(STRINGS "${SimGrid_INCLUDE_DIR}/simgrid_config.h" SimGrid_VERSION_STRING REGEX ${SimGrid_VERSION_REGEX})
endif()
include doc/webcruft/simgrid_logo_2011.png
include doc/webcruft/simgrid_logo_2011_small.png
include doc/webcruft/storage_sample_scenario.png
+include examples/c/actor-create/actor-create.c
+include examples/c/actor-create/actor-create.tesh
+include examples/c/actor-create/actor-create_d.xml
+include examples/c/app-pingpong/app-pingpong.c
+include examples/c/app-pingpong/app-pingpong.tesh
+include examples/c/app-pingpong/app-pingpong_d.xml
+include examples/c/async-waitany/async-waitany.c
+include examples/c/async-waitany/async-waitany.tesh
+include examples/c/async-waitany/async-waitany_d.xml
include examples/deprecated/java/app/bittorrent/Common.java
include examples/deprecated/java/app/bittorrent/Connection.java
include examples/deprecated/java/app/bittorrent/Main.java
include examples/python/actor-join/actor-join.tesh
include examples/python/actor-kill/actor-kill.py
include examples/python/actor-kill/actor-kill.tesh
+include examples/python/actor-lifetime/actor-lifetime.py
+include examples/python/actor-lifetime/actor-lifetime.tesh
include examples/python/actor-migrate/actor-migrate.py
include examples/python/actor-migrate/actor-migrate.tesh
include examples/python/actor-suspend/actor-suspend.py
include examples/s4u/cloud-migration/s4u-cloud-migration.tesh
include examples/s4u/cloud-simple/s4u-cloud-simple.cpp
include examples/s4u/cloud-simple/s4u-cloud-simple.tesh
+include examples/s4u/comm-dependent/s4u-comm-dependent.cpp
+include examples/s4u/comm-dependent/s4u-comm-dependent.tesh
include examples/s4u/dht-chord/s4u-dht-chord-node.cpp
include examples/s4u/dht-chord/s4u-dht-chord.cpp
include examples/s4u/dht-chord/s4u-dht-chord.hpp
include examples/s4u/exec-async/s4u-exec-async.tesh
include examples/s4u/exec-basic/s4u-exec-basic.cpp
include examples/s4u/exec-basic/s4u-exec-basic.tesh
+include examples/s4u/exec-dependent/s4u-exec-dependent.cpp
+include examples/s4u/exec-dependent/s4u-exec-dependent.tesh
include examples/s4u/exec-dvfs/s4u-exec-dvfs.cpp
include examples/s4u/exec-dvfs/s4u-exec-dvfs.tesh
include examples/s4u/exec-ptask/s4u-exec-ptask.cpp
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-dependent/s4u-io-dependent.cpp
+include examples/s4u/io-dependent/s4u-io-dependent.tesh
include examples/s4u/io-disk-raw/s4u-io-disk-raw.cpp
include examples/s4u/io-disk-raw/s4u-io-disk-raw.tesh
include examples/s4u/io-file-remote/s4u-io-file-remote.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 examples/smpi/replay_multiple_manual_deploy/workload_compute_simple
include examples/smpi/replay_multiple_manual_deploy/workload_mixed2_same_time
include examples/smpi/replay_multiple_manual_deploy/workload_mixed2_same_time_and_resources
-include examples/smpi/smpi_msg_masterslave/deployment_masterslave_mailbox_smpi.xml
-include examples/smpi/smpi_msg_masterslave/masterslave_mailbox_smpi.c
-include examples/smpi/smpi_msg_masterslave/msg_smpi.tesh
+include examples/smpi/smpi_s4u_masterslave/deployment_masterslave_mailbox_smpi.xml
+include examples/smpi/smpi_s4u_masterslave/masterslave_mailbox_smpi.cpp
+include examples/smpi/smpi_s4u_masterslave/s4u_smpi.tesh
include examples/smpi/trace/trace.c
include examples/smpi/trace/trace.tesh
include examples/smpi/trace_call_location/adjust
include teshsuite/mc/dwarf-expression/dwarf-expression.tesh
include teshsuite/mc/dwarf/dwarf.cpp
include teshsuite/mc/dwarf/dwarf.tesh
-include teshsuite/mc/mutex-handling/mutex-handling.c
+include teshsuite/mc/mutex-handling/mutex-handling.cpp
include teshsuite/mc/mutex-handling/mutex-handling.tesh
-include teshsuite/mc/mutex-handling/mutex-handling_d.xml
include teshsuite/mc/mutex-handling/without-mutex-handling.tesh
include teshsuite/mc/random-bug/random-bug-nocrash.tesh
include teshsuite/mc/random-bug/random-bug-replay.tesh
include teshsuite/msg/app-chainsend/messages.h
include teshsuite/msg/app-chainsend/peer.c
include teshsuite/msg/app-chainsend/peer.h
-include teshsuite/msg/app-pingpong/app-pingpong.c
-include teshsuite/msg/app-pingpong/app-pingpong.tesh
include teshsuite/msg/app-pingpong/app-pingpong_d.xml
include teshsuite/msg/app-token-ring/app-token-ring.c
include teshsuite/msg/app-token-ring/app-token-ring.tesh
include teshsuite/msg/trace_integration/test-hbp2.5-hbp1.5.xml
include teshsuite/msg/trace_integration/trace_integration.c
include teshsuite/msg/trace_integration/trace_integration.tesh
+include teshsuite/python/borken-context/borken-context.py
+include teshsuite/python/borken-context/borken-context.tesh
+include teshsuite/python/borken-context/borken-context_d.xml
+include teshsuite/python/corrupt-stack/corrupt-stack.py
+include teshsuite/python/corrupt-stack/corrupt-stack.tesh
+include teshsuite/python/corrupt-stack/corrupt-stack_d.xml
include teshsuite/s4u/activity-lifecycle/activity-lifecycle.cpp
include teshsuite/s4u/activity-lifecycle/activity-lifecycle.tesh
include teshsuite/s4u/activity-lifecycle/testing_platform.xml
include teshsuite/smpi/mpich3-test/init/testlist
include teshsuite/smpi/mpich3-test/init/timeout.c
include teshsuite/smpi/mpich3-test/init/version.c
+include teshsuite/smpi/mpich3-test/io/async.c
+include teshsuite/smpi/mpich3-test/io/async_any.c
+include teshsuite/smpi/mpich3-test/io/bigtype.c
+include teshsuite/smpi/mpich3-test/io/external32-derived-dtype.c
+include teshsuite/smpi/mpich3-test/io/getextent.c
+include teshsuite/smpi/mpich3-test/io/hindexed_io.c
+include teshsuite/smpi/mpich3-test/io/i_aggregation1.c
+include teshsuite/smpi/mpich3-test/io/i_aggregation2.c
+include teshsuite/smpi/mpich3-test/io/i_bigtype.c
+include teshsuite/smpi/mpich3-test/io/i_coll_test.c
+include teshsuite/smpi/mpich3-test/io/i_darray_read.c
+include teshsuite/smpi/mpich3-test/io/i_hindexed.c
+include teshsuite/smpi/mpich3-test/io/i_hindexed_io.c
+include teshsuite/smpi/mpich3-test/io/i_noncontig.c
+include teshsuite/smpi/mpich3-test/io/i_noncontig_coll.c
+include teshsuite/smpi/mpich3-test/io/i_noncontig_coll2.c
+include teshsuite/smpi/mpich3-test/io/i_rdwrord.c
+include teshsuite/smpi/mpich3-test/io/i_setviewcur.c
+include teshsuite/smpi/mpich3-test/io/i_types_with_zeros.c
+include teshsuite/smpi/mpich3-test/io/rdwrord.c
+include teshsuite/smpi/mpich3-test/io/rdwrzero.c
+include teshsuite/smpi/mpich3-test/io/resized.c
+include teshsuite/smpi/mpich3-test/io/resized2.c
+include teshsuite/smpi/mpich3-test/io/setinfo.c
+include teshsuite/smpi/mpich3-test/io/setviewcur.c
+include teshsuite/smpi/mpich3-test/io/simple_collective.c
+include teshsuite/smpi/mpich3-test/io/testlist
+include teshsuite/smpi/mpich3-test/io/userioerr.c
include teshsuite/smpi/mpich3-test/perf/README
include teshsuite/smpi/mpich3-test/perf/allredtrace.c
include teshsuite/smpi/mpich3-test/perf/commcreatep.c
include teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.tesh
include teshsuite/smpi/timers/timers.c
include teshsuite/smpi/timers/timers.tesh
+include teshsuite/smpi/topo-cart-sub/topo-cart-sub.c
+include teshsuite/smpi/topo-cart-sub/topo-cart-sub.tesh
include teshsuite/smpi/type-hvector/type-hvector.c
include teshsuite/smpi/type-hvector/type-hvector.tesh
include teshsuite/smpi/type-indexed/type-indexed.c
include teshsuite/xbt/signals/signals.tesh
include tools/MSG_visualization/colorize.pl
include tools/MSG_visualization/trace2fig.pl
+include tools/address_sanitizer.supp
include tools/doxygen/fig2dev_postprocessor.pl
include tools/doxygen/xbt_log_extract_hierarchy.pl
include tools/fix-paje-trace.sh
include tools/graphicator/graphicator.tesh
include tools/normalize-pointers.py
include tools/pkg-config/simgrid.pc.in
-include tools/sanitizers.supp
include tools/sg_xml_unit_converter.py
include tools/simgrid.supp
include tools/simgrid2vite.sed
include tools/tesh/set-timeout.tesh
include tools/tesh/setenv.tesh
include tools/tesh/tesh.py
+include tools/thread_sanitizer.supp
include AUTHORS
include CITATION.bib
include CMakeLists.txt
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 docs/source/tuto_smpi/img/lu.S.4.png
include docs/source/tuto_smpi/roundtrip.c
include examples/README.rst
+include examples/c/CMakeLists.txt
include examples/deprecated/java/.classpath
include examples/deprecated/java/.project
include examples/deprecated/java/CMakeLists.txt
include examples/platforms/wifi.xml
include examples/python/CMakeLists.txt
include examples/python/actor-create/actor-create_d.xml
-include examples/python/actor-lifetime/actor-lifetime.py
-include examples/python/actor-lifetime/actor-lifetime.tesh
include examples/python/actor-lifetime/actor-lifetime_d.xml
include examples/python/async-wait/async-wait_d.xml
include examples/python/async-waitall/async-waitall_d.xml
include examples/smpi/mc/only_send_deterministic.tesh
include examples/smpi/replay_multiple/CMakeLists.txt
include examples/smpi/replay_multiple_manual_deploy/CMakeLists.txt
-include examples/smpi/smpi_msg_masterslave/CMakeLists.txt
+include examples/smpi/smpi_s4u_masterslave/CMakeLists.txt
include include/simgrid/Exception.hpp
include include/simgrid/actor.h
include include/simgrid/barrier.h
include include/simgrid/chrono.hpp
+include include/simgrid/comm.h
include include/simgrid/cond.h
include include/simgrid/config.h.in
include include/simgrid/engine.h
include include/simgrid/simix/blocking_simcall.hpp
include include/simgrid/smpi/replay.hpp
include include/simgrid/storage.h
+include include/simgrid/version.h.in
include include/simgrid/vm.h
include include/simgrid/zone.h
include include/smpi/forward.hpp
include include/smpi/smpi_main.h
include include/xbt.h
include include/xbt/Extendable.hpp
+include include/xbt/PropertyHolder.hpp
include include/xbt/asserts.h
include include/xbt/automaton.h
include include/xbt/automaton.hpp
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 src/simdag/simdag_private.hpp
include src/simgrid/Exception.cpp
include src/simgrid/sg_config.cpp
+include src/simgrid/sg_version.cpp
include src/simgrid/util.hpp
-include src/simgrid/version.h.in
include src/simix/libsmx.cpp
include src/simix/popping.cpp
include src/simix/popping_accessors.hpp
include src/smpi/include/smpi_actor.hpp
include src/smpi/include/smpi_coll.hpp
include src/smpi/include/smpi_comm.hpp
+include src/smpi/include/smpi_config.hpp
include src/smpi/include/smpi_datatype.hpp
include src/smpi/include/smpi_datatype_derived.hpp
include src/smpi/include/smpi_errhandler.hpp
include src/smpi/internals/instr_smpi.cpp
include src/smpi/internals/smpi_actor.cpp
include src/smpi/internals/smpi_bench.cpp
+include src/smpi/internals/smpi_config.cpp
include src/smpi/internals/smpi_deployment.cpp
include src/smpi/internals/smpi_global.cpp
include src/smpi/internals/smpi_host.cpp
include src/smpi/smpitools.sh
include src/surf/HostImpl.cpp
include src/surf/HostImpl.hpp
-include src/surf/PropertyHolder.cpp
-include src/surf/PropertyHolder.hpp
include src/surf/StorageImpl.cpp
include src/surf/StorageImpl.hpp
include src/surf/cpu_cas01.cpp
include src/surf/xml/surfxml_parseplatf.cpp
include src/surf/xml/surfxml_sax_cb.cpp
include src/xbt/OsSemaphore.hpp
+include src/xbt/PropertyHolder.cpp
include src/xbt/automaton/automaton.c
include src/xbt/automaton/automaton_lexer.yy.c
include src/xbt/automaton/automatonparse_promela.c
include teshsuite/lua/lua_platforms.tesh
include teshsuite/mc/CMakeLists.txt
include teshsuite/msg/CMakeLists.txt
+include teshsuite/python/CMakeLists.txt
include teshsuite/s4u/CMakeLists.txt
include teshsuite/simdag/CMakeLists.txt
include teshsuite/simix/CMakeLists.txt
include teshsuite/smpi/mpich3-test/group/CMakeLists.txt
include teshsuite/smpi/mpich3-test/info/CMakeLists.txt
include teshsuite/smpi/mpich3-test/init/CMakeLists.txt
+include teshsuite/smpi/mpich3-test/io/CMakeLists.txt
include teshsuite/smpi/mpich3-test/perf/CMakeLists.txt
include teshsuite/smpi/mpich3-test/pt2pt/CMakeLists.txt
include teshsuite/smpi/mpich3-test/rma/CMakeLists.txt
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
+ _ _____ ____ __
+__ _____ _ __ ___(_) ___ _ __ |___ / |___ \ / /_
+\ \ / / _ \ '__/ __| |/ _ \| '_ \ |_ \ __) | '_ \
+ \ V / __/ | \__ \ | (_) | | | | ___) | / __/| (_) |
+ \_/ \___|_| |___/_|\___/|_| |_| |____(_)_____|\___/
+ (unreleased)
+
_ _____ ____ ____
__ _____ _ __ ___(_) ___ _ __ |___ / |___ \| ___|
\ \ / / _ \ '__/ __| |/ _ \| '_ \ |_ \ __) |___ \
\ V / __/ | \__ \ | (_) | | | | ___) | / __/ ___) |
\_/ \___|_| |___/_|\___/|_| |_| |____(_)_____|____/
- (not released yet)
+ February 2. 2020 (02 02 2020)
+
+The Palindrom Day Release.
+
+ * Improve the Python usability (stability and documentation).
+ * Further deprecate MSG: you now have to pass -Denable-MSG=ON to cmake.
+ * SimDAG++: Automatic dependencies on S4U activities (experimental).
+ * (+ many bug fixes and internal refactoring)
_ _____ ____ _ _
__ _____ _ __ ___(_) ___ _ __ |___ / |___ \| || |
* Introduce <disk> (cleaner logic than <storage>).
* SMPI: Implement Errhandlers and some more MPI3.1 calls.
* (+ many bug fixes and internal refactorings)
+
_ _____ ____ _____
__ _____ _ __ ___(_) ___ _ __ |___ / |___ \|___ /
\ \ / / _ \ '__/ __| |/ _ \| '_ \ |_ \ __) | |_ \
* SMPI: more of MPI3.1; some MPI/IO and async collectives.
* Python bindings can now be installed from pip.
* (+ a whole load of bug fixes and internal refactorings)
+
_ _____ ____ ____
__ _____ _ __ ___(_) ___ _ __ |___ / |___ \|___ \
\ \ / / _ \ '__/ __| |/ _ \| '_ \ |_ \ __) | __) |
* Doc: SMPI tutorial and platform description ported to RTD
* Many internal cleanups leading to some user-level speedups
* (+ the classical bug fixes and internal refactorings)
+
_ _____ ____ _
__ _____ _ __ ___(_) ___ _ __ |___ / |___ \/ |
\ \ / / _ \ '__/ __| |/ _ \| '_ \ |_ \ __) | |
* Reduce the changes to the binary interface of MSG,
accidentally introduced by v3.19.
+
_ _____ _ ___
__ _____ _ __ ___(_) ___ _ __ |___ / / |/ _ \
\ \ / / _ \ '__/ __| |/ _ \| '_ \ |_ \ | | (_) |
* SMPI: Support ICC, better testing on classical proxy apps.
* Some kernel headers are now installed, allowing external plugins.
* (+ the classical bug fixes and doc improvement)
+
_ _____ _ ___
__ _____ _ __ ___(_) ___ _ __ |___ / / |( _ )
\ \ / / _ \ '__/ __| |/ _ \| '_ \ |_ \ | |/ _ \
* New model: energy consumption due to the network.
* Major cleanups in the disk and storage subsystems.
* (+ further deprecate XBT, bug fixes and doc improvement)
+
_ _____ _ _____
__ _____ _ __ ___(_) ___ _ __ |___ / / |___ |
\ \ / / _ \ '__/ __| |/ _ \| '_ \ |_ \ | | / /
* The coverage of our tests is above 80%.
* All memleaks but one plugged; A dozen of bugs fixed.
* XBT: Further replace XBT with std::* constructs.
+
_ _____ _ __
__ _____ _ __ ___(_) ___ _ __ |___ / / |/ /_
\ \ / / _ \ '__/ __| |/ _ \| '_ \ |_ \ | | '_ \
* SMPI: Further performance improvements; RMA support.
* Cloud: Multi-core VMs (do not overcommit them yet)
* (+ bug fixes, cleanups and documentation improvements)
+
_ _____ _ ____
__ _____ _ __ ___(_) ___ _ __ |___ / / | ___|
\ \ / / _ \ '__/ __| |/ _ \| '_ \ |_ \ | |___ \
* SMPI: Support MPI 2.2; Convert internals to C++ (TBC).
* Java: Massive memleaks and performance issues fixed.
* (+ bug fixes, cleanups and documentation improvements)
+
_ _____ _ _ _ _ ____ ___
__ _____ _ __ ___(_) ___ _ __ |___ / / | || | / | ___|/ _ \
\ \ / / _ \ '__/ __| |/ _ \| '_ \ |_ \ | | || |_ | |___ \ (_) |
The Christmas Pi Release (better approximation).
* Fix various glitches in the previous release.
+
_ _____ _ _ _
__ _____ _ __ ___(_) ___ _ __ |___ / / | || |
\ \ / / _ \ '__/ __| |/ _ \| '_ \ |_ \ | | || |_
- MSG, SimDag, MPI interfaces mostly unchanged
* The model-checker now works on FreeBSD too.
+
_ _____ _ _____
__ _____ _ __ ___(_) ___ _ __ |___ / / |___ /
\ \ / / _ \ '__/ __| |/ _ \| '_ \ |_ \ | | |_ \
- All host manipulations now done in S4U
- SimDag was mostly rewritten on top of S4U
- MSG & SimDag interfaces mostly unchanged
+
_ _____ _ ____
__ _____ _ __ ___(_) ___ _ __ |___ / / |___ \
\ \ / / _ \ '__/ __| |/ _ \| '_ \ |_ \ | | __) |
[local copy](docs/source/Installing_SimGrid.rst). TL;DR:
```
cmake -DCMAKE_INSTALL_PREFIX=/opt/simgrid .
-# Check the full list of options with `cmake -LH`
+# Check the full list of options with `cmake -LH`
make
make install
```
for(i in 1:(length(h$counts)-1)){
if(h$counts[i]!=0 || h$counts[i+1]!=0){
counts2[j]<-h$counts[i]
- breaks2[j+1]<-h$breaks[i+1];
+ breaks2[j+1]<-h$breaks[i+1]
j<-j+1
}
}
-/* 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
mybench->output = fopen(tracefile, "a+");
if (mybench->output == NULL)
printf("Error while opening the tracefile");
-
}
/* Initializing StarPU benchmarking */
mybench->output = fopen(tracefile, "a+");
if (mybench->output == NULL)
printf("Error while opening the tracefile");
-
}
/* Start benchmarking using macros */
-/* 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
XBT_ATTRIB_NORETURN= \
XBT_ATTRIB_UNUSED= \
XBT_ATTRIB_DEPRECATED_v328(m)= \
- XBT_ATTRIB_DEPRECATED_v329(m)=
+ XBT_ATTRIB_DEPRECATED_v329(m)= \
+ XBT_ATTRIB_DEPRECATED_v330(m)=
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
https://framagit.org/simgrid/simgrid-template-s4u/pipelines
https://framagit.org/simgrid/external-projects-ci/pipelines
- The python module builds (see below).
+ - You can have a simgrid.jar from jenkins/macosx + AppVeyor
@subsection inside_release_c_releasing Actually releasing SimGrid
- docs/source/conf.py
- setup.py
- Commit and push to both framagit and github
-- Wait for both appveyor and jenkins/highsierra to complete the build
+- Wait for both appveyor and jenkins/osX to complete the build
- If it's not successful, fix it and push again
- Once it's successful everywhere: merge 'master' into 'stable' and push it to framagit
+ - You can interrupt the build on jenkins, as it was tested just before
- This builds the tar.gz and jar artefacts. The old doc says how to do manually if something goes wrong.
- Do not merge into 'stable' before appveyor and jenkins are done,
or your jarfile will not contain the code you expect for win and mac.
- Add a link to the version of the ChangeLog that comes with this tag.
- Update the website
- emacs org/org-templates/level-0.org to change the release version, the tgz link and the jar link.
- - make -C org all sync
- jed .gitlab-ci.yml
- Change the link to the SimGrid-doc-3_XX.zip file
- Only keep 2 versions so that people don't find older ones in google
@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
+if [ -e /opt/simgrid ] ; then chmod +x /opt/simgrid; fi
set -e
-if [ "x$1" != 'xdoxy' -a -e build/xml ] ; then
+if [ "x$1" != 'xdoxy' ] && [ -e build/xml ] ; then
echo "Doxygen not rerun: 'doxy' was not provided as an argument"
else
rm -rf build/xml source/api/
- cd source; doxygen; cd ..
+ (cd source; doxygen 2>&1; cd ..) | grep -v "is not documented." # XXXXX Reduce the verbosity for now
fi
-if [ "x$1" != 'xjava' -a -e source/java ] ; then
+if [ "x$1" != 'xjava' ] && [ -e source/java ] ; then
echo "javasphinx not rerun: 'java' was not provided as an argument"
else
rm -rf source/java
rm -f source/java/org/simgrid/msg/package-index.rst # api_generated/source_java_org_simgrid_msg_package-index.rst
for f in source/java/org/simgrid/msg/* ; do
# Add the package name to the page titles
- (echo -n "class org.simgrid.msg."; cat $f )>tmp
+ (printf "class org.simgrid.msg."; cat $f )>tmp
mv tmp $f
sed -i 's/==/========================/' $f # That's the right length knowing that I add 'class org.simgrid.msg.'
done
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
done
set +e # Don't fail
-if [ -e /usr/bin/linkchecker ] ; then
+if [ -e /usr/bin/linkchecker ] ; then
linkchecker --no-status -o csv --ignore-url='.*\.css$' --ignore-url=build/html/_modules --ignore-url=public/java/org build/html \
| grep -v '^#' \
| grep -v 'urlname;parentname;baseref;result;warningstring'
--- /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.
+
+# These ones trigger a bug in autodoxy, that get confused with the const in the function parameter
+# So I document them manually in the rst for now. Shame, weak.
+.. autodoxyvar:: simgrid::s4u::Link::on_communicate
+.. autodoxyvar:: simgrid::s4u::Actor::on_host_change
+.. autodoxyvar:: simgrid::s4u::Exec::on_completion
+.. autodoxyvar:: simgrid::s4u::Exec::on_start
+
+# This is a bug in find-missing, as these symbols are actually documented
+.. autodoxymethod:: simgrid::s4u::Host::route_to(const Host *dest, std::vector< Link * > &links, double *latency)
+.. autodoxymethod:: simgrid::s4u::Host::route_to(const Host *dest, std::vector< kernel::resource::LinkImpl * > &links, double *latency)
+
+
+# These could be hidden as private things, eg in s4u_Exec.cpp
+.. autodoxymethod:: simgrid::s4u::ExecPar::get_remaining()
+.. autodoxymethod:: simgrid::s4u::ExecPar::get_remaining_ratio()
+.. autodoxymethod:: simgrid::s4u::ExecPar::start()
+.. autodoxymethod:: simgrid::s4u::ExecSeq::get_remaining()
+.. autodoxymethod:: simgrid::s4u::ExecSeq::get_remaining_ratio()
+.. autodoxymethod:: simgrid::s4u::ExecSeq::set_host(Host *host)
+.. autodoxymethod:: simgrid::s4u::ExecSeq::start()
+
+# 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)
+member ::MIN is of kind define
+member ::MAX is of kind define
+member ::MSG_TASK_UNINITIALIZED is of kind define
+member ::MSG_init is of kind define
+member ::MSG_task_recv is of kind define
+member ::MSG_task_recv_bounded is of kind define
+member ::msg_error_t is of kind enum
+
+# Storage must die
+.. autodoxymethod:: sg_host_get_attached_storage_list(const_sg_host_t host)
+.. autodoxymethod:: sg_host_get_mounted_storage_list(sg_host_t host)
+.. autodoxymethod:: simgrid::s4u::Host::get_attached_storages()
+.. autodoxymethod:: simgrid::s4u::Host::get_mounted_storages()
+
+# These should not be public
+.. autodoxymethod:: simgrid::s4u::Link::get_impl()
+.. autodoxymethod:: simgrid::s4u::NetZone::get_impl()
+.. autodoxymethod:: simgrid::s4u::VirtualMachine::get_impl()
+.. autodoxymethod:: simgrid::s4u::Activity::get_impl()
+.. autodoxymethod:: simgrid::s4u::Comm::~Comm()
+.. autodoxymethod:: simgrid::s4u::Exec::~Exec()
+.. autodoxymethod:: simgrid::s4u::ExecPar::~ExecPar()
+.. autodoxymethod:: simgrid::s4u::ExecSeq::~ExecSeq()
+.. autodoxymethod:: simgrid::s4u::Io::~Io()
+
+# 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
+.. autodoxyvar:: ::const_sg_host_t
+.. autodoxyvar:: ::const_sg_storage_t
+.. autodoxyvar:: ::const_msg_comm_t
+.. autodoxyvar:: ::const_msg_task_t
+.. autodoxyvar:: ::const_sg_cond_t
+.. autodoxyvar:: ::const_sg_disk_t
+.. autodoxyvar:: ::const_sg_file_t
+.. autodoxyvar:: ::const_sg_link_t
+.. autodoxyvar:: ::const_sg_netzone_t
+.. autodoxyvar:: ::const_sg_vm_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)
for obj in doxy_vars:
for meth in sorted(doxy_vars[obj]):
print(".. autodoxyvar:: {}::{}".format(obj, meth))
-
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)=
+ XBT_ATTRIB_DEPRECATED_v329(m)= \
+ XBT_ATTRIB_DEPRECATED_v330(m)=
-.. Copyright 2005-2019
+.. Copyright 2005-2020
.. _install:
version for now.
enable_java (on/OFF)
- Generates the java bindings of SimGrid.
+ Generates the java bindings of SimGrid. You must also enable MSG for
+ this to work.
enable_jedule (on/OFF)
Produces execution traces from SimDag simulations, which can then be visualized with the
simulation speed** even when the model checker is not activated at
run time.
+enable_msg (on/OFF)
+ Activates the :ref:`MSG <MSG_doc>` legacy interface.
+
enable_ns3 (on/OFF)
Activates the ns-3 bindings. See section :ref:`model_ns3`.
Python-specific instructions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-Recompiling the Python bindings from the source should be as easy as:
+Once you have the Python development headers installed as well as a
+recent version of the `pybind11 <https://pybind11.readthedocs.io/en/stable/>`
+module (version at least 2.4), recompiling the Python bindings from
+the source should be as easy as:
.. code-block:: shell
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)
xpath_query = './/compoundname[text()="%s"]/..' % self.fullname
match = get_doxygen_root().xpath(xpath_query)
if len(match) != 1:
- raise ExtensionError('[autodoxy] could not find class (fullname="%s"). I tried'
+ raise ExtensionError('[autodoxy] could not find class (fullname="%s"). I tried '
'the following xpath: "%s"' % (self.fullname, xpath_query))
self.object = match[0]
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."
- .format(obj, meth, candidates[0].find('argsstring').text, obj, meth, self.argsstring))
+ 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
else:
rtype = rtype_el.text
- # print("rtype: {}".format(rtype))
+# print("rtype: {}".format(rtype))
signame = (rtype and (rtype + ' ') or '') + self.klassname + "::" + self.objname
return self.format_template_name() + signame
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)
if filename[-3:] == '.py':
language = 'Python'
langcode = 'py'
+ elif filename[-2:] == '.c':
+ language = 'C'
+ langcode = 'c'
elif filename[-4:] == '.cpp':
language = 'C++'
langcode = 'cpp'
language = 'XML'
langcode = 'xml'
else:
- raise Exception("Unknown language '{}'. Please choose '.cpp', '.py' or '.xml'".format(language))
+ raise Exception("Unknown language '{}'. Please choose '.cpp', '.py', '.c' or '.xml'".format(language))
for idx, line in enumerate(self.content.data):
self.content.data[idx] = ' ' + line
app.connect('builder-inited', add_assets)
app.connect('build-finished', copy_assets)
-
--- /dev/null
+object#TOC {
+ max-width: 100%;
+}
\ No newline at end of file
the process of releasing SimGrid 4. So MSG is frozen and will
probably never evolve. If you are starting a new project, you
should consider S4U instead. Note that the support for MSG will not
- be removed from SimGrid before 2020 at least.
+ be removed from SimGrid before 2020Q4 or 2021Q1.
+
+ This interface is disabled by default. Pass -Denable_msg=ON to
+ cmake if you still need it.
MSG is a simple API to write algorithms organized with Concurrent
Sequential Processes (CSP) that interact by exchanging messages. It
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
+.. autodoxyclass:: simgrid::s4u::Actor
- **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.
+.. doxygentypedef:: aid_t
-Querying info about activities
-------------------------------
+Basic management
+----------------
- .. 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
+.. tabs::
-Activities lifecycle
---------------------
+ .. group-tab:: C++
- .. 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)
+ .. code:: C++
+ #include <simgrid/s4u/Actor.hpp>
-.. _API_s4u_Actor:
+ .. doxygentypedef:: ActorPtr
-===========
-class Actor
-===========
+ .. group-tab:: Python
-.. doxygentypedef:: ActorPtr
+ .. code:: Python
-.. doxygentypedef:: aid_t
+ from simgrid import Actor
-.. autodoxyclass:: simgrid::s4u::Actor
+ .. 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_ref(const_sg_actor_t actor)
+ .. autodoxymethod:: sg_actor_unref(const_sg_actor_t actor)
Creating actors
---------------
.. automethod:: simgrid.Actor.create
-Searching specific actors
--------------------------
+ .. group-tab:: C
+
+ .. 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, const char *const *argv)
+
+ .. autodoxymethod:: sg_actor_attach(const char *name, void *data, sg_host_t host, xbt_dict_t properties)
+ .. autodoxymethod:: sg_actor_detach()
+
+Retrieving actors
+-----------------
.. tabs::
.. automethod:: simgrid.Actor.by_pid
.. automethod:: simgrid.Actor.self
-Querying info about actors
---------------------------
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_actor_by_PID(aid_t pid)
+ .. autodoxymethod:: sg_actor_self()
+
+Querying info
+-------------
.. tabs::
.. 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_creation
.. autodoxyvar:: simgrid::s4u::Actor::on_suspend
+ .. cpp:var:: xbt::signal<void(const Actor&, const Host & previous_location)> Actor::on_host_change
+
+ Signal fired when an actor is migrated from one host to another.
+
.. 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
-=========
-s4u::Comm
-=========
+ .. autofunction:: simgrid.this_actor.get_host
+ .. autofunction:: simgrid.this_actor.set_host
-.. doxygentypedef:: CommPtr
+ .. group-tab:: C
-.. doxygenclass:: simgrid::s4u::Comm
- :members:
- :protected-members:
- :undoc-members:
+ .. 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()
-.. _API_s4u_ConditionVariable:
+Suspending and resuming
+-----------------------
+
+.. tabs::
-======================
-s4u::ConditionVariable
-======================
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::this_actor::suspend()
+ .. autodoxymethod:: simgrid::s4u::this_actor::yield()
-.. doxygentypedef:: ConditionVariablePtr
+ .. group-tab:: Python
-.. doxygenclass:: simgrid::s4u::ConditionVariable
- :members:
- :protected-members:
- :undoc-members:
+ .. autofunction:: simgrid.this_actor.suspend
+ .. autofunction:: simgrid.this_actor.yield_
-.. _API_s4u_Disk:
+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::
-============
-s4u::Disk
-============
+ .. 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
-.. doxygenclass:: simgrid::s4u::Disk
- :members:
- :protected-members:
- :undoc-members:
+ .. autofunction:: simgrid.this_actor.exit
+ .. autofunction:: simgrid.this_actor.on_exit
.. _API_s4u_Engine:
-===========
-s4u::Engine
-===========
+====================
+ Simulation Engine
+====================
-.. doxygenclass:: simgrid::s4u::Engine
- :members:
- :protected-members:
- :undoc-members:
+.. autodoxyclass:: simgrid::s4u::Engine
-.. _API_s4u_Exec:
+Initialization
+--------------
-=========
-s4u::Exec
-=========
+.. tabs::
-.. doxygentypedef:: ExecPtr
+ .. group-tab:: C++
-.. doxygenclass:: simgrid::s4u::Exec
- :members:
- :protected-members:
- :undoc-members:
+ .. 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)
-.. _API_s4u_ExecSeq:
+ .. 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 >))
-============
-s4u::ExecSeq
-============
+ .. group-tab:: Python
+
+ .. automethod:: simgrid.Engine.load_deployment
+ .. automethod:: simgrid.Engine.load_platform
+ .. automethod:: simgrid.Engine.register_actor
-.. doxygentypedef:: ExecSeqPtr
+ .. group-tab:: C
-.. doxygenclass:: simgrid::s4u::ExecSeq
- :members:
- :protected-members:
- :undoc-members:
+ .. autodoxymethod:: simgrid_init
-.. _API_s4u_ExecPar:
+ .. autodoxymethod:: simgrid_load_deployment
+ .. autodoxymethod:: simgrid_load_platform
+ .. autodoxymethod:: simgrid_register_default
+ .. autodoxymethod:: simgrid_register_function
-============
-s4u::ExecPar
-============
+Run the simulation
+------------------
-.. doxygentypedef:: ExecParPtr
+.. tabs::
-.. doxygenclass:: simgrid::s4u::ExecPar
- :members:
- :protected-members:
- :undoc-members:
+ .. group-tab:: C++
-.. _API_s4u_Host:
+ .. autodoxymethod:: simgrid::s4u::Engine::get_clock()
+ .. autodoxymethod:: simgrid::s4u::Engine::run()
-=========
-s4u::Host
-=========
+ .. group-tab:: Python
+
+ .. automethod:: simgrid.Engine.get_clock
+ .. automethod:: simgrid.Engine.run
-.. doxygenclass:: simgrid::s4u::Host
- :members:
- :protected-members:
- :undoc-members:
+ .. group-tab:: C
-.. _API_s4u_Io:
+ .. autodoxymethod:: simgrid_get_clock
+ .. autodoxymethod:: simgrid_run
-=======
-s4u::Io
-=======
+Retrieving actors
+-----------------
-.. doxygentypedef:: IoPtr
+.. tabs::
-.. doxygenclass:: simgrid::s4u::Io
- :members:
- :protected-members:
- :undoc-members:
+ .. group-tab:: C++
-.. _API_s4u_Link:
+ .. 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)
-=========
-s4u::Link
-=========
+ .. group-tab:: C
-.. doxygenclass:: simgrid::s4u::Link
- :members:
- :protected-members:
- :undoc-members:
+ .. 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
+
+ .. group-tab:: C
+
+ See also :cpp:func:`sg_host_list` and :cpp:func:`sg_host_count`.
+
+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:
-============
-s4u::Mailbox
-============
+================
+ class Mailbox
+================
+
+.. autodoxyclass:: simgrid::s4u::Mailbox
Please also refer to the :ref:`full doc on s4u::Mailbox <s4u_mailbox>`.
-.. doxygenclass:: simgrid::s4u::Mailbox
- :members:
- :protected-members:
- :undoc-members:
+Basic management
+----------------
-.. _API_s4u_Mutex:
+.. tabs::
-==========
-s4u::Mutex
-==========
+ .. group-tab:: C++
-.. doxygentypedef:: MutexPtr
+ .. code-block:: C++
-.. doxygenclass:: simgrid::s4u::Mutex
- :members:
- :protected-members:
- :undoc-members:
+ #include <simgrid/s4u/Mailbox.hpp>
-.. _API_s4u_NetZone:
+ 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)
-============
-s4u::NetZone
-============
+ .. group-tab:: Python
-.. doxygenclass:: simgrid::s4u::NetZone
- :members:
- :protected-members:
- :undoc-members:
+ .. automethod:: simgrid.Mailbox.by_name
-.. _API_s4u_Semaphore:
+Querying info
+-------------
-==============
-s4u::Semaphore
-==============
+.. tabs::
-.. doxygentypedef:: SemaphorePtr
+ .. group-tab:: C++
-.. doxygenclass:: simgrid::s4u::Semaphore
- :members:
- :protected-members:
- :undoc-members:
+ .. autodoxymethod:: simgrid::s4u::Mailbox::get_cname() const
+ .. autodoxymethod:: simgrid::s4u::Mailbox::get_name() const
-.. _API_s4u_VirtualMachine:
+ .. group-tab:: Python
-===================
-s4u::VirtualMachine
-===================
+ .. autoattribute:: simgrid.Mailbox.name
-.. doxygenclass:: simgrid::s4u::VirtualMachine
- :members:
- :protected-members:
- :undoc-members:
+Sending data
+------------
-C API Reference
-***************
+.. tabs::
-==============
-Main functions
-==============
+ .. group-tab:: C++
-.. 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
+ .. 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)
-==================
-Condition Variable
-==================
+ .. group-tab:: Python
-See also the :ref:`C++ API <API_s4u_ConditionVariable>`.
+ .. automethod:: simgrid.Mailbox.put
+ .. automethod:: simgrid.Mailbox.put_async
-.. doxygenfunction:: sg_cond_init
-.. doxygenfunction:: sg_cond_notify_all
-.. doxygenfunction:: sg_cond_notify_one
-.. doxygenfunction:: sg_cond_wait
-.. doxygenfunction:: sg_cond_wait_for
-Python API Reference
-********************
+Receiving data
+--------------
-The Python API is automatically generated with pybind11. It closely mimicks the C++
-API, to which you should refer for more information.
+.. tabs::
-==========
-this_actor
-==========
+ .. group-tab:: C++
-.. automodule:: simgrid.this_actor
- :members:
+ .. 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()
-===========
-Class Actor
-===========
+ .. group-tab:: Python
+
+ .. automethod:: simgrid.Mailbox.get
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_mailbox_listen(const char *alias)
+
+Receiving actor
+---------------
+
+See :ref:`s4u_receiving_actor`.
-.. autoclass:: simgrid.Actor
- :members:
+.. 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:
+
+=========
+Resources
+=========
+
+.. _API_s4u_Disk:
+
+=============
+ class Disk
+=============
+
+.. autodoxyclass:: simgrid::s4u::Disk
+
+Basic management
+----------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. code-block:: C++
+
+ #include <simgrid/s4u/Disk.hpp>
+
+ Note that there is no DiskPtr type, and that you cannot use the RAII
+ idiom on disks because SimGrid does not allow (yet) to create nor
+ destroy resources once the simulation is started.
+
+
+Querying info
+-------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Disk::get_cname() const
+ .. autodoxymethod:: simgrid::s4u::Disk::get_host() const
+ .. autodoxymethod:: simgrid::s4u::Disk::get_name() const
+ .. autodoxymethod:: simgrid::s4u::Disk::get_properties() const
+ .. autodoxymethod:: simgrid::s4u::Disk::get_property(const std::string &key) const
+ .. autodoxymethod:: simgrid::s4u::Disk::get_read_bandwidth() const
+ .. autodoxymethod:: simgrid::s4u::Disk::get_write_bandwidth() const
+ .. autodoxymethod:: simgrid::s4u::Disk::set_property(const std::string &, const std::string &value)
+
+I/O operations
+--------------
+
+.. tabs::
-==========
-Class Comm
-==========
+ .. group-tab:: C++
-.. autoclass:: simgrid.Comm
- :members:
+ .. autodoxymethod:: simgrid::s4u::Disk::io_init(sg_size_t size, s4u::Io::OpType type)
+ .. autodoxymethod:: simgrid::s4u::Disk::read(sg_size_t size)
+ .. autodoxymethod:: simgrid::s4u::Disk::read_async(sg_size_t size)
+ .. autodoxymethod:: simgrid::s4u::Disk::write(sg_size_t size)
+ .. autodoxymethod:: simgrid::s4u::Disk::write_async(sg_size_t size)
-============
-Class Engine
-============
+Signals
+-------
-.. autoclass:: simgrid.Engine
- :members:
+.. tabs::
-==========
-Class Exec
-==========
+ .. group-tab:: C++
-.. autoclass:: simgrid.Exec
- :members:
+ .. autodoxyvar:: simgrid::s4u::Disk::on_creation
+ .. autodoxyvar:: simgrid::s4u::Disk::on_destruction
+ .. autodoxyvar:: simgrid::s4u::Disk::on_state_change
-==========
-Class Host
-==========
-.. autoclass:: simgrid.Host
- :members:
+.. _API_s4u_Host:
=============
-Class Mailbox
+ class Host
=============
-.. autoclass:: simgrid.Mailbox
- :members:
+.. autodoxyclass:: simgrid::s4u::Host
+
+Basic management
+----------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. code-block:: C++
+
+ #include <simgrid/s4u/Host.hpp>
+
+ Note that there is no HostPtr type, and that you cannot use the RAII
+ idiom on hosts because SimGrid does not allow (yet) to create nor
+ destroy resources once the simulation is started.
+
+ .. autodoxymethod:: simgrid::s4u::Host::destroy()
+
+ .. group-tab:: Python
+
+ .. code:: Python
+
+ from simgrid import Host
+
+ .. group-tab:: C
+
+ .. code:: C
+
+ #include <simgrid/host.h>
+
+ .. doxygentypedef:: sg_host_t
+ .. cpp:type:: const s4u_Host* const_sg_host_t
+
+ Pointer to a constant host object.
+
+Retrieving hosts
+----------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ See also :cpp:func:`simgrid::s4u::Engine::get_all_hosts`.
+
+ .. autodoxymethod:: simgrid::s4u::Host::by_name(const std::string &name)
+ .. autodoxymethod:: simgrid::s4u::Host::by_name_or_null(const std::string &name)
+ .. autodoxymethod:: simgrid::s4u::Host::current()
+
+ .. group-tab:: Python
+
+ See also :py:func:`simgrid.Engine.get_all_hosts`.
+
+ .. automethod:: simgrid.Host.by_name
+ .. automethod:: simgrid.Host.current
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_host_by_name(const char *name)
+ .. autodoxymethod:: sg_host_count()
+ .. autodoxymethod:: sg_host_list()
+ .. autodoxymethod:: sg_hosts_as_dynar()
+
+Querying info
+-------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Host::get_cname() const
+ .. autodoxymethod:: simgrid::s4u::Host::get_core_count() const
+ .. autodoxymethod:: simgrid::s4u::Host::get_name() const
+ .. autodoxymethod:: simgrid::s4u::Host::get_available_speed() const
+ .. autodoxymethod:: simgrid::s4u::Host::get_load() const
+ .. autodoxymethod:: simgrid::s4u::Host::get_speed() const
+
+ .. group-tab:: Python
+
+ .. autoattribute:: simgrid.Host.name
+ .. autoattribute:: simgrid.Host.load
+ .. autoattribute:: simgrid.Host.pstate
+ .. autoattribute:: simgrid.Host.speed
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_host_core_count(const_sg_host_t host)
+ .. autodoxymethod:: sg_host_dump(const_sg_host_t ws)
+ .. autodoxymethod:: sg_host_get_name(const_sg_host_t host)
+ .. autodoxymethod:: sg_host_load(const_sg_host_t host)
+ .. autodoxymethod:: sg_host_speed(const_sg_host_t host)
+
+User data and properties
+------------------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Host::get_properties() const
+ .. autodoxymethod:: simgrid::s4u::Host::get_property(const std::string &key) const
+ .. autodoxymethod:: simgrid::s4u::Host::set_properties(const std::map< std::string, std::string > &properties)
+ .. autodoxymethod:: simgrid::s4u::Host::set_property(const std::string &key, const std::string &value)
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_host_set_property_value(sg_host_t host, const char *name, const char *value)
+ .. autodoxymethod:: sg_host_get_properties(const_sg_host_t host)
+ .. autodoxymethod:: sg_host_get_property_value(const_sg_host_t host, const char *name)
+ .. autodoxymethod:: sg_host_extension_create(void(*deleter)(void *))
+ .. autodoxymethod:: sg_host_extension_get(const_sg_host_t host, size_t rank)
+
+Retrieving components
+---------------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Host::add_disk(Disk *disk)
+ .. autodoxymethod:: simgrid::s4u::Host::get_actor_count() const
+ .. autodoxymethod:: simgrid::s4u::Host::get_all_actors() const
+ .. autodoxymethod:: simgrid::s4u::Host::get_disks() const
+ .. autodoxymethod:: simgrid::s4u::Host::remove_disk(const std::string &disk_name)
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_host_get_actor_list(const_sg_host_t host, xbt_dynar_t whereto)
+
+On/Off
+------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Host::is_on() const
+ .. autodoxymethod:: simgrid::s4u::Host::turn_off()
+ .. autodoxymethod:: simgrid::s4u::Host::turn_on()
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_host_is_on(const_sg_host_t host)
+ .. autodoxymethod:: sg_host_turn_off(sg_host_t host)
+ .. autodoxymethod:: sg_host_turn_on(sg_host_t host)
+
+DVFS
+----
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Host::get_pstate() const
+ .. autodoxymethod:: simgrid::s4u::Host::get_pstate_count() const
+ .. autodoxymethod:: simgrid::s4u::Host::get_pstate_speed(int pstate_index) const
+ .. autodoxymethod:: simgrid::s4u::Host::set_pstate(int pstate_index)
+ .. autodoxymethod:: simgrid::s4u::Host::set_speed_profile(kernel::profile::Profile *p)
+ .. autodoxymethod:: simgrid::s4u::Host::set_state_profile(kernel::profile::Profile *p)
+
+ .. group-tab:: Python
+
+ .. automethod:: simgrid.Host.get_pstate_count
+ .. automethod:: simgrid.Host.get_pstate_speed
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_host_get_available_speed(const_sg_host_t host)
+ .. autodoxymethod:: sg_host_get_nb_pstates(const_sg_host_t host)
+ .. autodoxymethod:: sg_host_get_pstate(const_sg_host_t host)
+ .. autodoxymethod:: sg_host_get_pstate_speed(const_sg_host_t host, int pstate_index)
+ .. autodoxymethod:: sg_host_set_pstate(sg_host_t host, int pstate)
+
+Execution
+---------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Host::exec_async(double flops_amounts)
+ .. autodoxymethod:: simgrid::s4u::Host::execute(double flops)
+ .. autodoxymethod:: simgrid::s4u::Host::execute(double flops, double priority)
+
+Platform and routing
+--------------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Host::get_englobing_zone()
+ .. autodoxymethod:: simgrid::s4u::Host::get_netpoint() const
+ .. autodoxymethod:: simgrid::s4u::Host::route_to(const Host *dest, std::vector< Link *> &links, double *latency) const
+ .. autodoxymethod:: simgrid::s4u::Host::route_to(const Host *dest, std::vector< kernel::resource::LinkImpl *> &links, double *latency) const
+ .. autodoxymethod:: simgrid::s4u::Host::send_to(Host *dest, double byte_amount)
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_host_route(const_sg_host_t from, const_sg_host_t to, xbt_dynar_t links)
+ .. autodoxymethod:: sg_host_route_bandwidth(const_sg_host_t from, const_sg_host_t to)
+ .. autodoxymethod:: sg_host_route_latency(const_sg_host_t from, const_sg_host_t to)
+ .. autodoxymethod:: sg_host_send_to(sg_host_t from, sg_host_t to, double byte_amount)
+
+Signals
+-------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxyvar:: simgrid::s4u::Host::on_creation
+ .. autodoxyvar:: simgrid::s4u::Host::on_destruction
+ .. autodoxyvar:: simgrid::s4u::Host::on_speed_change
+ .. autodoxyvar:: simgrid::s4u::Host::on_state_change
+
+.. _API_s4u_Link:
+
+=============
+ class Link
+=============
+
+.. autodoxyclass:: simgrid::s4u::Link
+
+Basic management
+----------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. code-block:: C++
+
+ #include <simgrid/s4u/Link.hpp>
+
+ Note that there is no LinkPtr type, and that you cannot use the RAII
+ idiom on hosts because SimGrid does not allow (yet) to create nor
+ destroy resources once the simulation is started.
+
+ .. group-tab:: Python
+
+ .. code:: Python
+
+ from simgrid import Link
+
+ .. group-tab:: C
+
+ .. code:: C
+
+ #include <simgrid/link.h>
+
+ .. doxygentypedef:: sg_link_t
+ .. cpp:type:: const s4u_Link* const_sg_link_t
+
+ Pointer to a constant link object.
+
+Retrieving links
+----------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ See also :cpp:func:`simgrid::s4u::Engine::get_all_links`.
+
+ .. autodoxymethod:: simgrid::s4u::Link::by_name(const std::string &name)
+ .. autodoxymethod:: simgrid::s4u::Link::by_name_or_null(const std::string &name)
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_link_by_name(const char *name)
+ .. autodoxymethod:: sg_link_count()
+ .. autodoxymethod:: sg_link_list()
+
+Querying info
+--------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Link::get_bandwidth() const
+ .. autodoxymethod:: simgrid::s4u::Link::get_cname() const
+ .. autodoxymethod:: simgrid::s4u::Link::get_latency() const
+ .. autodoxymethod:: simgrid::s4u::Link::get_name() const
+ .. autodoxymethod:: simgrid::s4u::Link::get_sharing_policy() const
+ .. autodoxymethod:: simgrid::s4u::Link::get_usage() const
+ .. autodoxymethod:: simgrid::s4u::Link::is_used() const
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_link_bandwidth(const_sg_link_t link)
+ .. autodoxymethod:: sg_link_is_shared(const_sg_link_t link)
+ .. autodoxymethod:: sg_link_latency(const_sg_link_t link)
+ .. autodoxymethod:: sg_link_name(const_sg_link_t link)
+
+User data and properties
+------------------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Link::get_property(const std::string &key) const
+ .. autodoxymethod:: simgrid::s4u::Link::set_property(const std::string &key, const std::string &value)
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_link_data(const_sg_link_t link)
+ .. autodoxymethod:: sg_link_data_set(sg_link_t link, void *data)
+
+On/Off
+------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ See also :cpp:func:`simgrid::s4u::Link::set_state_profile`.
+
+ .. autodoxymethod:: simgrid::s4u::Link::is_on() const
+ .. autodoxymethod:: simgrid::s4u::Link::turn_off()
+ .. autodoxymethod:: simgrid::s4u::Link::turn_on()
+
+Dynamic profiles
+----------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Link::set_bandwidth_profile(kernel::profile::Profile *profile)
+ .. autodoxymethod:: simgrid::s4u::Link::set_latency_profile(kernel::profile::Profile *profile)
+ .. autodoxymethod:: simgrid::s4u::Link::set_state_profile(kernel::profile::Profile *profile)
+
+Signals
+-------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxyvar:: simgrid::s4u::Link::on_bandwidth_change
+ .. cpp:var:: xbt::signal<void(kernel::resource::NetworkAction&, Host* src, Host* dst)> Link::on_communicate
+ .. autodoxyvar:: simgrid::s4u::Link::on_communication_state_change
+ .. autodoxyvar:: simgrid::s4u::Link::on_creation
+ .. autodoxyvar:: simgrid::s4u::Link::on_destruction
+ .. autodoxyvar:: simgrid::s4u::Link::on_state_change
+
+.. _API_s4u_NetZone:
+
+================
+ class NetZone
+================
+
+.. autodoxyclass:: simgrid::s4u::NetZone
+
+Basic management
+----------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. code-block:: C++
+
+ #include <simgrid/s4u/NetZone.hpp>
+
+ Note that there is no NetZonePtr type, and that you cannot use the RAII
+ idiom on network zones because SimGrid does not allow (yet) to create nor
+ destroy resources once the simulation is started.
+
+ .. group-tab:: C
+
+ .. code:: C
+
+ #include <simgrid/zone.h>
+
+ .. doxygentypedef:: sg_netzone_t
+ .. cpp:type:: const s4u_NetZone* const_sg_netzone_t
+
+ Pointer to a constant network zone object.
+
+Retrieving zones
+----------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ See :cpp:func:`simgrid::s4u::Engine::get_netzone_root`,
+ :cpp:func:`simgrid::s4u::Engine::netzone_by_name_or_null` and
+ :cpp:func:`simgrid::s4u::Engine::get_filtered_netzones`.
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_zone_get_by_name(const char *name)
+ .. autodoxymethod:: sg_zone_get_root()
+
+Querying info
+--------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::NetZone::get_cname() const
+ .. autodoxymethod:: simgrid::s4u::NetZone::get_name() const
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_zone_get_name(const_sg_netzone_t zone)
+
+User data and properties
+------------------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::NetZone::get_properties() const
+ .. autodoxymethod:: simgrid::s4u::NetZone::get_property(const std::string &key) const
+ .. autodoxymethod:: simgrid::s4u::NetZone::set_property(const std::string &key, const std::string &value)
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_zone_get_property_value(const_sg_netzone_t as, const char *name)
+ .. autodoxymethod:: sg_zone_set_property_value(sg_netzone_t netzone, const char *name, const char *value)
+
+Retrieving components
+---------------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::NetZone::get_all_hosts() const
+ .. autodoxymethod:: simgrid::s4u::NetZone::get_host_count() const
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_zone_get_hosts(const_sg_netzone_t zone, xbt_dynar_t whereto)
+
+Routing data
+------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::NetZone::add_bypass_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)
+ .. autodoxymethod:: simgrid::s4u::NetZone::add_component(kernel::routing::NetPoint *elm)
+ .. autodoxymethod:: simgrid::s4u::NetZone::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)
+ .. autodoxymethod:: simgrid::s4u::NetZone::get_children() const
+ .. autodoxymethod:: simgrid::s4u::NetZone::get_father()
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_zone_get_sons(const_sg_netzone_t zone, xbt_dict_t whereto)
+
+Signals
+-------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxyvar:: simgrid::s4u::NetZone::on_creation
+ .. autodoxyvar:: simgrid::s4u::NetZone::on_route_creation
+ .. autodoxyvar:: simgrid::s4u::NetZone::on_seal
+
+.. _API_s4u_VirtualMachine:
+
+=======================
+ class VirtualMachine
+=======================
+
+
+.. autodoxyclass:: simgrid::s4u::VirtualMachine
+
+Basic management
+----------------
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. code-block:: C++
+
+ #include <simgrid/s4u/VirtualMachine.hpp>
+
+ Note that there is no VirtualMachinePtr type, and that you cannot use the RAII
+ idiom on virtual machines. There is no good reason for that and should change in the future.
+
+ .. group-tab:: C
+
+ .. code:: C
+
+ #include <simgrid/vm.h>
+
+ .. doxygentypedef:: sg_vm_t
+ .. cpp:type:: const s4u_VirtualMachine* const_sg_vm_t
+
+ Pointer to a constant virtual machine object.
+
+Creating VMs
+------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::VirtualMachine::VirtualMachine(const std::string &name, Host *physical_host, int core_amount)
+ .. autodoxymethod:: simgrid::s4u::VirtualMachine::VirtualMachine(const std::string &name, Host *physical_host, int core_amount, size_t ramsize)
+ .. autodoxymethod:: simgrid::s4u::VirtualMachine::destroy
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_vm_create_core
+ .. autodoxymethod:: sg_vm_create_multicore
+ .. autodoxymethod:: sg_vm_destroy
+
+Querying info
+--------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::VirtualMachine::get_pm() const
+ .. autodoxymethod:: simgrid::s4u::VirtualMachine::get_ramsize() const
+ .. autodoxymethod:: simgrid::s4u::VirtualMachine::get_state()
+
+ .. autodoxymethod:: simgrid::s4u::VirtualMachine::set_bound(double bound)
+ .. autodoxymethod:: simgrid::s4u::VirtualMachine::set_pm(Host *pm)
+ .. autodoxymethod:: simgrid::s4u::VirtualMachine::set_ramsize(size_t ramsize)
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_vm_get_ramsize(const_sg_vm_t vm)
+ .. autodoxymethod:: sg_vm_set_bound(sg_vm_t vm, double bound)
+ .. autodoxymethod:: sg_vm_set_ramsize(sg_vm_t vm, size_t size)
+
+ .. 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
+
+Life cycle
+----------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::VirtualMachine::resume()
+ .. autodoxymethod:: simgrid::s4u::VirtualMachine::shutdown()
+ .. autodoxymethod:: simgrid::s4u::VirtualMachine::start()
+ .. autodoxymethod:: simgrid::s4u::VirtualMachine::suspend()
+
+ .. group-tab:: C
+
+ .. autodoxymethod:: sg_vm_start
+ .. autodoxymethod:: sg_vm_suspend
+ .. autodoxymethod:: sg_vm_resume
+ .. autodoxymethod:: sg_vm_shutdown
+
+Signals
+-------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxyvar:: simgrid::s4u::VirtualMachine::on_migration_end
+ .. autodoxyvar:: simgrid::s4u::VirtualMachine::on_migration_start
+ .. autodoxyvar:: simgrid::s4u::VirtualMachine::on_resume
+ .. autodoxyvar:: simgrid::s4u::VirtualMachine::on_shutdown
+ .. autodoxyvar:: simgrid::s4u::VirtualMachine::on_start
+ .. autodoxyvar:: simgrid::s4u::VirtualMachine::on_started
+ .. autodoxyvar:: simgrid::s4u::VirtualMachine::on_suspend
+
+.. _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.
+
+Basic management
+----------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. code-block:: C++
+
+ #include <simgrid/s4u/Activity.hpp>
+
+ .. doxygentypedef:: ActivityPtr
+
+Querying info
+-------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Activity::get_cname
+ .. autodoxymethod:: simgrid::s4u::Activity::get_name
+ .. autodoxymethod:: simgrid::s4u::Activity::get_remaining() const
+ .. autodoxymethod:: simgrid::s4u::Activity::get_state() const
+ .. autodoxymethod:: simgrid::s4u::Activity::set_remaining(double remains)
+ .. autodoxymethod:: simgrid::s4u::Activity::set_state(Activity::State state)
+
+
+Activities life cycle
+---------------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. 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)
+ .. autodoxymethod:: simgrid::s4u::Activity::vetoable_start()
+
+.. _API_s4u_Comm:
+
+=============
+ class Comm
+=============
+
+.. autodoxyclass:: simgrid::s4u::Comm
+
+Basic management
+----------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. code-block:: C++
+
+ #include <simgrid/s4u/Comm.hpp>
+
+ .. doxygentypedef:: CommPtr
+
+ .. group-tab:: Python
+
+ .. code:: Python
+
+ from simgrid import Comm
+
+Querying info
+-------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Comm::get_dst_data_size() const
+ .. autodoxymethod:: simgrid::s4u::Comm::get_mailbox() const
+ .. autodoxymethod:: simgrid::s4u::Comm::get_sender() const
+ .. autodoxymethod:: simgrid::s4u::Comm::set_dst_data(void **buff)
+ .. autodoxymethod:: simgrid::s4u::Comm::set_dst_data(void **buff, size_t size)
+ .. autodoxymethod:: simgrid::s4u::Comm::detach()
+ .. autodoxymethod:: simgrid::s4u::Comm::detach(void(*clean_function)(void *))
+ .. autodoxymethod:: simgrid::s4u::Comm::set_rate(double rate)
+ .. autodoxymethod:: simgrid::s4u::Comm::set_src_data(void *buff)
+ .. autodoxymethod:: simgrid::s4u::Comm::set_src_data(void *buff, size_t size)
+ .. autodoxymethod:: simgrid::s4u::Comm::set_src_data_size(size_t size)
+ .. autodoxymethod:: simgrid::s4u::Comm::set_tracing_category(const std::string &category)
+
+Life cycle
+----------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Comm::cancel
+ .. autodoxymethod:: simgrid::s4u::Comm::start
+ .. autodoxymethod:: simgrid::s4u::Comm::test
+ .. autodoxymethod:: simgrid::s4u::Comm::test_any(const std::vector< CommPtr > *comms)
+ .. autodoxymethod:: simgrid::s4u::Comm::wait
+ .. autodoxymethod:: simgrid::s4u::Comm::wait_all(const std::vector< CommPtr > *comms)
+ .. autodoxymethod:: simgrid::s4u::Comm::wait_any(const std::vector< CommPtr > *comms)
+ .. autodoxymethod:: simgrid::s4u::Comm::wait_any_for(const std::vector< CommPtr > *comms_in, double timeout)
+ .. autodoxymethod:: simgrid::s4u::Comm::wait_for
+
+ .. group-tab:: Python
+
+ .. automethod:: simgrid.Comm.test
+ .. automethod:: simgrid.Comm.wait
+ .. automethod:: simgrid.Comm.wait_all
+ .. automethod:: simgrid.Comm.wait_any
+
+Signals
+-------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxyvar:: simgrid::s4u::Comm::on_completion
+ .. autodoxyvar:: simgrid::s4u::Comm::on_receiver_start
+ .. autodoxyvar:: simgrid::s4u::Comm::on_sender_start
+
+.. _API_s4u_Exec:
+
+=============
+ class Exec
+=============
+
+.. autodoxyclass:: simgrid::s4u::Exec
+
+Basic management
+----------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. code-block:: C++
+
+ #include <simgrid/s4u/Exec.hpp>
+
+ .. doxygentypedef:: ExecPtr
+
+ .. group-tab:: Python
+
+ .. code:: Python
+
+ from simgrid import Exec
+
+Querying info
+-------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Exec::get_cost() const
+ .. autodoxymethod:: simgrid::s4u::Exec::get_finish_time() const
+ .. autodoxymethod:: simgrid::s4u::Exec::get_host() const
+ .. autodoxymethod:: simgrid::s4u::Exec::get_host_number() const
+ .. cpp:function:: double Exec::get_remaining()
+
+ On sequential executions, returns the amount of flops that remain to be done;
+ This cannot be used on parallel executions.
+
+ .. autodoxymethod:: simgrid::s4u::Exec::get_remaining_ratio
+ .. autodoxymethod:: simgrid::s4u::Exec::get_start_time() const
+ .. autodoxymethod:: simgrid::s4u::Exec::set_bound(double bound)
+ .. autodoxymethod:: simgrid::s4u::Exec::set_host
+ .. autodoxymethod:: simgrid::s4u::Exec::set_priority(double priority)
+
+ .. group-tab:: Python
+
+ .. autoattribute:: simgrid.Exec.host
+ .. autoattribute:: simgrid.Exec.remaining
+ .. autoattribute:: simgrid.Exec.remaining_ratio
+
+Life cycle
+----------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Exec::cancel
+ .. autodoxymethod:: simgrid::s4u::Exec::set_timeout(double timeout)
+ .. autodoxymethod:: simgrid::s4u::Exec::start
+ .. autodoxymethod:: simgrid::s4u::Exec::test
+ .. autodoxymethod:: simgrid::s4u::Exec::wait
+ .. autodoxymethod:: simgrid::s4u::Exec::wait_any(std::vector< ExecPtr > *execs)
+ .. autodoxymethod:: simgrid::s4u::Exec::wait_any_for(std::vector< ExecPtr > *execs, double timeout)
+ .. autodoxymethod:: simgrid::s4u::Exec::wait_for
+
+ .. group-tab:: Python
+
+ .. automethod:: simgrid.Exec.cancel
+ .. automethod:: simgrid.Exec.start
+ .. automethod:: simgrid.Exec.test
+ .. automethod:: simgrid.Exec.wait
+
+Signals
+-------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. cpp:var:: xbt::signal<void(Actor const&, Exec const&)> Exec::on_completion
+ .. cpp:var:: xbt::signal<void(Actor const&, Exec const&)> Exec::on_start
+
+.. _API_s4u_Io:
+
+===========
+ class Io
+===========
+
+.. autodoxyclass:: simgrid::s4u::Io
+
+Basic management
+----------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. code-block:: C++
+
+ #include <simgrid/s4u/Io.hpp>
+
+ .. doxygentypedef:: IoPtr
+
+Querying info
+-------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Io::get_performed_ioops() const
+ .. autodoxymethod:: simgrid::s4u::Io::get_remaining
+
+Life cycle
+----------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Io::cancel
+ .. autodoxymethod:: simgrid::s4u::Io::start
+ .. autodoxymethod:: simgrid::s4u::Io::test
+ .. autodoxymethod:: simgrid::s4u::Io::wait
+ .. autodoxymethod:: simgrid::s4u::Io::wait_for
+
+.. _API_s4u_Synchronizations:
+
+=======================
+Synchronization Objects
+=======================
+
+.. _API_s4u_Mutex:
+
+==============
+ Mutex
+==============
+
+.. autodoxyclass:: simgrid::s4u::Mutex
+
+Basic management
+----------------
+
+ .. tabs::
+
+ .. group-tab:: C++
+
+ .. code-block:: C++
+
+ #include <simgrid/s4u/Mutex.hpp>
+
+ .. doxygentypedef:: MutexPtr
+
+ .. autodoxymethod:: simgrid::s4u::Mutex::Mutex(kernel::activity::MutexImpl *mutex)
+ .. autodoxymethod:: simgrid::s4u::Mutex::create()
+ .. autodoxymethod:: simgrid::s4u::Mutex::~Mutex()
+
+ .. group-tab:: C
+
+ .. code-block:: C
+
+ #include <simgrid/mutex.h>
+
+ .. doxygentypedef:: sg_mutex_t
+ .. cpp:type:: const s4u_Mutex* const_sg_mutex_t
+
+ Pointer to a constant mutex object.
+
+ .. autodoxymethod:: sg_mutex_init()
+ .. autodoxymethod:: sg_mutex_destroy(const_sg_mutex_t mutex)
+
+Locking
+-------
+
+ .. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Mutex::lock()
+ .. autodoxymethod:: simgrid::s4u::Mutex::try_lock()
+ .. autodoxymethod:: simgrid::s4u::Mutex::unlock()
+
+ .. 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>
+
+ .. 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
+ .. autodoxymethod:: sg_cond_init
+ .. autodoxymethod:: 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
+
+ .. autodoxymethod:: sg_cond_notify_all
+ .. autodoxymethod:: sg_cond_notify_one
+ .. autodoxymethod:: sg_cond_wait
+ .. autodoxymethod:: sg_cond_wait_for
+
+.. _API_s4u_Semaphore:
+
+==================
+ Semaphore
+==================
+
+.. autodoxyclass:: simgrid::s4u::Semaphore
+
+
+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)
.. |hr| raw:: html
- 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
import os
import subprocess
-# Search for our extensions too
+# Search for our extensions too
import sys
sys.path.append(os.path.abspath('_ext'))
# -- 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
-version = u'3.24.1'
+version = u'3.25.1'
# -- General configuration ---------------------------------------------------
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
-# html_static_path = ['_static']
+html_static_path = ['_static']
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
"gitlab_version": "master", # Version
"conf_py_path": "/docs/source/", # Path in the checkout to the docs root
}
+
+html_css_files = [
+ 'css/custom.css',
+]
+
+# -- Other options
+
+nitpicky = True # Generate a warning for all a cross-reference (such as :func:`myfunc`) that cannot be found
Describing the Simulated Platform <platform.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>
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
# Load and relabel the data
df = pajeng_read(args[1])
-names(df$state) = c("Type", "Actor", "Container", "Start", "End", "Duration", "Level", "State");
+names(df$state) = c("Type", "Actor", "Container", "Start", "End", "Duration", "Level", "State")
# Actually draw the graph
-p = ggplot(df$state) + geom_segment(aes(x=Start, xend=End, y=Actor, yend=Actor,color=State), size=5);
+p = ggplot(df$state) + geom_segment(aes(x=Start, xend=End, y=Actor, yend=Actor,color=State), size=5)
# Cosmetics to compact the resulting graph
-p.height <- length(unique(df$state$Actor)) * 0.05 + 2;
+p.height <- length(unique(df$state$Actor)) * 0.05 + 2
pdf(height = p.height)
# Produce the pdf 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. */
if (compute_cost > 0) /* If compute_cost is valid, execute a computation of that cost */
simgrid::s4u::this_actor::execute(compute_cost);
-
} while (compute_cost > 0); /* Stop when receiving an invalid compute_cost */
XBT_INFO("Exiting now.");
-/* 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. */
if (compute_cost > 0) /* If compute_cost is valid, execute a computation of that cost */
simgrid::s4u::this_actor::execute(compute_cost);
-
} while (compute_cost > 0); /* Stop when receiving an invalid compute_cost */
XBT_INFO("Exiting now.");
-/* 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. */
- Directly with :py:func:`simgrid.Actor.create()`
- From XML with :py:func:`simgrid.Engine.register_actor()` and then :py:func:`simgrid.Engine.load_deployment()`
+ .. example-tab:: examples/c/actor-create/actor-create.c
+
+ You create actors either:
+
+ - Directly with :cpp:func:`sg_actor_create()` followed by :cpp:func:`sg_actor_start`.
+ - From XML with :cpp:func:`simgrid_register_function` and then :cpp:func:`simgrid_load_deployment`.
+
.. example-tab:: examples/python/actor-create/actor-create_d.xml
The following file is used in both C++ and Python.
.. example-tab:: examples/python/async-waitany/async-waitany.py
See also :py:func:`simgrid.Comm.wait_any()`.
+
+ .. example-tab:: examples/c/async-waitany/async-waitany.c
+
+ See also :cpp:func:`sg_comm_wait_any`.
.. _s4u_ex_execution:
.. 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::
--- /dev/null
+foreach(x actor-create app-pingpong async-waitany)
+ add_executable (${x}-c EXCLUDE_FROM_ALL ${x}/${x}.c)
+ target_link_libraries(${x}-c simgrid)
+ set_target_properties(${x}-c PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
+ add_dependencies(tests ${x}-c)
+
+ set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
+ set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.c)
+endforeach()
+
+set(teshsuite_src ${teshsuite_src} PARENT_SCOPE)
+set(tesh_files ${tesh_files} PARENT_SCOPE)
+
+set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/actor-create/actor-create_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/app-pingpong/app-pingpong_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/async-waitany_d.xml
+ PARENT_SCOPE)
+
+foreach(x actor-create app-pingpong async-waitany)
+ ADD_TESH(c-${x} --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
+ --setenv bindir=${CMAKE_BINARY_DIR}/examples/c/${x}
+ --cd ${CMAKE_HOME_DIRECTORY}/examples/c/${x}
+ ${CMAKE_HOME_DIRECTORY}/examples/c/${x}/${x}.tesh)
+endforeach()
--- /dev/null
+actor-create-c
--- /dev/null
+/* Copyright (c) 2006-2018. The SimGrid Team. All rights reserved. */
+
+/* This program 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 example shows how to declare and start your actors.
+ *
+ * The first step is to declare the code of your actors (what they do exactly does not matter to this example) and then
+ * you ask SimGrid to start your actors. There is three ways of doing so:
+ * - Directly, by instantiating your actor as paramter to Actor::create()
+ * - By first registering your actors before instantiating it;
+ * - Through the deployment file.
+ *
+ * This example shows all these solutions, even if you obviously should use only one of these solutions to start your
+ * actors. The most advised solution is to use a deployment file, as it creates a clear separation between your
+ * application and the settings to test it. This is a better scientific methodology. Actually, starting an actor with
+ * Actor::create() is mostly useful to start an actor from another actor.
+ */
+
+#include <simgrid/actor.h>
+#include <simgrid/engine.h>
+#include <simgrid/host.h>
+#include <simgrid/mailbox.h>
+#include <xbt/asserts.h>
+#include <xbt/log.h>
+
+// This declares a logging channel so that XBT_INFO can be used later
+XBT_LOG_NEW_DEFAULT_CATEGORY(actor_create, "The logging channel used in this example");
+
+/* Our first class of actors is simply implemented with a function.
+ * As every CSG actors, its parameters are in a vector of string (argc/argv), and it does not return anything.
+ *
+ * One 'receiver' actor is instantiated within the simulation later in this file.
+ */
+static void receiver(int argc, char** argv)
+{
+ xbt_assert(argc == 2, "This actor expects a single argument: the mailbox on which to get messages");
+ sg_mailbox_t mailbox = sg_mailbox_by_name(argv[1]);
+
+ XBT_INFO("Hello, I'm ready to get any message you'd want on %s", argv[1]);
+
+ const char* msg1 = sg_mailbox_get(mailbox);
+ const char* msg2 = sg_mailbox_get(mailbox);
+ const char* msg3 = sg_mailbox_get(mailbox);
+ XBT_INFO("I received '%s', '%s' and '%s'", msg1, msg2, msg3);
+ XBT_INFO("I'm done. See you.");
+}
+
+/* Our second class of actors, in charge of sending stuff */
+static void sender(int argc, char** argv)
+{
+ xbt_assert(argc == 3, "Actor 'sender' requires 2 parameters (mailbox and data to send), but got only %d", argc - 1);
+ XBT_INFO("Hello, I have something to send");
+ char* sent_data = argv[1];
+ sg_mailbox_t mailbox = sg_mailbox_by_name(argv[2]);
+
+ sg_mailbox_put(mailbox, xbt_strdup(sent_data), strlen(sent_data));
+ XBT_INFO("I'm done. See you.");
+}
+
+static void forwarder(int argc, char** argv)
+{
+ xbt_assert(argc >= 3, "Actor forwarder requires 2 parameters, but got only %d", argc - 1);
+ sg_mailbox_t mailbox_in = sg_mailbox_by_name(argv[1]);
+ sg_mailbox_t mailbox_out = sg_mailbox_by_name(argv[2]);
+ char* msg = (char*)(sg_mailbox_get(mailbox_in));
+ XBT_INFO("Forward '%s'.", msg);
+ sg_mailbox_put(mailbox_out, msg, strlen(msg));
+}
+
+/* Here comes the main function of your program */
+int main(int argc, char** argv)
+{
+ /* When your program starts, you have to first start a new simulation engine, as follows */
+ simgrid_init(&argc, argv);
+
+ /* Then you should load a platform file, describing your simulated platform */
+ simgrid_load_platform("../../platforms/small_platform.xml");
+
+ /* And now you have to ask SimGrid to actually start your actors.
+ *
+ * The easiest way to do so is to implement the behavior of your actor in a single function,
+ * as we do here for the receiver actors. This function can take any kind of parameters, as
+ * long as the last parameters of Actor::create() match what your function expects.
+ */
+ int recv_argc = 2;
+ const char* recv_argv[] = {"receiver", "mb42", NULL};
+ sg_actor_t recv = sg_actor_init("receiver", sg_host_by_name("Fafard"));
+ sg_actor_start(recv, receiver, recv_argc, recv_argv);
+
+ int sender1_argc = 3;
+ const char* sender1_argv[] = {"sender", "GaBuZoMeu", "mb42", NULL};
+ sg_actor_t sender1 = sg_actor_init("sender1", sg_host_by_name("Tremblay"));
+ sg_actor_start(sender1, sender, sender1_argc, sender1_argv);
+
+ int sender2_argc = 3;
+ const char* sender2_argv[] = {"sender", "GloubiBoulga", "mb42", NULL};
+ sg_actor_t sender2 = sg_actor_init("sender2", sg_host_by_name("Jupiter"));
+ sg_actor_start(sender2, sender, sender2_argc, sender2_argv);
+
+ /* But starting actors directly is considered as a bad experimental habit, since it ties the code
+ * you want to test with the experimental scenario. Starting your actors from an external deployment
+ * file in XML ensures that you can test your code in several scenarios without changing the code itself.
+ *
+ * For that, you first need to register your function or your actor as follows.
+ * actor functions must be of type void(*)(int argc, char**argv). */
+ simgrid_register_function("sender", sender);
+ simgrid_register_function("forwarder", forwarder);
+ /* Once actors and functions are registered, just load the deployment file */
+ simgrid_load_deployment("actor-create_d.xml");
+
+ /* Once every actors are started in the engine, the simulation can start */
+ simgrid_run();
+
+ /* Once the simulation is done, the program is ended */
+ return 0;
+}
--- /dev/null
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/actor-create-c
+> [Tremblay:sender1:(2) 0.000000] [actor_create/INFO] Hello, I have something to send
+> [Jupiter:sender2:(3) 0.000000] [actor_create/INFO] Hello, I have something to send
+> [Fafard:sender:(4) 0.000000] [actor_create/INFO] Hello, I have something to send
+> [Fafard:receiver:(1) 0.000000] [actor_create/INFO] Hello, I'm ready to get any message you'd want on mb42
+> [Fafard:sender:(4) 0.016392] [actor_create/INFO] I'm done. See you.
+> [Ginette:forwarder:(5) 0.016392] [actor_create/INFO] Forward 'PopPop!'.
+> [Tremblay:sender1:(2) 0.025709] [actor_create/INFO] I'm done. See you.
+> [Jupiter:sender2:(3) 0.070434] [actor_create/INFO] I'm done. See you.
+> [Fafard:receiver:(1) 0.086825] [actor_create/INFO] I received 'GaBuZoMeu', 'GloubiBoulga' and 'PopPop!'
+> [Fafard:receiver:(1) 0.086825] [actor_create/INFO] I'm done. See you.
--- /dev/null
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
+<platform version="4.1">
+
+ <!-- This a weird deployment file: we only start one actor from here and the others from the main().
+ -
+ - This is only for the example, but don't do that at home.
+ - Instead, you want to start all your actors from the deployment file.
+ -->
+
+ <actor host="Fafard" function="sender">
+ <argument value="PopPop!"/> <!-- msg as argv[1] -->
+ <argument value="other mb"/> <!-- mbox as argv[2] -->
+ </actor>
+ <actor host="Ginette" function="forwarder">
+ <argument value="other mb"/>
+ <argument value="mb42"/>
+ </actor>
+</platform>
--- /dev/null
+/* 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 "simgrid/actor.h"
+#include "simgrid/comm.h"
+#include "simgrid/engine.h"
+#include "simgrid/forward.h"
+#include "simgrid/mailbox.h"
+#include "xbt/asserts.h"
+#include "xbt/log.h"
+#include "xbt/str.h"
+
+#include <stdio.h> /* snprintf */
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(app_pingpong, "Messages specific for this example");
+
+static void pinger(int argc, char* argv[])
+{
+ sg_mailbox_t mailbox_in = sg_mailbox_by_name("Mailbox 1");
+ sg_mailbox_t mailbox_out = sg_mailbox_by_name("Mailbox 2");
+
+ XBT_INFO("Ping from mailbox %s to mailbox %s", sg_mailbox_get_name(mailbox_in), sg_mailbox_get_name(mailbox_out));
+
+ /* - Do the ping with a 1-Byte task (latency bound) ... */
+ double* now = (double*)xbt_malloc(sizeof(double));
+ *now = simgrid_get_clock();
+ sg_mailbox_put(mailbox_out, now, 1);
+
+ /* - ... then wait for the (large) pong */
+ double* sender_time = (double*)sg_mailbox_get(mailbox_in);
+
+ double communication_time = simgrid_get_clock() - *sender_time;
+ XBT_INFO("Task received : large communication (bandwidth bound)");
+ XBT_INFO("Pong time (bandwidth bound): %.3f", communication_time);
+ xbt_free(sender_time);
+}
+
+static void ponger(int argc, char* argv[])
+{
+ sg_mailbox_t mailbox_in = sg_mailbox_by_name("Mailbox 2");
+ sg_mailbox_t mailbox_out = sg_mailbox_by_name("Mailbox 1");
+
+ XBT_INFO("Pong from mailbox %s to mailbox %s", sg_mailbox_get_name(mailbox_in), sg_mailbox_get_name(mailbox_out));
+
+ /* - Receive the (small) ping first ....*/
+ double* sender_time = (double*)sg_mailbox_get(mailbox_in);
+ double communication_time = simgrid_get_clock() - *sender_time;
+ XBT_INFO("Task received : small communication (latency bound)");
+ XBT_INFO(" Ping time (latency bound) %f", communication_time);
+ xbt_free(sender_time);
+
+ /* - ... Then send a 1GB pong back (bandwidth bound) */
+ double* payload = (double*)xbt_malloc(sizeof(double));
+ *payload = simgrid_get_clock();
+ XBT_INFO("task_bw->data = %.3f", *payload);
+ sg_mailbox_put(mailbox_out, payload, 1e9);
+}
+
+int main(int argc, char* argv[])
+{
+ simgrid_init(&argc, argv);
+ xbt_assert(argc > 2,
+ "Usage: %s platform_file deployment_file\n"
+ "\tExample: %s ../../platforms/small_platform.xml app-pingpong_d.xml\n",
+ argv[0], argv[0]);
+
+ simgrid_load_platform(argv[1]);
+
+ simgrid_register_function("pinger", pinger);
+ simgrid_register_function("ponger", ponger);
+ simgrid_load_deployment(argv[2]);
+
+ simgrid_run();
+
+ XBT_INFO("Total simulation time: %.3f", simgrid_get_clock());
+
+ return 0;
+}
p Testing with default compound
-$ ${bindir:=.}/app-pingpong ${platfdir}/small_platform.xml app-pingpong_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
-> [ 0.000000] (1:pinger@Tremblay) Ping -> Jupiter
-> [ 0.000000] (2:ponger@Jupiter) Pong -> Tremblay
+$ ${bindir:=.}/app-pingpong-c ${platfdir}/small_platform.xml app-pingpong_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 0.000000] (1:pinger@Tremblay) Ping from mailbox Mailbox 1 to mailbox Mailbox 2
+> [ 0.000000] (2:ponger@Jupiter) Pong from mailbox Mailbox 2 to mailbox Mailbox 1
> [ 0.019014] (2:ponger@Jupiter) Task received : small communication (latency bound)
> [ 0.019014] (2:ponger@Jupiter) Ping time (latency bound) 0.019014
> [ 0.019014] (2:ponger@Jupiter) task_bw->data = 0.019
p Testing with default compound and Full network optimization
-$ ${bindir:=.}/app-pingpong ${platfdir}/small_platform.xml app-pingpong_d.xml "--cfg=network/optim:Full" "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${bindir:=.}/app-pingpong-c ${platfdir}/small_platform.xml app-pingpong_d.xml "--cfg=network/optim:Full" "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (0:maestro@) Configuration change: Set 'network/optim' to 'Full'
-> [ 0.000000] (1:pinger@Tremblay) Ping -> Jupiter
-> [ 0.000000] (2:ponger@Jupiter) Pong -> Tremblay
+> [ 0.000000] (1:pinger@Tremblay) Ping from mailbox Mailbox 1 to mailbox Mailbox 2
+> [ 0.000000] (2:ponger@Jupiter) Pong from mailbox Mailbox 2 to mailbox Mailbox 1
> [ 0.019014] (2:ponger@Jupiter) Task received : small communication (latency bound)
> [ 0.019014] (2:ponger@Jupiter) Ping time (latency bound) 0.019014
> [ 0.019014] (2:ponger@Jupiter) task_bw->data = 0.019
p Testing the deprecated CM02 network model
-$ ${bindir:=.}/app-pingpong ${platfdir}/small_platform.xml app-pingpong_d.xml --cfg=cpu/model:Cas01 --cfg=network/model:CM02 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${bindir:=.}/app-pingpong-c ${platfdir}/small_platform.xml app-pingpong_d.xml --cfg=cpu/model:Cas01 --cfg=network/model:CM02 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (0:maestro@) Configuration change: Set 'cpu/model' to 'Cas01'
> [ 0.000000] (0:maestro@) Configuration change: Set 'network/model' to 'CM02'
-> [ 0.000000] (1:pinger@Tremblay) Ping -> Jupiter
-> [ 0.000000] (2:ponger@Jupiter) Pong -> Tremblay
+> [ 0.000000] (1:pinger@Tremblay) Ping from mailbox Mailbox 1 to mailbox Mailbox 2
+> [ 0.000000] (2:ponger@Jupiter) Pong from mailbox Mailbox 2 to mailbox Mailbox 1
> [ 0.001462] (2:ponger@Jupiter) Task received : small communication (latency bound)
> [ 0.001462] (2:ponger@Jupiter) Ping time (latency bound) 0.001462
> [ 0.001462] (2:ponger@Jupiter) task_bw->data = 0.001
p Testing the surf network constant model
-$ ${bindir:=.}/app-pingpong ${platfdir}/small_platform_constant.xml app-pingpong_d.xml "--cfg=host/model:compound cpu/model:Cas01 network/model:Constant" "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${bindir:=.}/app-pingpong-c ${platfdir}/small_platform_constant.xml app-pingpong_d.xml "--cfg=host/model:compound cpu/model:Cas01 network/model:Constant" "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (0:maestro@) Configuration change: Set 'host/model' to 'compound'
> [ 0.000000] (0:maestro@) Configuration change: Set 'cpu/model' to 'Cas01'
> [ 0.000000] (0:maestro@) Configuration change: Set 'network/model' to 'Constant'
-> [ 0.000000] (1:pinger@Tremblay) Ping -> Jupiter
-> [ 0.000000] (2:ponger@Jupiter) Pong -> Tremblay
+> [ 0.000000] (1:pinger@Tremblay) Ping from mailbox Mailbox 1 to mailbox Mailbox 2
+> [ 0.000000] (2:ponger@Jupiter) Pong from mailbox Mailbox 2 to mailbox Mailbox 1
> [ 13.010000] (2:ponger@Jupiter) Task received : small communication (latency bound)
> [ 13.010000] (2:ponger@Jupiter) Ping time (latency bound) 13.010000
> [ 13.010000] (2:ponger@Jupiter) task_bw->data = 13.010
<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
<platform version="4.1">
<!-- For using with ping_pong, platform_sendrecv.xml -->
- <actor host="Tremblay" function="pinger">
- <argument value="Jupiter"/>
- </actor>
- <actor host="Jupiter" function="ponger">
- <argument value="Tremblay"/>
- </actor>
+ <actor host="Tremblay" function="pinger"/>
+ <actor host="Jupiter" function="ponger"/>
</platform>
--- /dev/null
+/* 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/actor.h"
+#include "simgrid/comm.h"
+#include "simgrid/engine.h"
+#include "simgrid/forward.h"
+#include "simgrid/mailbox.h"
+#include "xbt/asserts.h"
+#include "xbt/log.h"
+#include "xbt/str.h"
+
+#include <stdio.h> /* snprintf */
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(async_waitany, "Messages specific for this example");
+
+static void sender(int argc, char* argv[])
+{
+ xbt_assert(argc == 4, "Expecting 3 parameters from the XML deployment file but got %d", argc);
+ long messages_count = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");
+ long msg_size = xbt_str_parse_int(argv[2], "Invalid communication size: %s");
+ long receivers_count = xbt_str_parse_int(argv[3], "Invalid amount of receivers: %s");
+
+ /* Array in which we store all ongoing communications */
+ sg_comm_t* pending_comms = malloc(sizeof(sg_comm_t) * (messages_count + receivers_count));
+ int pending_comms_count = 0;
+
+ /* Make an array of the mailboxes to use */
+ sg_mailbox_t* mboxes = malloc(sizeof(sg_mailbox_t) * receivers_count);
+ for (long i = 0; i < receivers_count; i++) {
+ char mailbox_name[80];
+ snprintf(mailbox_name, 79, "receiver-%ld", i);
+ sg_mailbox_t mbox = sg_mailbox_by_name(mailbox_name);
+ mboxes[i] = mbox;
+ }
+
+ /* Start dispatching all messages to receivers, in a round robin fashion */
+ for (int i = 0; i < messages_count; i++) {
+ char msg_content[80];
+ snprintf(msg_content, 79, "Message %d", i);
+ sg_mailbox_t mbox = mboxes[i % receivers_count];
+ XBT_INFO("Send '%s' to '%s'", msg_content, sg_mailbox_get_name(mbox));
+
+ /* Create a communication representing the ongoing communication, and store it in pending_comms */
+ pending_comms[pending_comms_count++] = sg_mailbox_put_async(mbox, xbt_strdup(msg_content), msg_size);
+ }
+ /* Start sending messages to let the workers know that they should stop */
+ for (int i = 0; i < receivers_count; i++) {
+ XBT_INFO("Send 'finalize' to 'receiver-%d'", i);
+ char* end_msg = xbt_strdup("finalize");
+ sg_mailbox_t mbox = mboxes[i % receivers_count];
+ pending_comms[pending_comms_count++] = sg_mailbox_put_async(mbox, end_msg, 0);
+ }
+
+ XBT_INFO("Done dispatching all messages");
+
+ /* Now that all message exchanges were initiated, wait for their completion, in order of termination.
+ *
+ * This loop waits for first terminating message with wait_any() and remove it from the array (with a memmove),
+ * until all comms are terminated.
+ * Even in this simple example, the pending comms do not terminate in the exact same order of creation.
+ */
+ while (pending_comms_count != 0) {
+ int changed_pos = sg_comm_wait_any(pending_comms, pending_comms_count);
+ memmove(pending_comms + changed_pos, pending_comms + changed_pos + 1,
+ sizeof(sg_comm_t) * (pending_comms_count - changed_pos - 1));
+ pending_comms_count--;
+
+ if (changed_pos != 0)
+ XBT_INFO("Remove the %dth pending comm: it terminated earlier than another comm that was initiated first.",
+ changed_pos);
+ }
+
+ free(pending_comms);
+ free(mboxes);
+
+ XBT_INFO("Goodbye now!");
+}
+
+static void receiver(int argc, char* argv[])
+{
+ xbt_assert(argc == 2, "Expecting one parameter from the XML deployment file but got %d", argc);
+ int id = xbt_str_parse_int(argv[1], "ID should be numerical, not %s");
+ char mailbox_name[80];
+ snprintf(mailbox_name, 79, "receiver-%d", id);
+ sg_mailbox_t mbox = sg_mailbox_by_name(mailbox_name);
+ XBT_INFO("Wait for my first message on '%s'", mailbox_name);
+ while (1) {
+ char* received = (char*)sg_mailbox_get(mbox);
+ XBT_INFO("I got a '%s'.", received);
+ if (!strcmp(received, "finalize")) { // If it's a finalize message, we're done
+ xbt_free(received);
+ break;
+ }
+ xbt_free(received);
+ }
+
+ XBT_INFO("I'm done. See you!");
+}
+
+int main(int argc, char* argv[])
+{
+ simgrid_init(&argc, argv);
+ xbt_assert(argc > 2,
+ "Usage: %s platform_file deployment_file\n"
+ "\tExample: %s msg_platform.xml msg_deployment.xml\n",
+ argv[0], argv[0]);
+
+ simgrid_load_platform(argv[1]);
+
+ simgrid_register_function("sender", sender);
+ simgrid_register_function("receiver", receiver);
+ simgrid_load_deployment(argv[2]);
+
+ simgrid_run();
+
+ XBT_INFO("Simulation time %g", simgrid_get_clock());
+
+ return 0;
+}
--- /dev/null
+#!/usr/bin/env tesh
+
+! output sort 19
+$ ${bindir:=.}/async-waitany-c ${platfdir:=.}/small_platform.xml ${srcdir:=.}/async-waitany_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 0.000000] (1:sender@Tremblay) Send 'Message 0' to 'receiver-0'
+> [ 0.000000] (1:sender@Tremblay) Send 'Message 1' to 'receiver-1'
+> [ 0.000000] (1:sender@Tremblay) Send 'Message 2' to 'receiver-0'
+> [ 0.000000] (1:sender@Tremblay) Send 'Message 3' to 'receiver-1'
+> [ 0.000000] (1:sender@Tremblay) Send 'Message 4' to 'receiver-0'
+> [ 0.000000] (1:sender@Tremblay) Send 'Message 5' to 'receiver-1'
+> [ 0.000000] (1:sender@Tremblay) Send 'finalize' to 'receiver-0'
+> [ 0.000000] (1:sender@Tremblay) Send 'finalize' to 'receiver-1'
+> [ 0.000000] (1:sender@Tremblay) Done dispatching all messages
+> [ 0.000000] (2:receiver@Fafard) Wait for my first message on 'receiver-0'
+> [ 0.000000] (3:receiver@Jupiter) Wait for my first message on 'receiver-1'
+> [ 0.158397] (2:receiver@Fafard) I got a 'Message 0'.
+> [ 0.169155] (3:receiver@Jupiter) I got a 'Message 1'.
+> [ 0.316794] (2:receiver@Fafard) I got a 'Message 2'.
+> [ 0.338309] (3:receiver@Jupiter) I got a 'Message 3'.
+> [ 0.475190] (2:receiver@Fafard) I got a 'Message 4'.
+> [ 0.500898] (1:sender@Tremblay) Remove the 1th pending comm: it terminated earlier than another comm that was initiated first.
+> [ 0.500898] (2:receiver@Fafard) I got a 'finalize'.
+> [ 0.500898] (2:receiver@Fafard) I'm done. See you!
+> [ 0.507464] (3:receiver@Jupiter) I got a 'Message 5'.
+> [ 0.526478] (0:maestro@) Simulation time 0.526478
+> [ 0.526478] (1:sender@Tremblay) Goodbye now!
+> [ 0.526478] (3:receiver@Jupiter) I got a 'finalize'.
+> [ 0.526478] (3:receiver@Jupiter) I'm done. See you!
\ No newline at end of file
--- /dev/null
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
+<platform version="4.1">
+ <!-- The master actor (with some arguments) -->
+ <actor host="Tremblay" function="sender">
+ <argument value="6"/> <!-- Number of tasks -->
+ <argument value="1000000"/> <!-- Communication size of tasks -->
+ <argument value="2"/> <!-- Number of receivers -->
+ </actor>
+ <!-- The receiver processes -->
+ <actor host="Fafard" function="receiver">
+ <argument value="0"/>
+ </actor>
+ <actor host="Jupiter" function="receiver">
+ <argument value="1"/>
+ </actor>
+</platform>
-/* 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
public void main(String[] args) throws MsgException {
int i = 1;
while(!Main.isEndOfTest()) {
- // TODO the binding is not yet available
try {
currentTask.execute();
} catch (HostFailureException e) {
-/* 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
synchro-semaphore trace-categories
trace-route-user-variables trace-link-user-variables trace-masterworker
trace-process-migration trace-host-user-variables)
- add_executable (${x} EXCLUDE_FROM_ALL ${x}/${x}.c)
- target_link_libraries(${x} simgrid)
- set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
- add_dependencies(tests ${x})
+ if(enable_msg)
+ add_executable (${x} EXCLUDE_FROM_ALL ${x}/${x}.c)
+ target_link_libraries(${x} simgrid)
+ set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
+ add_dependencies(tests ${x})
+ endif()
set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.c)
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
endforeach()
-if(SIMGRID_HAVE_NS3)
+if(SIMGRID_HAVE_NS3 AND enable_msg)
add_executable (network-ns3 EXCLUDE_FROM_ALL network-ns3/network-ns3.c)
target_link_libraries(network-ns3 simgrid)
set_target_properties(network-ns3 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/network-ns3)
add_dependencies(tests network-ns3)
endif()
-add_executable (dht-kademlia EXCLUDE_FROM_ALL dht-kademlia/dht-kademlia.c dht-kademlia/node.c dht-kademlia/routing_table.c dht-kademlia/task.c dht-kademlia/answer.c)
-target_link_libraries(dht-kademlia simgrid)
-set_target_properties(dht-kademlia PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dht-kademlia)
-add_dependencies(tests dht-kademlia)
+if(enable_msg)
+ add_executable (dht-kademlia EXCLUDE_FROM_ALL dht-kademlia/dht-kademlia.c dht-kademlia/node.c dht-kademlia/routing_table.c dht-kademlia/task.c dht-kademlia/answer.c)
+ target_link_libraries(dht-kademlia simgrid)
+ set_target_properties(dht-kademlia PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dht-kademlia)
+ add_dependencies(tests dht-kademlia)
+endif()
foreach (file answer dht-kademlia node routing_table task)
set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/${file}.c ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/${file}.h)
endforeach()
${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/onelink_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/one_cluster_d.xml PARENT_SCOPE)
-foreach(x app-masterworker cloud-masterworker
- dht-pastry dht-kademlia platform-failures
- energy-vm
- process-create
- synchro-semaphore)
- ADD_TESH_FACTORIES(msg-${x} "thread;ucontext;raw;boost"
- --setenv bindir=${CMAKE_BINARY_DIR}/examples/deprecated/msg/${x}
- --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/${x}
- --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
- ${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/${x}/${x}.tesh)
-endforeach()
+if(enable_msg)
+ foreach(x app-masterworker cloud-masterworker
+ dht-pastry dht-kademlia platform-failures
+ energy-vm
+ process-create
+ synchro-semaphore)
+ ADD_TESH_FACTORIES(msg-${x} "thread;ucontext;raw;boost"
+ --setenv bindir=${CMAKE_BINARY_DIR}/examples/deprecated/msg/${x}
+ --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/${x}
+ --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
+ ${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/${x}/${x}.tesh)
+ endforeach()
-foreach (x trace-categories trace-route-user-variables trace-link-user-variables trace-masterworker trace-process-migration trace-host-user-variables)
- ADD_TESH(msg-${x} --setenv bindir=${CMAKE_BINARY_DIR}/examples/deprecated/msg/${x}
- --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/${x}
- --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
- --cd ${CMAKE_BINARY_DIR}/examples/deprecated/msg/${x}
- ${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/${x}/${x}.tesh)
-endforeach()
+ foreach (x trace-categories trace-route-user-variables trace-link-user-variables trace-masterworker trace-process-migration trace-host-user-variables)
+ ADD_TESH(msg-${x} --setenv bindir=${CMAKE_BINARY_DIR}/examples/deprecated/msg/${x}
+ --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/${x}
+ --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
+ --cd ${CMAKE_BINARY_DIR}/examples/deprecated/msg/${x}
+ ${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/${x}/${x}.tesh)
+ endforeach()
-if(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
- # Thread-local storage (TLS) is needed for parallel execution, but it doesn't
- # play well with Ucontexts on 64bit SunOS (at least on x86_64).
- set(parallel-factories "thread;raw;boost")
-else()
- set(parallel-factories "thread;ucontext;raw;boost")
-endif()
-ADD_TESH_FACTORIES(msg-dht-kademlia-parallel "${parallel-factories}" --cfg contexts/nthreads:4 ${CONTEXTS_SYNCHRO}
- --setenv bindir=${CMAKE_BINARY_DIR}/examples/deprecated/msg/dht-kademlia
- --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/dht-kademlia
- --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
- ${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/dht-kademlia/dht-kademlia.tesh)
+ if(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
+ # Thread-local storage (TLS) is needed for parallel execution, but it doesn't
+ # play well with Ucontexts on 64bit SunOS (at least on x86_64).
+ set(parallel-factories "thread;raw;boost")
+ else()
+ set(parallel-factories "thread;ucontext;raw;boost")
+ endif()
+ ADD_TESH_FACTORIES(msg-dht-kademlia-parallel "${parallel-factories}" --cfg contexts/nthreads:4 ${CONTEXTS_SYNCHRO}
+ --setenv bindir=${CMAKE_BINARY_DIR}/examples/deprecated/msg/dht-kademlia
+ --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/dht-kademlia
+ --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
+ ${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/dht-kademlia/dht-kademlia.tesh)
-ADD_TESH_FACTORIES(app-masterworker-multicore "thread;ucontext;raw;boost"
- --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/app-masterworker
- --setenv bindir=${CMAKE_BINARY_DIR}/examples/deprecated/msg/app-masterworker
- --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
- ${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/app-masterworker/app-masterworker-multicore.tesh)
-ADD_TESH_FACTORIES(app-masterworker-vivaldi "thread;ucontext;raw;boost"
- --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/app-masterworker
- --setenv bindir=${CMAKE_BINARY_DIR}/examples/deprecated/msg/app-masterworker
- --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
- ${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/app-masterworker/app-masterworker-vivaldi.tesh)
+ ADD_TESH_FACTORIES(app-masterworker-multicore "thread;ucontext;raw;boost"
+ --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/app-masterworker
+ --setenv bindir=${CMAKE_BINARY_DIR}/examples/deprecated/msg/app-masterworker
+ --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
+ ${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/app-masterworker/app-masterworker-multicore.tesh)
+ ADD_TESH_FACTORIES(app-masterworker-vivaldi "thread;ucontext;raw;boost"
+ --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/app-masterworker
+ --setenv bindir=${CMAKE_BINARY_DIR}/examples/deprecated/msg/app-masterworker
+ --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
+ ${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/app-masterworker/app-masterworker-vivaldi.tesh)
-if(SIMGRID_HAVE_NS3)
- ADD_TESH_FACTORIES(msg-network-ns3 "thread;ucontext;raw;boost"
- --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg
- --setenv bindir=${CMAKE_BINARY_DIR}/examples/deprecated/msg
- --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
- ${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/network-ns3/network-ns3.tesh)
-endif()
+ if(SIMGRID_HAVE_NS3)
+ ADD_TESH_FACTORIES(msg-network-ns3 "thread;ucontext;raw;boost"
+ --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg
+ --setenv bindir=${CMAKE_BINARY_DIR}/examples/deprecated/msg
+ --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
+ ${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/network-ns3/network-ns3.tesh)
+ endif()
+endif(enable_msg)
\ No newline at end of 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) 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 {
char mailbox[MAILBOX_NAME_SIZE]; //node mailbox
unsigned int find_node_success; //Number of find_node which have succeeded.
unsigned int find_node_failed; //Number of find_node which have failed.
-
} 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
foreach (x bugged1 bugged2 bugged3 centralized_mutex electric_fence bugged1_liveness bugged2_liveness)
- if(SIMGRID_HAVE_MC)
+ if(SIMGRID_HAVE_MC AND SIMGRID_HAVE_MSG)
add_executable (${x} EXCLUDE_FROM_ALL ${x}.c)
target_link_libraries(${x} simgrid)
add_dependencies(tests ${x})
set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/deploy_${x}.xml)
endforeach()
-if(SIMGRID_HAVE_MC)
+if(SIMGRID_HAVE_MC AND SIMGRID_HAVE_MSG)
if(HAVE_C_STACK_CLEANER)
add_executable (bugged1_liveness_cleaner_on EXCLUDE_FROM_ALL bugged1_liveness.c)
target_link_libraries(bugged1_liveness_cleaner_on 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. */
#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
-foreach(example actor-create actor-daemon actor-join actor-kill actor-migrate actor-suspend actor-yield # actor-lifetime
+foreach(example actor-create actor-daemon actor-join actor-kill actor-migrate actor-suspend actor-yield actor-lifetime
async-wait async-waitall async-waitany
exec-async exec-basic exec-dvfs exec-remote)
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${example}/${example}.tesh)
set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${example}/${example}.py)
if(enable_python)
- ADD_TESH(python-${example} --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
+ ADD_TESH_FACTORIES(python-${example} "thread;ucontext;raw;boost"
+ --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
--setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
--setenv pythoncmd=${PYTHON_EXECUTABLE}
--setenv LD_LIBRARY_PATH=${TESH_LIBRARY_PATH}
--setenv PYTHONPATH=${CMAKE_BINARY_DIR}/lib
--cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
- ${CMAKE_HOME_DIRECTORY}/examples/python/${example}/${example}.tesh)
+ ${example}.tesh)
endif()
endforeach()
set(tesh_files examples/python/actor-create/actor-create_d.xml
examples/python/actor-lifetime/actor-lifetime_d.xml
- examples/python/actor-lifetime/actor-lifetime.py # example broken so far
- examples/python/actor-lifetime/actor-lifetime.tesh
examples/python/async-wait/async-wait_d.xml
examples/python/async-waitall/async-waitall_d.xml
examples/python/async-waitany/async-waitany_d.xml
-# 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.
def __init__(self, *args):
if len(args) != 1: # Receiver actor expects 1 argument: its ID
raise AssertionError("Actor receiver requires 1 parameter, but got {:d}".format(len(args)))
- self.id = int(args[0])
+ self.mbox = Mailbox.by_name("receiver-{:s}".format(args[0]))
def __call__(self):
- # FIXME: It should be ok to initialize self.mbox from __init__, but it's currently failing on the OS X Jenkins slave.
- self.mbox = Mailbox.by_name("receiver-{:d}".format(self.id))
this_actor.info("Wait for my first message")
while True:
received = self.mbox.get()
> [ 0.105458] (2:receiver@Ruby) I got a 'Message 0'.
> [ 0.210917] (2:receiver@Ruby) I got a 'Message 1'.
> [ 0.316375] (2:receiver@Ruby) I got a 'Message 2'.
+> [ 0.318326] (1:sender@Tremblay) Goodbye now!
> [ 0.318326] (2:receiver@Ruby) I got a 'finalize'.
-> [ 0.318326] (1:sender@Tremblay) Goodbye now!
\ No newline at end of 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) 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.
-# Regular examples: with only one source and tested with all factories
+# Regular examples: with only one source and tested with all factories
######################################################################
foreach (example actor-create actor-daemon actor-exiting actor-join actor-kill
actor-lifetime actor-migrate actor-suspend actor-yield
app-chainsend app-pingpong app-token-ring
async-ready async-wait async-waitany async-waitall async-waituntil
+ comm-dependent
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
- io-async io-file-system io-file-remote io-disk-raw
+ 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 io-dependent
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)
endforeach()
-# Model-checking examples: with only one source and tested with all factories but thread
+# Model-checking examples: with only one source and tested with all factories but thread
######################################################################
foreach (example mc-failing-assert)
${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/${file}.hpp)
endforeach()
+# The tests of DHT, along with the parallel variant
+
+if(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
+ # Thread-local storage (TLS) is needed for parallel execution, but it doesn't
+ # play well with Ucontexts on 64bit SunOS (at least on x86_64).
+ set(parallel-factories "thread;raw;boost")
+else()
+ set(parallel-factories "thread;ucontext;raw;boost")
+endif()
+
foreach(example app-bittorrent app-masterworkers
dht-chord dht-kademlia
)
--setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
--cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
${CMAKE_HOME_DIRECTORY}/examples/s4u/${example}/s4u-${example}.tesh)
+
+ ADD_TESH_FACTORIES(s4u-${example}-parallel "${parallel-factories}" --cfg contexts/nthreads:4 ${CONTEXTS_SYNCHRO}
+ --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
+ --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
+ --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
+ ${CMAKE_HOME_DIRECTORY}/examples/s4u/${example}/s4u-${example}.tesh)
endforeach()
# Examples not accepting factories
-/* 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;
}
/* Our second class of actors is also a function */
-static int forwarder(int argc, char** argv)
+static void forwarder(int argc, char** argv)
{
xbt_assert(argc >= 3, "Actor forwarder requires 2 parameters, but got only %d", argc - 1);
simgrid::s4u::Mailbox* in = simgrid::s4u::Mailbox::by_name(argv[1]);
std::string* msg = static_cast<std::string*>(in->get());
XBT_INFO("Forward '%s'.", msg->c_str());
out->put(msg, msg->size());
- return 0;
}
/* Declares a third class of actors which sends a message to the mailbox 'mb42'.
-/* 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. */
/* This actor just sleeps until termination */
class sleeper {
-
public:
explicit sleeper(std::vector<std::string> /*args*/)
{
-/* 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 {
simgrid::s4u::CommPtr comm_received = nullptr; // current comm
Message* message = nullptr; // current message being received
+
public:
explicit Peer(std::vector<std::string> args);
Peer(const Peer&) = delete;
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;
if (compute_cost > 0) /* If compute_cost is valid, execute a computation of that cost */
simgrid::s4u::this_actor::execute(compute_cost);
-
} while (compute_cost > 0); /* Stop when receiving an invalid compute_cost */
XBT_INFO("Exiting now.");
-/* 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;
if (compute_cost > 0) /* If compute_cost is valid, execute a computation of that cost */
simgrid::s4u::this_actor::execute(compute_cost);
-
} while (compute_cost > 0); /* Stop when receiving an invalid compute_cost */
XBT_INFO("Exiting now.");
-/* 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. */
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_async_ready, "Messages specific for this s4u example");
-static int peer(int argc, char** argv)
+static void peer(int argc, char** argv)
{
xbt_assert(argc == 5, "Expecting 4 parameters from the XML deployment file but got %d", argc);
int my_id = std::stoi(argv[1]); /* - my id */
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());
simgrid::s4u::Comm::wait_all(&pending_comms);
XBT_INFO("Goodbye now!");
- return 0;
}
> [ 0.110000] (3:peer@Perl) I got a 'Message 5 from peer 1'.
> [ 0.110000] (3:peer@Perl) I got a 'finalize'.
> [ 0.110000] (3:peer@Perl) I'm done, just waiting for my peers to receive the messages before exiting
-> [ 0.110000] (3:peer@Perl) Goodbye now!
> [ 0.110000] (1:peer@Tremblay) Goodbye now!
> [ 0.110000] (2:peer@Ruby) Goodbye now!
+> [ 0.110000] (3:peer@Perl) Goodbye now!
-/* 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_LOG_NEW_DEFAULT_CATEGORY(s4u_async_wait, "Messages specific for this s4u example");
-static int sender(int argc, char** argv)
+static void sender(int argc, char** argv)
{
xbt_assert(argc == 4, "Expecting 3 parameters from the XML deployment file but got %d", argc);
long messages_count = std::stol(argv[1]); /* - number of tasks */
/* Start dispatching all messages to receivers, in a round robin fashion */
for (int i = 0; i < messages_count; i++) {
std::string msg_content = std::string("Message ") + std::to_string(i);
- // Copy the data we send: 'msg_content' is not a stable storage location.
- // It will be destroyed when this actor leaves the loop, ie before the receiver gets it
+ // Copy the data we send: the 'msg_content' variable is not a stable storage location.
+ // It will be destroyed when this actor leaves the loop, ie before the receiver gets the data
std::string* payload = new std::string(msg_content);
XBT_INFO("Send '%s' to '%s'", msg_content.c_str(), mboxes[i % receivers_count]->get_cname());
}
XBT_INFO("Goodbye now!");
- return 0;
}
/* Receiver actor expects 1 argument: its ID */
-static int receiver(int argc, char** argv)
+static void receiver(int argc, char** argv)
{
xbt_assert(argc == 2, "Expecting one parameter from the XML deployment file but got %d", argc);
simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(std::string("receiver-") + argv[1]);
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.
delete received;
}
- return 0;
}
int main(int argc, char *argv[])
> [ 0.210917] (2:receiver@Ruby) I got a 'Message 1'.
> [ 0.316375] (2:receiver@Ruby) I got a 'Message 2'.
> [ 0.318326] (2:receiver@Ruby) I got a 'finalize'.
-> [ 0.318326] (1:sender@Tremblay) Goodbye now!
\ No newline at end of file
+> [ 0.318326] (1:sender@Tremblay) Goodbye now!
-/* 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. */
/* Start dispatching all messages to receivers, in a round robin fashion */
for (int i = 0; i < messages_count; i++) {
std::string msg_content = std::string("Message ") + std::to_string(i);
- // Copy the data we send: 'msg_content' is not a stable storage location.
+ // Copy the data we send: the 'msg_content' variable is not a stable storage location.
// It will be destroyed when this actor leaves the loop, ie before the receiver gets it
std::string* payload = new std::string(msg_content);
{
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. */
/* Start dispatching all messages to receivers, in a round robin fashion */
for (int i = 0; i < messages_count; i++) {
std::string msg_content = std::string("Message ") + std::to_string(i);
- // Copy the data we send: 'msg_content' is not a stable storage location.
+ // Copy the data we send: the 'msg_content' variable is not a stable storage location.
// It will be destroyed when this actor leaves the loop, ie before the receiver gets it
std::string* payload = new std::string(msg_content);
{
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_LOG_NEW_DEFAULT_CATEGORY(s4u_async_waituntil, "Messages specific for this s4u example");
-static int sender(int argc, char** argv)
+static void sender(int argc, char** argv)
{
xbt_assert(argc == 4, "Expecting 3 parameters from the XML deployment file but got %d", argc);
long messages_count = std::stol(argv[1]); /* - number of tasks */
/* Start dispatching all messages to receivers, in a round robin fashion */
for (int i = 0; i < messages_count; i++) {
-
std::string mboxName = std::string("receiver-") + std::to_string(i % receivers_count);
simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName);
std::string msgName = std::string("Message ") + std::to_string(i);
std::string* payload = new std::string(msgName); // copy the data we send:
+
// 'msgName' is not a stable storage location
XBT_INFO("Send '%s' to '%s'", msgName.c_str(), mboxName.c_str());
/* Create a communication representing the ongoing communication */
}
XBT_INFO("Goodbye now!");
- return 0;
}
/* Receiver actor expects 1 argument: its ID */
-static int receiver(int argc, char** argv)
+static void receiver(int argc, char** argv)
{
xbt_assert(argc == 2, "Expecting one parameter from the XML deployment file but got %d", argc);
simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(std::string("receiver-") + argv[1]);
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.
delete received;
}
- return 0;
}
int main(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) 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,
--- /dev/null
+/* 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 <simgrid/s4u.hpp>
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_comm_dependent, "Messages specific for this s4u example");
+
+static void sender(simgrid::s4u::Mailbox* mailbox)
+{
+ double* computation_amount = new double();
+ *computation_amount = simgrid::s4u::this_actor::get_host()->get_speed();
+ simgrid::s4u::ExecPtr exec = simgrid::s4u::this_actor::exec_init(2 * (*computation_amount));
+ simgrid::s4u::CommPtr comm = mailbox->put_init(computation_amount, 7e6);
+
+ exec->set_name("exec on sender")->add_successor(comm)->start();
+ comm->set_name("comm to receiver")->vetoable_start();
+ exec->wait();
+ comm->wait();
+}
+
+static void receiver(simgrid::s4u::Mailbox* mailbox)
+{
+ double* received = nullptr;
+ double computation_amount = simgrid::s4u::this_actor::get_host()->get_speed();
+ simgrid::s4u::ExecPtr exec = simgrid::s4u::this_actor::exec_init(2 * computation_amount);
+ simgrid::s4u::CommPtr comm = mailbox->get_init()->set_dst_data((void**)&received, sizeof(double));
+
+ comm->set_name("comm from sender")->add_successor(exec)->start();
+ exec->set_name("exec on receiver")->vetoable_start();
+
+ comm->wait();
+ exec->wait();
+ XBT_INFO("Received: %.0f flops were computed on sender", *received);
+ delete received;
+}
+
+int main(int argc, char* argv[])
+{
+ simgrid::s4u::Engine e(&argc, argv);
+ e.load_platform(argv[1]);
+
+ simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name("Mailbox");
+
+ simgrid::s4u::Actor::create("sender", simgrid::s4u::Host::by_name("Tremblay"), sender, mbox);
+ simgrid::s4u::Actor::create("receiver", simgrid::s4u::Host::by_name("Jupiter"), receiver, mbox);
+
+ e.run();
+
+ XBT_INFO("Simulation time: %.3f", e.get_clock());
+
+ return 0;
+}
--- /dev/null
+#!/usr/bin/env tesh
+
+p Testing with default compound
+
+$ ${bindir:=.}/s4u-comm-dependent ${platfdir}/small_platform.xml --log=s4u_activity.t:debug "--log=root.fmt:[%6.2r]%e(%i:%P@%h)%e%m%n"
+> [ 2.00] (1:sender@Tremblay) Remove a dependency from 'exec on sender' on 'comm to receiver'
+> [ 2.00] (1:sender@Tremblay) All dependencies are solved, let's start 'comm to receiver'
+> [ 3.07] (2:receiver@Jupiter) Remove a dependency from 'comm from sender' on 'exec on receiver'
+> [ 3.07] (2:receiver@Jupiter) All dependencies are solved, let's start 'exec on receiver'
+> [ 5.07] (2:receiver@Jupiter) Received: 98095000 flops were computed on sender
+> [ 5.07] (0:maestro@) Simulation time: 5.070
-/* 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;
delete message;
}
}
+
+void Node::operator()()
+{
+ simgrid::s4u::this_actor::sleep_for(start_time_);
+ if (known_id_ == -1) {
+ setPredecessor(-1); // -1 means that I have no predecessor
+ printFingerTable();
+ joined = true;
+ } else {
+ join(known_id_);
+ }
+
+ if (not joined)
+ return;
+ void* data = nullptr;
+ double now = simgrid::s4u::Engine::get_clock();
+ double next_stabilize_date = start_time_ + PERIODIC_STABILIZE_DELAY;
+ double next_fix_fingers_date = start_time_ + PERIODIC_FIX_FINGERS_DELAY;
+ double next_check_predecessor_date = start_time_ + PERIODIC_CHECK_PREDECESSOR_DELAY;
+ double next_lookup_date = start_time_ + PERIODIC_LOOKUP_DELAY;
+ simgrid::s4u::CommPtr comm_receive = nullptr;
+ while (now < std::min(start_time_ + deadline_, MAX_SIMULATION_TIME)) {
+ if (comm_receive == nullptr)
+ comm_receive = mailbox_->get_async(&data);
+ bool comm_completed = true;
+ try {
+ if (not comm_receive->test())
+ comm_completed = false;
+ } catch (const simgrid::TimeoutException&) {
+ XBT_DEBUG("Caught a timeout, go ahead.");
+ }
+
+ if (comm_completed) {
+ if (data != nullptr) {
+ ChordMessage* message = static_cast<ChordMessage*>(data);
+ handleMessage(message);
+ data = nullptr;
+ }
+ comm_receive = nullptr;
+ } else {
+ // no task was received: make some periodic calls
+ if (now >= next_stabilize_date) {
+ stabilize();
+ next_stabilize_date = simgrid::s4u::Engine::get_clock() + PERIODIC_STABILIZE_DELAY;
+ } else if (now >= next_fix_fingers_date) {
+ fixFingers();
+ next_fix_fingers_date = simgrid::s4u::Engine::get_clock() + PERIODIC_FIX_FINGERS_DELAY;
+ } else if (now >= next_check_predecessor_date) {
+ checkPredecessor();
+ next_check_predecessor_date = simgrid::s4u::Engine::get_clock() + PERIODIC_CHECK_PREDECESSOR_DELAY;
+ } else if (now >= next_lookup_date) {
+ randomLookup();
+ next_lookup_date = simgrid::s4u::Engine::get_clock() + PERIODIC_LOOKUP_DELAY;
+ } else {
+ // nothing to do: sleep for a while
+ simgrid::s4u::this_actor::sleep_for(SLEEP_DELAY);
+ }
+ }
+
+ now = simgrid::s4u::Engine::get_clock();
+ }
+ if (comm_receive != nullptr) {
+ try {
+ if (comm_receive->test())
+ delete static_cast<ChordMessage*>(data);
+ else
+ comm_receive->cancel();
+ } catch (const simgrid::TimeoutException&) {
+ XBT_DEBUG("Caught a timeout for last message, nevermind.");
+ }
+ }
+ // leave the ring
+ leave();
+}
-/* 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);
};
void stabilize();
void handleMessage(ChordMessage* message);
- void operator()()
- {
- simgrid::s4u::this_actor::sleep_for(start_time_);
- if (known_id_ == -1) {
- setPredecessor(-1); // -1 means that I have no predecessor
- printFingerTable();
- joined = true;
- } else {
- join(known_id_);
- }
-
- if (not joined)
- return;
- void* data = nullptr;
- double now = simgrid::s4u::Engine::get_clock();
- double next_stabilize_date = start_time_ + PERIODIC_STABILIZE_DELAY;
- double next_fix_fingers_date = start_time_ + PERIODIC_FIX_FINGERS_DELAY;
- double next_check_predecessor_date = start_time_ + PERIODIC_CHECK_PREDECESSOR_DELAY;
- double next_lookup_date = start_time_ + PERIODIC_LOOKUP_DELAY;
- simgrid::s4u::CommPtr comm_receive = nullptr;
- while ((now < (start_time_ + deadline_)) && now < MAX_SIMULATION_TIME) {
- if (comm_receive == nullptr)
- comm_receive = mailbox_->get_async(&data);
- while ((now < (start_time_ + deadline_)) && now < MAX_SIMULATION_TIME && not comm_receive->test()) {
- // no task was received: make some periodic calls
- if (now >= next_stabilize_date) {
- stabilize();
- next_stabilize_date = simgrid::s4u::Engine::get_clock() + PERIODIC_STABILIZE_DELAY;
- } else if (now >= next_fix_fingers_date) {
- fixFingers();
- next_fix_fingers_date = simgrid::s4u::Engine::get_clock() + PERIODIC_FIX_FINGERS_DELAY;
- } else if (now >= next_check_predecessor_date) {
- checkPredecessor();
- next_check_predecessor_date = simgrid::s4u::Engine::get_clock() + PERIODIC_CHECK_PREDECESSOR_DELAY;
- } else if (now >= next_lookup_date) {
- randomLookup();
- next_lookup_date = simgrid::s4u::Engine::get_clock() + PERIODIC_LOOKUP_DELAY;
- } else {
- // nothing to do: sleep for a while
- simgrid::s4u::this_actor::sleep_for(SLEEP_DELAY);
- }
- now = simgrid::s4u::Engine::get_clock();
- }
-
- if (data != nullptr) {
- ChordMessage* message = static_cast<ChordMessage*>(data);
- handleMessage(message);
- comm_receive = nullptr;
- data = nullptr;
- }
- now = simgrid::s4u::Engine::get_clock();
- }
- if (comm_receive != nullptr) {
- if (comm_receive->test())
- delete static_cast<ChordMessage*>(data);
- else
- comm_receive->cancel();
- }
- // leave the ring
- leave();
- }
+ void operator()();
};
#endif
-/* 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
* @param the ID of the person I know in the system (or not)
* @param Time before I leave the system because I'm bored
*/
-static int node(int argc, char* argv[])
+static void node(int argc, char* argv[])
{
bool join_success = true;
double deadline;
xbt_assert(argc == 3 || argc == 4, "Wrong number of arguments");
/* Node initialization */
unsigned int node_id = strtoul(argv[1], nullptr, 0);
- kademlia::Node* node = new kademlia::Node(node_id);
+ kademlia::Node node(node_id);
if (argc == 4) {
- XBT_INFO("Hi, I'm going to join the network with id %u", node->getId());
+ XBT_INFO("Hi, I'm going to join the network with id %u", node.getId());
unsigned int known_id = strtoul(argv[2], NULL, 0);
- join_success = node->join(known_id);
+ join_success = node.join(known_id);
deadline = std::stod(argv[3]);
} else {
deadline = std::stod(argv[2]);
- XBT_INFO("Hi, I'm going to create the network with id %u", node->getId());
- node->routingTableUpdate(node->getId());
+ XBT_INFO("Hi, I'm going to create the network with id %u", node.getId());
+ node.routingTableUpdate(node.getId());
}
if (join_success) {
- XBT_VERB("Ok, I'm joining the network with id %u", node->getId());
+ XBT_VERB("Ok, I'm joining the network with id %u", node.getId());
// We start the main loop
double next_lookup_time = simgrid::s4u::Engine::get_clock() + RANDOM_LOOKUP_INTERVAL;
XBT_VERB("Main loop start");
- simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(node->getId()));
+ simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(node.getId()));
while (simgrid::s4u::Engine::get_clock() < deadline) {
- if (node->receive_comm == nullptr)
- node->receive_comm = mailbox->get_async(&node->received_msg);
+ if (node.receive_comm == nullptr)
+ node.receive_comm = mailbox->get_async(&node.received_msg);
- if (node->receive_comm->test()) {
+ 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);
+ node.handleFindNode(msg);
delete msg->answer_;
delete msg;
- node->receive_comm = nullptr;
+ node.receive_comm = nullptr;
} else
simgrid::s4u::this_actor::sleep_for(1);
} else {
/* We search for a pseudo random node */
if (simgrid::s4u::Engine::get_clock() >= next_lookup_time) {
- node->randomLookup();
+ node.randomLookup();
next_lookup_time += RANDOM_LOOKUP_INTERVAL;
} else {
// Didn't get a message: sleep for a while...
XBT_INFO("I couldn't join the network :(");
}
XBT_DEBUG("I'm leaving the network");
- XBT_INFO("%u/%u FIND_NODE have succeeded", node->find_node_success, node->find_node_success + node->find_node_failed);
- delete node;
-
- return 0;
+ XBT_INFO("%u/%u FIND_NODE have succeeded", node.find_node_success, node.find_node_success + node.find_node_failed);
}
/** @brief Main function */
-/* 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. */
--- /dev/null
+/* Copyright (c) 2007-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. */
+
+#include "simgrid/s4u.hpp"
+#include <vector>
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+
+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);
+
+ // 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);
+ second_parent->add_successor(child);
+
+ // 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();
+
+ // 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);
+ }
+}
+
+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("Fafard"), worker);
+
+ e.run();
+
+ XBT_INFO("Simulation time %g", e.get_clock());
+
+ return 0;
+}
--- /dev/null
+#!/usr/bin/env tesh
+
+! 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
--- /dev/null
+/* Copyright (c) 2007-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. */
+
+#include "simgrid/s4u.hpp"
+#include <simgrid/plugins/file_system.h>
+#include <vector>
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+
+static void test()
+{
+ simgrid::s4u::ExecPtr bob_compute = simgrid::s4u::this_actor::exec_init(1e9);
+ simgrid::s4u::IoPtr bob_write =
+ simgrid::s4u::Host::current()->get_disks().front()->io_init(4000000, simgrid::s4u::Io::OpType::WRITE);
+ simgrid::s4u::IoPtr carl_read =
+ simgrid::s4u::Host::by_name("carl")->get_disks().front()->io_init(4000000, simgrid::s4u::Io::OpType::READ);
+ simgrid::s4u::ExecPtr carl_compute = simgrid::s4u::Host::by_name("carl")->exec_async(1e9);
+
+ // Name the activities (for logging purposes only)
+ bob_compute->set_name("bob compute");
+ bob_write->set_name("bob write");
+ carl_read->set_name("carl read");
+ carl_compute->set_name("carl compute");
+
+ // Create the dependencies:
+ // 'bob_write' is a successor of 'bob_compute'
+ // 'carl_read' is a successor of 'bob_write'
+ // 'carl_compute' is a successor of 'carl_read'
+ bob_compute->add_successor(bob_write);
+ bob_write->add_successor(carl_read);
+ carl_read->add_successor(carl_compute);
+
+ // Start the activities.
+ bob_compute->start();
+ bob_write->vetoable_start();
+ carl_read->vetoable_start();
+ carl_compute->vetoable_start();
+
+ // Wait for their completion (should be replaced by a wait_any_for at some point)
+ bob_compute->wait();
+ bob_write->wait();
+ carl_read->wait();
+ carl_compute->wait();
+}
+
+int main(int argc, char* argv[])
+{
+ simgrid::s4u::Engine e(&argc, argv);
+ sg_storage_file_system_init();
+ e.load_platform(argv[1]);
+
+ simgrid::s4u::Actor::create("bob", simgrid::s4u::Host::by_name("bob"), test);
+
+ e.run();
+
+ XBT_INFO("Simulation time %g", e.get_clock());
+
+ return 0;
+}
--- /dev/null
+#!/usr/bin/env tesh
+
+! output sort
+$ ${bindir:=.}/s4u-io-dependent ${platfdir}/hosts_with_disks.xml --log=s4u_activity.t:debug "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 1.000000] (1:bob@bob) All dependencies are solved, let's start 'bob write'
+> [ 1.000000] (1:bob@bob) Remove a dependency from 'bob compute' on 'bob write'
+> [ 1.100000] (1:bob@bob) All dependencies are solved, let's start 'carl read'
+> [ 1.100000] (1:bob@bob) Remove a dependency from 'bob write' on 'carl read'
+> [ 1.166667] (1:bob@bob) All dependencies are solved, let's start 'carl compute'
+> [ 1.166667] (1:bob@bob) Remove a dependency from 'carl read' on 'carl compute'
+> [ 2.166667] (0:maestro@) Simulation time 2.16667
-/* 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)
- XBT_INFO("Disk name: %s", disk->get_cname());
+ 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());
/* - Write 400,000 bytes on Disk1 */
simgrid::s4u::Disk* disk = disk_list.front();
/* - 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");
> [ 0.000000] (0:maestro@) *** carl properties ****
> [ 0.000000] (0:maestro@) remote_disk -> /scratch:Disk1:bob
> [ 0.000000] (1:@bob) *** Storage info on bob ***
-> [ 0.000000] (1:@bob) Disk name: Disk1
-> [ 0.000000] (1:@bob) Disk name: Disk2
+> [ 0.000000] (1:@bob) Disk name: Disk1 (read: 100000000 B/s -- write: 40000000 B/s
+> [ 0.000000] (1:@bob) Disk name: Disk2 (read: 200000000 B/s -- write: 80000000 B/s
> [ 0.010000] (1:@bob) Wrote 400000 bytes on 'Disk1'
> [ 0.012000] (1:@bob) Read 200000 bytes on 'Disk1'
> [ 0.012000] (1:@bob) *** Get/set data for storage element: Disk1 ***
-/* 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. */
XBT_LOG_NEW_DEFAULT_CATEGORY(remote_io, "Messages specific for this io example");
-static int host(int argc, char* argv[])
+static void host(int argc, char* argv[])
{
simgrid::s4u::File file(argv[1], nullptr);
const char* filename = file.get_path();
file.remote_copy(simgrid::s4u::Host::by_name(argv[2]), argv[3]);
}
}
- return 0;
}
int main(int argc, char** argv)
-/* 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_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
-static int master(int argc, char* argv[])
+static void master(int argc, char* argv[])
{
xbt_assert(argc == 5, "Expecting one parameter");
}
XBT_INFO("Goodbye now!");
- return 0;
}
-static int worker(int argc, char* argv[])
+static void worker(int argc, char* argv[])
{
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 {
XBT_INFO("Mmh. Something went wrong. Nevermind. Let's keep going!");
}
}
- return 0;
}
int main(int argc, char* argv[])
-/* 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. */
$ rm -rf ${bindir:=.}/smpi_trace.trace ${bindir:=.}/smpi_trace.trace_files
-$ ../../smpi_script/bin/smpirun -trace-ti --cfg=tracing/filename:${bindir:=.}/smpi_trace.trace --cfg=tracing/smpi/format/ti-one-file:yes -no-privatize -replay ${srcdir:=.}/replay/actions_bcast.txt --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc --cfg=smpi/simulate-computation:no -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./ampi_test/smpi_ampi_test --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/wtime:0
+$ ../../smpi_script/bin/smpirun -trace-ti --cfg=tracing/filename:${bindir:=.}/smpi_trace.trace --cfg=tracing/smpi/format/ti-one-file:yes -no-privatize -replay ${srcdir:=.}/replay/actions_bcast.txt --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc --cfg=smpi/simulate-computation:no -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./ampi_test/smpi_ampi_test --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/wtime:0
$ sh -c "cat ${bindir:=.}/smpi_trace.trace_files/*"
> 0 init
-/* 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
p Test smpi bindings for dvfs functions (C example)
-$ ${bindir:=.}/../smpi_script/bin/smpirun -np 2 -hostfile ${srcdir:=.}/hostfile -platform ${platfdir}/energy_platform.xml --cfg=smpi/simulate-computation:no ${bindir:=.}/../examples/smpi/energy/smpi_energy --cfg=plugin:host_energy --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/wtime:0
+$ ${bindir:=.}/../smpi_script/bin/smpirun -np 2 -hostfile ${srcdir:=.}/hostfile -platform ${platfdir}/energy_platform.xml --cfg=smpi/simulate-computation:no ${bindir:=.}/../examples/smpi/energy/smpi_energy --cfg=plugin:host_energy --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/wtime:0
> [0.000000] [rank 0] Pstates: 3; Powers: 100000000, 50000000, 20000000
> [0.000000] [rank 1] Pstates: 3; Powers: 100000000, 50000000, 20000000
> [0.000000] [rank 0] Current pstate: 0; Current power: 100000000
p Test instrumentation of SMPI
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ${srcdir:=.}/../hostfile -platform ${platfdir:=.}/small_platform.xml --cfg=path:${srcdir:=.}/../msg --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/host-speed:1 -np 8 ${bindir:=.}/smpi_gemm 1000 native
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ${srcdir:=.}/../hostfile -platform ${platfdir:=.}/small_platform.xml --cfg=path:${srcdir:=.}/../msg --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/host-speed:1 -np 8 ${bindir:=.}/smpi_gemm 1000 native
> You requested to use 8 ranks, but there is only 5 processes in your hostfile...
> Matrix Size : 1000x1000
> Native mode
> Performance= 227.39 GFlop/s, Time= 8.795 sec, Size= 2000000000 Ops
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ${srcdir:=.}/../hostfile -platform ${platfdir:=.}/small_platform.xml --cfg=path:${srcdir:=.}/../msg --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/host-speed:1 -np 8 ${bindir:=.}/smpi_gemm 1000 sampling
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ${srcdir:=.}/../hostfile -platform ${platfdir:=.}/small_platform.xml --cfg=path:${srcdir:=.}/../msg --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/host-speed:1 -np 8 ${bindir:=.}/smpi_gemm 1000 sampling
> You requested to use 8 ranks, but there is only 5 processes in your hostfile...
> Matrix Size : 1000x1000
> Sampling mode
/* 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. */
$ mkfile replay/one_trace_override
! timeout 60
-$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace_override --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace_override --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [Tremblay:0:(1) 0.000000] [smpi_replay/VERBOSE] 0 bcast 5e4 0.000000
> [Jupiter:1:(2) 0.015036] [smpi_replay/VERBOSE] 1 bcast 5e4 0.015036
> [Fafard:2:(3) 0.015676] [smpi_replay/VERBOSE] 2 bcast 5e4 0.015676
< replay/actions_bcast.txt
$ mkfile replay/one_trace_override
-$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace_override --log=replay.thresh:critical --log=no_loc --cfg=tracing:yes --cfg=tracing/smpi:yes --cfg=tracing/smpi/computing:yes --cfg=tracing/filename:./simgrid_override.trace -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace_override --log=replay.thresh:critical --log=no_loc --cfg=tracing:yes --cfg=tracing/smpi:yes --cfg=tracing/smpi/computing:yes --cfg=tracing/filename:./simgrid_override.trace -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [Fafard:2:(3) 19.691622] [smpi_replay/INFO] Simulation time 19.691622
# $ rm -f replay/one_trace_override
< replay/actions1.txt
$ mkfile ./split_traces_tesh_override
-$ ../../smpi_script/bin/smpirun -no-privatize -replay ./split_traces_tesh_override --log=smpi_replay.thresh:verbose --log=no_loc -np 2 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ../../smpi_script/bin/smpirun -no-privatize -replay ./split_traces_tesh_override --log=smpi_replay.thresh:verbose --log=no_loc -np 2 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [Tremblay:0:(1) 0.167158] [smpi_replay/VERBOSE] 0 send 1 0 1e6 0.167158
> [Jupiter:1:(2) 0.167158] [smpi_replay/VERBOSE] 1 recv 0 0 1e6 0.167158
> [Jupiter:1:(2) 13.274005] [smpi_replay/VERBOSE] 1 compute 1e9 13.106847
< replay/actions_barrier.txt
$ mkfile replay/one_trace_override
-$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace_override --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace_override --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [Tremblay:0:(1) 1.518421] [smpi_replay/VERBOSE] 0 send 1 0 1e7 1.518421
> [Jupiter:1:(2) 1.518421] [smpi_replay/VERBOSE] 1 recv 0 0 1e7 1.518421
> [Tremblay:0:(1) 1.520397] [smpi_replay/VERBOSE] 0 barrier 0.001976
< replay/actions_with_isend.txt
$ mkfile replay/one_trace_override
-$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace_override --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace_override --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [Jupiter:1:(2) 0.000000] [smpi_replay/VERBOSE] 1 irecv 0 0 1e6 0.000000
> [Jupiter:1:(2) 6.553424] [smpi_replay/VERBOSE] 1 compute 5e8 6.553424
> [Jupiter:1:(2) 6.553524] [smpi_replay/VERBOSE] 1 test 0 1 0 0.000100
< replay/actions_allreduce.txt
$ mkfile replay/one_trace_override
-$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace_override --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace_override --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [Tremblay:0:(1) 5.112775] [smpi_replay/VERBOSE] 0 allreduce 5e4 5e8 5.112775
> [Jupiter:1:(2) 6.584135] [smpi_replay/VERBOSE] 1 allreduce 5e4 5e8 6.584135
> [Fafard:2:(3) 6.584775] [smpi_replay/VERBOSE] 2 allreduce 5e4 5e8 6.584775
< replay/actions_alltoall.txt
$ mkfile replay/one_trace_override
-$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace_override --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace_override --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [Tremblay:0:(1) 0.004041] [smpi_replay/VERBOSE] 0 alltoall 500 500 0.004041
> [Fafard:2:(3) 0.006920] [smpi_replay/VERBOSE] 2 alltoall 500 500 0.006920
> [Jupiter:1:(2) 0.006920] [smpi_replay/VERBOSE] 1 alltoall 500 500 0.006920
< replay/actions_alltoallv.txt
$ mkfile replay/one_trace_override
-$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace_override --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace_override --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [Tremblay:0:(1) 0.004000] [smpi_replay/VERBOSE] 0 alltoallv 100 1 40 30 1000 1 80 100 0.004000
> [Jupiter:1:(2) 0.006935] [smpi_replay/VERBOSE] 1 alltoallv 1000 80 1 40 1000 40 1 30 0.006935
> [Fafard:2:(3) 0.006936] [smpi_replay/VERBOSE] 2 alltoallv 1000 100 30 1 1000 30 40 1 0.006936
< replay/actions_allgatherv.txt
$ mkfile replay/one_trace_override
-$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace_override --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 4 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace_override --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 4 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [Tremblay:0:(1) 1.397261] [smpi_replay/VERBOSE] 0 allgatherv 275427 275427 275427 275427 204020 0 0 1.397261
> [Ginette:3:(4) 1.760421] [smpi_replay/VERBOSE] 3 allgatherv 204020 275427 275427 275427 204020 0 0 1.760421
> [Fafard:2:(3) 1.941986] [smpi_replay/VERBOSE] 2 allgatherv 275427 275427 275427 275427 204020 0 0 1.941986
$ mkfile replay/one_trace_override
! output sort 19
-$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace_override --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace_override --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [Fafard:2:(3) 0.000000] [smpi_replay/VERBOSE] 2 irecv 1 1 3000 0.000000
> [Fafard:2:(3) 0.000000] [smpi_replay/VERBOSE] 2 isend 0 2 3000 0.000000
> [Jupiter:1:(2) 0.000000] [smpi_replay/VERBOSE] 1 isend 0 0 2000 0.000000
-/* 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. */
$ mkfile replay/one_trace
! timeout 60
-$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./replay/smpi_replay --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./replay/smpi_replay --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [Tremblay:0:(1) 0.000000] [smpi_replay/VERBOSE] 0 bcast 5e4 0.000000
> [Jupiter:1:(2) 0.015036] [smpi_replay/VERBOSE] 1 bcast 5e4 0.015036
> [Fafard:2:(3) 0.015676] [smpi_replay/VERBOSE] 2 bcast 5e4 0.015676
< replay/actions_bcast.txt
$ mkfile replay/one_trace
-$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace --log=replay.thresh:critical --log=no_loc --cfg=tracing:yes --cfg=tracing/smpi:yes --cfg=tracing/smpi/computing:yes -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./replay/smpi_replay --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace --log=replay.thresh:critical --log=no_loc --cfg=tracing:yes --cfg=tracing/smpi:yes --cfg=tracing/smpi/computing:yes -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./replay/smpi_replay --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [Fafard:2:(3) 19.691622] [smpi_replay/INFO] Simulation time 19.691622
$ rm -f replay/one_trace
< replay/actions1.txt
$ mkfile ./split_traces_tesh
-$ ../../smpi_script/bin/smpirun -no-privatize -replay ./split_traces_tesh --log=smpi_replay.thresh:verbose --log=no_loc -np 2 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./replay/smpi_replay --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ../../smpi_script/bin/smpirun -no-privatize -replay ./split_traces_tesh --log=smpi_replay.thresh:verbose --log=no_loc -np 2 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./replay/smpi_replay --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [Tremblay:0:(1) 0.167158] [smpi_replay/VERBOSE] 0 send 1 0 1e6 0.167158
> [Jupiter:1:(2) 0.167158] [smpi_replay/VERBOSE] 1 recv 0 0 1e6 0.167158
> [Jupiter:1:(2) 13.274005] [smpi_replay/VERBOSE] 1 compute 1e9 13.106847
< replay/actions_barrier.txt
$ mkfile replay/one_trace
-$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./replay/smpi_replay --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./replay/smpi_replay --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [Tremblay:0:(1) 1.518421] [smpi_replay/VERBOSE] 0 send 1 0 1e7 1.518421
> [Jupiter:1:(2) 1.518421] [smpi_replay/VERBOSE] 1 recv 0 0 1e7 1.518421
> [Tremblay:0:(1) 1.520397] [smpi_replay/VERBOSE] 0 barrier 0.001976
< replay/actions_with_isend.txt
$ mkfile replay/one_trace
-$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./replay/smpi_replay --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./replay/smpi_replay --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [Jupiter:1:(2) 0.000000] [smpi_replay/VERBOSE] 1 irecv 0 0 1e6 0.000000
> [Jupiter:1:(2) 6.553424] [smpi_replay/VERBOSE] 1 compute 5e8 6.553424
> [Jupiter:1:(2) 6.553524] [smpi_replay/VERBOSE] 1 test 0 1 0 0.000100
< replay/actions_allreduce.txt
$ mkfile replay/one_trace
-$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./replay/smpi_replay --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./replay/smpi_replay --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [Tremblay:0:(1) 5.112775] [smpi_replay/VERBOSE] 0 allreduce 5e4 5e8 5.112775
> [Jupiter:1:(2) 6.584135] [smpi_replay/VERBOSE] 1 allreduce 5e4 5e8 6.584135
> [Fafard:2:(3) 6.584775] [smpi_replay/VERBOSE] 2 allreduce 5e4 5e8 6.584775
< replay/actions_alltoall.txt
$ mkfile replay/one_trace
-$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./replay/smpi_replay --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./replay/smpi_replay --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [Tremblay:0:(1) 0.004041] [smpi_replay/VERBOSE] 0 alltoall 500 500 0.004041
> [Fafard:2:(3) 0.006920] [smpi_replay/VERBOSE] 2 alltoall 500 500 0.006920
> [Jupiter:1:(2) 0.006920] [smpi_replay/VERBOSE] 1 alltoall 500 500 0.006920
< replay/actions_alltoallv.txt
$ mkfile replay/one_trace
-$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./replay/smpi_replay --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./replay/smpi_replay --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [Tremblay:0:(1) 0.004000] [smpi_replay/VERBOSE] 0 alltoallv 100 1 40 30 1000 1 80 100 0.004000
> [Jupiter:1:(2) 0.006935] [smpi_replay/VERBOSE] 1 alltoallv 1000 80 1 40 1000 40 1 30 0.006935
> [Fafard:2:(3) 0.006936] [smpi_replay/VERBOSE] 2 alltoallv 1000 100 30 1 1000 30 40 1 0.006936
< replay/actions_allgatherv.txt
$ mkfile replay/one_trace
-$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 4 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./replay/smpi_replay --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 4 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./replay/smpi_replay --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [Tremblay:0:(1) 1.397261] [smpi_replay/VERBOSE] 0 allgatherv 275427 275427 275427 275427 204020 0 0 1.397261
> [Ginette:3:(4) 1.760421] [smpi_replay/VERBOSE] 3 allgatherv 204020 275427 275427 275427 204020 0 0 1.760421
> [Fafard:2:(3) 1.941986] [smpi_replay/VERBOSE] 2 allgatherv 275427 275427 275427 275427 204020 0 0 1.941986
$ mkfile replay/one_trace
! output sort 19
-$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./replay/smpi_replay --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ../../smpi_script/bin/smpirun -no-privatize -replay replay/one_trace --log=replay.thresh:critical --log=smpi_replay.thresh:verbose --log=no_loc -np 3 -platform ${srcdir:=.}/../platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile ./replay/smpi_replay --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [Fafard:2:(3) 0.000000] [smpi_replay/VERBOSE] 2 irecv 1 1 3000 0.000000
> [Fafard:2:(3) 0.000000] [smpi_replay/VERBOSE] 2 isend 0 2 3000 0.000000
> [Jupiter:1:(2) 0.000000] [smpi_replay/VERBOSE] 1 isend 0 0 2000 0.000000
#!/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.
if [ -n "${DESCRIPTIONFILE}" ] && [ -f "${DESCRIPTIONFILE}" ]; then
IFS_OLD=$IFS
- IFS=$'\n'
+ IFS=$(printf '\n_'); IFS=${IFS%_} # protect trailing \n
set -f
NUMPROCS=0
while IFS= read -r line; do
SEQ1=$( ${HAVE_SEQ} 0 $(( NUMPROCSMINE - 1 )) )
else
cnt=0
- while (( cnt < NUMPROCSMINE )) ; do
+ while [ $(( cnt < NUMPROCSMINE )) -ne 0 ]; do
SEQ1="$SEQ1 $cnt"
cnt=$((cnt + 1))
done
done
# return IFS back to newline for "for" loop
IFS_OLD=$IFS
- IFS=$'\n'
+ IFS=$(printf '\n_'); IFS=${IFS%_} # protect trailing \n
done < ${DESCRIPTIONFILE}
# return delimiter to previous value
-/* 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
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include "simgrid/msg.h"
#include "mpi.h"
+#include "simgrid/engine.h"
+#include "xbt/str.h"
#include <stdio.h>
#include <string.h>
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
-static int smpi_replay(int argc, char *argv[]) {
+static void smpi_replay(int argc, char* argv[])
+{
const char* instance_id = argv[1];
int rank = xbt_str_parse_int(argv[2], "Cannot parse rank '%s'");
const char* trace_filename = argv[3];
}
smpi_replay_run(instance_id, rank, start_delay_flops, trace_filename);
- return 0;
}
int main(int argc, char *argv[]){
- msg_error_t res;
-
- MSG_init(&argc, argv);
+ simgrid_init(&argc, argv);
SMPI_init();
xbt_assert(argc > 3, "Usage: %s description_file platform_file deployment_file\n"
"\tExample: %s smpi_multiple_apps msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
/* Simulation setting */
- MSG_create_environment(argv[2]);
+ simgrid_load_platform(argv[2]);
/* Application deployment: read the description file in order to identify instances to launch */
FILE* fp = fopen(argv[1], "r");
fclose(fp);
- MSG_launch_application(argv[3]);
+ simgrid_load_deployment(argv[3]);
+ simgrid_run();
- res = MSG_main();
-
- XBT_INFO("Simulation time %g", MSG_get_clock());
+ XBT_INFO("Simulation time %g", simgrid_get_clock());
SMPI_finalize();
- return res != MSG_OK;
+ return 0;
}
! timeout 120
$ ./replay_multiple description_file ${srcdir:=.}/../../platforms/small_platform_with_routers.xml ${bindir:=.}/deployment.xml --log=smpi.:info --cfg=maxmin/concurrency-limit:100
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/concurrency-limit' to '100'
-> [0.000000] [smpi_kernel/INFO] You did not set the power of the host running the simulation. The timings will certainly not be accurate. Use the option "--cfg=smpi/host-speed:<flops>" to set its value. Check https://simgrid.org/doc/latest/Configuring_SimGrid.html#automatic-benchmarking-of-smpi-code for more information.
+> [0.000000] [smpi_config/INFO] You did not set the power of the host running the simulation. The timings will certainly not be accurate. Use the option "--cfg=smpi/host-speed:<flops>" to set its value. Check https://simgrid.org/doc/latest/Configuring_SimGrid.html#automatic-benchmarking-of-smpi-code for more information.
> [0.000000] [msg_test/INFO] Initializing instance 1 of size 32
> [0.000000] [msg_test/INFO] Initializing instance 2 of size 32
> [Ginette:2:(34) 37298.251477] [smpi_replay/INFO] Simulation time 10442.494756
-/* 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
+++ /dev/null
-/* Copyright (c) 2010-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. */
-
-#include "simgrid/msg.h"
-#include "mpi.h"
-
-#include <stdio.h> /* snprintf */
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
-
-static int master(int argc, char *argv[])
-{
- xbt_assert(argc == 5);
- long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");
- double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s");
- double task_comm_size = xbt_str_parse_double(argv[3], "Invalid communication size: %s");
- long slaves_count = xbt_str_parse_int(argv[4], "Invalid amount of slaves: %s");
-
- XBT_INFO("Got %ld slaves and %ld tasks to process", slaves_count, number_of_tasks);
-
- for (int i = 0; i < number_of_tasks; i++) {
- char mailbox[256];
- char sprintf_buffer[256];
-
- snprintf(mailbox,256, "slave-%ld", i % slaves_count);
- snprintf(sprintf_buffer,256, "Task_%d", i);
- msg_task_t task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
- if (number_of_tasks < 10000 || i % 10000 == 0)
- XBT_INFO("Sending \"%s\" (of %ld) to mailbox \"%s\"", MSG_task_get_name(task), number_of_tasks, mailbox);
-
- MSG_task_send(task, mailbox);
- }
-
- XBT_INFO("All tasks have been dispatched. Let's tell everybody the computation is over.");
- for (int i = 0; i < slaves_count; i++) {
- char mailbox[80];
-
- snprintf(mailbox,80, "slave-%ld", i % slaves_count);
- msg_task_t finalize = MSG_task_create("finalize", 0, 0, 0);
- MSG_task_send(finalize, mailbox);
- }
-
- return 0;
-}
-
-static int master_mpi(int argc, char *argv[])
-{
- MPI_Init(&argc, &argv);
-
- int rank;
- MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- XBT_INFO("here for rank %d", rank);
- int test[1000]={rank};
- if(rank==0)
- MPI_Send(&test, 1000, MPI_INT, 1, 1, MPI_COMM_WORLD);
- else
- MPI_Recv(&test, 1000, MPI_INT, 0, 1, MPI_COMM_WORLD, MPI_STATUSES_IGNORE);
-
- XBT_INFO("After comm %d", rank);
- MPI_Finalize();
-
- XBT_INFO("After finalize %d %d", rank, test[0]);
- return 0;
-}
-
-static int alltoall_mpi(int argc, char *argv[])
-{
- MPI_Init(&argc, &argv);
-
- int rank;
- int size;
- MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- MPI_Comm_size(MPI_COMM_WORLD, &size);
- XBT_INFO("alltoall for rank %d", rank);
- int* out=malloc(1000*size*sizeof(int));
- int* in=malloc(1000*size*sizeof(int));
- MPI_Alltoall(out, 1000, MPI_INT,in, 1000, MPI_INT, MPI_COMM_WORLD);
-
- XBT_INFO("after alltoall %d", rank);
- free(out);
- free(in);
- MPI_Finalize();
- return 0;
-}
-
-static int slave(int argc, char *argv[])
-{
- xbt_assert(argc == 2);
- msg_task_t task = NULL;
- XBT_ATTRIB_UNUSED int res;
- int id = -1;
- char mailbox[80];
- XBT_ATTRIB_UNUSED int read;
-
- read = sscanf(argv[1], "%d", &id);
- xbt_assert(read, "Invalid argument %s\n", argv[1]);
-
- snprintf(mailbox,80, "slave-%d", id);
-
- while (1) {
- res = MSG_task_receive(&(task), mailbox);
- xbt_assert(res == MSG_OK, "MSG_task_get failed");
-
- if (strcmp(MSG_task_get_name(task), "finalize")==0) {
- MSG_task_destroy(task);
- break;
- }
- MSG_task_execute(task);
- MSG_task_destroy(task);
- task = NULL;
- }
- XBT_INFO("I'm done. See you!");
-
- return 0;
-}
-
-int main(int argc, char *argv[])
-{
- msg_error_t res;
-
- MSG_init(&argc, argv);
- SMPI_init();
-
- xbt_assert(argc > 2,"Usage: %s platform_file deployment_file\n"
- "\nexample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
-
- MSG_create_environment(argv[1]);
-
- MSG_function_register("master", master);
- MSG_function_register("slave", slave);
- // launch two MPI applications as well, one using master_mpi function as main on 2 nodes
- SMPI_app_instance_register("master_mpi", master_mpi,2);
- // the second performing an alltoall on 4 nodes
- SMPI_app_instance_register("alltoall_mpi", alltoall_mpi,4);
- MSG_launch_application(argv[2]);
-
- res = MSG_main();
-
- XBT_INFO("Simulation time %g", MSG_get_clock());
-
- SMPI_finalize();
- return res != MSG_OK;
-}
+++ /dev/null
-p Test the use of SMPI+MSG in the same file, as well as several different SMPI instances at the same time
-$ ./masterslave_mailbox_smpi ${srcdir:=.}/../../platforms/small_platform_with_routers.xml ${srcdir:=.}/deployment_masterslave_mailbox_smpi.xml --log=smpi.:info --cfg=smpi/simulate-computation:no
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'smpi/simulate-computation' to 'no'
-> [0.000000] [smpi_kernel/INFO] You did not set the power of the host running the simulation. The timings will certainly not be accurate. Use the option "--cfg=smpi/host-speed:<flops>" to set its value. Check https://simgrid.org/doc/latest/Configuring_SimGrid.html#automatic-benchmarking-of-smpi-code for more information.
-> [Tremblay:master:(1) 0.000000] [msg_test/INFO] Got 1 slaves and 20 tasks to process
-> [Tremblay:master:(1) 0.000000] [msg_test/INFO] Sending "Task_0" (of 20) to mailbox "slave-0"
-> [Ginette:master_mpi:(3) 0.000000] [msg_test/INFO] here for rank 0
-> [Bourassa:master_mpi:(4) 0.000000] [msg_test/INFO] here for rank 1
-> [Ginette:alltoall_mpi:(5) 0.000000] [msg_test/INFO] alltoall for rank 0
-> [Bourassa:alltoall_mpi:(6) 0.000000] [msg_test/INFO] alltoall for rank 1
-> [Jupiter:alltoall_mpi:(7) 0.000000] [msg_test/INFO] alltoall for rank 2
-> [Fafard:alltoall_mpi:(8) 0.000000] [msg_test/INFO] alltoall for rank 3
-> [Ginette:master_mpi:(3) 0.000000] [msg_test/INFO] After comm 0
-> [Ginette:master_mpi:(3) 0.000000] [msg_test/INFO] After finalize 0 0
-> [Tremblay:master:(1) 0.002265] [msg_test/INFO] Sending "Task_1" (of 20) to mailbox "slave-0"
-> [Bourassa:master_mpi:(4) 0.016868] [msg_test/INFO] After comm 1
-> [Bourassa:master_mpi:(4) 0.016868] [msg_test/INFO] After finalize 1 0
-> [Ginette:alltoall_mpi:(5) 0.098642] [msg_test/INFO] after alltoall 0
-> [Fafard:alltoall_mpi:(8) 0.099069] [msg_test/INFO] after alltoall 3
-> [Bourassa:alltoall_mpi:(6) 0.127526] [msg_test/INFO] after alltoall 1
-> [Jupiter:alltoall_mpi:(7) 0.127802] [msg_test/INFO] after alltoall 2
-> [Tremblay:master:(1) 0.514241] [msg_test/INFO] Sending "Task_2" (of 20) to mailbox "slave-0"
-> [Tremblay:master:(1) 1.026216] [msg_test/INFO] Sending "Task_3" (of 20) to mailbox "slave-0"
-> [Tremblay:master:(1) 1.538191] [msg_test/INFO] Sending "Task_4" (of 20) to mailbox "slave-0"
-> [Tremblay:master:(1) 2.050166] [msg_test/INFO] Sending "Task_5" (of 20) to mailbox "slave-0"
-> [Tremblay:master:(1) 2.562142] [msg_test/INFO] Sending "Task_6" (of 20) to mailbox "slave-0"
-> [Tremblay:master:(1) 3.074117] [msg_test/INFO] Sending "Task_7" (of 20) to mailbox "slave-0"
-> [Tremblay:master:(1) 3.586092] [msg_test/INFO] Sending "Task_8" (of 20) to mailbox "slave-0"
-> [Tremblay:master:(1) 4.098067] [msg_test/INFO] Sending "Task_9" (of 20) to mailbox "slave-0"
-> [Tremblay:master:(1) 4.610043] [msg_test/INFO] Sending "Task_10" (of 20) to mailbox "slave-0"
-> [Tremblay:master:(1) 5.122018] [msg_test/INFO] Sending "Task_11" (of 20) to mailbox "slave-0"
-> [Tremblay:master:(1) 5.633993] [msg_test/INFO] Sending "Task_12" (of 20) to mailbox "slave-0"
-> [Tremblay:master:(1) 6.145968] [msg_test/INFO] Sending "Task_13" (of 20) to mailbox "slave-0"
-> [Tremblay:master:(1) 6.657944] [msg_test/INFO] Sending "Task_14" (of 20) to mailbox "slave-0"
-> [Tremblay:master:(1) 7.169919] [msg_test/INFO] Sending "Task_15" (of 20) to mailbox "slave-0"
-> [Tremblay:master:(1) 7.681894] [msg_test/INFO] Sending "Task_16" (of 20) to mailbox "slave-0"
-> [Tremblay:master:(1) 8.193869] [msg_test/INFO] Sending "Task_17" (of 20) to mailbox "slave-0"
-> [Tremblay:master:(1) 8.705845] [msg_test/INFO] Sending "Task_18" (of 20) to mailbox "slave-0"
-> [Tremblay:master:(1) 9.217820] [msg_test/INFO] Sending "Task_19" (of 20) to mailbox "slave-0"
-> [Tremblay:master:(1) 9.729795] [msg_test/INFO] All tasks have been dispatched. Let's tell everybody the computation is over.
-> [Tremblay:slave:(2) 10.239700] [msg_test/INFO] I'm done. See you!
-> [10.239700] [msg_test/INFO] Simulation time 10.2397
-
if(enable_smpi)
include_directories(BEFORE "${CMAKE_HOME_DIRECTORY}/include/smpi")
- add_executable (masterslave_mailbox_smpi EXCLUDE_FROM_ALL masterslave_mailbox_smpi.c)
+ add_executable (masterslave_mailbox_smpi EXCLUDE_FROM_ALL masterslave_mailbox_smpi.cpp)
target_link_libraries(masterslave_mailbox_smpi simgrid)
- ADD_TESH_FACTORIES(smpi-msg-masterslave "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/smpi/smpi_msg_masterslave --cd ${CMAKE_BINARY_DIR}/examples/smpi/smpi_msg_masterslave ${CMAKE_HOME_DIRECTORY}/examples/smpi/smpi_msg_masterslave/msg_smpi.tesh)
+ ADD_TESH_FACTORIES(smpi-s4u-masterslave "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/smpi/smpi_s4u_masterslave --cd ${CMAKE_BINARY_DIR}/examples/smpi/smpi_s4u_masterslave ${CMAKE_HOME_DIRECTORY}/examples/smpi/smpi_s4u_masterslave/s4u_smpi.tesh)
add_dependencies(tests masterslave_mailbox_smpi)
endif()
-set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/msg_smpi.tesh PARENT_SCOPE)
+set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/s4u_smpi.tesh PARENT_SCOPE)
set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/deployment_masterslave_mailbox_smpi.xml PARENT_SCOPE)
-set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/masterslave_mailbox_smpi.c PARENT_SCOPE)
+set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/masterslave_mailbox_smpi.cpp PARENT_SCOPE)
<argument value="20"/> <!-- Number of tasks -->
<argument value="50000000"/> <!-- Computation size of tasks -->
<argument value="1000000"/> <!-- Communication size of tasks -->
- <argument value="1"/> <!-- Number of slaves -->
- </actor>
- <!-- The slave processes (with mailbox to listen on as argument) -->
- <actor host="Tremblay" function="slave">
- <argument value="0"/>
+ <argument value="Ginette"/> <!-- Hostname of the first worker -->
+ <argument value="Jupiter"/> <!-- Hostname of the second worker -->
</actor>
+ <!-- The worker processes (with mailbox to listen on as argument) -->
+ <actor host="Ginette" function="worker"/>
+ <actor host="Jupiter" function="worker"/>
+
<actor host="Ginette" function="master_mpi">
<prop id="instance_id" value="master_mpi"/>
<prop id="rank" value="0"/>
--- /dev/null
+/* 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 "mpi.h"
+#include "simgrid/s4u.hpp"
+
+#include <stdio.h> /* snprintf */
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
+
+static void master(std::vector<std::string> args)
+{
+ xbt_assert(args.size() > 4, "The master function expects at least 3 arguments");
+
+ long tasks_count = std::stol(args[1]);
+ double compute_cost = std::stod(args[2]);
+ double communication_cost = std::stod(args[3]);
+ std::vector<simgrid::s4u::Mailbox*> workers;
+ for (unsigned int i = 4; i < args.size(); i++)
+ workers.push_back(simgrid::s4u::Mailbox::by_name(args[i]));
+
+ XBT_INFO("Got %zu workers and %ld tasks to process", workers.size(), tasks_count);
+
+ for (int i = 0; i < tasks_count; i++) { /* For each task to be executed: */
+ /* - Select a worker in a round-robin way */
+ simgrid::s4u::Mailbox* mailbox = workers[i % workers.size()];
+
+ /* - Send the computation cost to that worker */
+ XBT_INFO("Sending task %d of %ld to mailbox '%s'", i, tasks_count, mailbox->get_cname());
+ mailbox->put(new double(compute_cost), communication_cost);
+ }
+
+ XBT_INFO("All tasks have been dispatched. Request all workers to stop.");
+ for (unsigned int i = 0; i < workers.size(); i++) {
+ /* The workers stop when receiving a negative compute_cost */
+ simgrid::s4u::Mailbox* mailbox = workers[i % workers.size()];
+
+ mailbox->put(new double(-1.0), 0);
+ }
+}
+
+static void worker(std::vector<std::string> args)
+{
+ xbt_assert(args.size() == 1, "The worker expects no argument");
+
+ 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 {
+ const double* msg = static_cast<double*>(mailbox->get());
+ compute_cost = *msg;
+ delete msg;
+
+ if (compute_cost > 0) /* If compute_cost is valid, execute a computation of that cost */
+ simgrid::s4u::this_actor::execute(compute_cost);
+ } while (compute_cost > 0); /* Stop when receiving an invalid compute_cost */
+
+ XBT_INFO("Exiting now.");
+}
+
+static void master_mpi(int argc, char* argv[])
+{
+ MPI_Init(&argc, &argv);
+
+ int rank;
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ XBT_INFO("here for rank %d", rank);
+ int test[1000] = {rank};
+ if (rank == 0)
+ MPI_Send(&test, 1000, MPI_INT, 1, 1, MPI_COMM_WORLD);
+ else
+ MPI_Recv(&test, 1000, MPI_INT, 0, 1, MPI_COMM_WORLD, MPI_STATUSES_IGNORE);
+
+ XBT_INFO("After comm %d", rank);
+ MPI_Finalize();
+
+ XBT_INFO("After finalize %d %d", rank, test[0]);
+}
+
+static void alltoall_mpi(int argc, char* argv[])
+{
+ MPI_Init(&argc, &argv);
+
+ int rank;
+ int size;
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ XBT_INFO("alltoall for rank %d", rank);
+ std::vector<int> out(1000 * size);
+ std::vector<int> in(1000 * size);
+ MPI_Alltoall(out.data(), 1000, MPI_INT, in.data(), 1000, MPI_INT, MPI_COMM_WORLD);
+
+ XBT_INFO("after alltoall %d", rank);
+ MPI_Finalize();
+}
+
+int main(int argc, char* argv[])
+{
+ simgrid::s4u::Engine e(&argc, argv);
+
+ SMPI_init();
+
+ xbt_assert(argc > 2,
+ "Usage: %s platform_file deployment_file\n"
+ "\nexample: %s msg_platform.xml msg_deployment.xml\n",
+ argv[0], argv[0]);
+
+ e.load_platform(argv[1]);
+
+ e.register_function("master", master);
+ e.register_function("worker", worker);
+ // launch two MPI applications as well, one using master_mpi function as main on 2 nodes
+ SMPI_app_instance_register("master_mpi", master_mpi, 2);
+ // the second performing an alltoall on 4 nodes
+ SMPI_app_instance_register("alltoall_mpi", alltoall_mpi, 4);
+ e.load_deployment(argv[2]);
+
+ e.run();
+
+ XBT_INFO("Simulation time %g", e.get_clock());
+
+ SMPI_finalize();
+ return 0;
+}
--- /dev/null
+p Test the use of SMPI+MSG in the same file, as well as several different SMPI instances at the same time
+$ ./masterslave_mailbox_smpi ${srcdir:=.}/../../platforms/small_platform_with_routers.xml ${srcdir:=.}/deployment_masterslave_mailbox_smpi.xml --log=smpi.:info --cfg=smpi/simulate-computation:no
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'smpi/simulate-computation' to 'no'
+> [0.000000] [smpi_config/INFO] You did not set the power of the host running the simulation. The timings will certainly not be accurate. Use the option "--cfg=smpi/host-speed:<flops>" to set its value. Check https://simgrid.org/doc/latest/Configuring_SimGrid.html#automatic-benchmarking-of-smpi-code for more information.
+> [Tremblay:master:(1) 0.000000] [msg_test/INFO] Got 2 workers and 20 tasks to process
+> [Tremblay:master:(1) 0.000000] [msg_test/INFO] Sending task 0 of 20 to mailbox 'Ginette'
+> [Ginette:master_mpi:(4) 0.000000] [msg_test/INFO] here for rank 0
+> [Bourassa:master_mpi:(5) 0.000000] [msg_test/INFO] here for rank 1
+> [Ginette:alltoall_mpi:(6) 0.000000] [msg_test/INFO] alltoall for rank 0
+> [Bourassa:alltoall_mpi:(7) 0.000000] [msg_test/INFO] alltoall for rank 1
+> [Jupiter:alltoall_mpi:(8) 0.000000] [msg_test/INFO] alltoall for rank 2
+> [Fafard:alltoall_mpi:(9) 0.000000] [msg_test/INFO] alltoall for rank 3
+> [Ginette:master_mpi:(4) 0.000000] [msg_test/INFO] After comm 0
+> [Ginette:master_mpi:(4) 0.000000] [msg_test/INFO] After finalize 0 0
+> [Bourassa:master_mpi:(5) 0.016868] [msg_test/INFO] After comm 1
+> [Bourassa:master_mpi:(5) 0.016868] [msg_test/INFO] After finalize 1 0
+> [Ginette:alltoall_mpi:(6) 0.100219] [msg_test/INFO] after alltoall 0
+> [Fafard:alltoall_mpi:(9) 0.100625] [msg_test/INFO] after alltoall 3
+> [Tremblay:master:(1) 0.125464] [msg_test/INFO] Sending task 1 of 20 to mailbox 'Jupiter'
+> [Bourassa:alltoall_mpi:(7) 0.129082] [msg_test/INFO] after alltoall 1
+> [Jupiter:alltoall_mpi:(8) 0.129358] [msg_test/INFO] after alltoall 2
+> [Tremblay:master:(1) 0.294619] [msg_test/INFO] Sending task 2 of 20 to mailbox 'Ginette'
+> [Tremblay:master:(1) 1.280294] [msg_test/INFO] Sending task 3 of 20 to mailbox 'Jupiter'
+> [Tremblay:master:(1) 1.449449] [msg_test/INFO] Sending task 4 of 20 to mailbox 'Ginette'
+> [Tremblay:master:(1) 2.435124] [msg_test/INFO] Sending task 5 of 20 to mailbox 'Jupiter'
+> [Tremblay:master:(1) 2.604279] [msg_test/INFO] Sending task 6 of 20 to mailbox 'Ginette'
+> [Tremblay:master:(1) 3.589954] [msg_test/INFO] Sending task 7 of 20 to mailbox 'Jupiter'
+> [Tremblay:master:(1) 3.759109] [msg_test/INFO] Sending task 8 of 20 to mailbox 'Ginette'
+> [Tremblay:master:(1) 4.744784] [msg_test/INFO] Sending task 9 of 20 to mailbox 'Jupiter'
+> [Tremblay:master:(1) 4.913938] [msg_test/INFO] Sending task 10 of 20 to mailbox 'Ginette'
+> [Tremblay:master:(1) 5.899614] [msg_test/INFO] Sending task 11 of 20 to mailbox 'Jupiter'
+> [Tremblay:master:(1) 6.068768] [msg_test/INFO] Sending task 12 of 20 to mailbox 'Ginette'
+> [Tremblay:master:(1) 7.054444] [msg_test/INFO] Sending task 13 of 20 to mailbox 'Jupiter'
+> [Tremblay:master:(1) 7.223598] [msg_test/INFO] Sending task 14 of 20 to mailbox 'Ginette'
+> [Tremblay:master:(1) 8.209273] [msg_test/INFO] Sending task 15 of 20 to mailbox 'Jupiter'
+> [Tremblay:master:(1) 8.378428] [msg_test/INFO] Sending task 16 of 20 to mailbox 'Ginette'
+> [Tremblay:master:(1) 9.364103] [msg_test/INFO] Sending task 17 of 20 to mailbox 'Jupiter'
+> [Tremblay:master:(1) 9.533258] [msg_test/INFO] Sending task 18 of 20 to mailbox 'Ginette'
+> [Tremblay:master:(1) 10.518933] [msg_test/INFO] Sending task 19 of 20 to mailbox 'Jupiter'
+> [Tremblay:master:(1) 10.688088] [msg_test/INFO] All tasks have been dispatched. Request all workers to stop.
+> [Ginette:worker:(2) 11.566584] [msg_test/INFO] Exiting now.
+> [Jupiter:worker:(3) 11.585598] [msg_test/INFO] Exiting now.
+> [11.585598] [msg_test/INFO] Simulation time 11.5856
-/* 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
p Test instrumentation of SMPI
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace -trace-file ${bindir:=.}/smpi_trace.trace -hostfile ${srcdir:=.}/../hostfile -platform ${platfdir:=.}/small_platform.xml --cfg=path:${srcdir:=.}/../msg --cfg=tracing/smpi/computing:yes --cfg=smpi/simulate-computation:no --cfg=tracing/smpi/sleeping:yes -np 3 ${bindir:=.}/smpi_trace --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace -trace-file ${bindir:=.}/smpi_trace.trace -hostfile ${srcdir:=.}/../hostfile -platform ${platfdir:=.}/small_platform.xml --cfg=path:${srcdir:=.}/../msg --cfg=tracing/smpi/computing:yes --cfg=smpi/simulate-computation:no --cfg=tracing/smpi/sleeping:yes -np 3 ${bindir:=.}/smpi_trace --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
! output sort 19
$ tail -n +3 ${bindir:=.}/smpi_trace.trace
> 7 11.906032 1 3
$ rm -f ${bindir:=.}/smpi_trace.trace
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace -trace-resource -trace-file ${bindir:=.}/smpi_trace.trace -hostfile ${srcdir:=.}/../hostfile -platform ${platfdir:=.}/small_platform.xml --cfg=path:${srcdir:=.}/../msg --cfg=smpi/host-speed:1 -np 3 ${bindir:=.}/smpi_trace --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace -trace-resource -trace-file ${bindir:=.}/smpi_trace.trace -hostfile ${srcdir:=.}/../hostfile -platform ${platfdir:=.}/small_platform.xml --cfg=path:${srcdir:=.}/../msg --cfg=smpi/host-speed:1 -np 3 ${bindir:=.}/smpi_trace --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
$ rm -f ${bindir:=.}/smpi_trace.trace
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace --cfg=tracing/smpi/display-sizes:yes --cfg=tracing/smpi/computing:yes --cfg=tracing/smpi/internals:yes -trace-file ${bindir:=.}/smpi_trace.trace -hostfile ${srcdir:=.}/../hostfile -platform ${platfdir:=.}/small_platform.xml --cfg=path:${srcdir:=.}/../msg --cfg=smpi/host-speed:1 -np 3 ${bindir:=.}/smpi_trace --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace --cfg=tracing/smpi/display-sizes:yes --cfg=tracing/smpi/computing:yes --cfg=tracing/smpi/internals:yes -trace-file ${bindir:=.}/smpi_trace.trace -hostfile ${srcdir:=.}/../hostfile -platform ${platfdir:=.}/small_platform.xml --cfg=path:${srcdir:=.}/../msg --cfg=smpi/host-speed:1 -np 3 ${bindir:=.}/smpi_trace --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
$ rm -f ${bindir:=.}/smpi_trace.trace
-/* 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
p Test SMPI with call-location tracing. This means that the binary must have
p already been compiled with the -trace-call-location switch.
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace -trace-file ${bindir:=.}/smpi_trace.trace -hostfile ${srcdir:=.}/hostfile -platform ${platfdir}/small_platform.xml --cfg=smpi/trace-call-location:1 -np 3 ${bindir:=.}/smpi_trace_call_location --cfg=smpi/trace-call-use-absolute-path:1 --cfg=smpi/host-speed:1 --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace -trace-file ${bindir:=.}/smpi_trace.trace -hostfile ${srcdir:=.}/hostfile -platform ${platfdir}/small_platform.xml --cfg=smpi/trace-call-location:1 -np 3 ${bindir:=.}/smpi_trace_call_location --cfg=smpi/trace-call-use-absolute-path:1 --cfg=smpi/host-speed:1 --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
$ grep -q "12 0.* 2 1 7 .*trace_call_location\.c\" 14$" ${bindir:=.}/smpi_trace.trace
$ rm -f ${bindir:=.}/smpi_trace.trace
#the same, but with trace-ti
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace-ti -trace-file ${bindir:=.}/smpi_trace.txt --cfg=tracing/smpi/sleeping:1 -hostfile ${srcdir:=.}/hostfile -platform ${platfdir}/small_platform.xml --cfg=smpi/trace-call-location:1 -np 3 ${bindir:=.}/smpi_trace_call_location --cfg=smpi/host-speed:1 --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/cpu-threshold:0
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace-ti -trace-file ${bindir:=.}/smpi_trace.txt --cfg=tracing/smpi/sleeping:1 -hostfile ${srcdir:=.}/hostfile -platform ${platfdir}/small_platform.xml --cfg=smpi/trace-call-location:1 -np 3 ${bindir:=.}/smpi_trace_call_location --cfg=smpi/host-speed:1 --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/cpu-threshold:0
#Test replaying the trace, without altering the time.
#We disable computation, but leave the sleep.
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ${srcdir:=.}/hostfile -platform ${platfdir}/small_platform.xml -np 3 -replay ${bindir:=.}/smpi_trace.txt ${bindir:=.}/../replay/smpi_replay --cfg=smpi/host-speed:1 --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/simulate-computation:no
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ${srcdir:=.}/hostfile -platform ${platfdir}/small_platform.xml -np 3 -replay ${bindir:=.}/smpi_trace.txt ${bindir:=.}/../replay/smpi_replay --cfg=smpi/host-speed:1 --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/simulate-computation:no
> [Fafard:2:(3) 1000.003952] [smpi_replay/INFO] Simulation time 1000.003952
#Test replaying the trace, altering the time to have the sleep much faster (1 instead of 1000).
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ${srcdir:=.}/hostfile -platform ${platfdir}/small_platform.xml --cfg=smpi/comp-adjustment-file:${srcdir:=.}/trace_call_location/adjust -np 3 -replay ${bindir:=.}/smpi_trace.txt ${bindir:=.}/../replay/smpi_replay --cfg=smpi/host-speed:1 --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/simulate-computation:no
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ${srcdir:=.}/hostfile -platform ${platfdir}/small_platform.xml --cfg=smpi/comp-adjustment-file:${srcdir:=.}/trace_call_location/adjust -np 3 -replay ${bindir:=.}/smpi_trace.txt ${bindir:=.}/../replay/smpi_replay --cfg=smpi/host-speed:1 --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/simulate-computation:no
> [Fafard:2:(3) 1.003952] [smpi_replay/INFO] Simulation time 1.003952
$ rm -f ${bindir:=.}/smpi_trace.tx*
-/* 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
# Go for the first test
p SMPI test
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace -trace-resource -trace-file smpi_trace.trace -hostfile ${srcdir:=.}/../hostfile -platform ${platfdir:=.}/small_platform.xml --cfg=path:${srcdir:=.}/../msg -np 3 ${bindir:=.}/smpi_trace_simple --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace -trace-resource -trace-file smpi_trace.trace -hostfile ${srcdir:=.}/../hostfile -platform ${platfdir:=.}/small_platform.xml --cfg=path:${srcdir:=.}/../msg -np 3 ${bindir:=.}/smpi_trace_simple --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
p Another SMPI test, with only -trace
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace -trace-file smpi_trace.trace -hostfile ${srcdir:=.}/../hostfile -platform ${platfdir:=.}/small_platform.xml --cfg=path:${srcdir:=.}/../msg -np 3 ${bindir:=.}/smpi_trace_simple --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace -trace-file smpi_trace.trace -hostfile ${srcdir:=.}/../hostfile -platform ${platfdir:=.}/small_platform.xml --cfg=path:${srcdir:=.}/../msg -np 3 ${bindir:=.}/smpi_trace_simple --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
p Testing without trace parameters
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ${srcdir:=.}/../hostfile -platform ${platfdir:=.}/small_platform.xml --cfg=path:${srcdir:=.}/../msg -np 3 ${bindir:=.}//smpi_trace_simple --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ${srcdir:=.}/../hostfile -platform ${platfdir:=.}/small_platform.xml --cfg=path:${srcdir:=.}/../msg -np 3 ${bindir:=.}//smpi_trace_simple --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
p Testing grouped tracing
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace -trace-grouped -trace-file smpi_trace.trace -hostfile ${srcdir:=.}/../hostfile -platform ${platfdir:=.}/small_platform.xml --cfg=path:${srcdir:=.}/../msg -np 3 ${bindir:=.}/smpi_trace_simple --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace -trace-grouped -trace-file smpi_trace.trace -hostfile ${srcdir:=.}/../hostfile -platform ${platfdir:=.}/small_platform.xml --cfg=path:${srcdir:=.}/../msg -np 3 ${bindir:=.}/smpi_trace_simple --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
p Testing with parameters but without activating them with the safe switch (-trace)
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace-resource -trace-file smpi_trace.trace -hostfile ${srcdir:=.}/../hostfile -platform ${platfdir:=.}/small_platform.xml --cfg=path:${srcdir:=.}/../msg -np 3 ${bindir:=.}/smpi_trace_simple --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace-resource -trace-file smpi_trace.trace -hostfile ${srcdir:=.}/../hostfile -platform ${platfdir:=.}/small_platform.xml --cfg=path:${srcdir:=.}/../msg -np 3 ${bindir:=.}/smpi_trace_simple --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
$ rm -f smpi_trace.trace
-/* 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. */
/** Start the previously initialized actor.
*
* 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 void sg_actor_start(sg_actor_t actor, xbt_main_func_t code, int argc, const char* const* argv);
+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. */
--- /dev/null
+/* 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. */
+
+#ifndef INCLUDE_SIMGRID_COMM_H_
+#define INCLUDE_SIMGRID_COMM_H_
+
+#include <simgrid/forward.h>
+#include <xbt/dynar.h>
+
+/* C interface */
+SG_BEGIN_DECL
+
+XBT_PUBLIC int sg_comm_wait_any_for(sg_comm_t* comms, size_t count, double timeout);
+XBT_PUBLIC int sg_comm_wait_any(sg_comm_t* comms, size_t count);
+
+SG_END_DECL
+
+#endif /* INCLUDE_SIMGRID_COMM_H_ */
-/* 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. */
#define SIMGRID_PUBLIC_CONFIG_H
#include <xbt/base.h>
-/** Define the version numbers of the used header files.
- See sg_version_get() to retrieve the version of the dynamic library. */
-#define SIMGRID_VERSION_MAJOR @SIMGRID_VERSION_MAJOR@
-#define SIMGRID_VERSION_MINOR @SIMGRID_VERSION_MINOR@
-#define SIMGRID_VERSION_PATCH @SIMGRID_VERSION_PATCH@
-#define SIMGRID_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
-
-SG_BEGIN_DECL
-/** Retrieves the version numbers of the used dynamic library (so, DLL or dynlib), while
- SIMGRID_VERSION_MAJOR and friends give the version numbers of the used header files */
-XBT_PUBLIC void sg_version_get(int* major, int* minor, int* patch);
-
-/** Display the version information and some additional blurb. */
-XBT_PUBLIC void sg_version();
-SG_END_DECL
-
-
-/* Version as a single integer. v3.4 is 30400, v3.16.2 is 31602, v42 will be 420000, and so on. */
-#define SIMGRID_VERSION (100UL * (100UL * (SIMGRID_VERSION_MAJOR) + (SIMGRID_VERSION_MINOR)) + (SIMGRID_VERSION_PATCH))
-
-#define SIMGRID_VERSION_STRING "@SIMGRID_VERSION_STRING@"
-
+/* Was MSG compiled in? */
+#cmakedefine01 SIMGRID_HAVE_MSG
/* Was Jedule compiled in? */
#cmakedefine01 SIMGRID_HAVE_JEDULE
/* Was the Lua support compiled in? */
-/* 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
*/
/** Run the simulation after initialization */
XBT_PUBLIC void simgrid_run();
/** Registers the main function of an actor that will be launched from the deployment file */
-XBT_PUBLIC void simgrid_register_function(const char* name, int (*code)(int, char**));
+XBT_PUBLIC void simgrid_register_function(const char* name, void (*code)(int, char**));
/** Registers a function as the default main function of actors
*
* It will be used as fallback when the function requested from the deployment file was not registered.
* It is used for trace-based simulations (see examples/s4u/replay-comms and similar).
*/
-XBT_PUBLIC void simgrid_register_default(int (*code)(int, char**));
+XBT_PUBLIC void simgrid_register_default(void (*code)(int, char**));
/** Retrieve the simulation time (in seconds) */
XBT_PUBLIC double simgrid_get_clock();
/** Retrieve the number of actors in the simulation */
-/* 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. */
#ifdef __cplusplus
#include <boost/intrusive_ptr.hpp>
+#include <vector>
namespace simgrid {
namespace s4u {
class Activity;
+/** Smart pointer to a simgrid::s4u::Actor */
+using ActivityPtr = boost::intrusive_ptr<Activity>;
+XBT_PUBLIC void intrusive_ptr_release(const Activity* actor);
+XBT_PUBLIC void intrusive_ptr_add_ref(const Activity* actor);
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);
+using ActorPtr = boost::intrusive_ptr<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 */
-typedef boost::intrusive_ptr<Barrier> BarrierPtr;
+using BarrierPtr = boost::intrusive_ptr<Barrier>;
XBT_PUBLIC void intrusive_ptr_release(Barrier* m);
XBT_PUBLIC void intrusive_ptr_add_ref(Barrier* m);
class Comm;
/** Smart pointer to a simgrid::s4u::Comm */
-typedef boost::intrusive_ptr<Comm> CommPtr;
+using CommPtr = boost::intrusive_ptr<Comm>;
XBT_PUBLIC void intrusive_ptr_release(Comm* c);
XBT_PUBLIC void intrusive_ptr_add_ref(Comm* c);
class ConditionVariable;
-/** Smart pointer to a simgrid::s4u::ConditionVariable */
-typedef boost::intrusive_ptr<ConditionVariable> ConditionVariablePtr;
-XBT_PUBLIC void intrusive_ptr_release(ConditionVariable* c);
-XBT_PUBLIC void intrusive_ptr_add_ref(ConditionVariable* c);
+/** @beginrst
+ * Smart pointer to a :cpp:type:`simgrid::s4u::ConditionVariable`
+ * @endrst
+ */
+using ConditionVariablePtr = boost::intrusive_ptr<ConditionVariable>;
+XBT_PUBLIC void intrusive_ptr_release(const ConditionVariable* c);
+XBT_PUBLIC void intrusive_ptr_add_ref(const ConditionVariable* c);
class Engine;
class Exec;
/** Smart pointer to a simgrid::s4u::Exec */
-typedef boost::intrusive_ptr<Exec> ExecPtr;
+using ExecPtr = boost::intrusive_ptr<Exec>;
XBT_PUBLIC void intrusive_ptr_release(Exec* e);
XBT_PUBLIC void intrusive_ptr_add_ref(Exec* e);
-class ExecSeq;
-typedef boost::intrusive_ptr<ExecSeq> ExecSeqPtr;
-class ExecPar;
-typedef boost::intrusive_ptr<ExecPar> ExecParPtr;
+class ExecSeq; // FIXME: hide this class in implementation
+class ExecPar; // FIXME: hide this class in implementation
class Host;
class Io;
/** Smart pointer to a simgrid::s4u::Io */
-typedef boost::intrusive_ptr<Io> IoPtr;
+using IoPtr = boost::intrusive_ptr<Io>;
XBT_PUBLIC void intrusive_ptr_release(Io* i);
XBT_PUBLIC void intrusive_ptr_add_ref(Io* i);
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 */
-typedef boost::intrusive_ptr<Mutex> MutexPtr;
+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
+ */
+using MutexPtr = boost::intrusive_ptr<Mutex>;
class NetZone;
class VirtualMachine;
class Semaphore;
/** Smart pointer to a simgrid::s4u::Semaphore */
-typedef boost::intrusive_ptr<Semaphore> SemaphorePtr;
+using SemaphorePtr = boost::intrusive_ptr<Semaphore>;
XBT_PUBLIC void intrusive_ptr_release(Semaphore* m);
XBT_PUBLIC void intrusive_ptr_add_ref(Semaphore* m);
namespace actor {
class ActorImpl;
typedef boost::intrusive_ptr<ActorImpl> ActorImplPtr;
+
+// What's executed as an actor code:
+typedef std::function<void()> ActorCode;
+// Create an ActorCode from the parameters parsed in the XML file (or elsewhere)
+typedef std::function<ActorCode(std::vector<std::string> args)> ActorCodeFactory;
} // namespace actor
namespace activity {
class ActivityImpl;
+ enum class State;
typedef boost::intrusive_ptr<ActivityImpl> ActivityImplPtr;
XBT_PUBLIC void intrusive_ptr_add_ref(ActivityImpl* activity);
XBT_PUBLIC void intrusive_ptr_release(ActivityImpl* activity);
typedef simgrid::s4u::Actor s4u_Actor;
typedef simgrid::s4u::Barrier s4u_Barrier;
+typedef simgrid::s4u::Comm s4u_Comm;
typedef simgrid::s4u::Host s4u_Host;
typedef simgrid::s4u::Link s4u_Link;
typedef simgrid::s4u::File s4u_File;
typedef simgrid::s4u::ConditionVariable s4u_ConditionVariable;
+typedef simgrid::s4u::Mailbox s4u_Mailbox;
typedef simgrid::s4u::Mutex s4u_Mutex;
typedef simgrid::s4u::Semaphore s4u_Semaphore;
typedef simgrid::s4u::Disk s4u_Disk;
typedef simgrid::s4u::Storage s4u_Storage;
typedef simgrid::s4u::NetZone s4u_NetZone;
typedef simgrid::s4u::VirtualMachine s4u_VM;
-typedef boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> smx_activity_t;
typedef simgrid::simix::Timer* smx_timer_t;
typedef simgrid::kernel::actor::ActorImpl* smx_actor_t;
+typedef simgrid::kernel::activity::ActivityImpl* smx_activity_t;
typedef simgrid::kernel::activity::ConditionVariableImpl* smx_cond_t;
typedef simgrid::kernel::activity::MailboxImpl* smx_mailbox_t;
typedef simgrid::kernel::activity::MutexImpl* smx_mutex_t;
typedef simgrid::kernel::activity::SemaphoreImpl* smx_sem_t;
-
+typedef simgrid::kernel::activity::State e_smx_state_t;
#else
typedef struct s4u_Actor s4u_Actor;
typedef struct s4u_Barrier s4u_Barrier;
+typedef struct s4u_Comm s4u_Comm;
typedef struct s4u_Host s4u_Host;
typedef struct s4u_Link s4u_Link;
typedef struct s4u_File s4u_File;
typedef struct s4u_ConditionVariable s4u_ConditionVariable;
+typedef struct s4u_Mailbox s4u_Mailbox;
typedef struct s4u_Mutex s4u_Mutex;
typedef struct s4u_Semaphore s4u_Semaphore;
typedef struct s4u_Disk s4u_Disk;
typedef struct s4u_Storage s4u_Storage;
typedef struct s4u_NetZone s4u_NetZone;
typedef struct s4u_VM s4u_VM;
-typedef struct kernel_Activity* smx_activity_t;
+typedef enum kernel_activity_state e_smx_state_t;
typedef struct s_smx_timer* smx_timer_t;
typedef struct s_smx_actor* smx_actor_t;
+typedef struct s_smx_activity* smx_activity_t;
typedef struct s_smx_cond_t* smx_cond_t;
typedef struct s_smx_mailbox* smx_mailbox_t;
typedef struct s_smx_mutex* smx_mutex_t;
#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_Comm* sg_comm_t;
+typedef const s4u_Comm* const_sg_comm_t;
typedef s4u_ConditionVariable* sg_cond_t;
+typedef const s4u_ConditionVariable* const_sg_cond_t;
+typedef s4u_Mailbox* sg_mailbox_t;
+typedef const s4u_Mailbox* const_sg_mailbox_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. */
#include <simgrid/forward.h>
SG_BEGIN_DECL
-/** @brief Host datatype.
+/** Returns an array of all existing hosts (use sg_host_count() to know the array size).
*
- * A <em>location</em> (or <em>host</em>) is any possible place where an actor may run. Thus it is represented as a
- * <em>physical resource with computing capabilities</em>, some <em>mailboxes</em> to enable running actors to
- * communicate with remote ones, and some <em>private data</em> that can be only accessed by local actors.
+ * @remark The host order in this array is generally different from the
+ * creation/declaration order in the XML platform (we use a hash table
+ * internally).
*/
-
XBT_PUBLIC sg_host_t* sg_host_list();
-/** @brief Return the current number of hosts. */
+/** Returns the amount of hosts existing in the platform. */
XBT_PUBLIC size_t sg_host_count();
/**
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.
- *
- * This is a name directory service
- * @param name the name of an host.
- * @return the corresponding host
- */
+/** Finds an host from 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);
+/** @brief Return the name of the sg_host_t. */
+XBT_PUBLIC const char* sg_host_get_name(const_sg_host_t host);
+#ifndef DOXYGEN
// ========== 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.
*
XBT_ATTRIB_DEPRECATED_v328("Please use sg_host_data_set()") XBT_PUBLIC
void sg_host_user_set(sg_host_t host, void* userdata);
XBT_ATTRIB_DEPRECATED_v328("Please use sg_host_data_set(h, NULL)") XBT_PUBLIC void sg_host_user_destroy(sg_host_t host);
+#endif
// ========= storage related functions ============
/** @brief Return the list of mount point names on an host.
* @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 {
* @details This represents a position in the network. One can send information between two netpoints
*/
class NetPoint : public simgrid::xbt::Extendable<NetPoint> {
-
public:
enum class Type { Host, Router, NetZone };
-/* 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 <simgrid/forward.h>
#include <simgrid/s4u/NetZone.hpp>
+#include <xbt/PropertyHolder.hpp>
#include <xbt/graph.h>
#include <map>
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
* called Autonomous Systems in this article).
*
*/
-class XBT_PUBLIC NetZoneImpl {
- friend simgrid::kernel::EngineImpl; // it destroys netRoot_
+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 */
- simgrid::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_;
-
- NetZoneImpl* father_ = nullptr;
-
- std::vector<NetZoneImpl*> children_; // sub-netzones
-
-public:
- unsigned int get_table_size() { return vertices_.size(); }
- std::vector<kernel::routing::NetPoint*> get_vertices() { return vertices_; }
-
- NetZoneImpl* get_father();
+ enum class RoutingMode {
+ unset = 0, /**< Undefined type */
+ base, /**< Base case: use simple link lists for routing */
+ recursive /**< Recursive case: also return gateway information */
+ };
- std::vector<NetZoneImpl*>* get_children(); // Sub netzones
+ /* FIXME: protect the following fields once the construction madness is sorted out */
+ RoutingMode hierarchy_ = RoutingMode::unset;
-private:
- std::string name_;
- bool sealed_ = false; // We cannot add more content when sealed
+ resource::NetworkModel* network_model_;
-public:
+ s4u::NetZone* get_iface() { return &piface_; }
+ unsigned int get_table_size() const { return vertices_.size(); }
+ std::vector<kernel::routing::NetPoint*> get_vertices() const { return vertices_; }
+ NetZoneImpl* get_father() const { 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();
+ std::vector<s4u::Host*> get_all_hosts() const;
+ int get_host_count() const;
+
+ /** @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
*
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. */
/* C interface */
SG_BEGIN_DECL
+XBT_PUBLIC sg_mailbox_t sg_mailbox_by_name(const char* alias);
+XBT_PUBLIC const char* sg_mailbox_get_name(const_sg_mailbox_t mailbox);
XBT_PUBLIC void sg_mailbox_set_receiver(const char* alias);
XBT_PUBLIC int sg_mailbox_listen(const char* alias);
+XBT_PUBLIC void sg_mailbox_put(sg_mailbox_t mailbox, void* payload, long simulated_size_in_bytes);
+XBT_PUBLIC sg_comm_t sg_mailbox_put_async(sg_mailbox_t mailbox, void* payload, long simulated_size_in_bytes);
+XBT_PUBLIC void* sg_mailbox_get(sg_mailbox_t mailbox);
+
SG_END_DECL
#endif /* INCLUDE_SIMGRID_MAILBOX_H_ */
/* 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. */
SG_BEGIN_DECL
+/** Explore every branches where that function returns a value between min and max (inclusive) */
XBT_PUBLIC int MC_random(int min, int max);
#if SIMGRID_HAVE_MC
-/* 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/plugins/live_migration.h>
#include <simgrid/semaphore.h>
#include <simgrid/storage.h>
+#include <simgrid/version.h>
#include <simgrid/vm.h>
#include <simgrid/zone.h>
#include <xbt.h>
}
}
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");
* @param code the function (must have the same prototype than the main function of any C program: int ..(int argc, char
* *argv[]))
*/
-XBT_PUBLIC void MSG_function_register(const char* name, xbt_main_func_t code);
+XBT_PUBLIC void MSG_function_register(const char* name, int (*code)(int, char**));
/** @brief Registers a code function as being the default value.
*
* This function will get used by MSG_launch_application() when there is no registered function of the requested name
* @param code the function (must have the same prototype than the main function of any C program: int ..(int argc, char
* *argv[]))
*/
-XBT_PUBLIC void MSG_function_register_default(xbt_main_func_t code);
+XBT_PUBLIC void MSG_function_register_default(int (*code)(int, char**));
/** @brief Creates a new platform, including hosts, links and the routing_table */
XBT_PUBLIC void MSG_create_environment(const char* file);
/** @brief Creates the application described in the provided file */
XBT_PUBLIC unsigned long int MSG_get_sent_msg();
/************************** Process handling *********************************/
-XBT_PUBLIC msg_process_t MSG_process_create(const char* name, xbt_main_func_t code, void* data, msg_host_t host);
-XBT_PUBLIC msg_process_t MSG_process_create_with_arguments(const char* name, xbt_main_func_t code, void* data,
+XBT_PUBLIC msg_process_t MSG_process_create(const char* name, int (*code)(int, char**), void* data, msg_host_t host);
+XBT_PUBLIC msg_process_t MSG_process_create_with_arguments(const char* name, int (*code)(int, char**), void* data,
msg_host_t host, int argc, char** argv);
-XBT_PUBLIC msg_process_t MSG_process_create_with_environment(const char* name, xbt_main_func_t code, void* data,
+XBT_PUBLIC msg_process_t MSG_process_create_with_environment(const char* name, int (*code)(int, char**), void* data,
msg_host_t host, int argc, char** argv,
xbt_dict_t properties);
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 "xbt/asserts.h"
#include <atomic>
+#include <set>
#include <simgrid/forward.h>
#include <string>
+#include <vector>
#include <xbt/signal.hpp>
+XBT_LOG_EXTERNAL_CATEGORY(s4u_activity);
+
namespace simgrid {
namespace s4u {
*/
class XBT_PUBLIC Activity {
friend Comm;
- friend XBT_PUBLIC void intrusive_ptr_release(Comm * c);
- friend XBT_PUBLIC void intrusive_ptr_add_ref(Comm * c);
-
friend Exec;
friend ExecSeq;
friend ExecPar;
- friend XBT_PUBLIC void intrusive_ptr_release(Exec * e);
- friend XBT_PUBLIC void intrusive_ptr_add_ref(Exec * e);
-
friend Io;
- friend XBT_PUBLIC void intrusive_ptr_release(Io* i);
- friend XBT_PUBLIC void intrusive_ptr_add_ref(Io* i);
protected:
Activity() = default;
virtual ~Activity() = default;
+ void release_dependencies()
+ {
+ while (not successors_.empty()) {
+ ActivityPtr b = successors_.back();
+ XBT_CDEBUG(s4u_activity, "Remove a dependency from '%s' on '%s'", get_cname(), b->get_cname());
+ b->dependencies_.erase(this);
+ if (b->dependencies_.empty()) {
+ b->vetoable_start();
+ }
+ successors_.pop_back();
+ }
+ }
+
+ void add_successor(ActivityPtr a)
+ {
+ successors_.push_back(a);
+ a->dependencies_.insert({this});
+ }
+
public:
+ void vetoable_start()
+ {
+ state_ = State::STARTING;
+ if (dependencies_.empty()) {
+ XBT_CDEBUG(s4u_activity, "All dependencies are solved, let's start '%s'", get_cname());
+ start();
+ }
+ }
+
#ifndef DOXYGEN
Activity(Activity const&) = delete;
Activity& operator=(Activity const&) = delete;
#endif
- enum class State { INITED = 0, STARTED, CANCELED, ERRORED, FINISHED };
+ enum class State { INITED = 0, STARTING, STARTED, CANCELED, ERRORED, FINISHED };
/** Starts a previously created activity.
*
/** Cancel that activity */
virtual Activity* cancel() = 0;
/** Retrieve the current state of the activity */
- Activity::State get_state() { return state_; }
+ Activity::State get_state() const { return state_; }
+ void set_state(Activity::State state) { state_ = state; }
/** Tests whether the given activity is terminated yet. This is a pure function. */
virtual bool test() = 0;
+ virtual const char* get_cname() const = 0;
+ virtual const std::string& get_name() const = 0;
/** Get the remaining amount of work that this Activity entails. When it's 0, it's done. */
- virtual double get_remaining();
-
+ virtual double get_remaining() const;
/** Set the [remaining] amount of work that this Activity will entail
*
* It is forbidden to change the amount of work once the Activity is started */
/** Returns the internal implementation of this Activity */
kernel::activity::ActivityImpl* get_impl() const { return pimpl_.get(); }
+#ifndef DOXYGEN
+ friend void intrusive_ptr_release(Activity* a)
+ {
+ if (a->refcount_.fetch_sub(1, std::memory_order_release) == 1) {
+ std::atomic_thread_fence(std::memory_order_acquire);
+ delete a;
+ }
+ }
+ friend void intrusive_ptr_add_ref(Activity* a) { a->refcount_.fetch_add(1, std::memory_order_relaxed); }
+#endif
+ Activity* add_ref()
+ {
+ intrusive_ptr_add_ref(this);
+ return this;
+ }
+ void unref() { intrusive_ptr_release(this); }
+
private:
kernel::activity::ActivityImplPtr pimpl_ = nullptr;
Activity::State state_ = Activity::State::INITED;
double remains_ = 0;
+ std::vector<ActivityPtr> successors_;
+ std::set<ActivityPtr> dependencies_;
+ std::atomic_int_fast32_t refcount_{0};
};
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};
public:
-#ifndef DOXYGEN
- friend void intrusive_ptr_release(AnyActivity* a)
+ AnyActivity* add_successor(ActivityPtr a)
{
- if (a->refcount_.fetch_sub(1, std::memory_order_release) == 1) {
- std::atomic_thread_fence(std::memory_order_acquire);
- delete a;
- }
+ Activity::add_successor(a);
+ return static_cast<AnyActivity*>(this);
}
- friend void intrusive_ptr_add_ref(AnyActivity* a) { a->refcount_.fetch_add(1, std::memory_order_relaxed); }
-#endif
+
AnyActivity* set_name(const std::string& name)
{
xbt_assert(get_state() == State::INITED, "Cannot change the name of an activity after its start");
name_ = name;
return static_cast<AnyActivity*>(this);
}
- const std::string& get_name() { return name_; }
- const char* get_cname() { return name_.c_str(); }
+ const std::string& get_name() const override { return name_; }
+ const char* get_cname() const override { return name_.c_str(); }
AnyActivity* set_tracing_category(const std::string& category)
{
tracing_category_ = category;
return static_cast<AnyActivity*>(this);
}
- const std::string& get_tracing_category() { return tracing_category_; }
+ const std::string& get_tracing_category() const { return tracing_category_; }
AnyActivity* set_user_data(void* data)
{
return static_cast<AnyActivity*>(this);
}
- void* get_user_data() { return user_data_; }
+ void* get_user_data() const { return user_data_; }
+#ifndef DOXYGEN
+ /* The refcounting is done in the ancestor class, Activity, but we want each of the classes benefiting of the CRTP
+ * (Exec, Comm, etc) to have smart pointers too, so we define these methods here, that forward the ptr_release and
+ * add_ref to the Activity class. Hopefully, the "inline" helps to not hinder the perf here.
+ */
+ friend void inline intrusive_ptr_release(AnyActivity* a) { intrusive_ptr_release(static_cast<Activity*>(a)); }
+ friend void inline intrusive_ptr_add_ref(AnyActivity* a) { intrusive_ptr_add_ref(static_cast<Activity*>(a)); }
+#endif
};
} // namespace s4u
-/* 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.
+ *
+ * \rst
* 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;
CommPtr set_tracing_category(const std::string& category);
/** Retrieve the mailbox on which this comm acts */
- Mailbox* get_mailbox();
+ Mailbox* get_mailbox() const;
/** Retrieve the size of the received data. Not to be mixed with @ref Activity::set_remaining() */
- size_t get_dst_data_size();
+ size_t get_dst_data_size() const;
- Actor* get_sender();
+ Actor* get_sender() const;
};
} // namespace s4u
} // namespace 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. */
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
*/
class XBT_PUBLIC Disk : public xbt::Extendable<Disk> {
+ kernel::resource::DiskImpl* const pimpl_;
+ std::string name_;
friend Engine;
friend Io;
friend kernel::resource::DiskImpl;
-public:
- explicit Disk(const std::string& name, kernel::resource::DiskImpl* pimpl) : pimpl_(pimpl), name_(name) {}
-
protected:
+#ifndef DOXYGEN
virtual ~Disk() = default;
+#endif
public:
+#ifndef DOXYGEN
+ explicit Disk(const std::string& name, kernel::resource::DiskImpl* pimpl) : pimpl_(pimpl), name_(name) {}
+#endif
+
/** @brief Callback signal fired when a new Disk is created */
static xbt::signal<void(Disk&)> on_creation;
/** @brief Callback signal fired when a Disk is destroyed */
std::string const& get_name() const { return name_; }
/** @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() 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);
IoPtr write_async(sg_size_t size);
sg_size_t write(sg_size_t size);
+#ifndef DOXYGEN
kernel::resource::DiskImpl* get_impl() const { return pimpl_; }
-
-private:
- kernel::resource::DiskImpl* const pimpl_;
- std::string name_;
+#endif
};
} // namespace s4u
-/* 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 {
+ friend simgrid::kernel::EngineImpl;
+
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) */
void load_platform(const std::string& platf);
- void register_function(const std::string& name, int (*code)(int, char**));
+ XBT_ATTRIB_DEPRECATED_v330("Please change the return code of your actors to void") void register_function(
+ const std::string& name, int (*code)(int, char**));
+
+ void register_function(const std::string& name, void (*code)(int, char**));
void register_function(const std::string& name, void (*code)(std::vector<std::string>));
- void register_default(int (*code)(int, char**));
+ XBT_ATTRIB_DEPRECATED_v330("Please change the return code of your actors to void") void register_default(
+ int (*code)(int, char**));
+ void register_default(void (*code)(int, char**));
+ void register_default(const kernel::actor::ActorCodeFactory& factory);
+
+ void register_function(const std::string& name, const kernel::actor::ActorCodeFactory& factory);
template <class F> void register_actor(const std::string& name)
{
- simix::register_function(name, [](std::vector<std::string> args) {
- return simix::ActorCode([args] {
+ register_function(name, [](std::vector<std::string> args) {
+ return kernel::actor::ActorCode([args] {
F code(std::move(args));
code();
});
});
}
-
template <class F> void register_actor(const std::string& name, F code)
{
- simix::register_function(name, [code](std::vector<std::string> args) {
- return simix::ActorCode([code, args] { code(std::move(args)); });
+ register_function(name, [code](std::vector<std::string> args) {
+ return kernel::actor::ActorCode([code, args] { code(std::move(args)); });
});
}
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);
#endif /*DOXYGEN*/
public:
+ /** Returns the amount of hosts existing in the platform. */
size_t get_host_count();
- /** @brief Returns the list of all hosts found in the platform */
+ /** Returns a vector of all hosts found in the platform.
+ *
+ * The order is generally different from the creation/declaration order in the XML platform because we use a hash
+ * table internally.
+ */
std::vector<Host*> get_all_hosts();
std::vector<Host*> get_filtered_hosts(const std::function<bool(Host*)>& filter);
Host* host_by_name(const std::string& name);
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. */
/** Computation Activity, representing the asynchronous executions.
*
- * They are generated from this_actor::exec_init() or Host::execute(), and can be used to model pools of threads or
- * similar mechanisms.
+ * @rst
+ * Most of them are created with :cpp:func:`simgrid::s4u::this_actor::exec_init()` or
+ * :cpp:func:`simgrid::s4u::Host::execute()`, and represent a classical (sequential) execution. This can be used to
+ * simulate some computation occuring in another thread when the calling actor is not blocked during the execution.
+ *
+ * You can also use :cpp:func:`simgrid::s4u::this_actor::parallel_execute()` to create *parallel* executions. These
+ * objects represent distributed computations involving computations on several hosts and communications between them.
+ * Such objects can for example represent a matrix multiplication done with ScaLAPACK on a real system. Once created,
+ * parallel Exec are very similar to the sequential ones. The only difference is that you cannot migrate them, and their
+ * remaining amount of work can only be defined as a ratio. See the doc of :cpp:func:`simgrid::s4u::Exec::get_remaining`
+ * and :cpp:func:`simgrid::s4u::Exec::get_remaining_ratio` for more info.
+ * @endrst
*/
class XBT_PUBLIC Exec : public Activity_T<Exec> {
double priority_ = 1.0;
static xbt::signal<void(Actor const&, Exec const&)> on_start;
static xbt::signal<void(Actor const&, Exec const&)> on_completion;
- virtual Exec* start() override = 0;
- virtual double get_remaining_ratio() = 0;
- virtual ExecPtr set_host(Host* host) = 0;
+ Exec* start() override = 0;
+ /** @brief On sequential executions, returns the amount of flops that remain to be done; This cannot be used on
+ * parallel executions. */
+ virtual double get_remaining_ratio() const = 0;
+ virtual ExecPtr set_host(Host* host) = 0;
Exec* wait() override;
Exec* wait_for(double timeout) override;
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;
ExecPtr set_host(Host* host) override;
- double get_remaining() override;
- double get_remaining_ratio() override;
+ double get_remaining() const override;
+ double get_remaining_ratio() const override;
};
class XBT_PUBLIC ExecPar : public Exec {
friend XBT_PUBLIC ExecPtr this_actor::exec_init(const std::vector<s4u::Host*>& hosts,
const std::vector<double>& flops_amounts,
const std::vector<double>& bytes_amounts);
- double get_remaining() override;
- double get_remaining_ratio() override;
+ double get_remaining() const override;
+ double get_remaining_ratio() const override;
Exec* start() 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 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> {
+#ifndef DOXYGEN
friend vm::VMModel; // Use the pimpl_cpu to compute the VM sharing
friend vm::VirtualMachineImpl; // creates the the pimpl_cpu
friend kernel::routing::NetZoneImpl;
public:
explicit Host(const std::string& name);
- /** Host destruction logic */
protected:
virtual ~Host();
void set_netpoint(kernel::routing::NetPoint* netpoint) { pimpl_netpoint_ = netpoint; }
private:
bool currently_destroying_ = false;
+#endif
public:
/** Called on each newly created host */
static xbt::signal<void(Host const&)> on_speed_change;
virtual void destroy();
+#ifndef DOXYGEN
// No copy/move
Host(Host const&) = delete;
Host& operator=(Host const&) = delete;
+#endif
/** Retrieve a host from its name, or return nullptr */
static Host* by_name_or_null(const std::string& name);
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
*
void set_state_profile(kernel::profile::Profile* p);
void set_speed_profile(kernel::profile::Profile* p);
+ /** @brief Get the peak computing speed in flops/s at the current pstate, NOT taking the external load into account.
+ *
+ * The amount of flops per second available for computing depends on several things:
+ * - The current pstate determines the maximal peak computing speed (use @ref get_pstate_speed() to retrieve the
+ * computing speed you would get at another pstate)
+ * - If you declared an external load (with @ref simgrid::surf::Cpu::set_speed_profile()), you must multiply the
+ * result of get_speed() by get_available_speed() to retrieve what a new computation would get.
+ *
+ * The remaining speed is then shared between the executions located on this host.
+ * You can retrieve the amount of tasks currently running on this host with @ref get_load().
+ *
+ * The host may have multiple cores, and your executions may be able to use more than a single core.
+ *
+ * Finally, executions of priority 2 get twice the amount of flops than executions of priority 1.
+ */
double get_speed() const;
+ /** @brief Get the available speed ratio, between 0 and 1.
+ *
+ * This accounts for external load (see @ref simgrid::surf::Cpu::set_speed_profile()).
+ */
double get_available_speed() const;
+ /** Returns the number of core of the processor. */
int get_core_count() const;
+ /** Returns the current computation load (in flops per second)
+ *
+ * The external load (coming from an availability trace) is not taken in account.
+ * You may also be interested in the load plugin.
+ */
double get_load() const;
double get_pstate_speed(int pstate_index) const;
*/
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. */
Io* cancel() override;
bool test() override;
- double get_remaining() override;
- sg_size_t get_performed_ioops();
+ double get_remaining() const override;
+ sg_size_t get_performed_ioops() const;
};
} // namespace s4u
-/* 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) */
+/**
+ * @rst
+ * A Link represents the network facilities between :cpp:class:`hosts <simgrid::s4u::Host>`.
+ * @endrst
+ */
class XBT_PUBLIC Link : public xbt::Extendable<Link> {
friend kernel::resource::LinkImpl;
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);
+ kernel::activity::ActivityImplPtr 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();
- int get_host_count();
+ std::vector<Host*> get_all_hosts() const;
+ int get_host_count() const;
kernel::routing::NetZoneImpl* get_impl() const { return pimpl_; }
private:
kernel::routing::NetZoneImpl* const pimpl_;
- std::unordered_map<std::string, std::string> properties_;
public:
/** Get the properties assigned to a netzone */
const std::unordered_map<std::string, std::string>* get_properties() const;
-
- std::vector<NetZone*> get_children();
-
/** Retrieve the property value (or nullptr if not set) */
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() 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 */
void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, kernel::routing::NetPoint* gw_src,
-/* 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
protected:
virtual ~Storage() = default;
+
public:
/** @brief Callback signal fired when a new Storage is created */
static xbt::signal<void(Storage&)> on_creation;
/** @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. */
explicit VirtualMachine(const std::string& name, Host* physical_host, int core_amount);
explicit VirtualMachine(const std::string& name, Host* physical_host, int core_amount, size_t ramsize);
+#ifndef DOXYGEN
// No copy/move
VirtualMachine(VirtualMachine const&) = delete;
VirtualMachine& operator=(VirtualMachine const&) = delete;
+#endif
enum class state {
CREATED, /**< created, but not yet started */
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. */
#include <simgrid/host.h>
#include <simgrid/link.h>
+#include <simgrid/version.h>
#include <xbt/log.h>
#include <xbt/sysdep.h>
*/
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. */
#include <vector>
#endif
-/* ******************************** Host ************************************ */
-/** @brief Host datatype
- @ingroup simix_host_management
-
- A <em>location</em> (or <em>host</em>) is any possible place where
- a process may run. Thus it is represented as a <em>physical
- resource with computing capabilities</em>, some <em>mailboxes</em>
- to enable running process to communicate with remote ones, and
- some <em>private data</em> that can be only accessed by local
- process.
-
- @see m_host_management
- @{ */
-typedef enum {
- SIMIX_WAITING,
- SIMIX_READY,
- SIMIX_RUNNING,
- SIMIX_DONE,
- SIMIX_CANCELED,
- SIMIX_FAILED,
- SIMIX_SRC_HOST_FAILURE,
- SIMIX_DST_HOST_FAILURE,
- SIMIX_TIMEOUT,
- SIMIX_SRC_TIMEOUT,
- SIMIX_DST_TIMEOUT,
- SIMIX_LINK_FAILURE
-} e_smx_state_t;
-/** @} */
-
/******************************* Networking ***********************************/
extern unsigned smx_context_stack_size;
extern unsigned smx_context_guard_size;
XBT_ATTRIB_DEPRECATED_v329("Please use simgrid::simix::Timer::get_date()") XBT_PUBLIC
double SIMIX_timer_get_date(smx_timer_t timer);
-XBT_PUBLIC void SIMIX_display_process_status();
+XBT_ATTRIB_DEPRECATED_v329("Please use simix_global->display_all_actor_status()") XBT_PUBLIC
+ void SIMIX_display_process_status();
SG_END_DECL
/******************************** Deployment **********************************/
SG_END_DECL
#ifdef __cplusplus
-XBT_PUBLIC void SIMIX_process_on_exit(smx_actor_t process, const std::function<void(bool /*failed*/)>& fun);
+XBT_ATTRIB_DEPRECATED_v329("This function will be removed in 3.29") XBT_PUBLIC
+ void SIMIX_process_on_exit(smx_actor_t process, const std::function<void(bool /*failed*/)>& fun);
#endif
/****************************** Communication *********************************/
/******************************* 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(simgrid::kernel::activity::ActivityImpl* 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);
+XBT_PUBLIC bool simcall_execution_test(simgrid::kernel::activity::ActivityImpl* execution);
+
+XBT_ATTRIB_DEPRECATED_v330("Please use an ActivityImpl* for first parameter") inline e_smx_state_t
+ simcall_execution_wait(const simgrid::kernel::activity::ActivityImplPtr& execution, double timeout)
+{
+ return simcall_execution_wait(execution.get(), timeout);
+}
+XBT_ATTRIB_DEPRECATED_v330("Please use an ActivityImpl* for first parameter") inline bool simcall_execution_test(
+ const simgrid::kernel::activity::ActivityImplPtr& execution)
+{
+ return simcall_execution_test(execution.get());
+}
#endif
/**************************** Process simcalls ********************************/
#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*),
- void (*clean_fun)(void*),
- void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
- void* data, bool detached);
+XBT_PUBLIC simgrid::kernel::activity::ActivityImplPtr
+simcall_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff,
+ size_t src_buff_size, 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*),
- void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
- void* data, double rate);
+XBT_PUBLIC simgrid::kernel::activity::ActivityImplPtr
+simcall_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_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 rate);
-XBT_PUBLIC smx_activity_t simcall_comm_iprobe(smx_mailbox_t mbox, int type,
- int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
- void* data);
+XBT_PUBLIC simgrid::kernel::activity::ActivityImplPtr
+simcall_comm_iprobe(smx_mailbox_t mbox, int type, 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 */
-XBT_PUBLIC unsigned int simcall_comm_waitany(smx_activity_t comms[], size_t count, double timeout);
+XBT_ATTRIB_DEPRECATED_v330("Please use a CommImpl*[] for first parameter") XBT_PUBLIC
+ unsigned int simcall_comm_waitany(simgrid::kernel::activity::ActivityImplPtr comms[], size_t count, double timeout);
XBT_PUBLIC unsigned int simcall_comm_waitany(simgrid::kernel::activity::CommImpl* comms[], size_t count,
double timeout);
-XBT_PUBLIC void simcall_comm_wait(const smx_activity_t& comm, double timeout);
-XBT_PUBLIC bool simcall_comm_test(const smx_activity_t& comm);
-XBT_PUBLIC int simcall_comm_testany(smx_activity_t comms[], size_t count);
+XBT_PUBLIC void simcall_comm_wait(simgrid::kernel::activity::ActivityImpl* comm, double timeout);
+XBT_PUBLIC bool simcall_comm_test(simgrid::kernel::activity::ActivityImpl* comm);
+XBT_ATTRIB_DEPRECATED_v330("Please use a CommImpl*[] for first parameter") XBT_PUBLIC
+ int simcall_comm_testany(simgrid::kernel::activity::ActivityImplPtr comms[], size_t count);
XBT_PUBLIC int simcall_comm_testany(simgrid::kernel::activity::CommImpl* comms[], size_t count);
+
+XBT_ATTRIB_DEPRECATED_v330("Please use a ActivityImpl* for first parameter") inline void simcall_comm_wait(
+ const simgrid::kernel::activity::ActivityImplPtr& comm, double timeout)
+{
+ simcall_comm_wait(comm.get(), timeout);
+}
+XBT_ATTRIB_DEPRECATED_v330("Please use a ActivityImpl* for first parameter") inline bool simcall_comm_test(
+ const simgrid::kernel::activity::ActivityImplPtr& comm)
+{
+ return simcall_comm_test(comm.get());
+}
#endif
/************************** Synchro simcalls **********************************/
/***************************** 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(simgrid::kernel::activity::ActivityImpl* io, double timeout);
+XBT_PUBLIC bool simcall_io_test(simgrid::kernel::activity::ActivityImpl* io);
+
+XBT_ATTRIB_DEPRECATED_v330("Please use an ActivityImpl* for first parameter") inline e_smx_state_t
+ simcall_io_wait(const simgrid::kernel::activity::ActivityImplPtr& io, double timeout)
+{
+ return simcall_io_wait(io.get(), timeout);
+}
+XBT_ATTRIB_DEPRECATED_v330("Please use an ActivityImpl* for first parameter") inline bool simcall_io_test(
+ const simgrid::kernel::activity::ActivityImplPtr& io)
+{
+ return simcall_io_test(io.get());
+}
+
#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
namespace simgrid {
namespace simix {
-// What's executed as SIMIX actor code:
-typedef std::function<void()> ActorCode;
-
-// Create an ActorCode based on a std::string
-typedef std::function<ActorCode(std::vector<std::string> args)> ActorCodeFactory;
-
-XBT_PUBLIC void register_function(const std::string& name, const ActorCodeFactory& factory);
typedef std::pair<double, Timer*> TimerQelt;
static boost::heap::fibonacci_heap<TimerQelt, boost::heap::compare<xbt::HeapComparator<TimerQelt>>> simix_timers;
} // namespace simix
} // namespace simgrid
-XBT_PUBLIC smx_actor_t simcall_process_create(const std::string& name, const simgrid::simix::ActorCode& code,
- void* data, sg_host_t host,
- std::unordered_map<std::string, std::string>* properties);
-
#endif
-/* 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 (...) {
},
nullptr);
}
+
private:
// We wrap an event-based kernel future:
simgrid::kernel::Future<T> future_;
-/* 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 {
class ActionArgParser {
public:
virtual ~ActionArgParser() = default;
- virtual void parse(simgrid::xbt::ReplayAction& action, const std::string& name) { CHECK_ACTION_PARAMS(action, 0, 0) }
+ virtual void parse(xbt::ReplayAction& action, const std::string& name) { CHECK_ACTION_PARAMS(action, 0, 0) }
};
class WaitTestParser : public ActionArgParser {
int dst;
int tag;
- void parse(simgrid::xbt::ReplayAction& action, const std::string& name) override;
+ void parse(xbt::ReplayAction& action, const std::string& name) override;
};
class SendRecvParser : public ActionArgParser {
int tag;
MPI_Datatype datatype1 = MPI_DEFAULT_TYPE;
- void parse(simgrid::xbt::ReplayAction& action, const std::string& name) override;
+ void parse(xbt::ReplayAction& action, const std::string& name) override;
};
class ComputeParser : public ActionArgParser {
public:
double flops;
- void parse(simgrid::xbt::ReplayAction& action, const std::string& name) override;
+ void parse(xbt::ReplayAction& action, const std::string& name) override;
};
class SleepParser : public ActionArgParser {
public:
double time;
- void parse(simgrid::xbt::ReplayAction& action, const std::string& name) override;
+ void parse(xbt::ReplayAction& action, const std::string& name) override;
};
class LocationParser : public ActionArgParser {
std::string filename;
int line;
- void parse(simgrid::xbt::ReplayAction& action, const std::string& name) override;
+ void parse(xbt::ReplayAction& action, const std::string& name) override;
};
class CollCommParser : public ActionArgParser {
class BcastArgParser : public CollCommParser {
public:
- void parse(simgrid::xbt::ReplayAction& action, const std::string& name) override;
+ void parse(xbt::ReplayAction& action, const std::string& name) override;
};
class ReduceArgParser : public CollCommParser {
public:
- void parse(simgrid::xbt::ReplayAction& action, const std::string& name) override;
+ void parse(xbt::ReplayAction& action, const std::string& name) override;
};
class AllReduceArgParser : public CollCommParser {
public:
- void parse(simgrid::xbt::ReplayAction& action, const std::string& name) override;
+ void parse(xbt::ReplayAction& action, const std::string& name) override;
};
class AllToAllArgParser : public CollCommParser {
public:
- void parse(simgrid::xbt::ReplayAction& action, const std::string& name) override;
+ void parse(xbt::ReplayAction& action, const std::string& name) override;
};
class GatherArgParser : public CollCommParser {
public:
- void parse(simgrid::xbt::ReplayAction& action, const std::string& name) override;
+ void parse(xbt::ReplayAction& action, const std::string& name) override;
};
class GatherVArgParser : public CollCommParser {
int recv_size_sum;
std::shared_ptr<std::vector<int>> recvcounts;
std::vector<int> disps;
- void parse(simgrid::xbt::ReplayAction& action, const std::string& name) override;
+ void parse(xbt::ReplayAction& action, const std::string& name) override;
};
class ScatterArgParser : public CollCommParser {
public:
- void parse(simgrid::xbt::ReplayAction& action, const std::string& name) override;
+ void parse(xbt::ReplayAction& action, const std::string& name) override;
};
class ScatterVArgParser : public CollCommParser {
int send_size_sum;
std::shared_ptr<std::vector<int>> sendcounts;
std::vector<int> disps;
- void parse(simgrid::xbt::ReplayAction& action, const std::string& name) override;
+ void parse(xbt::ReplayAction& action, const std::string& name) override;
};
class ReduceScatterArgParser : public CollCommParser {
int recv_size_sum;
std::shared_ptr<std::vector<int>> recvcounts;
std::vector<int> disps;
- void parse(simgrid::xbt::ReplayAction& action, const std::string& name) override;
+ void parse(xbt::ReplayAction& action, const std::string& name) override;
};
class AllToAllVArgParser : public CollCommParser {
std::vector<int> recvdisps;
int send_buf_size;
int recv_buf_size;
- void parse(simgrid::xbt::ReplayAction& action, const std::string& name) override;
+ void parse(xbt::ReplayAction& action, const std::string& name) override;
};
/**
* 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(simgrid::s4u::this_actor::get_pid()) {}
+ explicit ReplayAction(const std::string& name) : name_(name) {}
virtual ~ReplayAction() = default;
- void execute(simgrid::xbt::ReplayAction& action)
+ 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);
}
};
class WaitAction : public ReplayAction<WaitTestParser> {
-private:
RequestStorage& req_storage;
public:
explicit WaitAction(RequestStorage& storage) : ReplayAction("Wait"), req_storage(storage) {}
- void kernel(simgrid::xbt::ReplayAction& action) override;
+ void kernel(xbt::ReplayAction& action) override;
};
class SendAction : public ReplayAction<SendRecvParser> {
-private:
RequestStorage& req_storage;
public:
explicit SendAction(const std::string& name, RequestStorage& storage) : ReplayAction(name), req_storage(storage) {}
- void kernel(simgrid::xbt::ReplayAction& action) override;
+ void kernel(xbt::ReplayAction& action) override;
};
class RecvAction : public ReplayAction<SendRecvParser> {
-private:
RequestStorage& req_storage;
public:
explicit RecvAction(const std::string& name, RequestStorage& storage) : ReplayAction(name), req_storage(storage) {}
- void kernel(simgrid::xbt::ReplayAction& action) override;
+ void kernel(xbt::ReplayAction& action) override;
};
class ComputeAction : public ReplayAction<ComputeParser> {
public:
explicit ComputeAction() : ReplayAction("compute") {}
- void kernel(simgrid::xbt::ReplayAction& action) override;
+ void kernel(xbt::ReplayAction& action) override;
};
class SleepAction : public ReplayAction<SleepParser> {
public:
explicit SleepAction() : ReplayAction("sleep") {}
- void kernel(simgrid::xbt::ReplayAction& action) override;
+ void kernel(xbt::ReplayAction& action) override;
};
class LocationAction : public ReplayAction<LocationParser> {
public:
explicit LocationAction() : ReplayAction("location") {}
- void kernel(simgrid::xbt::ReplayAction& action) override;
+ void kernel(xbt::ReplayAction& action) override;
};
class TestAction : public ReplayAction<WaitTestParser> {
public:
explicit TestAction(RequestStorage& storage) : ReplayAction("Test"), req_storage(storage) {}
- void kernel(simgrid::xbt::ReplayAction& action) override;
+ void kernel(xbt::ReplayAction& action) override;
};
class InitAction : public ReplayAction<ActionArgParser> {
public:
explicit InitAction() : ReplayAction("Init") {}
- void kernel(simgrid::xbt::ReplayAction& action) override;
+ void kernel(xbt::ReplayAction& action) override;
};
class CommunicatorAction : public ReplayAction<ActionArgParser> {
public:
explicit CommunicatorAction() : ReplayAction("Comm") {}
- void kernel(simgrid::xbt::ReplayAction& action) override;
+ void kernel(xbt::ReplayAction& action) override;
};
class WaitAllAction : public ReplayAction<ActionArgParser> {
-private:
RequestStorage& req_storage;
public:
explicit WaitAllAction(RequestStorage& storage) : ReplayAction("waitall"), req_storage(storage) {}
- void kernel(simgrid::xbt::ReplayAction& action) override;
+ void kernel(xbt::ReplayAction& action) override;
};
class BarrierAction : public ReplayAction<ActionArgParser> {
public:
explicit BarrierAction() : ReplayAction("barrier") {}
- void kernel(simgrid::xbt::ReplayAction& action) override;
+ void kernel(xbt::ReplayAction& action) override;
};
class BcastAction : public ReplayAction<BcastArgParser> {
public:
explicit BcastAction() : ReplayAction("bcast") {}
- void kernel(simgrid::xbt::ReplayAction& action) override;
+ void kernel(xbt::ReplayAction& action) override;
};
class ReduceAction : public ReplayAction<ReduceArgParser> {
public:
explicit ReduceAction() : ReplayAction("reduce") {}
- void kernel(simgrid::xbt::ReplayAction& action) override;
+ void kernel(xbt::ReplayAction& action) override;
};
class AllReduceAction : public ReplayAction<AllReduceArgParser> {
public:
explicit AllReduceAction() : ReplayAction("allreduce") {}
- void kernel(simgrid::xbt::ReplayAction& action) override;
+ void kernel(xbt::ReplayAction& action) override;
};
class AllToAllAction : public ReplayAction<AllToAllArgParser> {
public:
explicit AllToAllAction() : ReplayAction("alltoall") {}
- void kernel(simgrid::xbt::ReplayAction& action) override;
+ void kernel(xbt::ReplayAction& action) override;
};
class GatherAction : public ReplayAction<GatherArgParser> {
public:
explicit GatherAction(const std::string& name) : ReplayAction(name) {}
- void kernel(simgrid::xbt::ReplayAction& action) override;
+ void kernel(xbt::ReplayAction& action) override;
};
class GatherVAction : public ReplayAction<GatherVArgParser> {
public:
explicit GatherVAction(const std::string& name) : ReplayAction(name) {}
- void kernel(simgrid::xbt::ReplayAction& action) override;
+ void kernel(xbt::ReplayAction& action) override;
};
class ScatterAction : public ReplayAction<ScatterArgParser> {
public:
explicit ScatterAction() : ReplayAction("scatter") {}
- void kernel(simgrid::xbt::ReplayAction& action) override;
+ void kernel(xbt::ReplayAction& action) override;
};
class ScatterVAction : public ReplayAction<ScatterVArgParser> {
public:
explicit ScatterVAction() : ReplayAction("scatterv") {}
- void kernel(simgrid::xbt::ReplayAction& action) override;
+ void kernel(xbt::ReplayAction& action) override;
};
class ReduceScatterAction : public ReplayAction<ReduceScatterArgParser> {
public:
explicit ReduceScatterAction() : ReplayAction("reducescatter") {}
- void kernel(simgrid::xbt::ReplayAction& action) override;
+ void kernel(xbt::ReplayAction& action) override;
};
class AllToAllVAction : public ReplayAction<AllToAllVArgParser> {
public:
explicit AllToAllVAction() : ReplayAction("alltoallv") {}
- void kernel(simgrid::xbt::ReplayAction& action) override;
+ void kernel(xbt::ReplayAction& action) override;
};
-}
-}
-}
+
+} // namespace replay
+} // namespace smpi
+} // namespace simgrid
#endif
/* 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);
--- /dev/null
+/* src/simgrid/version.h - internal versioning info */
+
+/* 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_VERSION_H
+#define SIMGRID_VERSION_H
+
+#define SIMGRID_GIT_VERSION "@GIT_VERSION@"
+
+/** Define the version numbers of the used header files.
+ See sg_version_get() to retrieve the version of the dynamic library. */
+#define SIMGRID_VERSION_MAJOR @SIMGRID_VERSION_MAJOR@
+#define SIMGRID_VERSION_MINOR @SIMGRID_VERSION_MINOR@
+#define SIMGRID_VERSION_PATCH @SIMGRID_VERSION_PATCH@
+#define SIMGRID_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
+
+SG_BEGIN_DECL
+/** Retrieves the version numbers of the used dynamic library (so, DLL or dynlib), while
+ SIMGRID_VERSION_MAJOR and friends give the version numbers of the used header files */
+XBT_PUBLIC void sg_version_get(int* major, int* minor, int* patch);
+
+/** Display the version information and some additional blurb. */
+XBT_PUBLIC void sg_version();
+SG_END_DECL
+
+
+/* Version as a single integer. v3.4 is 30400, v3.16.2 is 31602, v42 will be 420000, and so on. */
+#define SIMGRID_VERSION (100UL * (100UL * (SIMGRID_VERSION_MAJOR) + (SIMGRID_VERSION_MINOR)) + (SIMGRID_VERSION_PATCH))
+
+#define SIMGRID_VERSION_STRING "@SIMGRID_VERSION_STRING@"
+
+#endif /* SIMGRID_VERSION_H */
-/* Public interface to the Link datatype */
+/* Public interface to the Virtual Machine 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
-/** @brief Opaque type describing a Virtual Machine.
- * @ingroup msg_VMs
- *
- * All this is highly experimental and the interface will probably change in the future.
- * Please don't depend on this yet (although testing is welcomed if you feel so).
- * Usual lack of guaranty of any kind applies here, and is even increased.
- *
- */
XBT_PUBLIC sg_vm_t sg_vm_create_core(sg_host_t pm, const char* name);
-XBT_PUBLIC sg_vm_t sg_vm_create_multicore(sg_host_t pm, const char* name, int coreAmount);
+XBT_PUBLIC sg_vm_t sg_vm_create_multicore(sg_host_t pm, const char* name, int core_amount);
XBT_PUBLIC int sg_vm_is_created(sg_vm_t vm);
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(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
parameter(MPI_SUBVERSION=1)
parameter(MPI_LOCK_EXCLUSIVE=1)
parameter(MPI_LOCK_SHARED=2)
+
+
integer MPI_MODE_NOSTORE, MPI_MODE_NOPUT, MPI_MODE_NOPRECEDE
integer MPI_MODE_NOSUCCEED, MPI_MODE_NOCHECK
parameter(MPI_MODE_NOSTORE=1)
integer MPI_MODE_RDONLY, MPI_MODE_RDWR, MPI_MODE_WRONLY
integer MPI_MODE_CREATE, MPI_MODE_EXCL, MPI_MODE_DELETE_ON_CLOSE
integer MPI_MODE_UNIQUE_OPEN, MPI_MODE_APPEND, MPI_MODE_SEQUENTIAL
+ integer MPI_FILE_NULL
+ integer MPI_DISPLACEMENT_CURRENT, MPI_SEEK_SET, MPI_SEEK_CUR
+ integer MPI_MAX_DATAREP_STRING
+ parameter(MPI_FILE_NULL=0)
+ parameter(MPI_DISPLACEMENT_CURRENT=-54278278)
+ parameter(MPI_SEEK_SET=600)
+ parameter(MPI_SEEK_CUR=602)
+ parameter(MPI_MAX_DATAREP_STRING=128)
parameter( MPI_MODE_RDONLY=2)
parameter( MPI_MODE_RDWR=8)
-/* 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 SAMPI_H_
#define SAMPI_H_
-#define SAMPI_OVERRIDEN_MALLOC
+#define SMPI_NO_OVERRIDE_MALLOC
#include <stdlib.h>
#include <smpi/smpi.h>
-/* 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 MPI_Info smpi_process_info_env();
XBT_PUBLIC void* smpi_process_get_user_data();
XBT_PUBLIC void smpi_process_set_user_data(void*);
+XBT_PUBLIC void smpi_init_options();
XBT_PUBLIC void smpi_execute_flops(double flops);
+XBT_PUBLIC void smpi_execute_flops_benched(double flops);
XBT_PUBLIC void smpi_execute(double duration);
XBT_PUBLIC void smpi_execute_benched(double duration);
*/
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)
// This file has been automatically generated by the script
// in tools/smpi/generate_smpi_defines.pl
// DO NOT EDIT MANUALLY. ALL CHANGES WILL BE OVERWRITTEN!
-#define MPI_Init(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Init(__VA_ARGS__); }
-#define MPI_Finalize(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Finalize(__VA_ARGS__); }
-#define MPI_Finalized(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Finalized(__VA_ARGS__); }
-#define MPI_Init_thread(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Init_thread(__VA_ARGS__); }
-#define MPI_Initialized(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Initialized(__VA_ARGS__); }
-#define MPI_Query_thread(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Query_thread(__VA_ARGS__); }
-#define MPI_Is_thread_main(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Is_thread_main(__VA_ARGS__); }
-#define MPI_Get_version(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Get_version(__VA_ARGS__); }
-#define MPI_Get_library_version(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Get_library_version(__VA_ARGS__); }
-#define MPI_Get_processor_name(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Get_processor_name(__VA_ARGS__); }
-#define MPI_Abort(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Abort(__VA_ARGS__); }
-#define MPI_Alloc_mem(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Alloc_mem(__VA_ARGS__); }
-#define MPI_Free_mem(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Free_mem(__VA_ARGS__); }
-#define MPI_Wtime(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Wtime(__VA_ARGS__); }
-#define MPI_Wtick(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Wtick(__VA_ARGS__); }
-#define MPI_Buffer_attach(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Buffer_attach(__VA_ARGS__); }
-#define MPI_Buffer_detach(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Buffer_detach(__VA_ARGS__); }
-#define MPI_Address(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Address(__VA_ARGS__); }
-#define MPI_Get_address(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Get_address(__VA_ARGS__); }
-#define MPI_Error_class(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Error_class(__VA_ARGS__); }
-#define MPI_Error_string(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Error_string(__VA_ARGS__); }
-#define MPI_Attr_delete(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Attr_delete(__VA_ARGS__); }
-#define MPI_Attr_get(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Attr_get(__VA_ARGS__); }
-#define MPI_Attr_put(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Attr_put(__VA_ARGS__); }
-#define MPI_Keyval_create(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Keyval_create(__VA_ARGS__); }
-#define MPI_Keyval_free(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Keyval_free(__VA_ARGS__); }
-#define MPI_Type_free(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_free(__VA_ARGS__); }
-#define MPI_Type_size(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_size(__VA_ARGS__); }
-#define MPI_Type_size_x(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_size_x(__VA_ARGS__); }
-#define MPI_Type_get_extent(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_get_extent(__VA_ARGS__); }
-#define MPI_Type_get_true_extent(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_get_true_extent(__VA_ARGS__); }
-#define MPI_Type_extent(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_extent(__VA_ARGS__); }
-#define MPI_Type_lb(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_lb(__VA_ARGS__); }
-#define MPI_Type_ub(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_ub(__VA_ARGS__); }
-#define MPI_Type_commit(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_commit(__VA_ARGS__); }
-#define MPI_Type_hindexed(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_hindexed(__VA_ARGS__); }
-#define MPI_Type_create_hindexed(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_create_hindexed(__VA_ARGS__); }
-#define MPI_Type_create_hindexed_block(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_create_hindexed_block(__VA_ARGS__); }
-#define MPI_Type_hvector(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_hvector(__VA_ARGS__); }
-#define MPI_Type_create_hvector(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_create_hvector(__VA_ARGS__); }
-#define MPI_Type_indexed(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_indexed(__VA_ARGS__); }
-#define MPI_Type_create_indexed(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_create_indexed(__VA_ARGS__); }
-#define MPI_Type_create_indexed_block(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_create_indexed_block(__VA_ARGS__); }
-#define MPI_Type_struct(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_struct(__VA_ARGS__); }
-#define MPI_Type_create_struct(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_create_struct(__VA_ARGS__); }
-#define MPI_Type_vector(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_vector(__VA_ARGS__); }
-#define MPI_Type_contiguous(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_contiguous(__VA_ARGS__); }
-#define MPI_Type_create_resized(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_create_resized(__VA_ARGS__); }
-#define MPI_Type_f2c(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_f2c(__VA_ARGS__); }
-#define MPI_Type_c2f(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_c2f(__VA_ARGS__); }
-#define MPI_Get_count(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Get_count(__VA_ARGS__); }
-#define MPI_Type_get_attr(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_get_attr(__VA_ARGS__); }
-#define MPI_Type_set_attr(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_set_attr(__VA_ARGS__); }
-#define MPI_Type_delete_attr(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_delete_attr(__VA_ARGS__); }
-#define MPI_Type_create_keyval(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_create_keyval(__VA_ARGS__); }
-#define MPI_Type_free_keyval(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_free_keyval(__VA_ARGS__); }
-#define MPI_Type_dup(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_dup(__VA_ARGS__); }
-#define MPI_Type_set_name(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_set_name(__VA_ARGS__); }
-#define MPI_Type_get_name(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_get_name(__VA_ARGS__); }
-#define MPI_Pack(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Pack(__VA_ARGS__); }
-#define MPI_Pack_size(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Pack_size(__VA_ARGS__); }
-#define MPI_Unpack(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Unpack(__VA_ARGS__); }
-#define MPI_Op_create(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Op_create(__VA_ARGS__); }
-#define MPI_Op_free(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Op_free(__VA_ARGS__); }
-#define MPI_Op_commutative(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Op_commutative(__VA_ARGS__); }
-#define MPI_Op_f2c(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Op_f2c(__VA_ARGS__); }
-#define MPI_Op_c2f(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Op_c2f(__VA_ARGS__); }
-#define MPI_Group_free(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Group_free(__VA_ARGS__); }
-#define MPI_Group_size(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Group_size(__VA_ARGS__); }
-#define MPI_Group_rank(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Group_rank(__VA_ARGS__); }
-#define MPI_Group_translate_ranks(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Group_translate_ranks(__VA_ARGS__); }
-#define MPI_Group_compare(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Group_compare(__VA_ARGS__); }
-#define MPI_Group_union(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Group_union(__VA_ARGS__); }
-#define MPI_Group_intersection(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Group_intersection(__VA_ARGS__); }
-#define MPI_Group_difference(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Group_difference(__VA_ARGS__); }
-#define MPI_Group_incl(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Group_incl(__VA_ARGS__); }
-#define MPI_Group_excl(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Group_excl(__VA_ARGS__); }
-#define MPI_Group_range_incl(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Group_range_incl(__VA_ARGS__); }
-#define MPI_Group_range_excl(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Group_range_excl(__VA_ARGS__); }
-#define MPI_Group_f2c(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Group_f2c(__VA_ARGS__); }
-#define MPI_Group_c2f(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Group_c2f(__VA_ARGS__); }
-#define MPI_Comm_rank(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_rank(__VA_ARGS__); }
-#define MPI_Comm_size(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_size(__VA_ARGS__); }
-#define MPI_Comm_get_name(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_get_name(__VA_ARGS__); }
-#define MPI_Comm_set_name(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_set_name(__VA_ARGS__); }
-#define MPI_Comm_dup(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_dup(__VA_ARGS__); }
-#define MPI_Comm_dup_with_info(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_dup_with_info(__VA_ARGS__); }
-#define MPI_Comm_get_attr(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_get_attr(__VA_ARGS__); }
-#define MPI_Comm_set_attr(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_set_attr(__VA_ARGS__); }
-#define MPI_Comm_delete_attr(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_delete_attr(__VA_ARGS__); }
-#define MPI_Comm_create_keyval(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_create_keyval(__VA_ARGS__); }
-#define MPI_Comm_free_keyval(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_free_keyval(__VA_ARGS__); }
-#define MPI_Comm_group(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_group(__VA_ARGS__); }
-#define MPI_Comm_compare(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_compare(__VA_ARGS__); }
-#define MPI_Comm_create(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_create(__VA_ARGS__); }
-#define MPI_Comm_create_group(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_create_group(__VA_ARGS__); }
-#define MPI_Comm_free(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_free(__VA_ARGS__); }
-#define MPI_Comm_disconnect(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_disconnect(__VA_ARGS__); }
-#define MPI_Comm_split(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_split(__VA_ARGS__); }
-#define MPI_Comm_set_info(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_set_info(__VA_ARGS__); }
-#define MPI_Comm_get_info(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_get_info(__VA_ARGS__); }
-#define MPI_Comm_split_type(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_split_type(__VA_ARGS__); }
-#define MPI_Comm_f2c(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_f2c(__VA_ARGS__); }
-#define MPI_Comm_c2f(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_c2f(__VA_ARGS__); }
-#define MPI_Send_init(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Send_init(__VA_ARGS__); }
-#define MPI_Recv_init(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Recv_init(__VA_ARGS__); }
-#define MPI_Start(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Start(__VA_ARGS__); }
-#define MPI_Startall(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Startall(__VA_ARGS__); }
-#define MPI_Request_free(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Request_free(__VA_ARGS__); }
-#define MPI_Irecv(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Irecv(__VA_ARGS__); }
-#define MPI_Isend(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Isend(__VA_ARGS__); }
-#define MPI_Recv(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Recv(__VA_ARGS__); }
-#define MPI_Send(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Send(__VA_ARGS__); }
-#define MPI_Ssend(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Ssend(__VA_ARGS__); }
-#define MPI_Ssend_init(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Ssend_init(__VA_ARGS__); }
-#define MPI_Bsend(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Bsend(__VA_ARGS__); }
-#define MPI_Bsend_init(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Bsend_init(__VA_ARGS__); }
-#define MPI_Ibsend(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Ibsend(__VA_ARGS__); }
-#define MPI_Issend(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Issend(__VA_ARGS__); }
-#define MPI_Sendrecv(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Sendrecv(__VA_ARGS__); }
-#define MPI_Sendrecv_replace(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Sendrecv_replace(__VA_ARGS__); }
-#define MPI_Test(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Test(__VA_ARGS__); }
-#define MPI_Testany(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Testany(__VA_ARGS__); }
-#define MPI_Testall(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Testall(__VA_ARGS__); }
-#define MPI_Testsome(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Testsome(__VA_ARGS__); }
-#define MPI_Test_cancelled(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Test_cancelled(__VA_ARGS__); }
-#define MPI_Wait(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Wait(__VA_ARGS__); }
-#define MPI_Waitany(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Waitany(__VA_ARGS__); }
-#define MPI_Waitall(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Waitall(__VA_ARGS__); }
-#define MPI_Waitsome(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Waitsome(__VA_ARGS__); }
-#define MPI_Iprobe(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Iprobe(__VA_ARGS__); }
-#define MPI_Probe(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Probe(__VA_ARGS__); }
-#define MPI_Request_f2c(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Request_f2c(__VA_ARGS__); }
-#define MPI_Request_c2f(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Request_c2f(__VA_ARGS__); }
-#define MPI_Bcast(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Bcast(__VA_ARGS__); }
-#define MPI_Barrier(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Barrier(__VA_ARGS__); }
-#define MPI_Ibarrier(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Ibarrier(__VA_ARGS__); }
-#define MPI_Ibcast(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Ibcast(__VA_ARGS__); }
-#define MPI_Igather(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Igather(__VA_ARGS__); }
-#define MPI_Igatherv(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Igatherv(__VA_ARGS__); }
-#define MPI_Iallgather(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Iallgather(__VA_ARGS__); }
-#define MPI_Iallgatherv(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Iallgatherv(__VA_ARGS__); }
-#define MPI_Iscatter(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Iscatter(__VA_ARGS__); }
-#define MPI_Iscatterv(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Iscatterv(__VA_ARGS__); }
-#define MPI_Ireduce(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Ireduce(__VA_ARGS__); }
-#define MPI_Iallreduce(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Iallreduce(__VA_ARGS__); }
-#define MPI_Iscan(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Iscan(__VA_ARGS__); }
-#define MPI_Iexscan(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Iexscan(__VA_ARGS__); }
-#define MPI_Ireduce_scatter(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Ireduce_scatter(__VA_ARGS__); }
-#define MPI_Ireduce_scatter_block(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Ireduce_scatter_block(__VA_ARGS__); }
-#define MPI_Ialltoall(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Ialltoall(__VA_ARGS__); }
-#define MPI_Ialltoallv(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Ialltoallv(__VA_ARGS__); }
-#define MPI_Ialltoallw(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Ialltoallw(__VA_ARGS__); }
-#define MPI_Gather(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Gather(__VA_ARGS__); }
-#define MPI_Gatherv(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Gatherv(__VA_ARGS__); }
-#define MPI_Allgather(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Allgather(__VA_ARGS__); }
-#define MPI_Allgatherv(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Allgatherv(__VA_ARGS__); }
-#define MPI_Scatter(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Scatter(__VA_ARGS__); }
-#define MPI_Scatterv(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Scatterv(__VA_ARGS__); }
-#define MPI_Reduce(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Reduce(__VA_ARGS__); }
-#define MPI_Allreduce(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Allreduce(__VA_ARGS__); }
-#define MPI_Scan(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Scan(__VA_ARGS__); }
-#define MPI_Exscan(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Exscan(__VA_ARGS__); }
-#define MPI_Reduce_scatter(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Reduce_scatter(__VA_ARGS__); }
-#define MPI_Reduce_scatter_block(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Reduce_scatter_block(__VA_ARGS__); }
-#define MPI_Alltoall(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Alltoall(__VA_ARGS__); }
-#define MPI_Alltoallv(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Alltoallv(__VA_ARGS__); }
-#define MPI_Alltoallw(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Alltoallw(__VA_ARGS__); }
-#define MPI_Reduce_local(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Reduce_local(__VA_ARGS__); }
-#define MPI_Info_create(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Info_create(__VA_ARGS__); }
-#define MPI_Info_set(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Info_set(__VA_ARGS__); }
-#define MPI_Info_get(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Info_get(__VA_ARGS__); }
-#define MPI_Info_free(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Info_free(__VA_ARGS__); }
-#define MPI_Info_delete(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Info_delete(__VA_ARGS__); }
-#define MPI_Info_dup(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Info_dup(__VA_ARGS__); }
-#define MPI_Info_get_nkeys(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Info_get_nkeys(__VA_ARGS__); }
-#define MPI_Info_get_nthkey(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Info_get_nthkey(__VA_ARGS__); }
-#define MPI_Info_get_valuelen(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Info_get_valuelen(__VA_ARGS__); }
-#define MPI_Info_f2c(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Info_f2c(__VA_ARGS__); }
-#define MPI_Info_c2f(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Info_c2f(__VA_ARGS__); }
-#define MPI_Win_free(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_free(__VA_ARGS__); }
-#define MPI_Win_create(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_create(__VA_ARGS__); }
-#define MPI_Win_allocate(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_allocate(__VA_ARGS__); }
-#define MPI_Win_allocate_shared(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_allocate_shared(__VA_ARGS__); }
-#define MPI_Win_create_dynamic(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_create_dynamic(__VA_ARGS__); }
-#define MPI_Win_attach(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_attach(__VA_ARGS__); }
-#define MPI_Win_detach(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_detach(__VA_ARGS__); }
-#define MPI_Win_set_name(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_set_name(__VA_ARGS__); }
-#define MPI_Win_get_name(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_get_name(__VA_ARGS__); }
-#define MPI_Win_set_info(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_set_info(__VA_ARGS__); }
-#define MPI_Win_get_info(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_get_info(__VA_ARGS__); }
-#define MPI_Win_get_group(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_get_group(__VA_ARGS__); }
-#define MPI_Win_fence(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_fence(__VA_ARGS__); }
-#define MPI_Win_get_attr(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_get_attr(__VA_ARGS__); }
-#define MPI_Win_set_attr(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_set_attr(__VA_ARGS__); }
-#define MPI_Win_delete_attr(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_delete_attr(__VA_ARGS__); }
-#define MPI_Win_create_keyval(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_create_keyval(__VA_ARGS__); }
-#define MPI_Win_free_keyval(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_free_keyval(__VA_ARGS__); }
-#define MPI_Win_complete(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_complete(__VA_ARGS__); }
-#define MPI_Win_post(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_post(__VA_ARGS__); }
-#define MPI_Win_start(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_start(__VA_ARGS__); }
-#define MPI_Win_wait(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_wait(__VA_ARGS__); }
-#define MPI_Win_lock(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_lock(__VA_ARGS__); }
-#define MPI_Win_lock_all(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_lock_all(__VA_ARGS__); }
-#define MPI_Win_unlock(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_unlock(__VA_ARGS__); }
-#define MPI_Win_unlock_all(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_unlock_all(__VA_ARGS__); }
-#define MPI_Win_flush(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_flush(__VA_ARGS__); }
-#define MPI_Win_flush_local(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_flush_local(__VA_ARGS__); }
-#define MPI_Win_flush_all(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_flush_all(__VA_ARGS__); }
-#define MPI_Win_flush_local_all(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_flush_local_all(__VA_ARGS__); }
-#define MPI_Win_shared_query(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_shared_query(__VA_ARGS__); }
-#define MPI_Win_sync(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_sync(__VA_ARGS__); }
-#define MPI_Win_f2c(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_f2c(__VA_ARGS__); }
-#define MPI_Win_c2f(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_c2f(__VA_ARGS__); }
-#define MPI_Get(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Get(__VA_ARGS__); }
-#define MPI_Put(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Put(__VA_ARGS__); }
-#define MPI_Accumulate(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Accumulate(__VA_ARGS__); }
-#define MPI_Get_accumulate(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Get_accumulate(__VA_ARGS__); }
-#define MPI_Rget(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Rget(__VA_ARGS__); }
-#define MPI_Rput(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Rput(__VA_ARGS__); }
-#define MPI_Raccumulate(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Raccumulate(__VA_ARGS__); }
-#define MPI_Rget_accumulate(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Rget_accumulate(__VA_ARGS__); }
-#define MPI_Fetch_and_op(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Fetch_and_op(__VA_ARGS__); }
-#define MPI_Compare_and_swap(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Compare_and_swap(__VA_ARGS__); }
-#define MPI_Cart_coords(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Cart_coords(__VA_ARGS__); }
-#define MPI_Cart_create(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Cart_create(__VA_ARGS__); }
-#define MPI_Cart_get(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Cart_get(__VA_ARGS__); }
-#define MPI_Cart_rank(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Cart_rank(__VA_ARGS__); }
-#define MPI_Cart_shift(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Cart_shift(__VA_ARGS__); }
-#define MPI_Cart_sub(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Cart_sub(__VA_ARGS__); }
-#define MPI_Cartdim_get(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Cartdim_get(__VA_ARGS__); }
-#define MPI_Dims_create(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Dims_create(__VA_ARGS__); }
-#define MPI_Request_get_status(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Request_get_status(__VA_ARGS__); }
-#define MPI_Grequest_start(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Grequest_start(__VA_ARGS__); }
-#define MPI_Grequest_complete(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Grequest_complete(__VA_ARGS__); }
-#define MPI_Status_set_cancelled(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Status_set_cancelled(__VA_ARGS__); }
-#define MPI_Status_set_elements(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Status_set_elements(__VA_ARGS__); }
-#define MPI_Type_create_subarray(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_create_subarray(__VA_ARGS__); }
-#define MPI_File_open(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_open(__VA_ARGS__); }
-#define MPI_File_close(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_close(__VA_ARGS__); }
-#define MPI_File_delete(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_delete(__VA_ARGS__); }
-#define MPI_File_get_size(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_get_size(__VA_ARGS__); }
-#define MPI_File_get_group(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_get_group(__VA_ARGS__); }
-#define MPI_File_get_amode(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_get_amode(__VA_ARGS__); }
-#define MPI_File_set_info(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_set_info(__VA_ARGS__); }
-#define MPI_File_get_info(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_get_info(__VA_ARGS__); }
-#define MPI_File_read_at(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_read_at(__VA_ARGS__); }
-#define MPI_File_read_at_all(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_read_at_all(__VA_ARGS__); }
-#define MPI_File_write_at(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_write_at(__VA_ARGS__); }
-#define MPI_File_write_at_all(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_write_at_all(__VA_ARGS__); }
-#define MPI_File_read(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_read(__VA_ARGS__); }
-#define MPI_File_read_all(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_read_all(__VA_ARGS__); }
-#define MPI_File_write(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_write(__VA_ARGS__); }
-#define MPI_File_write_all(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_write_all(__VA_ARGS__); }
-#define MPI_File_seek(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_seek(__VA_ARGS__); }
-#define MPI_File_get_position(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_get_position(__VA_ARGS__); }
-#define MPI_File_read_shared(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_read_shared(__VA_ARGS__); }
-#define MPI_File_write_shared(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_write_shared(__VA_ARGS__); }
-#define MPI_File_read_ordered(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_read_ordered(__VA_ARGS__); }
-#define MPI_File_write_ordered(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_write_ordered(__VA_ARGS__); }
-#define MPI_File_seek_shared(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_seek_shared(__VA_ARGS__); }
-#define MPI_File_get_position_shared(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_get_position_shared(__VA_ARGS__); }
-#define MPI_File_sync(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_sync(__VA_ARGS__); }
-#define MPI_Errhandler_set(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Errhandler_set(__VA_ARGS__); }
-#define MPI_Errhandler_create(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Errhandler_create(__VA_ARGS__); }
-#define MPI_Errhandler_free(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Errhandler_free(__VA_ARGS__); }
-#define MPI_Errhandler_get(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Errhandler_get(__VA_ARGS__); }
-#define MPI_Comm_set_errhandler(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_set_errhandler(__VA_ARGS__); }
-#define MPI_Comm_get_errhandler(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_get_errhandler(__VA_ARGS__); }
-#define MPI_Comm_create_errhandler(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_create_errhandler(__VA_ARGS__); }
-#define MPI_Comm_call_errhandler(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_call_errhandler(__VA_ARGS__); }
-#define MPI_Win_set_errhandler(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_set_errhandler(__VA_ARGS__); }
-#define MPI_Win_get_errhandler(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_get_errhandler(__VA_ARGS__); }
-#define MPI_Win_create_errhandler(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_create_errhandler(__VA_ARGS__); }
-#define MPI_Win_call_errhandler(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_call_errhandler(__VA_ARGS__); }
-#define MPI_File_call_errhandler(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_call_errhandler(__VA_ARGS__); }
-#define MPI_File_create_errhandler(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_create_errhandler(__VA_ARGS__); }
-#define MPI_File_set_errhandler(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_set_errhandler(__VA_ARGS__); }
-#define MPI_File_get_errhandler(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_get_errhandler(__VA_ARGS__); }
-#define MPI_Errhandler_f2c(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Errhandler_f2c(__VA_ARGS__); }
-#define MPI_Errhandler_c2f(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Errhandler_c2f(__VA_ARGS__); }
-#define MPI_Cart_map(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Cart_map(__VA_ARGS__); }
-#define MPI_Graph_create(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Graph_create(__VA_ARGS__); }
-#define MPI_Graph_get(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Graph_get(__VA_ARGS__); }
-#define MPI_Graph_map(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Graph_map(__VA_ARGS__); }
-#define MPI_Graph_neighbors(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Graph_neighbors(__VA_ARGS__); }
-#define MPI_Graph_neighbors_count(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Graph_neighbors_count(__VA_ARGS__); }
-#define MPI_Graphdims_get(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Graphdims_get(__VA_ARGS__); }
-#define MPI_Topo_test(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Topo_test(__VA_ARGS__); }
-#define MPI_Add_error_class(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Add_error_class(__VA_ARGS__); }
-#define MPI_Add_error_code(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Add_error_code(__VA_ARGS__); }
-#define MPI_Add_error_string(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Add_error_string(__VA_ARGS__); }
-#define MPI_Cancel(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Cancel(__VA_ARGS__); }
-#define MPI_Comm_test_inter(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_test_inter(__VA_ARGS__); }
-#define MPI_Intercomm_create(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Intercomm_create(__VA_ARGS__); }
-#define MPI_Intercomm_merge(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Intercomm_merge(__VA_ARGS__); }
-#define MPI_Comm_remote_group(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_remote_group(__VA_ARGS__); }
-#define MPI_Comm_remote_size(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_remote_size(__VA_ARGS__); }
-#define MPI_Rsend(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Rsend(__VA_ARGS__); }
-#define MPI_Rsend_init(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Rsend_init(__VA_ARGS__); }
-#define MPI_Irsend(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Irsend(__VA_ARGS__); }
-#define MPI_Get_elements(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Get_elements(__VA_ARGS__); }
-#define MPI_Pcontrol(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Pcontrol(__VA_ARGS__); }
-#define MPI_Type_get_contents(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_get_contents(__VA_ARGS__); }
-#define MPI_Type_create_darray(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_create_darray(__VA_ARGS__); }
-#define MPI_Pack_external_size(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Pack_external_size(__VA_ARGS__); }
-#define MPI_Pack_external(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Pack_external(__VA_ARGS__); }
-#define MPI_Unpack_external(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Unpack_external(__VA_ARGS__); }
-#define MPI_Type_match_size(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_match_size(__VA_ARGS__); }
-#define MPI_Comm_connect(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_connect(__VA_ARGS__); }
-#define MPI_Unpublish_name(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Unpublish_name(__VA_ARGS__); }
-#define MPI_Publish_name(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Publish_name(__VA_ARGS__); }
-#define MPI_Lookup_name(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Lookup_name(__VA_ARGS__); }
-#define MPI_Comm_join(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_join(__VA_ARGS__); }
-#define MPI_Open_port(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Open_port(__VA_ARGS__); }
-#define MPI_Close_port(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Close_port(__VA_ARGS__); }
-#define MPI_Comm_accept(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_accept(__VA_ARGS__); }
-#define MPI_Comm_spawn(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_spawn(__VA_ARGS__); }
-#define MPI_Comm_spawn_multiple(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_spawn_multiple(__VA_ARGS__); }
-#define MPI_Comm_get_parent(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_get_parent(__VA_ARGS__); }
-#define MPI_Win_test(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_test(__VA_ARGS__); }
-#define MPI_File_c2f(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_c2f(__VA_ARGS__); }
-#define MPI_File_f2c(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_f2c(__VA_ARGS__); }
-#define MPI_Register_datarep(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Register_datarep(__VA_ARGS__); }
-#define MPI_File_set_size(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_set_size(__VA_ARGS__); }
-#define MPI_File_preallocate(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_preallocate(__VA_ARGS__); }
-#define MPI_File_set_view(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_set_view(__VA_ARGS__); }
-#define MPI_File_get_view(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_get_view(__VA_ARGS__); }
-#define MPI_File_iread_at(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_iread_at(__VA_ARGS__); }
-#define MPI_File_iwrite_at(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_iwrite_at(__VA_ARGS__); }
-#define MPI_File_iread_at_all(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_iread_at_all(__VA_ARGS__); }
-#define MPI_File_iwrite_at_all(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_iwrite_at_all(__VA_ARGS__); }
-#define MPI_File_iread(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_iread(__VA_ARGS__); }
-#define MPI_File_iwrite(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_iwrite(__VA_ARGS__); }
-#define MPI_File_iread_all(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_iread_all(__VA_ARGS__); }
-#define MPI_File_iwrite_all(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_iwrite_all(__VA_ARGS__); }
-#define MPI_File_get_byte_offset(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_get_byte_offset(__VA_ARGS__); }
-#define MPI_File_iread_shared(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_iread_shared(__VA_ARGS__); }
-#define MPI_File_iwrite_shared(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_iwrite_shared(__VA_ARGS__); }
-#define MPI_File_read_at_all_begin(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_read_at_all_begin(__VA_ARGS__); }
-#define MPI_File_read_at_all_end(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_read_at_all_end(__VA_ARGS__); }
-#define MPI_File_write_at_all_begin(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_write_at_all_begin(__VA_ARGS__); }
-#define MPI_File_write_at_all_end(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_write_at_all_end(__VA_ARGS__); }
-#define MPI_File_read_all_begin(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_read_all_begin(__VA_ARGS__); }
-#define MPI_File_read_all_end(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_read_all_end(__VA_ARGS__); }
-#define MPI_File_write_all_begin(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_write_all_begin(__VA_ARGS__); }
-#define MPI_File_write_all_end(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_write_all_end(__VA_ARGS__); }
-#define MPI_File_read_ordered_begin(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_read_ordered_begin(__VA_ARGS__); }
-#define MPI_File_read_ordered_end(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_read_ordered_end(__VA_ARGS__); }
-#define MPI_File_write_ordered_begin(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_write_ordered_begin(__VA_ARGS__); }
-#define MPI_File_write_ordered_end(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_write_ordered_end(__VA_ARGS__); }
-#define MPI_File_get_type_extent(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_get_type_extent(__VA_ARGS__); }
-#define MPI_File_set_atomicity(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_set_atomicity(__VA_ARGS__); }
-#define MPI_File_get_atomicity(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_get_atomicity(__VA_ARGS__); }
-#define MPI_Mrecv(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Mrecv(__VA_ARGS__); }
-#define MPI_Mprobe(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Mprobe(__VA_ARGS__); }
-#define MPI_Imrecv(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Imrecv(__VA_ARGS__); }
-#define MPI_Improbe(...) { smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Improbe(__VA_ARGS__); }
+#define MPI_Init(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Init(__VA_ARGS__))
+#define MPI_Finalize(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Finalize(__VA_ARGS__))
+#define MPI_Finalized(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Finalized(__VA_ARGS__))
+#define MPI_Init_thread(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Init_thread(__VA_ARGS__))
+#define MPI_Initialized(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Initialized(__VA_ARGS__))
+#define MPI_Query_thread(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Query_thread(__VA_ARGS__))
+#define MPI_Is_thread_main(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Is_thread_main(__VA_ARGS__))
+#define MPI_Get_version(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Get_version(__VA_ARGS__))
+#define MPI_Get_library_version(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Get_library_version(__VA_ARGS__))
+#define MPI_Get_processor_name(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Get_processor_name(__VA_ARGS__))
+#define MPI_Abort(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Abort(__VA_ARGS__))
+#define MPI_Alloc_mem(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Alloc_mem(__VA_ARGS__))
+#define MPI_Free_mem(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Free_mem(__VA_ARGS__))
+#define MPI_Wtime(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Wtime(__VA_ARGS__))
+#define MPI_Wtick(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Wtick(__VA_ARGS__))
+#define MPI_Buffer_attach(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Buffer_attach(__VA_ARGS__))
+#define MPI_Buffer_detach(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Buffer_detach(__VA_ARGS__))
+#define MPI_Address(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Address(__VA_ARGS__))
+#define MPI_Get_address(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Get_address(__VA_ARGS__))
+#define MPI_Error_class(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Error_class(__VA_ARGS__))
+#define MPI_Error_string(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Error_string(__VA_ARGS__))
+#define MPI_Attr_delete(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Attr_delete(__VA_ARGS__))
+#define MPI_Attr_get(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Attr_get(__VA_ARGS__))
+#define MPI_Attr_put(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Attr_put(__VA_ARGS__))
+#define MPI_Keyval_create(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Keyval_create(__VA_ARGS__))
+#define MPI_Keyval_free(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Keyval_free(__VA_ARGS__))
+#define MPI_Type_free(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_free(__VA_ARGS__))
+#define MPI_Type_size(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_size(__VA_ARGS__))
+#define MPI_Type_size_x(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_size_x(__VA_ARGS__))
+#define MPI_Type_get_extent(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_get_extent(__VA_ARGS__))
+#define MPI_Type_get_true_extent(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_get_true_extent(__VA_ARGS__))
+#define MPI_Type_extent(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_extent(__VA_ARGS__))
+#define MPI_Type_lb(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_lb(__VA_ARGS__))
+#define MPI_Type_ub(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_ub(__VA_ARGS__))
+#define MPI_Type_commit(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_commit(__VA_ARGS__))
+#define MPI_Type_hindexed(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_hindexed(__VA_ARGS__))
+#define MPI_Type_create_hindexed(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_create_hindexed(__VA_ARGS__))
+#define MPI_Type_create_hindexed_block(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_create_hindexed_block(__VA_ARGS__))
+#define MPI_Type_hvector(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_hvector(__VA_ARGS__))
+#define MPI_Type_create_hvector(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_create_hvector(__VA_ARGS__))
+#define MPI_Type_indexed(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_indexed(__VA_ARGS__))
+#define MPI_Type_create_indexed(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_create_indexed(__VA_ARGS__))
+#define MPI_Type_create_indexed_block(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_create_indexed_block(__VA_ARGS__))
+#define MPI_Type_struct(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_struct(__VA_ARGS__))
+#define MPI_Type_create_struct(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_create_struct(__VA_ARGS__))
+#define MPI_Type_vector(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_vector(__VA_ARGS__))
+#define MPI_Type_contiguous(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_contiguous(__VA_ARGS__))
+#define MPI_Type_create_resized(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_create_resized(__VA_ARGS__))
+#define MPI_Type_f2c(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_f2c(__VA_ARGS__))
+#define MPI_Type_c2f(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_c2f(__VA_ARGS__))
+#define MPI_Get_count(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Get_count(__VA_ARGS__))
+#define MPI_Type_get_attr(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_get_attr(__VA_ARGS__))
+#define MPI_Type_set_attr(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_set_attr(__VA_ARGS__))
+#define MPI_Type_delete_attr(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_delete_attr(__VA_ARGS__))
+#define MPI_Type_create_keyval(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_create_keyval(__VA_ARGS__))
+#define MPI_Type_free_keyval(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_free_keyval(__VA_ARGS__))
+#define MPI_Type_dup(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_dup(__VA_ARGS__))
+#define MPI_Type_set_name(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_set_name(__VA_ARGS__))
+#define MPI_Type_get_name(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_get_name(__VA_ARGS__))
+#define MPI_Pack(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Pack(__VA_ARGS__))
+#define MPI_Pack_size(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Pack_size(__VA_ARGS__))
+#define MPI_Unpack(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Unpack(__VA_ARGS__))
+#define MPI_Op_create(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Op_create(__VA_ARGS__))
+#define MPI_Op_free(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Op_free(__VA_ARGS__))
+#define MPI_Op_commutative(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Op_commutative(__VA_ARGS__))
+#define MPI_Op_f2c(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Op_f2c(__VA_ARGS__))
+#define MPI_Op_c2f(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Op_c2f(__VA_ARGS__))
+#define MPI_Group_free(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Group_free(__VA_ARGS__))
+#define MPI_Group_size(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Group_size(__VA_ARGS__))
+#define MPI_Group_rank(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Group_rank(__VA_ARGS__))
+#define MPI_Group_translate_ranks(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Group_translate_ranks(__VA_ARGS__))
+#define MPI_Group_compare(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Group_compare(__VA_ARGS__))
+#define MPI_Group_union(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Group_union(__VA_ARGS__))
+#define MPI_Group_intersection(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Group_intersection(__VA_ARGS__))
+#define MPI_Group_difference(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Group_difference(__VA_ARGS__))
+#define MPI_Group_incl(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Group_incl(__VA_ARGS__))
+#define MPI_Group_excl(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Group_excl(__VA_ARGS__))
+#define MPI_Group_range_incl(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Group_range_incl(__VA_ARGS__))
+#define MPI_Group_range_excl(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Group_range_excl(__VA_ARGS__))
+#define MPI_Group_f2c(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Group_f2c(__VA_ARGS__))
+#define MPI_Group_c2f(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Group_c2f(__VA_ARGS__))
+#define MPI_Comm_rank(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_rank(__VA_ARGS__))
+#define MPI_Comm_size(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_size(__VA_ARGS__))
+#define MPI_Comm_get_name(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_get_name(__VA_ARGS__))
+#define MPI_Comm_set_name(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_set_name(__VA_ARGS__))
+#define MPI_Comm_dup(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_dup(__VA_ARGS__))
+#define MPI_Comm_dup_with_info(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_dup_with_info(__VA_ARGS__))
+#define MPI_Comm_get_attr(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_get_attr(__VA_ARGS__))
+#define MPI_Comm_set_attr(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_set_attr(__VA_ARGS__))
+#define MPI_Comm_delete_attr(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_delete_attr(__VA_ARGS__))
+#define MPI_Comm_create_keyval(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_create_keyval(__VA_ARGS__))
+#define MPI_Comm_free_keyval(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_free_keyval(__VA_ARGS__))
+#define MPI_Comm_group(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_group(__VA_ARGS__))
+#define MPI_Comm_compare(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_compare(__VA_ARGS__))
+#define MPI_Comm_create(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_create(__VA_ARGS__))
+#define MPI_Comm_create_group(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_create_group(__VA_ARGS__))
+#define MPI_Comm_free(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_free(__VA_ARGS__))
+#define MPI_Comm_disconnect(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_disconnect(__VA_ARGS__))
+#define MPI_Comm_split(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_split(__VA_ARGS__))
+#define MPI_Comm_set_info(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_set_info(__VA_ARGS__))
+#define MPI_Comm_get_info(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_get_info(__VA_ARGS__))
+#define MPI_Comm_split_type(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_split_type(__VA_ARGS__))
+#define MPI_Comm_f2c(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_f2c(__VA_ARGS__))
+#define MPI_Comm_c2f(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_c2f(__VA_ARGS__))
+#define MPI_Send_init(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Send_init(__VA_ARGS__))
+#define MPI_Recv_init(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Recv_init(__VA_ARGS__))
+#define MPI_Start(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Start(__VA_ARGS__))
+#define MPI_Startall(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Startall(__VA_ARGS__))
+#define MPI_Request_free(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Request_free(__VA_ARGS__))
+#define MPI_Irecv(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Irecv(__VA_ARGS__))
+#define MPI_Isend(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Isend(__VA_ARGS__))
+#define MPI_Recv(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Recv(__VA_ARGS__))
+#define MPI_Send(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Send(__VA_ARGS__))
+#define MPI_Ssend(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Ssend(__VA_ARGS__))
+#define MPI_Ssend_init(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Ssend_init(__VA_ARGS__))
+#define MPI_Bsend(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Bsend(__VA_ARGS__))
+#define MPI_Bsend_init(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Bsend_init(__VA_ARGS__))
+#define MPI_Ibsend(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Ibsend(__VA_ARGS__))
+#define MPI_Issend(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Issend(__VA_ARGS__))
+#define MPI_Sendrecv(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Sendrecv(__VA_ARGS__))
+#define MPI_Sendrecv_replace(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Sendrecv_replace(__VA_ARGS__))
+#define MPI_Test(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Test(__VA_ARGS__))
+#define MPI_Testany(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Testany(__VA_ARGS__))
+#define MPI_Testall(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Testall(__VA_ARGS__))
+#define MPI_Testsome(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Testsome(__VA_ARGS__))
+#define MPI_Test_cancelled(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Test_cancelled(__VA_ARGS__))
+#define MPI_Wait(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Wait(__VA_ARGS__))
+#define MPI_Waitany(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Waitany(__VA_ARGS__))
+#define MPI_Waitall(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Waitall(__VA_ARGS__))
+#define MPI_Waitsome(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Waitsome(__VA_ARGS__))
+#define MPI_Iprobe(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Iprobe(__VA_ARGS__))
+#define MPI_Probe(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Probe(__VA_ARGS__))
+#define MPI_Request_f2c(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Request_f2c(__VA_ARGS__))
+#define MPI_Request_c2f(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Request_c2f(__VA_ARGS__))
+#define MPI_Bcast(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Bcast(__VA_ARGS__))
+#define MPI_Barrier(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Barrier(__VA_ARGS__))
+#define MPI_Ibarrier(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Ibarrier(__VA_ARGS__))
+#define MPI_Ibcast(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Ibcast(__VA_ARGS__))
+#define MPI_Igather(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Igather(__VA_ARGS__))
+#define MPI_Igatherv(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Igatherv(__VA_ARGS__))
+#define MPI_Iallgather(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Iallgather(__VA_ARGS__))
+#define MPI_Iallgatherv(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Iallgatherv(__VA_ARGS__))
+#define MPI_Iscatter(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Iscatter(__VA_ARGS__))
+#define MPI_Iscatterv(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Iscatterv(__VA_ARGS__))
+#define MPI_Ireduce(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Ireduce(__VA_ARGS__))
+#define MPI_Iallreduce(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Iallreduce(__VA_ARGS__))
+#define MPI_Iscan(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Iscan(__VA_ARGS__))
+#define MPI_Iexscan(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Iexscan(__VA_ARGS__))
+#define MPI_Ireduce_scatter(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Ireduce_scatter(__VA_ARGS__))
+#define MPI_Ireduce_scatter_block(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Ireduce_scatter_block(__VA_ARGS__))
+#define MPI_Ialltoall(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Ialltoall(__VA_ARGS__))
+#define MPI_Ialltoallv(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Ialltoallv(__VA_ARGS__))
+#define MPI_Ialltoallw(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Ialltoallw(__VA_ARGS__))
+#define MPI_Gather(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Gather(__VA_ARGS__))
+#define MPI_Gatherv(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Gatherv(__VA_ARGS__))
+#define MPI_Allgather(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Allgather(__VA_ARGS__))
+#define MPI_Allgatherv(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Allgatherv(__VA_ARGS__))
+#define MPI_Scatter(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Scatter(__VA_ARGS__))
+#define MPI_Scatterv(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Scatterv(__VA_ARGS__))
+#define MPI_Reduce(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Reduce(__VA_ARGS__))
+#define MPI_Allreduce(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Allreduce(__VA_ARGS__))
+#define MPI_Scan(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Scan(__VA_ARGS__))
+#define MPI_Exscan(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Exscan(__VA_ARGS__))
+#define MPI_Reduce_scatter(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Reduce_scatter(__VA_ARGS__))
+#define MPI_Reduce_scatter_block(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Reduce_scatter_block(__VA_ARGS__))
+#define MPI_Alltoall(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Alltoall(__VA_ARGS__))
+#define MPI_Alltoallv(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Alltoallv(__VA_ARGS__))
+#define MPI_Alltoallw(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Alltoallw(__VA_ARGS__))
+#define MPI_Reduce_local(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Reduce_local(__VA_ARGS__))
+#define MPI_Info_create(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Info_create(__VA_ARGS__))
+#define MPI_Info_set(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Info_set(__VA_ARGS__))
+#define MPI_Info_get(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Info_get(__VA_ARGS__))
+#define MPI_Info_free(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Info_free(__VA_ARGS__))
+#define MPI_Info_delete(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Info_delete(__VA_ARGS__))
+#define MPI_Info_dup(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Info_dup(__VA_ARGS__))
+#define MPI_Info_get_nkeys(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Info_get_nkeys(__VA_ARGS__))
+#define MPI_Info_get_nthkey(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Info_get_nthkey(__VA_ARGS__))
+#define MPI_Info_get_valuelen(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Info_get_valuelen(__VA_ARGS__))
+#define MPI_Info_f2c(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Info_f2c(__VA_ARGS__))
+#define MPI_Info_c2f(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Info_c2f(__VA_ARGS__))
+#define MPI_Win_free(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_free(__VA_ARGS__))
+#define MPI_Win_create(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_create(__VA_ARGS__))
+#define MPI_Win_allocate(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_allocate(__VA_ARGS__))
+#define MPI_Win_allocate_shared(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_allocate_shared(__VA_ARGS__))
+#define MPI_Win_create_dynamic(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_create_dynamic(__VA_ARGS__))
+#define MPI_Win_attach(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_attach(__VA_ARGS__))
+#define MPI_Win_detach(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_detach(__VA_ARGS__))
+#define MPI_Win_set_name(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_set_name(__VA_ARGS__))
+#define MPI_Win_get_name(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_get_name(__VA_ARGS__))
+#define MPI_Win_set_info(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_set_info(__VA_ARGS__))
+#define MPI_Win_get_info(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_get_info(__VA_ARGS__))
+#define MPI_Win_get_group(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_get_group(__VA_ARGS__))
+#define MPI_Win_fence(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_fence(__VA_ARGS__))
+#define MPI_Win_get_attr(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_get_attr(__VA_ARGS__))
+#define MPI_Win_set_attr(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_set_attr(__VA_ARGS__))
+#define MPI_Win_delete_attr(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_delete_attr(__VA_ARGS__))
+#define MPI_Win_create_keyval(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_create_keyval(__VA_ARGS__))
+#define MPI_Win_free_keyval(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_free_keyval(__VA_ARGS__))
+#define MPI_Win_complete(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_complete(__VA_ARGS__))
+#define MPI_Win_post(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_post(__VA_ARGS__))
+#define MPI_Win_start(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_start(__VA_ARGS__))
+#define MPI_Win_wait(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_wait(__VA_ARGS__))
+#define MPI_Win_lock(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_lock(__VA_ARGS__))
+#define MPI_Win_lock_all(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_lock_all(__VA_ARGS__))
+#define MPI_Win_unlock(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_unlock(__VA_ARGS__))
+#define MPI_Win_unlock_all(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_unlock_all(__VA_ARGS__))
+#define MPI_Win_flush(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_flush(__VA_ARGS__))
+#define MPI_Win_flush_local(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_flush_local(__VA_ARGS__))
+#define MPI_Win_flush_all(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_flush_all(__VA_ARGS__))
+#define MPI_Win_flush_local_all(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_flush_local_all(__VA_ARGS__))
+#define MPI_Win_shared_query(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_shared_query(__VA_ARGS__))
+#define MPI_Win_sync(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_sync(__VA_ARGS__))
+#define MPI_Win_f2c(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_f2c(__VA_ARGS__))
+#define MPI_Win_c2f(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_c2f(__VA_ARGS__))
+#define MPI_Get(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Get(__VA_ARGS__))
+#define MPI_Put(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Put(__VA_ARGS__))
+#define MPI_Accumulate(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Accumulate(__VA_ARGS__))
+#define MPI_Get_accumulate(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Get_accumulate(__VA_ARGS__))
+#define MPI_Rget(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Rget(__VA_ARGS__))
+#define MPI_Rput(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Rput(__VA_ARGS__))
+#define MPI_Raccumulate(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Raccumulate(__VA_ARGS__))
+#define MPI_Rget_accumulate(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Rget_accumulate(__VA_ARGS__))
+#define MPI_Fetch_and_op(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Fetch_and_op(__VA_ARGS__))
+#define MPI_Compare_and_swap(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Compare_and_swap(__VA_ARGS__))
+#define MPI_Cart_coords(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Cart_coords(__VA_ARGS__))
+#define MPI_Cart_create(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Cart_create(__VA_ARGS__))
+#define MPI_Cart_get(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Cart_get(__VA_ARGS__))
+#define MPI_Cart_rank(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Cart_rank(__VA_ARGS__))
+#define MPI_Cart_shift(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Cart_shift(__VA_ARGS__))
+#define MPI_Cart_sub(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Cart_sub(__VA_ARGS__))
+#define MPI_Cartdim_get(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Cartdim_get(__VA_ARGS__))
+#define MPI_Dims_create(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Dims_create(__VA_ARGS__))
+#define MPI_Request_get_status(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Request_get_status(__VA_ARGS__))
+#define MPI_Grequest_start(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Grequest_start(__VA_ARGS__))
+#define MPI_Grequest_complete(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Grequest_complete(__VA_ARGS__))
+#define MPI_Status_set_cancelled(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Status_set_cancelled(__VA_ARGS__))
+#define MPI_Status_set_elements(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Status_set_elements(__VA_ARGS__))
+#define MPI_Type_create_subarray(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_create_subarray(__VA_ARGS__))
+#define MPI_File_open(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_open(__VA_ARGS__))
+#define MPI_File_close(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_close(__VA_ARGS__))
+#define MPI_File_delete(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_delete(__VA_ARGS__))
+#define MPI_File_get_size(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_get_size(__VA_ARGS__))
+#define MPI_File_get_group(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_get_group(__VA_ARGS__))
+#define MPI_File_get_amode(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_get_amode(__VA_ARGS__))
+#define MPI_File_set_info(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_set_info(__VA_ARGS__))
+#define MPI_File_get_info(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_get_info(__VA_ARGS__))
+#define MPI_File_read_at(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_read_at(__VA_ARGS__))
+#define MPI_File_read_at_all(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_read_at_all(__VA_ARGS__))
+#define MPI_File_write_at(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_write_at(__VA_ARGS__))
+#define MPI_File_write_at_all(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_write_at_all(__VA_ARGS__))
+#define MPI_File_read(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_read(__VA_ARGS__))
+#define MPI_File_read_all(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_read_all(__VA_ARGS__))
+#define MPI_File_write(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_write(__VA_ARGS__))
+#define MPI_File_write_all(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_write_all(__VA_ARGS__))
+#define MPI_File_seek(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_seek(__VA_ARGS__))
+#define MPI_File_get_position(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_get_position(__VA_ARGS__))
+#define MPI_File_read_shared(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_read_shared(__VA_ARGS__))
+#define MPI_File_write_shared(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_write_shared(__VA_ARGS__))
+#define MPI_File_read_ordered(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_read_ordered(__VA_ARGS__))
+#define MPI_File_write_ordered(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_write_ordered(__VA_ARGS__))
+#define MPI_File_seek_shared(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_seek_shared(__VA_ARGS__))
+#define MPI_File_get_position_shared(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_get_position_shared(__VA_ARGS__))
+#define MPI_File_sync(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_sync(__VA_ARGS__))
+#define MPI_Errhandler_set(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Errhandler_set(__VA_ARGS__))
+#define MPI_Errhandler_create(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Errhandler_create(__VA_ARGS__))
+#define MPI_Errhandler_free(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Errhandler_free(__VA_ARGS__))
+#define MPI_Errhandler_get(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Errhandler_get(__VA_ARGS__))
+#define MPI_Comm_set_errhandler(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_set_errhandler(__VA_ARGS__))
+#define MPI_Comm_get_errhandler(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_get_errhandler(__VA_ARGS__))
+#define MPI_Comm_create_errhandler(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_create_errhandler(__VA_ARGS__))
+#define MPI_Comm_call_errhandler(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_call_errhandler(__VA_ARGS__))
+#define MPI_Win_set_errhandler(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_set_errhandler(__VA_ARGS__))
+#define MPI_Win_get_errhandler(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_get_errhandler(__VA_ARGS__))
+#define MPI_Win_create_errhandler(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_create_errhandler(__VA_ARGS__))
+#define MPI_Win_call_errhandler(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_call_errhandler(__VA_ARGS__))
+#define MPI_File_call_errhandler(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_call_errhandler(__VA_ARGS__))
+#define MPI_File_create_errhandler(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_create_errhandler(__VA_ARGS__))
+#define MPI_File_set_errhandler(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_set_errhandler(__VA_ARGS__))
+#define MPI_File_get_errhandler(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_get_errhandler(__VA_ARGS__))
+#define MPI_Errhandler_f2c(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Errhandler_f2c(__VA_ARGS__))
+#define MPI_Errhandler_c2f(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Errhandler_c2f(__VA_ARGS__))
+#define MPI_Cart_map(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Cart_map(__VA_ARGS__))
+#define MPI_Graph_create(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Graph_create(__VA_ARGS__))
+#define MPI_Graph_get(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Graph_get(__VA_ARGS__))
+#define MPI_Graph_map(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Graph_map(__VA_ARGS__))
+#define MPI_Graph_neighbors(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Graph_neighbors(__VA_ARGS__))
+#define MPI_Graph_neighbors_count(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Graph_neighbors_count(__VA_ARGS__))
+#define MPI_Graphdims_get(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Graphdims_get(__VA_ARGS__))
+#define MPI_Topo_test(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Topo_test(__VA_ARGS__))
+#define MPI_Add_error_class(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Add_error_class(__VA_ARGS__))
+#define MPI_Add_error_code(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Add_error_code(__VA_ARGS__))
+#define MPI_Add_error_string(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Add_error_string(__VA_ARGS__))
+#define MPI_Cancel(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Cancel(__VA_ARGS__))
+#define MPI_Comm_test_inter(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_test_inter(__VA_ARGS__))
+#define MPI_Intercomm_create(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Intercomm_create(__VA_ARGS__))
+#define MPI_Intercomm_merge(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Intercomm_merge(__VA_ARGS__))
+#define MPI_Comm_remote_group(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_remote_group(__VA_ARGS__))
+#define MPI_Comm_remote_size(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_remote_size(__VA_ARGS__))
+#define MPI_Rsend(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Rsend(__VA_ARGS__))
+#define MPI_Rsend_init(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Rsend_init(__VA_ARGS__))
+#define MPI_Irsend(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Irsend(__VA_ARGS__))
+#define MPI_Get_elements(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Get_elements(__VA_ARGS__))
+#define MPI_Pcontrol(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Pcontrol(__VA_ARGS__))
+#define MPI_Type_get_contents(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_get_contents(__VA_ARGS__))
+#define MPI_Type_create_darray(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_create_darray(__VA_ARGS__))
+#define MPI_Pack_external_size(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Pack_external_size(__VA_ARGS__))
+#define MPI_Pack_external(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Pack_external(__VA_ARGS__))
+#define MPI_Unpack_external(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Unpack_external(__VA_ARGS__))
+#define MPI_Type_match_size(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Type_match_size(__VA_ARGS__))
+#define MPI_Comm_connect(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_connect(__VA_ARGS__))
+#define MPI_Unpublish_name(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Unpublish_name(__VA_ARGS__))
+#define MPI_Publish_name(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Publish_name(__VA_ARGS__))
+#define MPI_Lookup_name(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Lookup_name(__VA_ARGS__))
+#define MPI_Comm_join(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_join(__VA_ARGS__))
+#define MPI_Open_port(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Open_port(__VA_ARGS__))
+#define MPI_Close_port(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Close_port(__VA_ARGS__))
+#define MPI_Comm_accept(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_accept(__VA_ARGS__))
+#define MPI_Comm_spawn(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_spawn(__VA_ARGS__))
+#define MPI_Comm_spawn_multiple(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_spawn_multiple(__VA_ARGS__))
+#define MPI_Comm_get_parent(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Comm_get_parent(__VA_ARGS__))
+#define MPI_Win_test(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Win_test(__VA_ARGS__))
+#define MPI_File_c2f(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_c2f(__VA_ARGS__))
+#define MPI_File_f2c(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_f2c(__VA_ARGS__))
+#define MPI_Register_datarep(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Register_datarep(__VA_ARGS__))
+#define MPI_File_set_size(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_set_size(__VA_ARGS__))
+#define MPI_File_preallocate(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_preallocate(__VA_ARGS__))
+#define MPI_File_set_view(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_set_view(__VA_ARGS__))
+#define MPI_File_get_view(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_get_view(__VA_ARGS__))
+#define MPI_File_iread_at(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_iread_at(__VA_ARGS__))
+#define MPI_File_iwrite_at(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_iwrite_at(__VA_ARGS__))
+#define MPI_File_iread_at_all(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_iread_at_all(__VA_ARGS__))
+#define MPI_File_iwrite_at_all(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_iwrite_at_all(__VA_ARGS__))
+#define MPI_File_iread(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_iread(__VA_ARGS__))
+#define MPI_File_iwrite(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_iwrite(__VA_ARGS__))
+#define MPI_File_iread_all(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_iread_all(__VA_ARGS__))
+#define MPI_File_iwrite_all(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_iwrite_all(__VA_ARGS__))
+#define MPI_File_get_byte_offset(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_get_byte_offset(__VA_ARGS__))
+#define MPI_File_iread_shared(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_iread_shared(__VA_ARGS__))
+#define MPI_File_iwrite_shared(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_iwrite_shared(__VA_ARGS__))
+#define MPI_File_read_at_all_begin(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_read_at_all_begin(__VA_ARGS__))
+#define MPI_File_read_at_all_end(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_read_at_all_end(__VA_ARGS__))
+#define MPI_File_write_at_all_begin(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_write_at_all_begin(__VA_ARGS__))
+#define MPI_File_write_at_all_end(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_write_at_all_end(__VA_ARGS__))
+#define MPI_File_read_all_begin(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_read_all_begin(__VA_ARGS__))
+#define MPI_File_read_all_end(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_read_all_end(__VA_ARGS__))
+#define MPI_File_write_all_begin(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_write_all_begin(__VA_ARGS__))
+#define MPI_File_write_all_end(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_write_all_end(__VA_ARGS__))
+#define MPI_File_read_ordered_begin(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_read_ordered_begin(__VA_ARGS__))
+#define MPI_File_read_ordered_end(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_read_ordered_end(__VA_ARGS__))
+#define MPI_File_write_ordered_begin(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_write_ordered_begin(__VA_ARGS__))
+#define MPI_File_write_ordered_end(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_write_ordered_end(__VA_ARGS__))
+#define MPI_File_get_type_extent(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_get_type_extent(__VA_ARGS__))
+#define MPI_File_set_atomicity(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_set_atomicity(__VA_ARGS__))
+#define MPI_File_get_atomicity(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_File_get_atomicity(__VA_ARGS__))
+#define MPI_Mrecv(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Mrecv(__VA_ARGS__))
+#define MPI_Mprobe(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Mprobe(__VA_ARGS__))
+#define MPI_Imrecv(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Imrecv(__VA_ARGS__))
+#define MPI_Improbe(...) (smpi_trace_set_call_location(__FILE__, __LINE__), MPI_Improbe(__VA_ARGS__))
-/* 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. */
#define sleep(x) smpi_sleep(x)
#define usleep(x) smpi_usleep(x)
#else
-#define sleep(x) { smpi_trace_set_call_location(__FILE__,__LINE__); smpi_sleep(x); }
-#define usleep(x) { smpi_trace_set_call_location(__FILE__,__LINE__); smpi_usleep(x); }
+#define sleep(x) (smpi_trace_set_call_location(__FILE__, __LINE__), smpi_sleep(x))
+#define usleep(x) (smpi_trace_set_call_location(__FILE__, __LINE__), smpi_usleep(x))
#endif
#define gettimeofday(x, y) smpi_gettimeofday((x), 0)
#ifndef TRACE_CALL_LOCATION /* Defined by smpicc on the command line */
#define nanosleep(x, y) smpi_nanosleep((x), (y))
#else
-#define nanosleep(x) { smpi_trace_set_call_location(__FILE__,__LINE__); smpi_nanosleep(x); }
+#define nanosleep(x) (smpi_trace_set_call_location(__FILE__, __LINE__), smpi_nanosleep(x))
#endif
#define clock_gettime(x, y) smpi_clock_gettime((x), (y))
#endif
#define getopt(x, y, z) smpi_getopt((x), (y), (z))
#define getopt_long(x, y, z, a, b) smpi_getopt_long((x), (y), (z), (a), (b))
#define getopt_long_only(x, y, z, a, b) smpi_getopt_long_only((x), (y), (z), (a), (b))
-#ifndef SAMPI_OVERRIDEN_MALLOC
+#ifndef SMPI_NO_OVERRIDE_MALLOC
#define malloc(x) smpi_shared_malloc_intercept((x), __FILE__, __LINE__)
#define calloc(x, y) smpi_shared_calloc_intercept((x), (y), __FILE__, __LINE__)
#define free(x) smpi_shared_free(x)
-/* 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. */
-#ifndef SRC_SURF_PROPERTYHOLDER_HPP_
-#define SRC_SURF_PROPERTYHOLDER_HPP_
+#ifndef XBT_PROPERTYHOLDER_HPP
+#define XBT_PROPERTYHOLDER_HPP
#include <memory>
#include <string>
#include <unordered_map>
namespace simgrid {
-namespace surf {
+namespace xbt {
/** @brief a PropertyHolder can be given a set of textual properties
*
* Common PropertyHolders are elements of the platform file, such as Host, Link or Storage.
*/
class PropertyHolder { // DO NOT DERIVE THIS CLASS, or the diamond inheritance mayhem will get you
+ std::unique_ptr<std::unordered_map<std::string, std::string>> properties_ = nullptr;
public:
- PropertyHolder() = default;
+ PropertyHolder() = default;
PropertyHolder(const PropertyHolder&) = delete;
PropertyHolder& operator=(const PropertyHolder&) = delete;
const std::unordered_map<std::string, std::string>* get_properties();
template <class Assoc> void set_properties(const Assoc& properties);
-
-private:
- std::unique_ptr<std::unordered_map<std::string, std::string>> properties_ = nullptr;
};
-} /* namespace surf */
-} /* namespace simgrid */
+} // namespace xbt
+} // namespace simgrid
-#endif /* SRC_SURF_PROPERTYHOLDER_HPP_ */
+#endif
/* 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): */
XBT_ATTRIB_DEPRECATED(mesg " (this compatibility wrapper will be dropped in v3.28)")
#define XBT_ATTRIB_DEPRECATED_v329(mesg) \
XBT_ATTRIB_DEPRECATED(mesg " (this compatibility wrapper will be dropped in v3.29)")
+#define XBT_ATTRIB_DEPRECATED_v330(mesg) \
+ XBT_ATTRIB_DEPRECATED(mesg " (this compatibility wrapper will be dropped in v3.30)")
#if !defined(__APPLE__)
# define XBT_ATTRIB_CONSTRUCTOR(prio) __attribute__((__constructor__(prio)))
/* 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. */
typedef int (*int_f_pvoid_pvoid_t) (void *, void *);
typedef int (*int_f_cpvoid_cpvoid_t) (const void *, const void *);
-typedef int (*xbt_main_func_t) (int argc, char *argv[]);
+typedef void (*xbt_main_func_t)(int argc, char* argv[]);
SG_END_DECL
#endif /* XBT_FUNCTION_TYPE_H */
-/* 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
throw std::future_error(std::future_errc::no_state);
}
}
+
private:
boost::variant<boost::blank, T, std::exception_ptr> value_;
};
-/* 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_LOG_NEW_SUBCATEGORY_helper(catName, parent, desc) \
SG_BEGIN_DECL \
extern void _XBT_LOGV_CTOR(catName)(void) XBT_ATTRIB_CONSTRUCTOR(600); \
+ SG_END_DECL \
void _XBT_LOGV_CTOR(catName)(void) \
{ \
XBT_LOG_EXTERNAL_CATEGORY(catName); \
_xbt_log_cat_init(&_XBT_LOGV(catName), xbt_log_priority_uninitialized); \
} \
} \
- SG_END_DECL \
XBT_EXPORT_NO_IMPORT s_xbt_log_category_t _XBT_LOGV(catName) = { \
&_XBT_LOGV(parent), \
NULL /* firstChild */, \
#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);
setup(
name='simgrid',
- version='3.24.1',
+ version='3.25.1',
author='Da SimGrid Team',
author_email='simgrid-devel@lists.gforge.inria.fr',
description='Toolkit for scalable simulation of distributed applications',
"sudo apt install cmake libboost-dev pybind11-dev g++ gcc"),
ext_modules=[CMakeExtension('simgrid')],
cmdclass=dict(build_ext=CMakeBuild),
- install_requires=['pybind11>=2.3'],
- setup_requires=['pybind11>=2.3'],
+ install_requires=['pybind11>=2.4'],
+ setup_requires=['pybind11>=2.4'],
zip_safe=False,
classifiers=[
"Development Status :: 4 - Beta",
sonar.organization=simgrid
sonar.projectKey=simgrid_simgrid
sonar.projectName=SimGrid
-sonar.projectVersion=3.24.1
+sonar.projectVersion=3.25.1
sonar.links.homepage=https://simgrid.org
sonar.links.issue=https://framagit.org/simgrid/simgrid/issues
# 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
+# But we don't have no better mechanism, and our Java apps are not rocket science
+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
+# 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=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
+# But this file is used before SimGrid is initialized
+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)
# - Collectives that we borrowed elsewhere (mpich, openMPI and other implems)
# - the NAS, that are included in our examples
# - The Catch2 library, that is included in our unit tests
-sonar.exclusions=src/include/catch.hpp,src/*_unit.c*,teshsuite/smpi/mpich3-test/**,teshsuite/smpi/isp/**,**/*_dtd.c,**/*_dtd.h,**/*yy.c,src/xbt/automaton/parserPromela.tab.*,src/smpi/colls/**/*,examples/smpi/NAS/*,examples/smpi/gemm/gemm.c
+# - MSG along with its examples and teshsuite, and the simdag examples
+sonar.exclusions=src/include/catch.hpp,src/*_unit.c*,teshsuite/smpi/mpich3-test/**,teshsuite/smpi/isp/**,**/*_dtd.c,**/*_dtd.h,**/*yy.c,src/xbt/automaton/parserPromela.tab.*,src/smpi/colls/**/*,examples/smpi/NAS/*,examples/smpi/gemm/gemm.c,src/msg/**,include/msg/**,examples/deprecated/**,teshsuite/msg/**
# Exclude our examples from the duplication detection.
# Examples are expected to be somehow repetitive
# - XML files
# - Python files used to generate either simcalls or deployment files
# - Any java source code (it's deprecated now)
-sonar.coverage.exclusions=teshsuite/smpi/isp/**,teshsuite/smpi/mpich3-test/**,**/*.xml,src/simix/simcalls.py,**/generate.py,**/*.java,src/bindings/java/**
+# - MSG (deprecated too)
+sonar.coverage.exclusions=teshsuite/smpi/isp/**,teshsuite/smpi/mpich3-test/**,**/*.xml,src/simix/simcalls.py,**/generate.py,**/*.java,src/bindings/java/**,src/msg/**,include/msg/**,examples/deprecated/**,teshsuite/msg/**
# Encoding of the source files
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
* Unsortable functions *
***************************************************************************************/
-JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Msg_getClock(JNIEnv * env, jclass cls)
+JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Msg_getClock(JNIEnv*, jclass)
{
return (jdouble) MSG_get_clock();
}
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_init(JNIEnv* env, jclass, jobjectArray jargs)
{
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);
JAVA_HOST_LEVEL = simgrid::s4u::Host::extension_create(nullptr);
}
-JNIEXPORT void JNICALL JNICALL Java_org_simgrid_msg_Msg_run(JNIEnv * env, jclass cls)
+JNIEXPORT void JNICALL JNICALL Java_org_simgrid_msg_Msg_run(JNIEnv* env, jclass)
{
/* Run everything */
XBT_DEBUG("Ready to run MSG_MAIN");
/* 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);
env->CallStaticVoidMethod(clsProcess, idDebug);
}
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_createEnvironment(JNIEnv * env, jclass cls, jstring jplatformFile)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_createEnvironment(JNIEnv* env, jclass, jstring jplatformFile)
{
const char *platformFile = env->GetStringUTFChars(jplatformFile, 0);
env->ReleaseStringUTFChars(jplatformFile, platformFile);
}
-JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Msg_environmentGetRoutingRoot(JNIEnv * env, jclass cls)
+JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Msg_environmentGetRoutingRoot(JNIEnv* env, jclass)
{
msg_netzone_t as = MSG_zone_get_root();
jobject jas = jnetzone_new_instance(env);
return (jobject) jas;
}
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_debug(JNIEnv * env, jclass cls, jstring js)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_debug(JNIEnv* env, jclass, jstring js)
{
const char *s = env->GetStringUTFChars(js, 0);
XBT_DEBUG("%s", s);
env->ReleaseStringUTFChars(js, s);
}
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_verb(JNIEnv * env, jclass cls, jstring js)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_verb(JNIEnv* env, jclass, jstring js)
{
const char *s = env->GetStringUTFChars(js, 0);
XBT_VERB("%s", s);
env->ReleaseStringUTFChars(js, s);
}
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_info(JNIEnv * env, jclass cls, jstring js)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_info(JNIEnv* env, jclass, jstring js)
{
const char *s = env->GetStringUTFChars(js, 0);
XBT_INFO("%s", s);
env->ReleaseStringUTFChars(js, s);
}
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_warn(JNIEnv * env, jclass cls, jstring js)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_warn(JNIEnv* env, jclass, jstring js)
{
const char *s = env->GetStringUTFChars(js, 0);
XBT_WARN("%s", s);
env->ReleaseStringUTFChars(js, s);
}
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_error(JNIEnv * env, jclass cls, jstring js)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_error(JNIEnv* env, jclass, jstring js)
{
const char *s = env->GetStringUTFChars(js, 0);
XBT_ERROR("%s", s);
env->ReleaseStringUTFChars(js, s);
}
-JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_critical(JNIEnv * env, jclass cls, jstring js)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_critical(JNIEnv* env, jclass, jstring js)
{
const char *s = env->GetStringUTFChars(js, 0);
XBT_CRITICAL("%s", s);
env->ReleaseStringUTFChars(js, s);
}
-static int java_main(int argc, char *argv[]);
+static void java_main(int argc, char* argv[]);
-JNIEXPORT void JNICALL
-Java_org_simgrid_msg_Msg_deployApplication(JNIEnv * env, jclass cls, jstring jdeploymentFile)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_deployApplication(JNIEnv* env, jclass, jstring jdeploymentFile)
{
const char *deploymentFile = env->GetStringUTFChars(jdeploymentFile, 0);
}
/** Create a Java org.simgrid.msg.Process with the arguments and run it */
-static int java_main(int argc, char *argv[])
+static void java_main(int argc, char* argv[])
{
JNIEnv *env = get_current_thread_env();
simgrid::kernel::context::JavaContext* context =
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 */
jprocess_bind(jprocess, process, env);
run_jprocess(env, context->jprocess_);
- return 0;
}
namespace simgrid {
/* 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);
}
jobject jprocess = jprocess_ref(jprocess_arg, env);
/* Actually build the MSG process */
- jstring jname = (jstring)env->GetObjectField(jprocess, jprocess_field_Process_name);
- const char* name = env->GetStringUTFChars(jname, 0);
- simgrid::simix::ActorCode function = [jprocess]() { simgrid::kernel::context::java_main_jprocess(jprocess); };
- smx_actor_t self = SIMIX_process_self();
- sg_host_t host = jhost_get_native(env, jhost);
- smx_actor_t actor = simgrid::kernel::actor::simcall([name, function, host, self] {
- return simgrid::kernel::actor::ActorImpl::create(std::move(name), std::move(function), nullptr, host, nullptr, self)
+ jstring jname = (jstring)env->GetObjectField(jprocess, jprocess_field_Process_name);
+ const char* name = env->GetStringUTFChars(jname, 0);
+ auto actor_code = [jprocess]() { simgrid::kernel::context::java_main_jprocess(jprocess); };
+ smx_actor_t self = SIMIX_process_self();
+ sg_host_t host = jhost_get_native(env, jhost);
+ smx_actor_t actor = simgrid::kernel::actor::simcall([name, actor_code, host, self] {
+ return simgrid::kernel::actor::ActorImpl::create(std::move(name), std::move(actor_code), nullptr, host, nullptr,
+ self)
.get();
});
MSG_process_yield();
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
*/
const char* sglua_tostring(lua_State* L, int index)
{
-
static char buff[64];
switch (lua_type(L, index)) {
-
case LUA_TNIL:
snprintf(buff, 4, "nil");
break;
*/
const char* sglua_keyvalue_tostring(lua_State* L, int key_index, int value_index)
{
-
static char buff[64];
/* value_tostring also always returns the same pointer */
int len = snprintf(buff, 63, "[%s] -> ", sglua_tostring(L, key_index));
-/* 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 debug(lua_State* L) {
-
+static int debug(lua_State* L)
+{
const char* str = luaL_checkstring(L, 1);
XBT_DEBUG("%s", str);
return 0;
*
* - 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. */
#include <simgrid/Exception.hpp>
#include <simgrid/s4u/Actor.hpp>
#include <simgrid/s4u/Comm.hpp>
-#include <simgrid/s4u/Exec.hpp>
#include <simgrid/s4u/Engine.hpp>
+#include <simgrid/s4u/Exec.hpp>
#include <simgrid/s4u/Host.hpp>
#include <simgrid/s4u/Mailbox.hpp>
+#include <simgrid/version.h>
#include <memory>
#include <string>
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();
+/* Classes GilScopedAcquire and GilScopedRelease have the same purpose as pybind11::gil_scoped_acquire and
+ * pybind11::gil_scoped_release. Refer to the manual of pybind11 for details:
+ * https://pybind11.readthedocs.io/en/stable/advanced/misc.html#global-interpreter-lock-gil
+ *
+ * The pybind11 versions are however too sophisticated (using TLS for example) and don't work well with all kinds of
+ * contexts.
+ * See also https://github.com/pybind/pybind11/issues/1276, which may be related.
+ *
+ * Briefly, GilScopedAcquire can be used on actor creation to acquire a new PyThreadState. The PyThreadState has to be
+ * released for context switches (i.e. before simcalls). That's the purpose of GilScopedRelease.
+ *
+ * Like their pybind11 counterparts, both classes use a RAII pattern.
+ */
+class XBT_PRIVATE GilScopedAcquire {
+ static PyThreadState* acquire()
+ {
+ PyThreadState* state = PyThreadState_New(PyInterpreterState_Head());
+ PyEval_AcquireThread(state);
+ return state;
+ }
+ static void release(PyThreadState* state)
+ {
+ PyEval_ReleaseThread(state);
+ PyThreadState_Clear(state);
+ PyThreadState_Delete(state);
+ }
+
+ std::unique_ptr<PyThreadState, decltype(&release)> thread_state{acquire(), &release};
+
+public:
+ void reset() { thread_state.reset(); }
+};
+
+class XBT_PRIVATE GilScopedRelease {
+ std::unique_ptr<PyThreadState, decltype(&PyEval_RestoreThread)> thread_state{PyEval_SaveThread(),
+ &PyEval_RestoreThread};
+};
} // 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),
+ py::call_guard<GilScopedRelease>(),
+ "Block the current actor, computing the given amount of flops at the given priority.", py::arg("flops"),
+ py::arg("priority") = 1)
+ .def("exec_init", py::overload_cast<double>(&simgrid::s4u::this_actor::exec_init),
+ py::call_guard<GilScopedRelease>())
+ .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, py::call_guard<GilScopedRelease>(),
+ "Moves the current actor to another host.", py::arg("dest"))
+ .def("sleep_for", static_cast<void (*)(double)>(&simgrid::s4u::this_actor::sleep_for),
+ py::call_guard<GilScopedRelease>(), "Block the actor sleeping for that amount of seconds.",
+ py::arg("duration"))
+ .def("sleep_until", static_cast<void (*)(double)>(&simgrid::s4u::this_actor::sleep_until),
+ py::call_guard<GilScopedRelease>(), "Block the actor sleeping until the specified timestamp.",
+ py::arg("duration"))
+ .def("suspend", &simgrid::s4u::this_actor::suspend, py::call_guard<GilScopedRelease>(),
+ "Suspend the current actor, that is blocked until resume()ed by another actor.")
+ .def("yield_", &simgrid::s4u::this_actor::yield, py::call_guard<GilScopedRelease>(), "Yield the actor")
+ .def("exit", &simgrid::s4u::this_actor::exit, py::call_guard<GilScopedRelease>(), "kill the current actor")
+ .def(
+ "on_exit",
+ [](py::object fun) {
+ simgrid::s4u::this_actor::on_exit([fun](bool /*failed*/) {
+ GilScopedAcquire py_context; // need a new context for callback
+ try {
+ fun();
+ } catch (const py::error_already_set& e) {
+ std::string what = e.what();
+ py_context.reset();
+ xbt_die("Error while executing the on_exit lambda: %s", what.c_str());
+ }
+ });
+ },
+ py::call_guard<GilScopedRelease>(), "");
/* 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* {
+ py::class_<Engine>(m, "Engine", "Simulation 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()`")
- .def("load_deployment", &Engine::load_deployment,
- "Load a deployment file and launch the actors that it contains, see "
- ":cpp:func:`simgrid::s4u::Engine::load_deployment()`")
- .def("run", &Engine::run, "Run the simulation")
- .def("register_actor",
- [](Engine* e, const std::string& name, py::object fun_or_class) {
- e->register_actor(name, [fun_or_class](std::vector<std::string> args) {
- try {
- /* Convert the std::vector into a py::tuple */
- py::tuple params(args.size() - 1);
- for (size_t i = 1; i < args.size(); i++)
- params[i - 1] = py::cast(args[i]);
+ .def("load_platform", &Engine::load_platform, "Load a platform file describing the environment")
+ .def("load_deployment", &Engine::load_deployment, "Load a deployment file and launch the actors that it contains")
+ .def("run", &Engine::run, py::call_guard<GilScopedRelease>(), "Run the simulation")
+ .def(
+ "register_actor",
+ [](Engine* e, const std::string& name, py::object fun_or_class) {
+ e->register_actor(name, [fun_or_class](std::vector<std::string> args) {
+ GilScopedAcquire py_context;
+ try {
+ /* Convert the std::vector into a py::tuple */
+ py::tuple params(args.size() - 1);
+ for (size_t i = 1; i < args.size(); i++)
+ params[i - 1] = py::cast(args[i]);
- py::object res = fun_or_class(*params);
+ py::object res = fun_or_class(*params);
- /* 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) {
- if (ex.matches(pyForcefulKillEx)) {
- XBT_VERB("Actor killed");
- /* Stop here that ForcefulKill exception which was meant to free the RAII stuff on the stack */
- } else {
- throw;
- }
- }
- });
- },
- "Registers the main function of an actor, see :cpp:func:`simgrid::s4u::Engine::register_actor()`");
+ /* 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 (const py::error_already_set& ex) {
+ bool ffk = ex.matches(pyForcefulKillEx);
+ py_context.reset();
+ if (ffk) {
+ XBT_VERB("Actor killed");
+ /* Forward that ForcefulKill exception */
+ simgrid::ForcefulKillException::do_throw();
+ }
+ throw;
+ }
+ });
+ },
+ "Registers the main function of an 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", "Simulated 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_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("get_pstate_count", &Host::get_pstate_count, "Retrieve the cound of defined pstate levels")
+ .def("get_pstate_speed", &Host::get_pstate_speed, "Retrieve the maximal speed at the given pstate")
+ .def_property(
+ "pstate", &Host::get_pstate,
+ [](Host* h, int i) {
+ GilScopedRelease gil_guard;
+ h->set_pstate(i);
+ },
+ "The current pstate")
+ .def("current", &Host::current, py::call_guard<GilScopedRelease>(),
+ "Retrieves the host on which the running actor is located.")
+ .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.")
+ .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.");
/* 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")
+ .def(
+ "__str__", [](const Mailbox* self) { return std::string("Mailbox(") + self->get_cname() + ")"; },
+ "Textual representation of the Mailbox`")
+ .def("by_name", &Mailbox::by_name, py::call_guard<GilScopedRelease>(), "Retrieve a Mailbox from its 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")
+ .def(
+ "put",
+ [](Mailbox* self, py::object data, int size) {
+ data.inc_ref();
+ self->put(data.ptr(), size);
+ },
+ py::call_guard<GilScopedRelease>(), "Blocking data transmission")
+ .def(
+ "put_async",
+ [](Mailbox* self, py::object data, int size) {
+ data.inc_ref();
+ return self->put_async(data.ptr(), size);
+ },
+ py::call_guard<GilScopedRelease>(), "Non-blocking data transmission")
+ .def(
+ "get",
+ [](Mailbox* self) {
+ py::object data = pybind11::reinterpret_steal<py::object>(static_cast<PyObject*>(self->get()));
+ // data.dec_ref(); // FIXME: why does it break python-actor-create?
+ return data;
+ },
+ py::call_guard<GilScopedRelease>(), "Blocking data reception");
/* 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(); },
- "Test whether the communication is terminated, see :cpp:func:`simgrid::s4u::Comm::test()`")
- .def("wait", [](simgrid::s4u::CommPtr self) { self->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); },
- "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_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::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()`");
+ py::class_<simgrid::s4u::Comm, simgrid::s4u::CommPtr>(m, "Comm", "Communication")
+ .def("test", &simgrid::s4u::Comm::test, py::call_guard<GilScopedRelease>(),
+ "Test whether the communication is terminated.")
+ .def("wait", &simgrid::s4u::Comm::wait, py::call_guard<GilScopedRelease>(),
+ "Block until the completion of that communication.")
+ .def("wait_all", &simgrid::s4u::Comm::wait_all, py::call_guard<GilScopedRelease>(),
+ "Block until the completion of all communications in the list.")
+ .def("wait_any", &simgrid::s4u::Comm::wait_any, py::call_guard<GilScopedRelease>(),
+ "Block until the completion of any communication in the list and return the index of the terminated one.");
+
+ /* Class Exec */
+ py::class_<simgrid::s4u::Exec, simgrid::s4u::ExecPtr>(m, "Exec", "Execution")
+ .def_property_readonly(
+ "remaining",
+ [](simgrid::s4u::ExecPtr self) {
+ GilScopedRelease gil_guard;
+ return self->get_remaining();
+ },
+ "Amount of flops that remain to be computed until completion.")
+ .def_property_readonly(
+ "remaining_ratio",
+ [](simgrid::s4u::ExecPtr self) {
+ GilScopedRelease gil_guard;
+ return self->get_remaining_ratio();
+ },
+ "Amount of work remaining until completion from 0 (completely done) to 1 (nothing done "
+ "yet).")
+ .def_property("host", &simgrid::s4u::Exec::get_host, &simgrid::s4u::Exec::set_host,
+ "Host on which this execution runs. Only the first host is returned for parallel executions.")
+ .def("test", &simgrid::s4u::Exec::test, py::call_guard<GilScopedRelease>(),
+ "Test whether the execution is terminated.")
+ .def("cancel", &simgrid::s4u::Exec::cancel, py::call_guard<GilScopedRelease>(), "Cancel that execution.")
+ .def("start", &simgrid::s4u::Exec::start, py::call_guard<GilScopedRelease>(), "Start that execution.")
+ .def("wait", &simgrid::s4u::Exec::wait, py::call_guard<GilScopedRelease>(),
+ "Block until the completion of that execution.");
/* 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]() {
-
- try {
- fun(*args);
- } catch (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 */
- } else {
- throw;
- }
- }
- });
- },
- "Create an actor from a function or an object.")
- .def_property("host", &Actor::get_host, &Actor::set_host, "The host on which this actor is located")
+ "application")
+ .def(
+ "create",
+ [](py::str name, Host* host, py::object fun, py::args args) {
+ fun.inc_ref(); // FIXME: why is this needed for tests like exec-async, exec-dvfs and exec-remote?
+ args.inc_ref(); // FIXME: why is this needed for tests like actor-migrate?
+ return simgrid::s4u::Actor::create(name, host, [fun, args]() {
+ GilScopedAcquire py_context;
+ try {
+ fun(*args);
+ } catch (const py::error_already_set& ex) {
+ bool ffk = ex.matches(pyForcefulKillEx);
+ py_context.reset();
+ if (ffk) {
+ XBT_VERB("Actor killed");
+ /* Forward that ForcefulKill exception */
+ simgrid::ForcefulKillException::do_throw();
+ }
+ throw;
+ }
+ });
+ },
+ py::call_guard<GilScopedRelease>(), "Create an actor from a function or an object.")
+ .def_property(
+ "host", &Actor::get_host,
+ [](Actor* a, Host* h) {
+ GilScopedRelease gil_guard;
+ a->set_host(h);
+ },
+ "The host on which this actor is located")
.def_property_readonly("name", &Actor::get_cname, "The name of this actor.")
.def_property_readonly("pid", &Actor::get_pid, "The PID (unique identifier) of this actor.")
.def_property_readonly("ppid", &Actor::get_ppid,
"The PID (unique identifier) of the actor that created this one.")
.def("by_pid", &Actor::by_pid, "Retrieve an actor by its PID")
- .def("daemonize", &Actor::daemonize,
+ .def("daemonize", &Actor::daemonize, py::call_guard<GilScopedRelease>(),
"This actor will be automatically terminated when the last non-daemon actor finishes (more info in the C++ "
"documentation).")
.def("is_daemon", &Actor::is_daemon,
"Returns True if that actor is a daemon and will be terminated automatically when the last non-daemon actor "
"terminates.")
- .def("join", py::overload_cast<double>(&Actor::join),
+ .def("join", py::overload_cast<double>(&Actor::join), py::call_guard<GilScopedRelease>(),
"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_all", &Actor::kill_all, "Kill all actors but the caller.")
+ .def("kill", &Actor::kill, py::call_guard<GilScopedRelease>(), "Kill that actor")
+ .def("kill_all", &Actor::kill_all, py::call_guard<GilScopedRelease>(), "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.")
- .def("suspend", &Actor::suspend, "Suspend that actor, that is blocked until resume()ed by another actor.")
- .def("resume", &Actor::resume, "Resume that actor, that was previously suspend()ed.");
+ .def("suspend", &Actor::suspend, py::call_guard<GilScopedRelease>(),
+ "Suspend that actor, that is blocked until resume()ed by another actor.")
+ .def("resume", &Actor::resume, py::call_guard<GilScopedRelease>(),
+ "Resume that actor, that was previously suspend()ed.");
}
-/* 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 "include/xbt/config.hpp"
#include "simgrid/Exception.hpp"
#include "simgrid/s4u/Engine.hpp"
+#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
simgrid::xbt::string_printf("mark_type with name (%s) is not declared", mark_type));
} else {
XBT_DEBUG("MARK %s %s", mark_type, mark_value);
- new simgrid::instr::NewEvent(MSG_get_clock(), simgrid::instr::Container::get_root(), type,
+ new simgrid::instr::NewEvent(simgrid_get_clock(), simgrid::instr::Container::get_root(), type,
type->get_entity_value(mark_value));
}
}
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,
*/
void TRACE_vm_variable_set (const char *vm, const char *variable, double value)
{
- TRACE_vm_variable_set_with_time (MSG_get_clock(), vm, variable, value);
+ TRACE_vm_variable_set_with_time(simgrid_get_clock(), vm, variable, value);
}
/** @ingroup TRACE_user_variables
*/
void TRACE_vm_variable_add (const char *vm, const char *variable, double value)
{
- TRACE_vm_variable_add_with_time (MSG_get_clock(), vm, variable, value);
+ TRACE_vm_variable_add_with_time(simgrid_get_clock(), vm, variable, value);
}
/** @ingroup TRACE_user_variables
*/
void TRACE_vm_variable_sub (const char *vm, const char *variable, double value)
{
- TRACE_vm_variable_sub_with_time (MSG_get_clock(), vm, variable, value);
+ TRACE_vm_variable_sub_with_time(simgrid_get_clock(), vm, variable, value);
}
/** @ingroup TRACE_user_variables
*/
void TRACE_host_variable_set (const char *host, const char *variable, double value)
{
- TRACE_host_variable_set_with_time (MSG_get_clock(), host, variable, value);
+ TRACE_host_variable_set_with_time(simgrid_get_clock(), host, variable, value);
}
/** @ingroup TRACE_user_variables
*/
void TRACE_host_variable_add (const char *host, const char *variable, double value)
{
- TRACE_host_variable_add_with_time (MSG_get_clock(), host, variable, value);
+ TRACE_host_variable_add_with_time(simgrid_get_clock(), host, variable, value);
}
/** @ingroup TRACE_user_variables
*/
void TRACE_host_variable_sub (const char *host, const char *variable, double value)
{
- TRACE_host_variable_sub_with_time (MSG_get_clock(), host, variable, value);
+ TRACE_host_variable_sub_with_time(simgrid_get_clock(), host, variable, value);
}
/** @ingroup TRACE_user_variables
*/
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 */
*/
void TRACE_link_variable_set (const char *link, const char *variable, double value)
{
- TRACE_link_variable_set_with_time (MSG_get_clock(), link, variable, value);
+ TRACE_link_variable_set_with_time(simgrid_get_clock(), link, variable, value);
}
/** @ingroup TRACE_user_variables
*/
void TRACE_link_variable_add (const char *link, const char *variable, double value)
{
- TRACE_link_variable_add_with_time (MSG_get_clock(), link, variable, value);
+ TRACE_link_variable_add_with_time(simgrid_get_clock(), link, variable, value);
}
/** @ingroup TRACE_user_variables
*/
void TRACE_link_variable_sub (const char *link, const char *variable, double value)
{
- TRACE_link_variable_sub_with_time (MSG_get_clock(), link, variable, value);
+ TRACE_link_variable_sub_with_time(simgrid_get_clock(), link, variable, value);
}
/** @ingroup TRACE_user_variables
*/
void TRACE_link_srcdst_variable_set (const char *src, const char *dst, const char *variable, double value)
{
- TRACE_link_srcdst_variable_set_with_time (MSG_get_clock(), src, dst, variable, value);
+ TRACE_link_srcdst_variable_set_with_time(simgrid_get_clock(), src, dst, variable, value);
}
/** @ingroup TRACE_user_variables
*/
void TRACE_link_srcdst_variable_add (const char *src, const char *dst, const char *variable, double value)
{
- TRACE_link_srcdst_variable_add_with_time (MSG_get_clock(), src, dst, variable, value);
+ TRACE_link_srcdst_variable_add_with_time(simgrid_get_clock(), src, dst, variable, value);
}
/** @ingroup TRACE_user_variables
*/
void TRACE_link_srcdst_variable_sub (const char *src, const char *dst, const char *variable, double value)
{
- TRACE_link_srcdst_variable_sub_with_time (MSG_get_clock(), src, dst, variable, value);
+ TRACE_link_srcdst_variable_sub_with_time(simgrid_get_clock(), src, dst, variable, value);
}
/** @ingroup TRACE_user_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. */
class Container {
long long int id_;
std::string name_; /* Unique name of this container */
+
public:
Container(const std::string& name, const std::string& type_name, Container* father);
Container(const Container&) = delete;
-/* 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)
+std::string instr_pid(simgrid::s4u::Actor const& proc)
+{
+ return std::string(proc.get_name()) + "-" + std::to_string(proc.get_pid());
+}
+
+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. */
surf_parse();
surf_parse_close();
}
-void EngineImpl::register_function(const std::string& name, xbt_main_func_t code)
-{
- simix_global->registered_functions[name] = [code](std::vector<std::string> args) {
- return simgrid::xbt::wrap_main(code, std::move(args));
- };
-}
-void EngineImpl::register_function(const std::string& name, void (*code)(std::vector<std::string>))
+void EngineImpl::register_function(const std::string& name, const actor::ActorCodeFactory& code)
{
- simix_global->registered_functions[name] = [code](std::vector<std::string> args) {
- return std::bind(std::move(code), std::move(args));
- };
+ registered_functions[name] = code;
}
-
-void EngineImpl::register_default(xbt_main_func_t code)
+void EngineImpl::register_default(const actor::ActorCodeFactory& code)
{
- simix_global->default_function = [code](std::vector<std::string> args) {
- return simgrid::xbt::wrap_main(code, std::move(args));
- };
+ default_function = code;
}
} // namespace kernel
-/* 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 <map>
+#include <simgrid/s4u/Engine.hpp>
#include <simgrid/s4u/NetZone.hpp>
#include <simgrid/simix.hpp>
#include <string>
std::map<std::string, resource::LinkImpl*> links_;
std::map<std::string, resource::StorageImpl*> storages_;
std::unordered_map<std::string, routing::NetPoint*> netpoints_;
+ std::unordered_map<std::string, actor::ActorCodeFactory> registered_functions; // Maps function names to actor code
+ actor::ActorCodeFactory default_function; // Function to use as a fallback when the provided name matches nothing
+
friend s4u::Engine;
public:
virtual ~EngineImpl();
void load_deployment(const std::string& file);
- void register_function(const std::string& name, xbt_main_func_t code);
- void register_function(const std::string& name, void (*code)(std::vector<std::string>));
- void register_default(xbt_main_func_t code);
+ void register_function(const std::string& name, const actor::ActorCodeFactory& code);
+ void register_default(const actor::ActorCodeFactory& code);
routing::NetZoneImpl* netzone_root_ = nullptr;
+ static EngineImpl* get_instance() { return simgrid::s4u::Engine::get_instance()->pimpl; }
+ actor::ActorCodeFactory get_function(const std::string& name)
+ {
+ auto res = registered_functions.find(name);
+ if (res == registered_functions.end())
+ return default_function;
+ else
+ return res->second;
+ }
};
} // 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_VERB("Activity %p is canceled", this);
if (surf_action_ != nullptr)
surf_action_->cancel();
- state_ = SIMIX_CANCELED;
+ state_ = State::CANCELED;
}
// boost::intrusive_ptr<Activity> support:
-/* 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 simgrid {
namespace kernel {
namespace activity {
+enum class State {
+ WAITING = 0,
+ READY,
+ RUNNING,
+ DONE,
+ CANCELED,
+ FAILED,
+ SRC_HOST_FAILURE,
+ DST_HOST_FAILURE,
+ TIMEOUT,
+ SRC_TIMEOUT,
+ DST_TIMEOUT,
+ LINK_FAILURE
+};
class XBT_PUBLIC ActivityImpl {
std::atomic_int_fast32_t refcount_{0};
+
public:
virtual ~ActivityImpl();
ActivityImpl() = default;
- e_smx_state_t state_ = SIMIX_WAITING; /* State of the activity */
+ State state_ = State::WAITING; /* State of the activity */
std::list<smx_simcall_t> simcalls_; /* List of simcalls waiting for this activity */
resource::Action* surf_action_ = nullptr;
virtual void register_simcall(smx_simcall_t simcall);
void clean_action();
virtual double get_remaining() const;
- // boost::intrusive_ptr<ActivityImpl> support:
+ // Support for the boost::intrusive_ptr<ActivityImpl> datatype
friend XBT_PUBLIC void intrusive_ptr_add_ref(ActivityImpl* activity);
friend XBT_PUBLIC void intrusive_ptr_release(ActivityImpl* activity);
-/* 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)
{
- smx_activity_t comm = simcall_HANDLER_comm_isend(simcall, src, mbox, task_size, rate, src_buff, src_buff_size,
- match_fun, nullptr, copy_data_fun, data, 0);
+ simgrid::kernel::activity::ActivityImplPtr comm = simcall_HANDLER_comm_isend(
+ simcall, src, mbox, task_size, rate, src_buff, src_buff_size, match_fun, nullptr, copy_data_fun, data, 0);
SIMCALL_SET_MC_VALUE(*simcall, 0);
simcall_HANDLER_comm_wait(simcall, static_cast<simgrid::kernel::activity::CommImpl*>(comm.get()), timeout);
}
-XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend(
+XBT_PRIVATE simgrid::kernel::activity::ActivityImplPtr 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)
if (mbox->permanent_receiver_ != nullptr) {
// this mailbox is for small messages, which have to be sent right now
- other_comm->state_ = SIMIX_READY;
+ other_comm->state_ = simgrid::kernel::activity::State::READY;
other_comm->dst_actor_ = mbox->permanent_receiver_.get();
mbox->done_comm_queue_.push_back(other_comm);
XBT_DEBUG("pushing a message into the permanent receive list %p, comm %p", mbox, other_comm.get());
} else {
XBT_DEBUG("Receive already pushed");
- other_comm->state_ = SIMIX_READY;
+ other_comm->state_ = simgrid::kernel::activity::State::READY;
other_comm->set_type(simgrid::kernel::activity::CommImpl::Type::READY);
}
other_comm->copy_data_fun = copy_data_fun;
if (MC_is_active() || MC_record_replay_is_active())
- other_comm->state_ = SIMIX_RUNNING;
+ other_comm->state_ = simgrid::kernel::activity::State::RUNNING;
else
other_comm->start();
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)
{
- smx_activity_t comm = simcall_HANDLER_comm_irecv(simcall, receiver, mbox, dst_buff, dst_buff_size, match_fun,
- copy_data_fun, data, rate);
+ simgrid::kernel::activity::ActivityImplPtr comm = simcall_HANDLER_comm_irecv(
+ simcall, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, rate);
SIMCALL_SET_MC_VALUE(*simcall, 0);
simcall_HANDLER_comm_wait(simcall, static_cast<simgrid::kernel::activity::CommImpl*>(comm.get()), timeout);
}
-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)
+XBT_PRIVATE simgrid::kernel::activity::ActivityImplPtr
+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, 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());
simgrid::kernel::activity::CommImplPtr other_comm;
// communication already done, get it inside the list of completed comms
if (mbox->permanent_receiver_ != nullptr && not mbox->done_comm_queue_.empty()) {
-
XBT_DEBUG("We have a comm that has probably already been received, trying to match it, to skip the communication");
// find a match in the list of already received comms
other_comm = mbox->find_matching_comm(simgrid::kernel::activity::CommImpl::Type::SEND, match_fun, data,
} else {
if (other_comm->surf_action_ && other_comm->get_remaining() < 1e-12) {
XBT_DEBUG("comm %p has been already sent, and is finished, destroy it", other_comm.get());
- other_comm->state_ = SIMIX_DONE;
+ other_comm->state_ = simgrid::kernel::activity::State::DONE;
other_comm->set_type(simgrid::kernel::activity::CommImpl::Type::DONE).set_mailbox(nullptr);
}
}
} else {
XBT_DEBUG("Match my %p with the existing %p", this_synchro.get(), other_comm.get());
- other_comm->state_ = SIMIX_READY;
+ other_comm->state_ = simgrid::kernel::activity::State::READY;
other_comm->set_type(simgrid::kernel::activity::CommImpl::Type::READY);
}
receiver->comms.push_back(other_comm);
other_comm->copy_data_fun = copy_data_fun;
if (MC_is_active() || MC_record_replay_is_active()) {
- other_comm->state_ = SIMIX_RUNNING;
+ other_comm->state_ = simgrid::kernel::activity::State::RUNNING;
return other_comm;
}
other_comm->start();
if (MC_is_active() || MC_record_replay_is_active()) {
int idx = SIMCALL_GET_MC_VALUE(*simcall);
if (idx == 0) {
- comm->state_ = SIMIX_DONE;
+ comm->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 */
THROW_IMPOSSIBLE;
if (comm->src_actor_ == simcall->issuer_)
- comm->state_ = SIMIX_SRC_TIMEOUT;
+ comm->state_ = simgrid::kernel::activity::State::SRC_TIMEOUT;
else
- comm->state_ = SIMIX_DST_TIMEOUT;
+ comm->state_ = simgrid::kernel::activity::State::DST_TIMEOUT;
}
comm->finish();
/* If the synchro has already finish perform the error handling, */
/* otherwise set up a waiting timeout on the right side */
- if (comm->state_ != SIMIX_WAITING && comm->state_ != SIMIX_RUNNING) {
+ if (comm->state_ != simgrid::kernel::activity::State::WAITING &&
+ comm->state_ != simgrid::kernel::activity::State::RUNNING) {
comm->finish();
} else { /* we need a sleep action (even when there is no timeout) to be notified of host failures */
simgrid::kernel::resource::Action* sleep = simcall->issuer_->get_host()->pimpl_cpu->sleep(timeout);
if (MC_is_active() || MC_record_replay_is_active()) {
res = comm->src_actor_ && comm->dst_actor_;
if (res)
- comm->state_ = SIMIX_DONE;
+ comm->state_ = simgrid::kernel::activity::State::DONE;
} else {
- res = comm->state_ != SIMIX_WAITING && comm->state_ != SIMIX_RUNNING;
+ res = comm->state_ != simgrid::kernel::activity::State::WAITING &&
+ comm->state_ != simgrid::kernel::activity::State::RUNNING;
}
simcall_comm_test__set__result(simcall, res);
simgrid::kernel::activity::CommImpl* comm = comms[idx];
simcall_comm_testany__set__result(simcall, idx);
comm->simcalls_.push_back(simcall);
- comm->state_ = SIMIX_DONE;
+ comm->state_ = simgrid::kernel::activity::State::DONE;
comm->finish();
}
return;
for (std::size_t i = 0; i != count; ++i) {
simgrid::kernel::activity::CommImpl* comm = comms[i];
- if (comm->state_ != SIMIX_WAITING && comm->state_ != SIMIX_RUNNING) {
+ if (comm->state_ != simgrid::kernel::activity::State::WAITING &&
+ comm->state_ != simgrid::kernel::activity::State::RUNNING) {
simcall_comm_testany__set__result(simcall, i);
comm->simcalls_.push_back(simcall);
comm->finish();
auto* comm = comms[idx];
comm->simcalls_.push_back(simcall);
simcall_comm_waitany__set__result(simcall, idx);
- comm->state_ = SIMIX_DONE;
+ comm->state_ = simgrid::kernel::activity::State::DONE;
comm->finish();
return;
}
comm->simcalls_.push_back(simcall);
/* see if the synchro is already finished */
- if (comm->state_ != SIMIX_WAITING && comm->state_ != SIMIX_RUNNING) {
+ if (comm->state_ != simgrid::kernel::activity::State::WAITING &&
+ comm->state_ != simgrid::kernel::activity::State::RUNNING) {
comm->finish();
break;
}
cleanupSurf();
- if (detached_ && state_ != SIMIX_DONE) {
+ if (detached_ && state_ != State::DONE) {
/* the communication has failed and was detached:
* we have to free the buffer */
if (clean_fun)
CommImpl* CommImpl::start()
{
/* If both the sender and the receiver are already there, start the communication */
- if (state_ == SIMIX_READY) {
-
+ if (state_ == State::READY) {
s4u::Host* sender = src_actor_->get_host();
s4u::Host* receiver = dst_actor_->get_host();
surf_action_ = surf_network_model->communicate(sender, receiver, size_, rate_);
surf_action_->set_activity(this);
surf_action_->set_category(get_tracing_category());
- state_ = SIMIX_RUNNING;
+ state_ = State::RUNNING;
XBT_DEBUG("Starting communication %p from '%s' to '%s' (surf_action: %p)", this, sender->get_cname(),
receiver->get_cname(), surf_action_);
if (surf_action_->get_state() == resource::Action::State::FAILED) {
XBT_DEBUG("Communication from '%s' to '%s' failed to start because of a link failure", sender->get_cname(),
receiver->get_cname());
- state_ = SIMIX_LINK_FAILURE;
+ state_ = State::LINK_FAILURE;
post();
} else if (src_actor_->is_suspended() || dst_actor_->is_suspended()) {
void CommImpl::cancel()
{
/* if the synchro is a waiting state means that it is still in a mbox so remove from it and delete it */
- if (state_ == SIMIX_WAITING) {
+ if (state_ == State::WAITING) {
if (not detached_) {
mbox_->remove(this);
- state_ = SIMIX_CANCELED;
+ state_ = State::CANCELED;
}
} else if (not MC_is_active() /* when running the MC there are no surf actions */
- && not MC_record_replay_is_active() && (state_ == SIMIX_READY || state_ == SIMIX_RUNNING)) {
+ && not MC_record_replay_is_active() && (state_ == State::READY || state_ == State::RUNNING)) {
surf_action_->cancel();
}
}
{
/* Update synchro state */
if (src_timeout_ && src_timeout_->get_state() == resource::Action::State::FINISHED)
- state_ = SIMIX_SRC_TIMEOUT;
+ state_ = State::SRC_TIMEOUT;
else if (dst_timeout_ && dst_timeout_->get_state() == resource::Action::State::FINISHED)
- state_ = SIMIX_DST_TIMEOUT;
+ state_ = State::DST_TIMEOUT;
else if (src_timeout_ && src_timeout_->get_state() == resource::Action::State::FAILED)
- state_ = SIMIX_SRC_HOST_FAILURE;
+ state_ = State::SRC_HOST_FAILURE;
else if (dst_timeout_ && dst_timeout_->get_state() == resource::Action::State::FAILED)
- state_ = SIMIX_DST_HOST_FAILURE;
+ state_ = State::DST_HOST_FAILURE;
else if (surf_action_ && surf_action_->get_state() == resource::Action::State::FAILED) {
- state_ = SIMIX_LINK_FAILURE;
+ state_ = State::LINK_FAILURE;
} else
- state_ = SIMIX_DONE;
+ state_ = State::DONE;
XBT_DEBUG("SIMIX_post_comm: comm %p, state %d, src_proc %p, dst_proc %p, detached: %d", this, (int)state_,
src_actor_.get(), dst_actor_.get(), detached_);
/* 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 SIMIX_DONE:
+ case State::DONE:
XBT_DEBUG("Communication %p complete!", this);
copy_data();
break;
- case SIMIX_SRC_TIMEOUT:
+ case State::SRC_TIMEOUT:
simcall->issuer_->exception_ = std::make_exception_ptr(
simgrid::TimeoutException(XBT_THROW_POINT, "Communication timeouted because of the sender"));
break;
- case SIMIX_DST_TIMEOUT:
+ case State::DST_TIMEOUT:
simcall->issuer_->exception_ = std::make_exception_ptr(
simgrid::TimeoutException(XBT_THROW_POINT, "Communication timeouted because of the receiver"));
break;
- case SIMIX_SRC_HOST_FAILURE:
+ 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"));
break;
- case SIMIX_DST_HOST_FAILURE:
+ 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"));
break;
- case SIMIX_LINK_FAILURE:
+ case State::LINK_FAILURE:
XBT_DEBUG("Link failure in synchro %p between '%s' and '%s': posting an exception to the issuer: %s (%p) "
"detached:%d",
this, src_actor_ ? src_actor_->get_host()->get_cname() : nullptr,
std::make_exception_ptr(simgrid::NetworkFailureException(XBT_THROW_POINT, "Link failure")));
break;
- case SIMIX_CANCELED:
+ case State::CANCELED:
if (simcall->issuer_ == dst_actor_)
simcall->issuer_->exception_ = std::make_exception_ptr(
simgrid::CancelException(XBT_THROW_POINT, "Communication canceled by the sender"));
-/* 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 post() override;
void finish() override;
- CommImpl::Type type_; /* Type of the communication (SIMIX_COMM_SEND or SIMIX_COMM_RECEIVE) */
+ CommImpl::Type type_; /* Type of the communication (SEND or RECEIVE) */
#if SIMGRID_HAVE_MC
MailboxImpl* mbox_cpy = nullptr; /* Copy of the rendez-vous where the comm is queued, MC needs it for DPOR
#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. */
-#ifndef SIMGRID_KERNEL_ACTIVITY_CONDITIONVARIABLEIMPL_HPP
-#define SIMGRID_KERNEL_ACTIVITY_CONDITIONVARIABLEIMPL_HPP
+#ifndef SIMGRID_KERNEL_ACTIVITY_CONDITIONVARIABLE_HPP
+#define SIMGRID_KERNEL_ACTIVITY_CONDITIONVARIABLE_HPP
#include "simgrid/s4u/ConditionVariable.hpp"
#include "src/kernel/actor/ActorImpl.hpp"
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_ = SIMIX_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_ != SIMIX_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)
{
- bool res = (synchro->state_ != SIMIX_WAITING && synchro->state_ != SIMIX_RUNNING);
+ 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();
exec->simcalls_.push_back(simcall);
/* see if the synchro is already finished */
- if (exec->state_ != SIMIX_WAITING && exec->state_ != SIMIX_RUNNING) {
+ if (exec->state_ != simgrid::kernel::activity::State::WAITING &&
+ exec->state_ != simgrid::kernel::activity::State::RUNNING) {
exec->finish();
break;
}
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;
ExecImpl* ExecImpl::start()
{
- state_ = SIMIX_RUNNING;
+ state_ = State::RUNNING;
if (not MC_is_active() && not MC_record_replay_is_active()) {
if (hosts_.size() == 1) {
surf_action_ = hosts_.front()->pimpl_cpu->execution_start(flops_amounts_.front());
if (hosts_.size() == 1 && not hosts_.front()->is_on()) { /* FIXME: handle resource failure for parallel tasks too */
/* If the host running the synchro failed, notice it. This way, the asking
* process can be killed if it runs on that host itself */
- state_ = SIMIX_FAILED;
+ state_ = State::FAILED;
} else if (surf_action_ && surf_action_->get_state() == resource::Action::State::FAILED) {
/* If the host running the synchro didn't fail, then the synchro was canceled */
- state_ = SIMIX_CANCELED;
+ state_ = State::CANCELED;
} else if (timeout_detector_ && timeout_detector_->get_state() == resource::Action::State::FINISHED) {
- state_ = SIMIX_TIMEOUT;
+ state_ = State::TIMEOUT;
} else {
- state_ = SIMIX_DONE;
+ state_ = State::DONE;
}
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 SIMIX_DONE:
+ case State::DONE:
/* do nothing, synchro done */
XBT_DEBUG("ExecImpl::finish(): execution successful");
break;
- case SIMIX_FAILED:
+ 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"));
/* else, the actor will be killed with no possibility to survive */
break;
- case SIMIX_CANCELED:
+ case State::CANCELED:
XBT_DEBUG("ExecImpl::finish(): execution canceled");
simcall->issuer_->exception_ =
std::make_exception_ptr(simgrid::CancelException(XBT_THROW_POINT, "Execution Canceled"));
break;
- case SIMIX_TIMEOUT:
+ case State::TIMEOUT:
XBT_DEBUG("ExecImpl::finish(): execution timeouted");
simcall->issuer_->exception_ = std::make_exception_ptr(simgrid::TimeoutException(XBT_THROW_POINT, "Timeouted"));
break;
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. */
-#ifndef SIMIX_SYNCHRO_EXEC_HPP
-#define SIMIX_SYNCHRO_EXEC_HPP
+#ifndef SIMGRID_KERNEL_ACTIVITY_EXEC_HPP
+#define SIMGRID_KERNEL_ACTIVITY_EXEC_HPP
#include "src/kernel/activity/ActivityImpl.hpp"
#include "src/kernel/context/Context.hpp"
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_ = SIMIX_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();
+ return;
+ }
/* If the synchro is already finished then perform the error handling */
- if (synchro->state_ != SIMIX_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 */
+ 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 {
IoImpl* IoImpl::start()
{
- state_ = SIMIX_RUNNING;
+ state_ = State::RUNNING;
if (storage_)
surf_action_ = storage_->io_start(size_, type_);
else
performed_ioops_ = surf_action_->get_cost();
if (surf_action_->get_state() == resource::Action::State::FAILED) {
if ((storage_ && not storage_->is_on()) || (disk_ && not disk_->is_on()))
- state_ = SIMIX_FAILED;
+ state_ = State::FAILED;
else
- state_ = SIMIX_CANCELED;
+ state_ = State::CANCELED;
} else if (surf_action_->get_state() == resource::Action::State::FINISHED) {
- state_ = SIMIX_DONE;
+ 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 SIMIX_DONE:
+ case State::DONE:
/* do nothing, synchro done */
break;
- case SIMIX_FAILED:
- simcall->issuer_->context_->iwannadie = true;
+ case State::FAILED:
+ simcall->issuer_->context_->set_wannadie();
simcall->issuer_->exception_ =
std::make_exception_ptr(StorageFailureException(XBT_THROW_POINT, "Storage failed"));
break;
- case SIMIX_CANCELED:
+ 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. */
-#ifndef SIMIX_SYNCHRO_IO_HPP
-#define SIMIX_SYNCHRO_IO_HPP
+#ifndef SIMGRID_KERNEL_ACTIVITY_IO_HPP
+#define SIMGRID_KERNEL_ACTIVITY_IO_HPP
#include "src/kernel/activity/ActivityImpl.hpp"
#include "surf/surf.hpp"
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);
- sg_size_t get_performed_ioops() { return performed_ioops_; }
+ void set_timeout_detector(resource::Action* action)
+ {
+ timeout_detector_ = action;
+ timeout_detector_->set_activity(this);
+ }
+
+ sg_size_t get_performed_ioops() const { return performed_ioops_; }
+ resource::DiskImpl* get_disk() const { return disk_; }
+ resource::StorageImpl* get_storage() const { 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. */
-#ifndef SIMIX_MAILBOXIMPL_H
-#define SIMIX_MAILBOXIMPL_H
+#ifndef SIMGRID_KERNEL_ACTIVITY_MAILBOX_HPP
+#define SIMGRID_KERNEL_ACTIVITY_MAILBOX_HPP
#include <boost/circular_buffer.hpp>
#include <xbt/string.hpp>
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
XBT_PRIVATE void SIMIX_mailbox_exit();
-#endif /* SIMIX_MAILBOXIMPL_H */
+#endif
-/* 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. */
-#ifndef SIMIX_MUTEXIMPL_HPP
-#define SIMIX_MUTEXIMPL_HPP
+#ifndef SIMGRID_KERNEL_ACTIVITY_MUTEX_HPP
+#define SIMGRID_KERNEL_ACTIVITY_MUTEX_HPP
#include "simgrid/s4u/ConditionVariable.hpp"
#include "src/kernel/actor/ActorImpl.hpp"
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)
s4u::Mutex& mutex() { return piface_; }
};
-}
-}
-}
-#endif /* SIMIX_MUTEXIMPL_HPP */
+} // namespace activity
+} // namespace kernel
+} // namespace simgrid
+#endif
-/* 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_SEMAPHOREIMPL_HPP_
-#define SIMGRID_KERNEL_ACTIVITY_SEMAPHOREIMPL_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. */
{
if (surf_action_->get_state() == resource::Action::State::FAILED) {
if (host_ && not host_->is_on())
- state_ = SIMIX_SRC_HOST_FAILURE;
+ state_ = State::SRC_HOST_FAILURE;
else
- state_ = SIMIX_CANCELED;
+ state_ = State::CANCELED;
} else if (surf_action_->get_state() == resource::Action::State::FINISHED) {
- state_ = SIMIX_DONE;
+ state_ = State::DONE;
}
/* Answer all simcalls associated with the synchro */
finish();
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. */
-#ifndef SIMIX_SYNCHRO_SLEEP_HPP
-#define SIMIX_SYNCHRO_SLEEP_HPP
+#ifndef SIMGRID_KERNEL_ACTIVITY_SLEEP_HPP
+#define SIMGRID_KERNEL_ACTIVITY_SLEEP_HPP
#include "src/kernel/activity/ActivityImpl.hpp"
#include "surf/surf.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 RawImpl::post()
{
if (surf_action_->get_state() == resource::Action::State::FAILED) {
- state_ = SIMIX_FAILED;
+ state_ = State::FAILED;
} else if (surf_action_->get_state() == resource::Action::State::FINISHED) {
- state_ = SIMIX_SRC_TIMEOUT;
+ state_ = State::SRC_TIMEOUT;
}
finish();
}
smx_simcall_t simcall = simcalls_.front();
simcalls_.pop_front();
- if (state_ == SIMIX_FAILED) {
+ 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_ != SIMIX_SRC_TIMEOUT) {
+ } 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. */
-#ifndef SIMIX_SYNCHRO_RAW_HPP
-#define SIMIX_SYNCHRO_RAW_HPP
+#ifndef SIMGRID_KERNEL_ACTIVITY_SYNCHRO_RAW_HPP
+#define SIMGRID_KERNEL_ACTIVITY_SYNCHRO_RAW_HPP
#include "src/kernel/activity/ActivityImpl.hpp"
#include "surf/surf.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. */
*/
smx_actor_t SIMIX_process_self()
{
- simgrid::kernel::context::Context* self_context = simgrid::kernel::context::Context::self();
-
- return (self_context != nullptr) ? self_context->get_actor() : nullptr;
+ return simgrid::kernel::actor::ActorImpl::self();
}
namespace simgrid {
return maxpid;
}
-ActorImpl::ActorImpl(simgrid::xbt::string name, s4u::Host* host) : host_(host), name_(std::move(name)), piface_(this)
+ActorImpl* ActorImpl::self()
+{
+ context::Context* self_context = context::Context::self();
+
+ return (self_context != nullptr) ? self_context->get_actor() : nullptr;
+}
+
+ActorImpl::ActorImpl(xbt::string name, s4u::Host* host) : host_(host), name_(std::move(name)), piface_(this)
{
pid_ = maxpid++;
simcall.issuer_ = this;
ActorImpl::~ActorImpl()
{
- if (simix_global != nullptr && this != simix_global->maestro_process) {
- 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
- simgrid::kernel::actor::simcall([this] { simgrid::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
{
// This is mostly a copy/paste from create(), it'd be nice to share some code between those two functions.
- XBT_DEBUG("Attach process %s on host '%s'", name.c_str(), host->get_cname());
+ XBT_DEBUG("Attach actor %s on host '%s'", name.c_str(), host->get_cname());
if (not host->is_on()) {
- XBT_WARN("Cannot launch process '%s' on failed host '%s'", name.c_str(), host->get_cname());
- throw simgrid::HostFailureException(XBT_THROW_POINT, "Cannot attach actor on failed host.");
+ XBT_WARN("Cannot attach actor '%s' on failed host '%s'", name.c_str(), host->get_cname());
+ throw HostFailureException(XBT_THROW_POINT, "Cannot attach actor on failed host.");
}
ActorImpl* actor = new ActorImpl(xbt::string(name), host);
if (properties != nullptr)
actor->set_properties(*properties);
- /* Add the process to it's host process list */
+ /* Add the actor to it's host actor list */
host->pimpl_->add_actor(actor);
- /* Now insert it in the global process list and in the process to run list */
+ /* Now insert it in the global actor list and in the actors to run list */
simix_global->process_list[actor->get_pid()] = actor;
XBT_DEBUG("Inserting [%p] %s(%s) in the to_run list", actor, actor->get_cname(), host->get_cname());
simix_global->actors_to_run.push_back(actor);
intrusive_ptr_add_ref(actor);
- auto* context = dynamic_cast<simgrid::kernel::context::AttachContext*>(actor->context_.get());
+ auto* context = dynamic_cast<context::AttachContext*>(actor->context_.get());
xbt_assert(nullptr != context, "Not a suitable context");
context->attach_start();
/* The on_creation() signal must be delayed until there, where the pid and everything is set */
- simgrid::s4u::Actor::on_creation(*actor->ciface());
+ s4u::Actor::on_creation(*actor->ciface());
return ActorImplPtr(actor);
}
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();
XBT_DEBUG("%s@%s(%ld) should not run anymore", get_cname(), get_host()->get_cname(), get_pid());
- if (this == simix_global->maestro_process) /* Do not cleanup maestro */
+ if (this == simix_global->maestro_) /* Do not cleanup maestro */
return;
XBT_DEBUG("Cleanup actor %s (%p), waiting synchro %p", get_cname(), this, waiting_synchro.get());
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
- simgrid::kernel::actor::simcall([this] { simgrid::s4u::Actor::on_termination(*ciface()); });
- context_->iwannadie = true;
+ 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_->set_wannadie();
}
void ActorImpl::exit()
{
- context_->iwannadie = true;
+ context_->set_wannadie();
suspended_ = false;
exception_ = nullptr;
/* destroy the blocking synchro if any */
if (waiting_synchro != nullptr) {
waiting_synchro->cancel();
- waiting_synchro->state_ = SIMIX_FAILED;
+ waiting_synchro->state_ = activity::State::FAILED;
activity::ExecImplPtr exec = boost::dynamic_pointer_cast<activity::ExecImpl>(waiting_synchro);
activity::CommImplPtr comm = boost::dynamic_pointer_cast<activity::CommImpl>(waiting_synchro);
void ActorImpl::kill(ActorImpl* actor)
{
- xbt_assert(actor != simix_global->maestro_process, "Killing maestro is a rather bad idea");
+ xbt_assert(actor != simix_global->maestro_, "Killing maestro is a rather bad idea");
if (actor->finished_) {
XBT_DEBUG("Ignoring request to kill actor %s@%s that is already dead", actor->get_cname(),
actor->host_->get_cname());
/* 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;
s4u::Actor* ActorImpl::restart()
{
- xbt_assert(this != simix_global->maestro_process, "Restarting maestro is not supported");
+ xbt_assert(this != simix_global->maestro_, "Restarting maestro is not supported");
XBT_DEBUG("Restarting actor %s on %s", get_cname(), host_->get_cname());
{
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);
- SIMIX_process_on_exit(actor, [sleep](bool) {
+ actor->on_exit->emplace_back([sleep](bool) {
if (sleep->surf_action_)
sleep->surf_action_->finish(resource::Action::State::FINISHED);
});
activity::ActivityImplPtr ActorImpl::sleep(double duration)
{
if (not host_->is_on())
- throw_exception(std::make_exception_ptr(simgrid::HostFailureException(
+ throw_exception(std::make_exception_ptr(HostFailureException(
XBT_THROW_POINT, std::string("Host ") + host_->get_cname() + " failed, you cannot sleep there.")));
auto sleep = new activity::SleepImpl();
void ActorImpl::simcall_answer()
{
- if (this != simix_global->maestro_process){
+ if (this != simix_global->maestro_) {
XBT_DEBUG("Answer simcall %s (%d) issued by %s (%p)", SIMIX_simcall_name(simcall.call_), (int)simcall.call_,
get_cname(), this);
simcall.call_ = SIMCALL_NONE;
return ActorImplPtr(actor);
}
-ActorImpl* ActorImpl::start(const simix::ActorCode& code)
+ActorImpl* ActorImpl::start(const ActorCode& code)
{
xbt_assert(code && host_ != nullptr, "Invalid parameters");
if (not host_->is_on()) {
XBT_WARN("Cannot launch actor '%s' on failed host '%s'", name_.c_str(), host_->get_cname());
intrusive_ptr_release(this);
- throw simgrid::HostFailureException(XBT_THROW_POINT, "Cannot start actor on failed host.");
+ throw HostFailureException(XBT_THROW_POINT, "Cannot start actor on failed host.");
}
this->code_ = code;
XBT_VERB("Create context %s", get_cname());
- context_.reset(simix_global->context_factory->create_context(simix::ActorCode(code), this));
+ context_.reset(simix_global->context_factory->create_context(ActorCode(code), this));
XBT_DEBUG("Start context '%s'", get_cname());
return this;
}
-ActorImplPtr ActorImpl::create(const std::string& name, const simix::ActorCode& code, void* data, s4u::Host* host,
+ActorImplPtr ActorImpl::create(const std::string& name, const ActorCode& code, void* data, s4u::Host* host,
const std::unordered_map<std::string, std::string>* properties, ActorImpl* parent_actor)
{
XBT_DEBUG("Start actor %s@'%s'", name.c_str(), host->get_cname());
if (parent_actor != nullptr)
actor = parent_actor->init(xbt::string(name), host);
else
- actor = SIMIX_process_self()->init(xbt::string(name), host);
+ actor = self()->init(xbt::string(name), host);
/* actor data */
actor->set_user_data(data);
ActorImpl* maestro = new ActorImpl(xbt::string(""), /*host*/ nullptr);
if (not code) {
- maestro->context_.reset(simix_global->context_factory->create_context(simix::ActorCode(), maestro));
+ maestro->context_.reset(simix_global->context_factory->create_context(ActorCode(), maestro));
} else {
- maestro->context_.reset(simix_global->context_factory->create_maestro(simix::ActorCode(code), maestro));
+ maestro->context_.reset(simix_global->context_factory->create_maestro(ActorCode(code), maestro));
}
maestro->simcall.issuer_ = maestro;
- simix_global->maestro_process = maestro;
+ simix_global->maestro_ = maestro;
}
} // namespace actor
// XBT_DEPRECATED_v329
void* SIMIX_process_self_get_data()
{
- smx_actor_t self = SIMIX_process_self();
+ smx_actor_t self = simgrid::kernel::actor::ActorImpl::self();
if (self == nullptr) {
return nullptr;
// XBT_DEPRECATED_v329
void SIMIX_process_self_set_data(void* data)
{
- SIMIX_process_self()->set_user_data(data);
+ simgrid::kernel::actor::ActorImpl::self()->set_user_data(data);
}
/* needs to be public and without simcall because it is called
by exceptions and logging events */
const char* SIMIX_process_self_get_name()
{
- return SIMIX_is_maestro() ? "maestro" : SIMIX_process_self()->get_cname();
+ return SIMIX_is_maestro() ? "maestro" : simgrid::kernel::actor::ActorImpl::self()->get_cname();
}
/**
return item->second;
}
-void SIMIX_process_on_exit(smx_actor_t actor, const std::function<void(bool /*failed*/)>& fun)
+void SIMIX_process_on_exit(smx_actor_t actor,
+ const std::function<void(bool /*failed*/)>& fun) // XBT_ATTRIB_DEPRECATED_v329
{
xbt_assert(actor, "current process not found: are you in maestro context ?");
actor->on_exit->emplace_back(fun);
* @param host where the new agent is executed.
* @param properties the properties of the process
*/
-smx_actor_t simcall_process_create(const std::string& name, const simgrid::simix::ActorCode& code, void* data,
+smx_actor_t simcall_process_create(const std::string& name, const simgrid::kernel::actor::ActorCode& code, void* data,
sg_host_t host, std::unordered_map<std::string, std::string>* properties)
{
- smx_actor_t self = SIMIX_process_self();
+ smx_actor_t self = simgrid::kernel::actor::ActorImpl::self();
return simgrid::kernel::actor::simcall([&name, &code, data, host, properties, self] {
return simgrid::kernel::actor::ActorImpl::create(name, code, data, host, properties, self).get();
});
-/* 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 SIMIX_ACTORIMPL_H
-#define SIMIX_ACTORIMPL_H
+#ifndef SIMGRID_KERNEL_ACTOR_ACTORIMPL_HPP
+#define SIMGRID_KERNEL_ACTOR_ACTORIMPL_HPP
#include "simgrid/s4u/Actor.hpp"
#include "src/simix/popping_private.hpp"
-#include "src/surf/PropertyHolder.hpp"
+#include "xbt/PropertyHolder.hpp"
#include <boost/intrusive/list.hpp>
#include <functional>
#include <list>
namespace kernel {
namespace actor {
-class XBT_PUBLIC ActorImpl : public surf::PropertyHolder {
+class XBT_PUBLIC ActorImpl : public xbt::PropertyHolder {
s4u::Host* host_ = nullptr; /* the host on which the actor is running */
// XBT_DEPRECATED_v329
void* userdata_ = nullptr; /* kept for compatibility, it should be replaced with moddata */
ActorImpl& operator=(const ActorImpl&) = delete;
~ActorImpl();
+ static ActorImpl* self();
double get_kill_time();
void set_kill_time(double kill_time);
boost::intrusive::list_member_hook<> host_actor_list_hook; /* simgrid::simix::Host::process_list */
private:
s4u::Actor piface_; // Our interface is part of ourselves
+ void cleanup_from_simix();
void undaemonize();
public:
s4u::Actor* ciface() { return &piface_; }
ActorImplPtr init(const std::string& name, s4u::Host* host);
- ActorImpl* start(const simix::ActorCode& code);
+ ActorImpl* start(const ActorCode& code);
- static ActorImplPtr create(const std::string& name, const simix::ActorCode& code, void* data, s4u::Host* host,
+ static ActorImplPtr create(const std::string& name, const ActorCode& code, void* data, s4u::Host* host,
const std::unordered_map<std::string, std::string>* properties, ActorImpl* parent_actor);
static ActorImplPtr attach(const std::string& name, void* data, s4u::Host* host,
const std::unordered_map<std::string, std::string>* properties);
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);
extern void (*SMPI_switch_data_segment)(simgrid::s4u::ActorPtr actor);
+XBT_PUBLIC smx_actor_t simcall_process_create(const std::string& name, const simgrid::kernel::actor::ActorCode& code,
+ void* data, sg_host_t host,
+ std::unordered_map<std::string, std::string>* properties);
+
#endif
-/* 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_; }
#ifndef WIN32
XBT_PUBLIC_DATA unsigned char sigsegv_stack[SIGSTKSZ];
#endif
-
-XBT_PRIVATE simgrid::simix::ActorCodeFactory& SIMIX_get_actor_code_factory(const std::string& name);
-
#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. */
#include "ContextBoost.hpp"
-#include "context_private.hpp"
#include "simgrid/Exception.hpp"
#include "src/simix/smx_private.hpp"
BoostContext::BoostContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory)
: SwappedContext(std::move(code), actor, factory)
{
-
/* 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. */
-#ifndef SIMGRID_SIMIX_BOOST_CONTEXT_HPP
-#define SIMGRID_SIMIX_BOOST_CONTEXT_HPP
+#ifndef SIMGRID_KERNEL_CONTEXT_BOOST_CONTEXT_HPP
+#define SIMGRID_KERNEL_CONTEXT_BOOST_CONTEXT_HPP
#include <boost/version.hpp>
#if BOOST_VERSION < 106100
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. */
-#ifndef SIMGRID_SIMIX_RAW_CONTEXT_HPP
-#define SIMGRID_SIMIX_RAW_CONTEXT_HPP
+#ifndef SIMGRID_KERNEL_CONTEXT_RAW_CONTEXT_HPP
+#define SIMGRID_KERNEL_CONTEXT_RAW_CONTEXT_HPP
#include <atomic>
#include <cstdint>
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_SIMIX_SWAPPED_CONTEXT_HPP
-#define SIMGRID_SIMIX_SWAPPED_CONTEXT_HPP
+#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 {
void ThreadContext::attach_start()
{
// We're breaking the layers here by depending on the upper layer:
- ThreadContext* maestro = static_cast<ThreadContext*>(simix_global->maestro_process->context_.get());
+ ThreadContext* maestro = static_cast<ThreadContext*>(simix_global->maestro_->context_.get());
maestro->begin_.release();
xbt_assert(not this->is_maestro());
this->start();
xbt_assert(not this->is_maestro());
this->yield();
- ThreadContext* maestro = static_cast<ThreadContext*>(simix_global->maestro_process->context_.get());
+ ThreadContext* maestro = static_cast<ThreadContext*>(simix_global->maestro_->context_.get());
maestro->end_.acquire();
Context::set_current(nullptr);
-/* 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 ThreadContext.hpp Context switching with native threads */
-#ifndef SIMGRID_SIMIX_THREAD_CONTEXT_HPP
-#define SIMGRID_SIMIX_THREAD_CONTEXT_HPP
+#ifndef SIMGRID_KERNEL_CONTEXT_THREAD_CONTEXT_HPP
+#define SIMGRID_KERNEL_CONTEXT_THREAD_CONTEXT_HPP
#include "simgrid/simix.hpp"
#include "src/kernel/context/Context.hpp"
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. */
-#ifndef SIMGRID_SIMIX_UNIX_CONTEXT_HPP
-#define SIMGRID_SIMIX_UNIX_CONTEXT_HPP
+#ifndef SIMGRID_KERNEL_CONTEXT_UNIX_CONTEXT_HPP
+#define SIMGRID_KERNEL_CONTEXT_UNIX_CONTEXT_HPP
#include <ucontext.h> /* context relative declarations */
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())
double min_bound = -1;
XBT_DEBUG("Active constraints : %zu", cnst_list.size());
- /* Init: Only modified code portions: reset the value of active variables */
- for (Constraint const& cnst : cnst_list) {
- for (Element const& elem : cnst.enabled_element_set_) {
- xbt_assert(elem.variable->sharing_penalty_ > 0.0);
- elem.variable->value_ = 0.0;
- }
- }
-
- ConstraintLight* cnst_light_tab = new ConstraintLight[cnst_list.size()]();
+ cnst_light_vec.reserve(cnst_list.size());
+ ConstraintLight* cnst_light_tab = cnst_light_vec.data();
int cnst_light_num = 0;
- dyn_light_t saturated_constraints;
for (Constraint& cnst : cnst_list) {
/* INIT: Collect constraints that actually need to be saturated (i.e remaining and usage are strictly positive)
continue;
cnst.usage_ = 0;
for (Element& elem : cnst.enabled_element_set_) {
- xbt_assert(elem.variable->sharing_penalty_ > 0);
+ xbt_assert(elem.variable->sharing_penalty_ > 0.0);
+ elem.variable->value_ = 0.0;
if (elem.consumption_weight > 0) {
if (cnst.sharing_policy_ != s4u::Link::SharingPolicy::FATPIPE)
cnst.usage_ += elem.consumption_weight / elem.variable->sharing_penalty_;
// 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;
}
saturated_variable_set_update(cnst_light_tab, saturated_constraints, this);
-
} while (cnst_light_num > 0);
modified_ = false;
}
check_concurrency();
-
- delete[] cnst_light_tab;
}
/** @brief Attribute the value bound to var->bound.
// Cannot use foreach loop, because System::enable_var() will modify disabled_element_set.. within the loop
while (numelem-- && elem) {
-
Element* nextelem;
if (elem->disabled_element_set_hook.is_linked()) {
auto iter = std::next(cnstr->disabled_element_set_.iterator_to(*elem));
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;
return std::count_if(std::begin(enabled_element_set_), std::end(enabled_element_set_),
[](const Element& elem) { return elem.consumption_weight > 0; });
}
-}
-}
-}
+
+} // namespace lmm
+} // namespace kernel
+} // 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. */
#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_;
inline void Element::make_inactive()
{
if (active_element_set_hook.is_linked())
- simgrid::xbt::intrusive_erase(constraint->active_element_set_, *this);
+ xbt::intrusive_erase(constraint->active_element_set_, *this);
}
/**
/** @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 remove_variable(Variable * var)
{
if (var->variable_set_hook_.is_linked())
- simgrid::xbt::intrusive_erase(variable_set, *var);
+ xbt::intrusive_erase(variable_set, *var);
if (var->saturated_variable_set_hook_.is_linked())
- simgrid::xbt::intrusive_erase(saturated_variable_set, *var);
+ xbt::intrusive_erase(saturated_variable_set, *var);
}
void make_constraint_active(Constraint * cnst)
{
void make_constraint_inactive(Constraint * cnst)
{
if (cnst->active_constraint_set_hook_.is_linked())
- simgrid::xbt::intrusive_erase(active_constraint_set, *cnst);
+ xbt::intrusive_erase(active_constraint_set, *cnst);
if (cnst->modified_constraint_set_hook_.is_linked())
- simgrid::xbt::intrusive_erase(modified_constraint_set, *cnst);
+ xbt::intrusive_erase(modified_constraint_set, *cnst);
}
void enable_var(Variable * var);
*/
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
+ std::vector<ConstraintLight> cnst_light_vec;
+ dyn_light_t saturated_constraints;
+
bool selective_update_active; /* flag to update partially the system only selecting changed portions */
unsigned visited_counter_ = 1; /* used by System::update_modified_set() and System::remove_all_modified_set() to
* cleverly (un-)flag the constraints (more details in these functions) */
XBT_PUBLIC System* make_new_fair_bottleneck_system(bool selective_update);
/** @} */
-}
-}
-}
+} // namespace lmm
+} // namespace kernel
+} // namespace simgrid
#endif
-/* 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;
return action;
}
-} // namespace surf
+} // namespace resource
} // namespace kernel
} // namespace simgrid
-/* 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. */
DiskImpl::DiskImpl(kernel::resource::Model* model, const std::string& name, kernel::lmm::System* maxminSystem,
double read_bw, double write_bw)
- : Resource(model, name, maxminSystem->constraint_new(this, std::max(read_bw, write_bw))), piface_(name, this)
+ : Resource(model, name, maxminSystem->constraint_new(this, std::max(read_bw, write_bw)))
+ , piface_(name, this)
+ , read_bw_(read_bw)
+ , write_bw_(write_bw)
{
DiskImpl::turn_on();
- XBT_DEBUG("Create resource with read_bw '%f' write_bw '%f'", read_bw, write_bw);
+ XBT_DEBUG("Create resource with read_bw '%f' write_bw '%f'", read_bw_, write_bw_);
constraint_read_ = maxminSystem->constraint_new(this, read_bw);
constraint_write_ = maxminSystem->constraint_new(this, write_bw);
}
-/* 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 "simgrid/kernel/resource/Resource.hpp"
#include "simgrid/s4u/Disk.hpp"
#include "simgrid/s4u/Io.hpp"
-#include "src/surf/PropertyHolder.hpp"
#include "src/surf/surf_interface.hpp"
+#include <xbt/PropertyHolder.hpp>
#include <map>
/*********
* Model *
*********/
-class DiskModel : public kernel::resource::Model {
+class DiskModel : public Model {
public:
DiskModel();
DiskModel(const DiskModel&) = delete;
/************
* Resource *
************/
-class DiskImpl : public Resource, public surf::PropertyHolder {
+class DiskImpl : public Resource, public xbt::PropertyHolder {
bool currently_destroying_ = false;
s4u::Host* host_ = nullptr;
s4u::Disk piface_;
+ double read_bw_;
+ double write_bw_;
public:
DiskImpl(Model* model, const std::string& name, kernel::lmm::System* maxmin_system, double read_bw, double bwrite_bw);
/** @brief Public interface */
s4u::Disk* get_iface() { return &piface_; }
+ double get_read_bandwidth() { return read_bw_; }
+ double get_write_bandwidth() { return write_bw_; }
+
/** @brief Check if the Storage is used (if an action currently uses its resources) */
bool is_used() override;
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;
}
THROW_UNIMPLEMENTED;
}
-} // namespace surf
+} // namespace resource
} // namespace kernel
} // 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. */
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. */
TEST_CASE("kernel::profile: Resource profiles, defining the external load", "kernel::profile")
{
-
SECTION("No event, no loop")
{
std::vector<simgrid::kernel::profile::DatedValue> got = trace2vector("");
SECTION("Three events, no loop")
{
-
std::vector<simgrid::kernel::profile::DatedValue> got = trace2vector("3.0 1.0\n"
"5.0 2.0\n"
"9.0 3.0\n");
-/* 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. */
}
if (not dst->is_router()) { // No specific link for router
-
std::pair<resource::LinkImpl*, resource::LinkImpl*> info =
private_links_.at(node_pos_with_loopback_limiter(dst->id()));
+
if (info.second) { // link down
route->link_list.push_back(info.second);
if (lat)
}
}
-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;
}
for (unsigned int j = 0; j < this->nodes_by_level_[i]; j++) {
-
if (XBT_LOG_ISENABLED(surf_route_fat_tree, xbt_log_priority_debug)) {
std::stringstream msgBuffer;
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;
}
uniqueId++;
}
-}
-}
-} // 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. */
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,
* not the ones contained in sub-netzones.
*/
-std::vector<s4u::Host*> NetZoneImpl::get_all_hosts()
+std::vector<s4u::Host*> NetZoneImpl::get_all_hosts() const
{
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);
}
return res;
}
-int NetZoneImpl::get_host_count()
+int NetZoneImpl::get_host_count() const
{
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; }
this->read_bytes(&res[0], len, address);
return res;
}
-
};
}
-/* 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:
+public:
ModelChecker(ModelChecker const&) = delete;
ModelChecker& operator=(ModelChecker const&) = delete;
explicit ModelChecker(std::unique_ptr<RemoteClient> process);
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. */
#include "src/mc/Session.hpp"
#include "src/mc/checker/Checker.hpp"
#include "src/mc/mc_config.hpp"
+#include "src/internal_config.h" // HAVE_SMPI
+#if HAVE_SMPI
+#include "smpi/smpi.h"
+#endif
#include "src/mc/mc_private.hpp"
#include "src/mc/mc_state.hpp"
#include "xbt/log.h"
static void setup_child_environment(int socket)
{
+ /* On startup, simix_global_init() calls simgrid::mc::Client::initialize(), which checks whether the MC_ENV_SOCKET_FD
+ * env variable is set. If so, MC mode is assumed, and the client is setup from its side
+ */
+
#ifdef __linux__
// Make sure we do not outlive our parent
sigset_t mask;
Session::Session(const std::function<void()>& code)
{
#if HAVE_SMPI
- xbt_assert(smpi_privatize_global_variables != SmpiPrivStrategies::MMAP,
+ smpi_init_options();//only performed once
+ xbt_assert(smpi_cfg_privatization() != SmpiPrivStrategies::MMAP,
"Please use the dlopen privatization schema when model-checking SMPI code");
#endif
::close(sockets[1]);
setup_child_environment(sockets[0]);
code();
- xbt_die("The model-checked process failed to exec()");
+ xbt_die("The model-checked process failed to exec(): %s", strerror(errno));
}
// Parent (model-checker):
this->close();
}
+/** Take the initial snapshot of the application, that must be stopped. */
void Session::initialize()
{
xbt_assert(initial_snapshot_ == nullptr);
}
if (getenv("SIMGRID_MC_SYSTEM_STATISTICS")){
int ret=system("free");
- if(ret!=0)XBT_WARN("system call did not return 0, but %d",ret);
+ if (ret != 0)
+ XBT_WARN("Call to system(free) did not return 0, but %d", ret);
}
}
-/* 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
// abstract
class Checker {
Session* session_;
+
public:
explicit Checker(Session& session);
-/* 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();
-
this->real_run();
}
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:
void get_comm_pattern(smx_simcall_t request, e_mc_call_type_t call_type, int backtracking);
-/* 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
#include "src/mc/checker/Checker.hpp"
#include "src/mc/mc_config.hpp"
#include "src/mc/mc_exit.hpp"
+#include "src/internal_config.h"
+
+#if HAVE_SMPI
+#include "smpi/smpi.h"
+#endif
#include <cstring>
#include <memory>
_sg_do_model_check = 1;
// The initialization function can touch argv.
- // We make a copy of argv before modifying it in order to pass the original
- // value to the model-checked:
+ // We make a copy of argv before modifying it in order to pass the original value to the model-checked application:
char** argv_copy = argvdup(argc, argv);
xbt_log_init(&argc, argv);
+#if HAVE_SMPI
+ smpi_init_options(); // only performed once
+#endif
sg_config_init(&argc, argv);
-
- simgrid::mc::session = new simgrid::mc::Session([argv_copy] { execvp(argv_copy[1], argv_copy + 1); });
+ simgrid::mc::session = new simgrid::mc::Session([argv_copy] {
+ int i = 1;
+ while (argv_copy[i] != nullptr && argv_copy[i][0] == '-')
+ i++;
+ xbt_assert(argv_copy[i] != nullptr,
+ "Unable to find a binary to exec on the command line. Did you only pass config flags?");
+ execvp(argv_copy[i], argv_copy + i);
+ });
delete[] argv_copy;
- std::unique_ptr<simgrid::mc::Checker> checker = create_checker(*simgrid::mc::session);
- int res = SIMGRID_MC_EXIT_SUCCESS;
+ auto checker = create_checker(*simgrid::mc::session);
+ int res = SIMGRID_MC_EXIT_SUCCESS;
try {
checker->run();
} catch (const simgrid::mc::DeadlockError&) {
-/* 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;
snapshot2.read<malloc_info*>(RemotePtr<malloc_info*>((std::uint64_t)heapinfo_address));
while (i1 < state.heaplimit) {
-
const malloc_info* heapinfo1 =
(const malloc_info*)heap_region1->read(&heapinfo_temp1, &heapinfos1[i1], sizeof(malloc_info));
const malloc_info* heapinfo2 =
void* addr_block1 = ((void*)(((ADDR2UINT(i1)) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase));
- if (heapinfo1->type == MMALLOC_TYPE_UNFRAGMENTED) { /* Large block */
-
+ if (heapinfo1->type == MMALLOC_TYPE_UNFRAGMENTED) { /* Large block */
if (is_stack(addr_block1)) {
for (size_t k = 0; k < heapinfo1->busy_block.size; k++)
state.equals_to_<1>(i1 + k, 0) = HeapArea(i1, -1);
/* 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;
}
while (i2 < state.heaplimit && not equal) {
-
const malloc_info* heapinfo2b =
(const malloc_info*)heap_region2->read(&heapinfo_temp2b, &heapinfos2[i2], sizeof(malloc_info));
xbt_assert(heapinfo2b->type >= 0, "Unkown mmalloc block type: %d", heapinfo2b->type);
for (size_t j2 = 0; j2 < (size_t)(BLOCKSIZE >> heapinfo2b->type); j2++) {
-
if (i2 == i1 && j2 == j1)
continue;
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) {
ssize_t ignore1 = heap_comparison_ignore_size(state.processStates[0].to_ignore, (const char*)real_area1 + i);
if (ignore1 != -1) {
if (MC_snapshot_region_memcmp((const char*)real_area1 + i, heap_region1, (const char*)real_area2 + i, heap_region2,
1) != 0) {
-
int pointer_align = (i / sizeof(void *)) * sizeof(void *);
const void* addr_pointed1 = snapshot1.read(remote((void* const*)((const char*)real_area1 + pointer_align)));
const void* addr_pointed2 = snapshot2.read(remote((void* const*)((const char*)real_area2 + pointer_align)));
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:
case DW_TAG_class_type:
if (type->full_type)
type = type->full_type;
+ if (type->byte_size == 0)
+ return false;
if (area_size != -1 && type->byte_size != area_size) {
if (area_size <= type->byte_size || area_size % type->byte_size != 0)
return false;
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 type;
switch (type->type) {
-
case DW_TAG_structure_type:
case DW_TAG_class_type:
if (type->full_type)
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;
}
default:
/* FIXME: other cases ? */
return nullptr;
-
}
}
* @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 = -1;
else
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 */
-
// Fragment number:
ssize_t frag1 = ((uintptr_t)(ADDR2UINT(area1) % (BLOCKSIZE))) >> heapinfo1->type;
ssize_t frag2 = ((uintptr_t)(ADDR2UINT(area2) % (BLOCKSIZE))) >> heapinfo2->type;
}
// 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;
return areas_differ_with_type(state, addr_pointed1, snapshot1, region1, addr_pointed2, snapshot2, region2,
type->subtype, pointer_level);
} else {
-
// TODO, We do not handle very well the case where
// it belongs to a different (non-heap) region from the current one.
}
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.");
const std::vector<simgrid::mc::Variable>& variables = object_info->global_variables;
for (simgrid::mc::Variable const& current_var : variables) {
-
// If the variable is not in this object, skip it:
// We do not expect to find a pointer to something which is not reachable
// by the global variables.
|| (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;
for (res = dwarf_child(die, &child); res == 0; res = dwarf_siblingof(&child, &child)) {
int tag = dwarf_tag(&child);
if (tag == DW_TAG_member || tag == DW_TAG_inheritance) {
-
// Skip declarations:
if (MC_dwarf_attr_flag(&child, DW_AT_declaration, false))
continue;
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);
Dwarf_Addr high_pc;
switch (simgrid::dwarf::classify_form(dwarf_whatform(&attr))) {
-
- // DW_AT_high_pc if an offset from the low_pc:
+ // DW_AT_high_pc if an offset from the low_pc:
case simgrid::dwarf::FormClass::Constant:
xbt_assert(dwarf_formsdata(&attr, &offset) == 0, "Could not read constant");
int tag = dwarf_tag(die);
simgrid::dwarf::TagClass klass = simgrid::dwarf::classify_tag(tag);
switch (klass) {
-
- // Type:
+ // Type:
case simgrid::dwarf::TagClass::Type:
MC_dwarf_handle_type_die(info, die, unit, frame, ns);
break;
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;
static void mc_post_process_scope(simgrid::mc::ObjectInformation* info, simgrid::mc::Frame* scope)
{
-
if (scope->tag == DW_TAG_inlined_subroutine) {
// Attach correct namespaced name in inlined subroutine:
auto i = info->subprograms.find(scope->abstract_origin_id);
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. */
default:
xbt_die("Unexpected call type %i", (int)call_type);
}
-
}
-/* 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. */
fprintf(dot_output,
"digraph graphname{\n fixedsize=true; rankdir=TB; ranksep=.25; edge [fontsize=12]; node [fontsize=10, shape=circle,width=.5 ]; graph [resolution=20, fontsize=10];\n");
-
}
/******************************* Core of MC *******************************/
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))
const char* current = data;
while (*current) {
-
simgrid::mc::Transition item;
int count = sscanf(current, "%d/%d", &item.pid_, &item.argument_);
+
if(count != 2 && count != 1)
throw std::invalid_argument("Could not parse record path");
res.push_back(item);
-/* 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. */
using simgrid::mc::remote;
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_request, mc,
- "Logging specific to MC (request)");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_request, mc, "Logging specific to MC (request)");
static char *pointer_to_string(void *pointer);
static char *buff_size_to_string(size_t size);
if (r1->call_ == SIMCALL_COMM_IRECV && r2->call_ == SIMCALL_COMM_ISEND)
return false;
- // Those are internal requests, we do not need indirection
- // because those objects are copies:
- simgrid::kernel::activity::CommImpl* synchro1 = MC_get_comm(r1);
- simgrid::kernel::activity::CommImpl* synchro2 = MC_get_comm(r2);
+ // Those are internal requests, we do not need indirection because those objects are copies:
+ 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 false;
}
- /* FIXME: the following rule assumes that the result of the
- * isend/irecv call is not stored in a buffer used in the
+ /* FIXME: the following rule assumes that the result of the isend/irecv call is not stored in a buffer used in the
* test call. */
#if 0
if((r1->call == SIMCALL_COMM_ISEND || r1->call == SIMCALL_COMM_IRECV)
- && r2->call == SIMCALL_COMM_TEST)
- return false;
+ && r2->call == SIMCALL_COMM_TEST)
+ return false;
#endif
if (r1->call_ == SIMCALL_COMM_WAIT && (r2->call_ == SIMCALL_COMM_WAIT || r2->call_ == SIMCALL_COMM_TEST) &&
if (req1->call_ != req2->call_)
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:
- simgrid::kernel::activity::CommImpl* synchro1 = MC_get_comm(req1);
- simgrid::kernel::activity::CommImpl* synchro2 = MC_get_comm(req2);
+ // Those are internal requests, we do not need indirection because those objects are copies:
+ 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:
}
}
-}
-}
+} // namespace mc
+} // namespace simgrid
static char *pointer_to_string(void *pointer)
{
-
if (XBT_LOG_ISENABLED(mc_request, xbt_log_priority_verbose))
return bprintf("%p", pointer);
static char *buff_size_to_string(size_t buff_size)
{
-
if (XBT_LOG_ISENABLED(mc_request, xbt_log_priority_verbose))
return bprintf("%zu", buff_size);
smx_actor_t issuer = MC_smx_simcall_get_issuer(req);
switch (req->call_) {
-
case SIMCALL_COMM_ISEND: {
type = "iSend";
char* p = pointer_to_string(simcall_comm_isend__get__src_buff(req));
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;
bool request_is_enabled_by_idx(smx_simcall_t req, unsigned int idx)
{
- simgrid::kernel::activity::CommImpl* remote_act = nullptr;
+ kernel::activity::CommImpl* remote_act = nullptr;
switch (req->call_) {
-
case SIMCALL_COMM_WAIT:
/* FIXME: check also that src and dst processes are not suspended */
remote_act = simcall_comm_wait__getraw__comm(req);
return true;
}
- simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
+ Remote<kernel::activity::CommImpl> temp_comm;
mc_model_checker->process().read(temp_comm, remote(remote_act));
- simgrid::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();
}
-
static const char* colors[] = {
- "blue",
- "red",
- "green3",
- "goldenrod",
- "brown",
- "purple",
- "magenta",
- "turquoise4",
- "gray25",
- "forestgreen",
- "hotpink",
- "lightblue",
- "tan",
+ "blue", "red", "green3", "goldenrod", "brown", "purple", "magenta",
+ "turquoise4", "gray25", "forestgreen", "hotpink", "lightblue", "tan",
};
static inline const char* get_color(int id)
switch (req->call_) {
case SIMCALL_COMM_ISEND:
if (issuer->get_host())
- label = simgrid::xbt::string_printf("[(%ld)%s] iSend", issuer->get_pid(), MC_smx_actor_get_host_name(issuer));
+ label = xbt::string_printf("[(%ld)%s] iSend", issuer->get_pid(), MC_smx_actor_get_host_name(issuer));
else
label = bprintf("[(%ld)] iSend", issuer->get_pid());
break;
case SIMCALL_COMM_IRECV:
if (issuer->get_host())
- label = simgrid::xbt::string_printf("[(%ld)%s] iRecv", issuer->get_pid(), MC_smx_actor_get_host_name(issuer));
+ label = xbt::string_printf("[(%ld)%s] iRecv", issuer->get_pid(), MC_smx_actor_get_host_name(issuer));
else
- label = simgrid::xbt::string_printf("[(%ld)] iRecv", issuer->get_pid());
+ label = xbt::string_printf("[(%ld)] iRecv", issuer->get_pid());
break;
case SIMCALL_COMM_WAIT:
if (value == -1) {
if (issuer->get_host())
- label = simgrid::xbt::string_printf("[(%ld)%s] WaitTimeout", issuer->get_pid(),
- MC_smx_actor_get_host_name(issuer));
+ label = xbt::string_printf("[(%ld)%s] WaitTimeout", issuer->get_pid(), MC_smx_actor_get_host_name(issuer));
else
- label = simgrid::xbt::string_printf("[(%ld)] WaitTimeout", issuer->get_pid());
+ label = xbt::string_printf("[(%ld)] WaitTimeout", issuer->get_pid());
} else {
- simgrid::kernel::activity::ActivityImpl* remote_act = simcall_comm_wait__getraw__comm(req);
- simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
- mc_model_checker->process().read(temp_comm,
- remote(static_cast<simgrid::kernel::activity::CommImpl*>(remote_act)));
- 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()));
+ 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)));
+ const kernel::activity::CommImpl* comm = temp_comm.get_buffer();
+
+ 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 = simgrid::xbt::string_printf("[(%ld)%s] Wait [(%ld)->(%ld)]", issuer->get_pid(),
- MC_smx_actor_get_host_name(issuer), src_proc ? src_proc->get_pid() : 0,
- dst_proc ? dst_proc->get_pid() : 0);
+ label =
+ xbt::string_printf("[(%ld)%s] Wait [(%ld)->(%ld)]", issuer->get_pid(), MC_smx_actor_get_host_name(issuer),
+ src_proc ? src_proc->get_pid() : 0, dst_proc ? dst_proc->get_pid() : 0);
else
- label = simgrid::xbt::string_printf("[(%ld)] Wait [(%ld)->(%ld)]", issuer->get_pid(),
- src_proc ? src_proc->get_pid() : 0, dst_proc ? dst_proc->get_pid() : 0);
+ label = xbt::string_printf("[(%ld)] Wait [(%ld)->(%ld)]", issuer->get_pid(),
+ src_proc ? src_proc->get_pid() : 0, dst_proc ? dst_proc->get_pid() : 0);
}
break;
case SIMCALL_COMM_TEST: {
- simgrid::kernel::activity::ActivityImpl* remote_act = simcall_comm_test__getraw__comm(req);
- simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
- mc_model_checker->process().read(temp_comm,
- remote(static_cast<simgrid::kernel::activity::CommImpl*>(remote_act)));
- simgrid::kernel::activity::CommImpl* comm = temp_comm.get_buffer();
+ 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)));
+ 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 = simgrid::xbt::string_printf("[(%ld)%s] Test FALSE", issuer->get_pid(),
- MC_smx_actor_get_host_name(issuer));
+ label = xbt::string_printf("[(%ld)%s] Test FALSE", issuer->get_pid(), MC_smx_actor_get_host_name(issuer));
else
label = bprintf("[(%ld)] Test FALSE", issuer->get_pid());
} else {
if (issuer->get_host())
- label =
- simgrid::xbt::string_printf("[(%ld)%s] Test TRUE", issuer->get_pid(), MC_smx_actor_get_host_name(issuer));
+ label = xbt::string_printf("[(%ld)%s] Test TRUE", issuer->get_pid(), MC_smx_actor_get_host_name(issuer));
else
- label = simgrid::xbt::string_printf("[(%ld)] Test TRUE", issuer->get_pid());
+ label = xbt::string_printf("[(%ld)] Test TRUE", issuer->get_pid());
}
break;
}
case SIMCALL_COMM_WAITANY: {
size_t comms_size = simcall_comm_waitany__get__count(req);
if (issuer->get_host())
- label = simgrid::xbt::string_printf("[(%ld)%s] WaitAny [%d of %zu]", issuer->get_pid(),
- MC_smx_actor_get_host_name(issuer), value + 1, comms_size);
+ label = xbt::string_printf("[(%ld)%s] WaitAny [%d of %zu]", issuer->get_pid(),
+ MC_smx_actor_get_host_name(issuer), value + 1, comms_size);
else
- label = simgrid::xbt::string_printf("[(%ld)] WaitAny [%d of %zu]", issuer->get_pid(), value + 1, comms_size);
+ label = xbt::string_printf("[(%ld)] WaitAny [%d of %zu]", issuer->get_pid(), value + 1, comms_size);
break;
}
case SIMCALL_COMM_TESTANY:
if (value == -1) {
if (issuer->get_host())
- label = simgrid::xbt::string_printf("[(%ld)%s] TestAny FALSE", issuer->get_pid(),
- MC_smx_actor_get_host_name(issuer));
+ label = xbt::string_printf("[(%ld)%s] TestAny FALSE", issuer->get_pid(), MC_smx_actor_get_host_name(issuer));
else
- label = simgrid::xbt::string_printf("[(%ld)] TestAny FALSE", issuer->get_pid());
+ label = xbt::string_printf("[(%ld)] TestAny FALSE", issuer->get_pid());
} else {
if (issuer->get_host())
- label = simgrid::xbt::string_printf("[(%ld)%s] TestAny TRUE [%d of %lu]", issuer->get_pid(),
- MC_smx_actor_get_host_name(issuer), value + 1,
- simcall_comm_testany__get__count(req));
+ label =
+ xbt::string_printf("[(%ld)%s] TestAny TRUE [%d of %lu]", issuer->get_pid(),
+ MC_smx_actor_get_host_name(issuer), value + 1, simcall_comm_testany__get__count(req));
else
- label = simgrid::xbt::string_printf("[(%ld)] TestAny TRUE [%d of %lu]", issuer->get_pid(), value + 1,
- simcall_comm_testany__get__count(req));
+ label = xbt::string_printf("[(%ld)] TestAny TRUE [%d of %lu]", issuer->get_pid(), value + 1,
+ simcall_comm_testany__get__count(req));
}
break;
case SIMCALL_MUTEX_TRYLOCK:
- label = simgrid::xbt::string_printf("[(%ld)] Mutex TRYLOCK", issuer->get_pid());
+ label = xbt::string_printf("[(%ld)] Mutex TRYLOCK", issuer->get_pid());
break;
case SIMCALL_MUTEX_LOCK:
- label = simgrid::xbt::string_printf("[(%ld)] Mutex LOCK", issuer->get_pid());
+ label = xbt::string_printf("[(%ld)] Mutex LOCK", issuer->get_pid());
break;
case SIMCALL_MC_RANDOM:
if (issuer->get_host())
- label = simgrid::xbt::string_printf("[(%ld)%s] MC_RANDOM (%d)", issuer->get_pid(),
- MC_smx_actor_get_host_name(issuer), value);
+ label = xbt::string_printf("[(%ld)%s] MC_RANDOM (%d)", issuer->get_pid(), MC_smx_actor_get_host_name(issuer),
+ value);
else
- label = simgrid::xbt::string_printf("[(%ld)] MC_RANDOM (%d)", issuer->get_pid(), value);
+ label = xbt::string_printf("[(%ld)] MC_RANDOM (%d)", issuer->get_pid(), value);
break;
default:
THROW_UNIMPLEMENTED;
}
- return simgrid::xbt::string_printf(
- "label = \"%s\", color = %s, fontcolor = %s", label.c_str(),
- color, color);
+ return xbt::string_printf("label = \"%s\", color = %s, fontcolor = %s", label.c_str(), color, color);
}
-}
-}
+} // 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. 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)
{
// Load each element of the vector from the MCed process:
for (unsigned int i = 0; i < dynar.used; ++i) {
-
simgrid::mc::ActorInformation info;
+
info.address = simgrid::mc::RemotePtr<simgrid::kernel::actor::ActorImpl>(data[i]);
info.hostname = nullptr;
process->read_bytes(&info.copy, sizeof(info.copy), remote(data[i]));
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. */
"libm",
"libomp",
"libpapi",
+ "libpcre2",
"libpfm",
"libpgmath",
"libpthread",
"libunwind-ptrace",
"libunwind-x86",
"libunwind-x86_64",
- "libz"};
+ "libz",
+ "libkrb5support", /*odd behaviour on fedora rawhide ... remove these when fixed*/
+ "libkeyutils",
+ "libunistring",
+ "libbrotlidec",
+ "liblber",
+ "libldap",
+ "libcom_err",
+ "libk5crypto",
+ "libkrb5",
+ "libgssapi_krb5",
+ "libssl",
+ "libpsl",
+ "libssh",
+ "libidn2",
+ "libnghttp2",
+ "libcurl",
+ "libdebuginfod",
+ "libbrotlicommon",
+ "libsasl2",
+ "libresolv",
+ "libcrypt",
+ "libselinux"
+};
static bool is_simgrid_lib(const std::string& libname)
{
this->init_memory_map_info();
int fd = open_vm(this->pid_, O_RDWR);
- if (fd < 0)
- xbt_die("Could not open file for process virtual address space");
+ xbt_assert(fd >= 0, "Could not open file for process virtual address space");
this->memory_file = fd;
// Read std_heap (is a struct mdesc*):
const simgrid::mc::Variable* std_heap_var = this->find_variable("__mmalloc_default_mdp");
- if (not std_heap_var)
- xbt_die("No heap information in the target process");
- if (not std_heap_var->address)
- xbt_die("No constant address for this variable");
+ xbt_assert(std_heap_var, "No heap information in the target process");
+ xbt_assert(std_heap_var->address, "No constant address for this variable");
this->read_bytes(&this->heap_address, sizeof(mdesc*), remote(std_heap_var->address));
this->smx_actors_infos.clear();
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);
for (size_t i = 0; i != page_count; ++i) {
-
RemotePtr<void> page = remote((void*)simgrid::mc::mmu::join(i, addr.address()));
xbt_assert(simgrid::mc::mmu::split(page.address()).second == 0, "Not at the beginning of a page");
-/* 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_whole_region()
{
for (int n = 1; n != 32; ++n) {
-
prologue_return ret = prologue(n);
INFO("Unexpected match in MC_snapshot_region_memcmp() with previous snapshot");
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. */
* @brief Initialize MSG with less verifications
* You should use the MSG_init() function instead. Failing to do so may turn into PEBKAC some day. You've been warned.
*/
-void MSG_init_nocheck(int *argc, char **argv) {
-
+void MSG_init_nocheck(int* argc, char** argv)
+{
TRACE_global_init();
if (not msg_global) {
atexit(MSG_exit);
}
-void MSG_config(const char *key, const char *value){
+void MSG_config(const char* key, const char* value)
+{
xbt_assert(msg_global,"ERROR: Please call MSG_init() before using MSG_config()");
simgrid::config::set_as_string(key, value);
}
-static void MSG_exit() {
+static void MSG_exit()
+{
delete msg_global;
msg_global = nullptr;
}
-/* 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/Exception.hpp"
+#include "simgrid/s4u/Engine.hpp"
#include "src/msg/msg_private.hpp"
+#include "xbt/functional.hpp"
#define MSG_CALL(type, oldname, args)
simgrid_run();
return MSG_OK;
}
-void MSG_function_register(const char* name, xbt_main_func_t code)
+void MSG_function_register(const char* name, int (*code)(int, char**))
{
- simgrid_register_function(name, code);
+ simgrid::s4u::Engine::get_instance()->register_function(
+ name, [code](std::vector<std::string> args) { return simgrid::xbt::wrap_main(code, std::move(args)); });
}
-void MSG_function_register_default(xbt_main_func_t code)
+void MSG_function_register_default(int (*code)(int, char**))
{
- simgrid_register_default(code);
+ simgrid::s4u::Engine::get_instance()->register_default(
+ [code](std::vector<std::string> args) { return simgrid::xbt::wrap_main(code, std::move(args)); });
}
double MSG_get_clock()
{
}
/* ************************** 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. */
#include "msg_private.hpp"
#include "simgrid/Exception.hpp"
#include "simgrid/s4u/Host.hpp"
-#include "src/instr/instr_private.hpp"
#include "src/simix/smx_private.hpp"
-std::string instr_pid(simgrid::s4u::Actor const& proc)
-{
- return std::string(proc.get_name()) + "-" + std::to_string(proc.get_pid());
-}
-
/******************************** Process ************************************/
/** @brief Creates and runs a new #msg_process_t.
*
* Does exactly the same as #MSG_process_create_with_arguments but without providing standard arguments
* (@a argc, @a argv, @a start_time, @a kill_time).
*/
-msg_process_t MSG_process_create(const char *name, xbt_main_func_t code, void *data, msg_host_t host)
+msg_process_t MSG_process_create(const char* name, int (*code)(int, char**), void* data, msg_host_t host)
{
return MSG_process_create_with_environment(name == nullptr ? "" : name, code, data, host, 0, nullptr, nullptr);
}
* @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
*/
-msg_process_t MSG_process_create_with_arguments(const char *name, xbt_main_func_t code, void *data, msg_host_t host,
- int argc, char **argv)
+msg_process_t MSG_process_create_with_arguments(const char* name, int (*code)(int, char**), void* data, msg_host_t host,
+ int argc, char** argv)
{
return MSG_process_create_with_environment(name, code, data, host, argc, argv, nullptr);
}
* @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
* @see msg_process_t
* @return The new corresponding object.
*/
-msg_process_t 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)
+msg_process_t MSG_process_create_with_environment(const char* name, int (*code)(int, char**), void* data,
+ msg_host_t host, int argc, char** argv, xbt_dict_t properties)
{
xbt_assert(host != nullptr, "Invalid parameters: host param must not be nullptr");
sg_actor_t actor = sg_actor_init(std::move(name), host);
xbt_dict_foreach (properties, cursor, key, value)
actor->set_property(key, value);
}
- sg_actor_start(actor, code, argc, argv);
+ actor->start(std::move(simgrid::xbt::wrap_main(code, argc, argv)));
} catch (simgrid::HostFailureException const&) {
xbt_die("Could not launch a new process on failed host %s.", host->get_cname());
}
-/* 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) {
// Task in progress
* 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_;
local_disk_->extension<FileSystemDiskExt>()->decr_used_size(size_);
// Remove the file from storage
- content->erase(fullpath_);
+ content->erase(path_);
return 0;
}
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;
public:
explicit Conservative(simgrid::s4u::Host* ptr) : Governor(ptr) {}
- virtual std::string get_name() const override { return "Conservative"; }
+ std::string get_name() const override { return "Conservative"; }
- virtual void update() override
+ void update() override
{
double load = get_host()->get_core_count() * sg_host_get_avg_load(get_host());
int pstate = get_host()->get_pstate();
// 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();
}
});
}
- virtual std::string get_name() const override { return "Adagio"; }
+ std::string get_name() const override { return "Adagio"; }
void pre_task()
{
task_id++;
}
- virtual void update() override {}
+ void update() override {}
};
#endif
} // namespace dvfs
-/* 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
};
class HostEnergy {
+ simgrid::s4u::Host* host_ = nullptr;
+ /*< List of (idle_power, epsilon_power, max_power) tuple corresponding to each cpu pstate */
+ std::vector<PowerRange> power_range_watts_list_;
+
+ /* We need to keep track of what pstate has been used, as we will sometimes be notified only *after* a pstate has been
+ * used (but we need to update the energy consumption with the old pstate!)
+ */
+ 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
+ */
+ bool host_was_used_ = false;
+
+ void init_watts_range_list();
friend void ::on_simulation_end(); // For access to host_was_used_
+
public:
static simgrid::xbt::Extension<simgrid::s4u::Host, HostEnergy> EXTENSION_ID;
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();
-
-private:
- void init_watts_range_list();
- simgrid::s4u::Host* host_ = nullptr;
- /*< List of (idle_power, epsilon_power, max_power) tuple corresponding to each cpu pstate */
- std::vector<PowerRange> power_range_watts_list_;
-
- /* We need to keep track of what pstate has been used, as we will sometimes be notified only *after* a pstate has been
- * used (but we need to update the energy consumption with the old pstate!)
- */
- int pstate_ = 0;
- const int pstate_off_ = -1;
-
- /* 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
- */
- bool host_was_used_ = false;
-public:
- 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();
for (simgrid::kernel::resource::Cpu* const& cpu : action.cpus()) {
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();
}
}
double used_hosts_energy = 0.0; // Energy consumed by hosts that computed something
for (size_t i = 0; i < hosts.size(); i++) {
if (dynamic_cast<simgrid::s4u::VirtualMachine*>(hosts[i]) == nullptr) { // Ignore virtual machines
-
double energy = hosts[i]->extension<HostEnergy>()->get_consumed_energy();
total_energy += energy;
if (hosts[i]->extension<HostEnergy>()->host_was_used_)
/** @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;
auto current_iter = iter;
++iter;
- if (action != nullptr && action->get_finish_time() != now && activity->state_ == e_smx_state_t::SIMIX_RUNNING) {
+ if (action != nullptr && action->get_finish_time() != now && activity->state_ == kernel::activity::State::RUNNING) {
if (remaining_cost_after_last_update == activity_uninitialized_remaining_cost) {
remaining_cost_after_last_update = action->get_cost();
}
double computed_flops_since_last_update = remaining_cost_after_last_update - /*remaining now*/activity->get_remaining();
computed_flops_ += computed_flops_since_last_update;
remaining_cost_after_last_update = activity->get_remaining();
- }
- else if (activity->state_ == e_smx_state_t::SIMIX_DONE) {
+ } else if (activity->state_ == kernel::activity::State::DONE) {
computed_flops_ += remaining_cost_after_last_update;
current_activities.erase(current_iter);
}
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:");
double clock_sta = s4u::Engine::get_clock();
- s4u::Activity* comm = nullptr;
+ s4u::CommPtr comm = mbox->put_init(msg, size);
+ if (mig_speed > 0)
+ comm->set_rate(mig_speed);
try {
- if (mig_speed > 0)
- comm = mbox->put_init(msg, size)->set_rate(mig_speed)->wait_for(timeout);
- else
- comm = mbox->put_async(msg, size)->wait_for(timeout);
- } catch (const Exception&) {
- if (comm) {
- sg_size_t remaining = static_cast<sg_size_t>(comm->get_remaining());
- XBT_VERB("timeout (%lf s) in sending_migration_data, remaining %llu bytes of %llu", timeout, remaining, size);
- sent -= remaining;
- }
+ comm->wait_for(timeout);
+ } catch (const simgrid::TimeoutException&) {
+ sg_size_t remaining = static_cast<sg_size_t>(comm->get_remaining());
+ XBT_VERB("timeout (%lf s) in sending_migration_data, remaining %llu bytes of %llu", timeout, remaining, size);
+ sent -= remaining;
delete msg;
}
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. */
{
on_start(*this);
- simgrid::kernel::actor::simcall([this]() {
- simgrid::vm::VmHostExt::ensureVmExtInstalled();
+ kernel::actor::simcall([this]() {
+ vm::VmHostExt::ensureVmExtInstalled();
- simgrid::s4u::Host* pm = this->pimpl_vm_->get_physical_host();
- if (pm->extension<simgrid::vm::VmHostExt>() == nullptr)
- pm->extension_set(new simgrid::vm::VmHostExt());
+ Host* pm = this->pimpl_vm_->get_physical_host();
+ if (pm->extension<vm::VmHostExt>() == nullptr)
+ pm->extension_set(new vm::VmHostExt());
- long pm_ramsize = pm->extension<simgrid::vm::VmHostExt>()->ramsize;
- int pm_overcommit = pm->extension<simgrid::vm::VmHostExt>()->overcommit;
+ long pm_ramsize = pm->extension<vm::VmHostExt>()->ramsize;
+ int pm_overcommit = pm->extension<vm::VmHostExt>()->overcommit;
long vm_ramsize = this->get_ramsize();
if (pm_ramsize && not pm_overcommit) { /* Only verify that we don't overcommit on need */
/* Retrieve the memory occupied by the VMs on that host. Yep, we have to traverse all VMs of all hosts for that */
long total_ramsize_of_vms = 0;
- for (simgrid::s4u::VirtualMachine* const& ws_vm : simgrid::vm::VirtualMachineImpl::allVms_)
+ for (VirtualMachine* const& ws_vm : vm::VirtualMachineImpl::allVms_)
if (pm == ws_vm->get_pm())
total_ramsize_of_vms += ws_vm->get_ramsize();
void VirtualMachine::suspend()
{
on_suspend(*this);
- smx_actor_t issuer = SIMIX_process_self();
- simgrid::kernel::actor::simcall([this, issuer]() { pimpl_vm_->suspend(issuer); });
+ kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
+ kernel::actor::simcall([this, issuer]() { pimpl_vm_->suspend(issuer); });
}
void VirtualMachine::resume()
void VirtualMachine::shutdown()
{
- smx_actor_t issuer = SIMIX_process_self();
- simgrid::kernel::actor::simcall([this, issuer]() { pimpl_vm_->shutdown(issuer); });
+ kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
+ kernel::actor::simcall([this, issuer]() { pimpl_vm_->shutdown(issuer); });
on_shutdown(*this);
}
Host::destroy();
}
-simgrid::s4u::Host* VirtualMachine::get_pm()
+simgrid::s4u::Host* VirtualMachine::get_pm() const
{
return pimpl_vm_->get_physical_host();
}
void VirtualMachine::set_pm(simgrid::s4u::Host* pm)
{
- simgrid::kernel::actor::simcall([this, pm]() { pimpl_vm_->set_physical_host(pm); });
+ kernel::actor::simcall([this, pm]() { pimpl_vm_->set_physical_host(pm); });
}
VirtualMachine::state VirtualMachine::get_state()
{
- return simgrid::kernel::actor::simcall([this]() { return pimpl_vm_->get_state(); });
+ 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();
}
*/
void VirtualMachine::set_bound(double bound)
{
- simgrid::kernel::actor::simcall([this, bound]() { pimpl_vm_->set_bound(bound); });
+ kernel::actor::simcall([this, bound]() { pimpl_vm_->set_bound(bound); });
}
} // namespace simgrid
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. */
wait_for(time_limit - now);
}
-double Activity::get_remaining()
+double Activity::get_remaining() const
{
return remains_;
}
-/* 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 "simgrid/s4u/Host.hpp"
#include "simgrid/s4u/VirtualMachine.hpp"
#include "src/include/mc/mc.h"
+#include "src/kernel/EngineImpl.hpp"
#include "src/kernel/activity/ExecImpl.hpp"
#include "src/mc/mc_replay.hpp"
#include "src/surf/HostImpl.hpp"
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::init(const std::string& name, s4u::Host* host)
{
- kernel::actor::ActorImpl* self = SIMIX_process_self();
+ kernel::actor::ActorImpl* self = kernel::actor::ActorImpl::self();
kernel::actor::ActorImpl* actor =
kernel::actor::simcall([self, &name, host] { return self->init(name, host).get(); });
return actor->iface();
ActorPtr Actor::create(const std::string& name, s4u::Host* host, const std::function<void()>& code)
{
- kernel::actor::ActorImpl* self = SIMIX_process_self();
+ kernel::actor::ActorImpl* self = kernel::actor::ActorImpl::self();
kernel::actor::ActorImpl* actor =
kernel::actor::simcall([self, &name, host, &code] { return self->init(name, host)->start(code); });
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 simgrid::kernel::actor::ActorCodeFactory& factory =
+ simgrid::kernel::EngineImpl::get_instance()->get_function(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_);
}
void Actor::join(double timeout)
{
- kernel::actor::ActorImpl* issuer = SIMIX_process_self();
+ kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
kernel::actor::ActorImpl* target = pimpl_;
kernel::actor::simcall_blocking<void>([issuer, target, timeout] {
if (target->finished_) {
// The joined process is already finished, just wake up the issuer right away
issuer->simcall_answer();
} else {
- smx_activity_t sync = issuer->join(target, timeout);
+ kernel::activity::ActivityImplPtr sync = issuer->join(target, timeout);
sync->register_simcall(&issuer->simcall);
}
});
void Actor::on_exit(const std::function<void(bool /*failed*/)>& fun) const
{
- kernel::actor::simcall([this, &fun] { SIMIX_process_on_exit(pimpl_, fun); });
+ kernel::actor::simcall([this, &fun] { pimpl_->on_exit->emplace_back(fun); });
}
void Actor::set_host(Host* new_host)
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 Actor::suspend()
{
- kernel::actor::ActorImpl* issuer = SIMIX_process_self();
+ kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
kernel::actor::ActorImpl* target = pimpl_;
s4u::Actor::on_suspend(*this);
kernel::actor::simcall_blocking<void>([issuer, target]() {
void Actor::kill()
{
- kernel::actor::ActorImpl* self = SIMIX_process_self();
+ kernel::actor::ActorImpl* self = kernel::actor::ActorImpl::self();
kernel::actor::simcall([this, self] { self->kill(pimpl_); });
}
void Actor::kill_all()
{
- kernel::actor::ActorImpl* self = SIMIX_process_self();
+ kernel::actor::ActorImpl* self = kernel::actor::ActorImpl::self();
kernel::actor::simcall([self] { self->kill_all(); });
}
xbt_assert(std::isfinite(duration), "duration is not finite!");
if (duration > 0) {
- kernel::actor::ActorImpl* issuer = SIMIX_process_self();
+ kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
Actor::on_sleep(*issuer->ciface());
kernel::actor::simcall_blocking<void>([issuer, duration]() {
issuer->simcall_answer();
return;
}
- smx_activity_t sync = issuer->sleep(duration);
+ kernel::activity::ActivityImplPtr sync = issuer->sleep(duration);
sync->register_simcall(&issuer->simcall);
});
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));
}
aid_t get_pid()
{
- return SIMIX_process_self()->get_pid();
+ return simgrid::kernel::actor::ActorImpl::self()->get_pid();
}
aid_t get_ppid()
{
- return SIMIX_process_self()->get_ppid();
+ return simgrid::kernel::actor::ActorImpl::self()->get_ppid();
}
std::string get_name()
{
- return SIMIX_process_self()->get_name();
+ return simgrid::kernel::actor::ActorImpl::self()->get_name();
}
const char* get_cname()
{
- return SIMIX_process_self()->get_cname();
+ return simgrid::kernel::actor::ActorImpl::self()->get_cname();
}
Host* get_host()
{
- return SIMIX_process_self()->get_host();
+ return simgrid::kernel::actor::ActorImpl::self()->get_host();
}
void suspend()
{
- kernel::actor::ActorImpl* self = SIMIX_process_self();
+ kernel::actor::ActorImpl* self = simgrid::kernel::actor::ActorImpl::self();
s4u::Actor::on_suspend(*self->ciface());
kernel::actor::simcall_blocking<void>([self] { self->suspend(); });
}
-void resume()
-{
- kernel::actor::ActorImpl* self = SIMIX_process_self();
- kernel::actor::simcall([self] { self->resume(); });
- Actor::on_resume(*self->ciface());
-}
-
void exit()
{
- kernel::actor::ActorImpl* self = SIMIX_process_self();
+ kernel::actor::ActorImpl* self = simgrid::kernel::actor::ActorImpl::self();
simgrid::kernel::actor::simcall([self] { self->exit(); });
}
void on_exit(const std::function<void(bool)>& fun)
{
- SIMIX_process_self()->iface()->on_exit(fun);
+ simgrid::kernel::actor::ActorImpl::self()->iface()->on_exit(fun);
}
/** @brief Moves the current actor to another host
*/
void set_host(Host* new_host)
{
- SIMIX_process_self()->iface()->set_host(new_host);
+ simgrid::kernel::actor::ActorImpl::self()->iface()->set_host(new_host);
}
void migrate(Host* new_host) // deprecated
{
return simgrid::s4u::Actor::init(name, host).get();
}
-void sg_actor_start(sg_actor_t actor, xbt_main_func_t code, int argc, char** argv)
+void sg_actor_start(sg_actor_t actor, xbt_main_func_t code, int argc, const char* const* argv)
{
- simgrid::simix::ActorCode function;
+ simgrid::kernel::actor::ActorCode function;
if (code)
- function = simgrid::xbt::wrap_main(code, argc, static_cast<const char* const*>(argv));
+ function = simgrid::xbt::wrap_main(code, argc, argv);
actor->start(std::move(function));
}
*
* 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. */
#include "simgrid/s4u/Comm.hpp"
#include "simgrid/s4u/Mailbox.hpp"
+#include <simgrid/comm.h>
+
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_comm, s4u_activity, "S4U asynchronous communications");
namespace simgrid {
Comm::~Comm()
{
- if (state_ == State::STARTED && not detached_ && (pimpl_ == nullptr || pimpl_->state_ == SIMIX_RUNNING)) {
+ if (state_ == State::STARTED && not detached_ &&
+ (pimpl_ == nullptr || pimpl_->state_ == kernel::activity::State::RUNNING)) {
XBT_INFO("Comm %p freed before its completion. Detached: %d, State: %d", this, detached_, (int)state_);
if (pimpl_ != nullptr)
- XBT_INFO("pimpl_->state: %d", pimpl_->state_);
+ XBT_INFO("pimpl_->state: %d", static_cast<int>(pimpl_->state_));
else
XBT_INFO("pimpl_ is null");
xbt_backtrace_display_current();
}
}
-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(),
[](const CommPtr& comm) { return static_cast<kernel::activity::CommImpl*>(comm->pimpl_.get()); });
- return simcall_comm_waitany(rcomms.get(), comms->size(), timeout);
+ int changed_pos = simcall_comm_waitany(rcomms.get(), comms->size(), timeout);
+ if (changed_pos != -1)
+ comms->at(changed_pos)->release_dependencies();
+ return changed_pos;
}
-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
src_buff_size_ = size;
return this;
}
+
CommPtr Comm::set_dst_data(void** buff)
{
xbt_assert(state_ == State::INITED, "You cannot use %s() once your communication started (not implemented)",
return this;
}
-size_t Comm::get_dst_data_size()
+size_t Comm::get_dst_data_size() const
{
xbt_assert(state_ == State::FINISHED, "You cannot use %s before your communication terminated", __FUNCTION__);
return dst_buff_size_;
Comm* Comm::start()
{
- xbt_assert(get_state() == State::INITED, "You cannot use %s() once your communication started (not implemented)",
- __FUNCTION__);
+ xbt_assert(get_state() == State::INITED || get_state() == State::STARTING,
+ "You cannot use %s() once your communication started (not implemented)", __FUNCTION__);
if (src_buff_ != nullptr) { // Sender side
on_sender_start(*Actor::self());
case State::FINISHED:
break;
- case State::INITED: // It's not started yet. Do it in one simcall
+ case State::INITED:
+ case State::STARTING: // It's not started yet. Do it in one simcall
if (src_buff_ != nullptr) {
on_sender_start(*Actor::self());
simcall_comm_send(sender_, mailbox_->get_impl(), remains_, rate_, src_buff_, src_buff_size_, match_fun_,
get_user_data(), timeout, rate_);
}
state_ = State::FINISHED;
+ this->release_dependencies();
break;
case State::STARTED:
- simcall_comm_wait(pimpl_, timeout);
+ simcall_comm_wait(get_impl(), timeout);
on_completion(*Actor::self());
state_ = State::FINISHED;
+ this->release_dependencies();
break;
case State::CANCELED:
}
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(),
[](const CommPtr& comm) { return static_cast<kernel::activity::CommImpl*>(comm->pimpl_.get()); });
- return simcall_comm_testany(rcomms.get(), comms->size());
+ int changed_pos = simcall_comm_testany(rcomms.get(), comms->size());
+ if (changed_pos != -1)
+ comms->at(changed_pos)->release_dependencies();
+ return changed_pos;
}
Comm* Comm::detach()
__FUNCTION__);
xbt_assert(src_buff_ != nullptr && src_buff_size_ != 0, "You can only detach sends, not recvs");
detached_ = true;
- return start();
+ vetoable_start();
+ return this;
}
Comm* Comm::cancel()
if (state_ == State::FINISHED)
return true;
- if (state_ == State::INITED)
- this->start();
+ if (state_ == State::INITED || state_ == State::STARTING)
+ this->vetoable_start();
- if (simcall_comm_test(pimpl_)) {
+ if (simcall_comm_test(get_impl())) {
state_ = State::FINISHED;
+ this->release_dependencies();
return true;
}
return false;
}
-Mailbox* Comm::get_mailbox()
+Mailbox* Comm::get_mailbox() const
{
return mailbox_;
}
-Actor* Comm::get_sender()
+Actor* Comm::get_sender() const
{
return sender_ ? sender_->ciface() : nullptr;
}
} // namespace s4u
} // namespace simgrid
+/* **************************** Public C interface *************************** */
+int sg_comm_wait_any(sg_comm_t* comms, size_t count)
+{
+ return sg_comm_wait_any_for(comms, count, -1);
+}
+int sg_comm_wait_any_for(sg_comm_t* comms, size_t count, double timeout)
+{
+ std::vector<simgrid::s4u::CommPtr> s4u_comms;
+ for (unsigned int i = 0; i < count; i++) {
+ s4u_comms.emplace_back(comms[i]);
+ }
+ int pos = simgrid::s4u::Comm::wait_any_for(&s4u_comms, timeout);
+ if (pos != -1)
+ s4u_comms[pos]->unref();
+ return pos;
+}
-/* 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 {
xbt::signal<void(Disk const&)> Disk::on_destruction;
xbt::signal<void(Disk const&)> Disk::on_state_change;
-Host* Disk::get_host()
+double Disk::get_read_bandwidth() const
+{
+ return this->pimpl_->get_read_bandwidth();
+}
+
+double Disk::get_write_bandwidth() const
+{
+ return pimpl_->get_write_bandwidth();
+}
+
+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. */
XBT_DEBUG("PARSE TIME: %g", (end - start));
}
+void Engine::register_function(const std::string& name, int (*code)(int, char**)) // deprecated
+{
+ register_function(name, [code](std::vector<std::string> args) { return xbt::wrap_main(code, std::move(args)); });
+}
+void Engine::register_default(int (*code)(int, char**)) // deprecated
+{
+ register_default([code](std::vector<std::string> args) { return xbt::wrap_main(code, std::move(args)); });
+}
+
/** Registers the main function of an actor that will be launched from the deployment file */
-void Engine::register_function(const std::string& name, int (*code)(int, char**))
+void Engine::register_function(const std::string& name, void (*code)(int, char**))
{
- pimpl->register_function(name, code);
+ register_function(name, [code](std::vector<std::string> args) { return xbt::wrap_main(code, std::move(args)); });
}
/** Registers the main function of an actor that will be launched from the deployment file */
void Engine::register_function(const std::string& name, void (*code)(std::vector<std::string>))
{
- pimpl->register_function(name, code);
+ register_function(name,
+ [code](std::vector<std::string> args) { return std::bind(std::move(code), std::move(args)); });
}
/** Registers a function as the default main function of actors
*
* It will be used as fallback when the function requested from the deployment file was not registered.
* It is used for trace-based simulations (see examples/s4u/replay-comms and similar).
*/
-void Engine::register_default(int (*code)(int, char**))
+void Engine::register_default(void (*code)(int, char**))
+{
+ register_default([code](std::vector<std::string> args) { return xbt::wrap_main(code, std::move(args)); });
+}
+void Engine::register_default(const kernel::actor::ActorCodeFactory& code)
+{
+ simgrid::kernel::actor::simcall([this, &code]() { pimpl->register_default(code); });
+}
+
+void Engine::register_function(const std::string& name, const kernel::actor::ActorCodeFactory& code)
{
- pimpl->register_default(code);
+ simgrid::kernel::actor::simcall([this, name, &code]() { pimpl->register_function(name, code); });
}
/** Load a deployment file and launch the actors that it contains
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 */
{
simgrid::s4u::Engine::get_instance()->run();
}
-void simgrid_register_function(const char* name, int (*code)(int, char**))
+void simgrid_register_function(const char* name, void (*code)(int, char**))
{
simgrid::s4u::Engine::get_instance()->register_function(name, code);
}
-void simgrid_register_default(int (*code)(int, char**))
+void simgrid_register_default(void (*code)(int, char**))
{
simgrid::s4u::Engine::get_instance()->register_default(code);
}
-/* 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. */
bool Exec::test()
{
- xbt_assert(state_ == State::INITED || state_ == State::STARTED || state_ == State::FINISHED);
+ xbt_assert(state_ == State::INITED || state_ == State::STARTED || state_ == State::STARTING ||
+ state_ == State::FINISHED);
if (state_ == State::FINISHED)
return true;
- if (state_ == State::INITED)
- this->start();
+ if (state_ == State::INITED || state_ == State::STARTING)
+ this->vetoable_start();
- if (simcall_execution_test(pimpl_)) {
+ if (simcall_execution_test(get_impl())) {
state_ = State::FINISHED;
+ this->release_dependencies();
return true;
}
}
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(get_impl(), 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;
ExecSeq::ExecSeq(sg_host_t host, double flops_amount) : Exec(), flops_amount_(flops_amount)
{
Activity::set_remaining(flops_amount_);
- boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(pimpl_)->set_host(host);
+ boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->set_host(host);
}
Exec* ExecSeq::start()
xbt_assert(state_ == State::INITED || state_ == State::STARTED,
"Cannot change the host of an exec once it's done (state: %d)", (int)state_);
if (state_ == State::STARTED)
- boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(pimpl_)->migrate(host);
- boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(pimpl_)->set_host(host);
+ boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->migrate(host);
+ boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->set_host(host);
return this;
}
-/** @brief Returns the amount of flops that remain to be done */
-double ExecSeq::get_remaining()
+double ExecSeq::get_remaining() const
{
- return simgrid::kernel::actor::simcall(
- [this]() { return boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(pimpl_)->get_remaining(); });
+ return kernel::actor::simcall(
+ [this]() { return boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->get_remaining(); });
}
/** @brief Returns the ratio of elements that are still to do
*
* The returned value is between 0 (completely done) and 1 (nothing done yet).
*/
-double ExecSeq::get_remaining_ratio()
+double ExecSeq::get_remaining_ratio() const
{
- return simgrid::kernel::actor::simcall([this]() {
- return boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(pimpl_)->get_seq_remaining_ratio();
- });
+ return kernel::actor::simcall(
+ [this]() { return boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->get_seq_remaining_ratio(); });
}
///////////// PARALLEL EXECUTIONS ////////
return this;
}
-double ExecPar::get_remaining_ratio()
+double ExecPar::get_remaining_ratio() const
{
return kernel::actor::simcall(
[this]() { return boost::static_pointer_cast<kernel::activity::ExecImpl>(pimpl_)->get_par_remaining_ratio(); });
}
-double ExecPar::get_remaining()
+double ExecPar::get_remaining() const
{
XBT_WARN("Calling get_remaining() on a parallel execution is not allowed. Call get_remaining_ratio() instead.");
return get_remaining_ratio();
-/* 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 {
*
* Don't delete directly a host, call h->destroy() instead.
*
- * This is cumbersome but this is the simplest solution to ensure that the onDestruction() callback receives a valid
+ * This is cumbersome but this is the simplest solution to ensure that the on_destruction() callback receives a valid
* object (because of the destructor order in a class hierarchy).
*/
void Host::destroy()
Host* Host::current()
{
- kernel::actor::ActorImpl* self = SIMIX_process_self();
+ kernel::actor::ActorImpl* self = kernel::actor::ActorImpl::self();
if (self == nullptr)
xbt_die("Cannot call Host::current() from the maestro context");
return self->get_host();
void Host::turn_off()
{
if (is_on()) {
- kernel::actor::ActorImpl* self = SIMIX_process_self();
+ kernel::actor::ActorImpl* self = kernel::actor::ActorImpl::self();
kernel::actor::simcall([this, self] {
for (VirtualMachine* const& vm : vm::VirtualMachineImpl::allVms_)
if (vm->get_pm() == this) {
*
* 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)) {
return this->pimpl_cpu->get_pstate_peak_speed(pstate_index);
}
-/** @brief Get the peak computing speed in flops/s at the current pstate, NOT taking the external load into account.
- *
- * The amount of flops per second available for computing depends on several things:
- * - The current pstate determines the maximal peak computing speed (use @ref get_pstate_speed() to retrieve the
- * computing speed you would get at another pstate)
- * - If you declared an external load (with @ref simgrid::surf::Cpu::set_speed_profile()), you must multiply the
- * result of get_speed() by get_available_speed() to retrieve what a new computation would get.
- *
- * The remaining speed is then shared between the executions located on this host.
- * You can retrieve the amount of tasks currently running on this host with @ref get_load().
- *
- * The host may have multiple cores, and your executions may be able to use more than a single core.
- *
- * Finally, executions of priority 2 get twice the amount of flops than executions of priority 1.
- */
double Host::get_speed() const
{
return this->pimpl_cpu->get_speed(1.0);
}
-/** @brief Returns the current computation load (in flops per second)
- *
- * The external load (coming from an availability trace) is not taken in account.
- * You may also be interested in the load plugin.
- */
double Host::get_load() const
{
return this->pimpl_cpu->get_load();
}
-/** @brief Get the available speed ratio, between 0 and 1.
- *
- * This accounts for external load (see @ref simgrid::surf::Cpu::set_speed_profile()).
- */
double Host::get_available_speed() const
{
return this->pimpl_cpu->get_speed_ratio();
}
-/** @brief Returns the number of core of the processor. */
int Host::get_core_count() const
{
return this->pimpl_cpu->get_core_count();
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 simgrid::s4u::Engine::get_instance()->get_host_count();
}
-/** @brief Returns the host list
- *
- * Uses sg_host_count() to know the array size.
- *
- * @return an array of @ref sg_host_t containing all the hosts in the platform.
- * @remark The host order in this array is generally different from the
- * creation/declaration order in the XML platform (we use a hash table
- * internally).
- * @see sg_host_count()
- */
sg_host_t* sg_host_list()
{
xbt_assert(sg_host_count() > 0, "There is no host!");
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);
}
sg_host_t sg_host_self()
{
- return SIMIX_is_maestro() ? nullptr : SIMIX_process_self()->get_host();
+ return SIMIX_is_maestro() ? nullptr : simgrid::kernel::actor::ActorImpl::self()->get_host();
}
/* needs to be public and without simcall for exceptions and logging events */
const char* sg_host_self_get_name()
{
- return SIMIX_is_maestro() ? "" : SIMIX_process_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;
+ if (state_ == State::INITED)
+ vetoable_start();
+ simcall_io_wait(get_impl(), timeout);
+ state_ = State::FINISHED;
+ this->release_dependencies();
+ return this;
}
bool Io::test()
{
- xbt_assert(state_ == State::INITED || state_ == State::STARTED || state_ == State::FINISHED);
+ xbt_assert(state_ == State::INITED || state_ == State::STARTED || state_ == State::STARTING ||
+ state_ == State::FINISHED);
if (state_ == State::FINISHED)
return true;
- if (state_ == State::INITED)
- this->start();
+ if (state_ == State::INITED || state_ == State::STARTING)
+ this->vetoable_start();
- THROW_UNIMPLEMENTED;
+ if (simcall_io_test(get_impl())) {
+ state_ = State::FINISHED;
+ this->release_dependencies();
+ return true;
+ }
- // return false
+ return false;
}
/** @brief Returns the amount of flops that remain to be done */
-double Io::get_remaining()
+double Io::get_remaining() const
{
return kernel::actor::simcall(
[this]() { return boost::static_pointer_cast<kernel::activity::IoImpl>(pimpl_)->get_remaining(); });
}
-sg_size_t Io::get_performed_ioops()
+sg_size_t Io::get_performed_ioops() const
{
- return kernel::actor::simcall(
- [this]() { return boost::static_pointer_cast<kernel::activity::IoImpl>(pimpl_)->get_performed_ioops(); });
+ return boost::static_pointer_cast<kernel::activity::IoImpl>(pimpl_)->get_performed_ioops();
}
} // namespace s4u
-/* 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. */
{
bool comm_ready = false;
if (not pimpl_->comm_queue_.empty()) {
- comm_ready = pimpl_->comm_queue_.front()->state_ == SIMIX_DONE;
-
+ comm_ready = pimpl_->comm_queue_.front()->state_ == kernel::activity::State::DONE;
+
} else if (pimpl_->permanent_receiver_ && not pimpl_->done_comm_queue_.empty()) {
- comm_ready = pimpl_->done_comm_queue_.front()->state_ == SIMIX_DONE;
+ comm_ready = pimpl_->done_comm_queue_.front()->state_ == kernel::activity::State::DONE;
}
return comm_ready;
}
CommPtr Mailbox::put_init()
{
CommPtr res = CommPtr(new s4u::Comm());
- res->sender_ = SIMIX_process_self();
+ res->sender_ = kernel::actor::ActorImpl::self();
res->mailbox_ = this;
return res;
}
xbt_assert(payload != nullptr, "You cannot send nullptr");
s4u::CommPtr res = put_init(payload, simulated_size_in_bytes);
- res->start();
+ res->vetoable_start();
return res;
}
void Mailbox::put(void* payload, uint64_t simulated_size_in_bytes)
CommPtr c = put_init();
c->set_remaining(simulated_size_in_bytes);
c->set_src_data(payload);
+ c->vetoable_start();
c->wait();
}
/** Blocking send with timeout */
CommPtr c = put_init();
c->set_remaining(simulated_size_in_bytes);
c->set_src_data(payload);
- // c->start() is optional.
+ c->vetoable_start();
c->wait_for(timeout);
}
s4u::CommPtr Mailbox::get_init()
{
CommPtr res = CommPtr(new s4u::Comm());
- res->receiver_ = SIMIX_process_self();
+ res->receiver_ = kernel::actor::ActorImpl::self();
res->mailbox_ = this;
return res;
}
{
s4u::CommPtr res = get_init();
res->set_dst_data(data, sizeof(*data));
- res->start();
+ res->vetoable_start();
return res;
}
void* res = nullptr;
CommPtr c = get_init();
c->set_dst_data(&res, sizeof(res));
+ c->vetoable_start();
c->wait();
return res;
}
void* res = nullptr;
CommPtr c = get_init();
c->set_dst_data(&res, sizeof(res));
+ c->vetoable_start();
c->wait_for(timeout);
return res;
}
-smx_activity_t Mailbox::iprobe(int type, int (*match_fun)(void*, void*, kernel::activity::CommImpl*), void* data)
+kernel::activity::ActivityImplPtr
+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); });
}
} // namespace simgrid
/* **************************** Public C interface *************************** */
+sg_mailbox_t sg_mailbox_by_name(const char* alias)
+{
+ return simgrid::s4u::Mailbox::by_name(alias);
+}
+
+const char* sg_mailbox_get_name(const_sg_mailbox_t mailbox)
+{
+ return mailbox->get_cname();
+}
+
/** @brief Set the mailbox to receive in asynchronous mode
*
* All messages sent to this mailbox will be transferred to the receiver without waiting for the receive call.
{
return simgrid::s4u::Mailbox::by_name(alias)->listen() ? 1 : 0;
}
+
+void* sg_mailbox_get(sg_mailbox_t mailbox)
+{
+ return mailbox->get();
+}
+
+void sg_mailbox_put(sg_mailbox_t mailbox, void* payload, long simulated_size_in_bytes)
+{
+ return mailbox->put(payload, simulated_size_in_bytes);
+}
+
+sg_comm_t sg_mailbox_put_async(sg_mailbox_t mailbox, void* payload, long simulated_size_in_bytes)
+{
+ auto comm = mailbox->put_async(payload, simulated_size_in_bytes);
+ comm->add_ref();
+ return comm.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. */
}
/* 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. */
const std::unordered_map<std::string, std::string>* NetZone::get_properties() const
{
- return &properties_;
+ return pimpl_->get_properties();
}
/** Retrieve the property value (or nullptr if not set) */
const char* NetZone::get_property(const std::string& key) const
{
- auto prop = properties_.find(key);
- return prop == properties_.end() ? nullptr : prop->second.c_str();
+ return pimpl_->get_property(key);
}
void NetZone::set_property(const std::string& key, const std::string& value)
{
- kernel::actor::simcall([this, &key, &value] { properties_[key] = value; });
+ kernel::actor::simcall([this, &key, &value] { pimpl_->set_property(key, value); });
}
/** @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();
}
-int NetZone::get_host_count()
+int NetZone::get_host_count() const
{
return pimpl_->get_host_count();
}
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. */
#include "simgrid/sg_config.hpp"
#include "simgrid/instr.h"
+#include "simgrid/version.h"
#include "src/instr/instr_private.hpp"
#include "src/internal_config.h"
#include "src/kernel/lmm/maxmin.hpp"
#include "src/mc/mc_config.hpp"
#include "src/mc/mc_replay.hpp"
+#include "src/smpi/include/smpi_config.hpp"
#include "src/surf/surf_interface.hpp"
#include "surf/surf.hpp"
#include "xbt/config.hpp"
"contention (default value based on Stampede cluster profiling)",
"0.965;0.925;1.35");
simgrid::config::alias("smpi/IB-penalty-factors", {"smpi/IB_penalty_factors"});
-
-#if HAVE_SMPI
- simgrid::config::declare_flag<double>("smpi/host-speed", "Speed of the host running the simulation (in flop/s). "
- "Used to bench the operations.",
- 20000.0, [](const double& val) {
- xbt_assert(val > 0.0, "Invalid value (%f) for 'smpi/host-speed': it must be positive.", val);
- });
- simgrid::config::alias("smpi/host-speed", {"smpi/running_power", "smpi/running-power"});
-
- simgrid::config::declare_flag<bool>("smpi/keep-temps", "Whether we should keep the generated temporary files.",
- false);
-
- simgrid::config::declare_flag<bool>("smpi/display-timing", "Whether we should display the timing after simulation.",
- false);
- simgrid::config::alias("smpi/display-timing", {"smpi/display_timing"});
-
- simgrid::config::declare_flag<bool>(
- "smpi/simulate-computation", "Whether the computational part of the simulated application should be simulated.",
- true);
- simgrid::config::alias("smpi/simulate-computation", {"smpi/simulate_computation"});
-
- simgrid::config::declare_flag<std::string>(
- "smpi/shared-malloc", "Whether SMPI_SHARED_MALLOC is enabled. Disable it for debugging purposes.", "global");
- simgrid::config::alias("smpi/shared-malloc", {"smpi/use_shared_malloc", "smpi/use-shared-malloc"});
- simgrid::config::declare_flag<double>("smpi/shared-malloc-blocksize",
- "Size of the bogus file which will be created for global shared allocations",
- 1UL << 20);
- simgrid::config::declare_flag<double>("smpi/auto-shared-malloc-thresh",
- "Threshold size for the automatic sharing of memory",
- 0);
-
- simgrid::config::declare_flag<std::string>("smpi/shared-malloc-hugepage",
- "Path to a mounted hugetlbfs, to use huge pages with shared malloc.", "");
-
- simgrid::config::declare_flag<double>(
- "smpi/cpu-threshold", "Minimal computation time (in seconds) not discarded, or -1 for infinity.", 1e-6);
- simgrid::config::alias("smpi/cpu-threshold", {"smpi/cpu_threshold"});
-
- simgrid::config::declare_flag<int>(
- "smpi/async-small-thresh",
- "Maximal size of messages that are to be sent asynchronously, without waiting for the receiver", 0);
- simgrid::config::alias("smpi/async-small-thresh", {"smpi/async_small_thres", "smpi/async_small_thresh"});
-
- simgrid::config::declare_flag<bool>("smpi/trace-call-location",
- "Should filename and linenumber of MPI calls be traced?", false);
- simgrid::config::declare_flag<bool>("smpi/trace-call-use-absolute-path",
- "Should filenames for trace-call tracing be absolute or not?", false);
- simgrid::config::declare_flag<int>(
- "smpi/send-is-detached-thresh",
- "Threshold of message size where MPI_Send stops behaving like MPI_Isend and becomes MPI_Ssend", 65536);
- simgrid::config::alias("smpi/send-is-detached-thresh",
- {"smpi/send_is_detached_thres", "smpi/send_is_detached_thresh"});
-
- const char* default_privatization = std::getenv("SMPI_PRIVATIZATION");
- if (default_privatization == nullptr)
- default_privatization = "no";
-
- simgrid::config::declare_flag<std::string>(
- "smpi/privatization", "How we should privatize global variable at runtime (no, yes, mmap, dlopen).",
- default_privatization);
- simgrid::config::alias("smpi/privatization", {"smpi/privatize_global_variables", "smpi/privatize-global-variables"});
-
- simgrid::config::declare_flag<std::string>(
- "smpi/privatize-libs", "Add libraries (; separated) to privatize (libgfortran for example). You need to provide the full names of the files (libgfortran.so.4), or its full path", "");
-
- simgrid::config::declare_flag<bool>("smpi/grow-injected-times",
- "Whether we want to make the injected time in MPI_Iprobe and MPI_Test grow, to "
- "allow faster simulation. This can make simulation less precise, though.",
- true);
-
-#if HAVE_PAPI
- simgrid::config::declare_flag<std::string>("smpi/papi-events",
- "This switch enables tracking the specified counters with PAPI", "");
-#endif
- simgrid::config::declare_flag<std::string>("smpi/comp-adjustment-file",
- "A file containing speedups or slowdowns for some parts of the code.", "");
- simgrid::config::declare_flag<std::string>(
- "smpi/os", "Small messages timings (MPI_Send minimum time for small messages)", "0:0:0:0:0");
- simgrid::config::declare_flag<std::string>(
- "smpi/ois", "Small messages timings (MPI_Isend minimum time for small messages)", "0:0:0:0:0");
- simgrid::config::declare_flag<std::string>(
- "smpi/or", "Small messages timings (MPI_Recv minimum time for small messages)", "0:0:0:0:0");
-
- simgrid::config::declare_flag<double>("smpi/iprobe-cpu-usage",
- "Maximum usage of CPUs by MPI_Iprobe() calls. We've observed that MPI_Iprobes "
- "consume significantly less power than the maximum of a specific application. "
- "This value is then (Iprobe_Usage/Max_Application_Usage).",
- 1.0);
-
- simgrid::config::declare_flag<std::string>("smpi/coll-selector", "Which collective selector to use", "default");
- simgrid::config::alias("smpi/coll-selector", {"smpi/coll_selector"});
- simgrid::config::declare_flag<std::string>("smpi/gather", "Which collective to use for gather", "");
- simgrid::config::declare_flag<std::string>("smpi/allgather", "Which collective to use for allgather", "");
- simgrid::config::declare_flag<std::string>("smpi/barrier", "Which collective to use for barrier", "");
- simgrid::config::declare_flag<std::string>("smpi/reduce_scatter", "Which collective to use for reduce_scatter", "");
- simgrid::config::alias("smpi/reduce_scatter", {"smpi/reduce-scatter"});
- simgrid::config::declare_flag<std::string>("smpi/scatter", "Which collective to use for scatter", "");
- simgrid::config::declare_flag<std::string>("smpi/allgatherv", "Which collective to use for allgatherv", "");
- simgrid::config::declare_flag<std::string>("smpi/allreduce", "Which collective to use for allreduce", "");
- simgrid::config::declare_flag<std::string>("smpi/alltoall", "Which collective to use for alltoall", "");
- simgrid::config::declare_flag<std::string>("smpi/alltoallv", "Which collective to use for alltoallv", "");
- simgrid::config::declare_flag<std::string>("smpi/bcast", "Which collective to use for bcast", "");
- simgrid::config::declare_flag<std::string>("smpi/reduce", "Which collective to use for reduce", "");
-#endif // HAVE_SMPI
-
/* Others */
simgrid::config::declare_flag<bool>(
--- /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/config.h"
+#include "simgrid/version.h"
+#include "xbt/base.h"
+#include "xbt/log.h"
+#include "xbt/misc.h"
+#include "xbt/sysdep.h"
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sg_version, surf, "About the versioning of SimGrid");
+
+void sg_version_check(int lib_version_major, int lib_version_minor, int lib_version_patch)
+{
+ if ((lib_version_major != SIMGRID_VERSION_MAJOR) || (lib_version_minor != SIMGRID_VERSION_MINOR)) {
+ fprintf(stderr,
+ "FATAL ERROR: Your program was compiled with SimGrid version %d.%d.%d, "
+ "and then linked against SimGrid %d.%d.%d. Please fix this.\n",
+ lib_version_major, lib_version_minor, lib_version_patch, SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR,
+ SIMGRID_VERSION_PATCH);
+ abort();
+ }
+ if (lib_version_patch != SIMGRID_VERSION_PATCH) {
+ if (SIMGRID_VERSION_PATCH > 89 || lib_version_patch > 89) {
+ fprintf(
+ stderr,
+ "FATAL ERROR: Your program was compiled with SimGrid version %d.%d.%d, "
+ "and then linked against SimGrid %d.%d.%d. \n"
+ "One of them is a development version, and should not be mixed with the stable release. Please fix this.\n",
+ lib_version_major, lib_version_minor, lib_version_patch, SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR,
+ SIMGRID_VERSION_PATCH);
+ abort();
+ }
+ fprintf(stderr,
+ "Warning: Your program was compiled with SimGrid version %d.%d.%d, "
+ "and then linked against SimGrid %d.%d.%d. Proceeding anyway.\n",
+ lib_version_major, lib_version_minor, lib_version_patch, SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR,
+ SIMGRID_VERSION_PATCH);
+ }
+}
+
+void sg_version_get(int* ver_major, int* ver_minor, int* ver_patch)
+{
+ *ver_major = SIMGRID_VERSION_MAJOR;
+ *ver_minor = SIMGRID_VERSION_MINOR;
+ *ver_patch = SIMGRID_VERSION_PATCH;
+}
+
+void sg_version()
+{
+ XBT_HELP("This program was linked against %s (git: %s), found in %s.", SIMGRID_VERSION_STRING, SIMGRID_GIT_VERSION,
+ SIMGRID_INSTALL_PREFIX);
+
+#if SIMGRID_HAVE_MC
+ XBT_HELP(" Model-checking support compiled in.");
+#else
+ XBT_HELP(" Model-checking support disabled at compilation.");
+#endif
+
+#if SIMGRID_HAVE_NS3
+ XBT_HELP(" ns-3 support compiled in.");
+#else
+ XBT_HELP(" ns-3 support disabled at compilation.");
+#endif
+
+#if SIMGRID_HAVE_JEDULE
+ XBT_HELP(" Jedule support compiled in.");
+#else
+ XBT_HELP(" Jedule support disabled at compilation.");
+#endif
+
+#if SIMGRID_HAVE_LUA
+ XBT_HELP(" Lua support compiled in.");
+#else
+ XBT_HELP(" Lua support disabled at compilation.");
+#endif
+
+#if SIMGRID_HAVE_MALLOCATOR
+ XBT_HELP(" Mallocator support compiled in.");
+#else
+ XBT_HELP(" Mallocator support disabled at compilation.");
+#endif
+
+ XBT_HELP("\nTo cite SimGrid in a publication, please use:\n"
+ " Henri Casanova, Arnaud Giersch, Arnaud Legrand, Martin Quinson, Frédéric Suter. \n"
+ " Versatile, Scalable, and Accurate Simulation of Distributed Applications and Platforms. \n"
+ " Journal of Parallel and Distributed Computing, Elsevier, 2014, 74 (10), pp.2899-2917.\n"
+ "The pdf file and a BibTeX entry for LaTeX users can be found at http://hal.inria.fr/hal-01017319");
+}
-/* 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
+++ /dev/null
-/* src/simgrid/version.h - internal versioning info */
-
-/* Copyright (c) 2009-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_VERSION_H
-#define SIMGRID_VERSION_H
-
-#define SIMGRID_GIT_VERSION "@GIT_VERSION@"
-
-#endif /* SIMGRID_PUBLIC_CONFIG_H */
/* */
/* 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(simgrid::kernel::activity::ActivityImpl* 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),
+ timeout);
}
-bool simcall_execution_test(const smx_activity_t& execution)
+bool simcall_execution_test(simgrid::kernel::activity::ActivityImpl* execution)
{
- return simcall_BODY_execution_test(static_cast<simgrid::kernel::activity::ExecImpl*>(execution.get()));
+ return simcall_BODY_execution_test(static_cast<simgrid::kernel::activity::ExecImpl*>(execution));
}
unsigned int simcall_execution_waitany_for(simgrid::kernel::activity::ExecImpl* execs[], size_t count, double timeout)
void simcall_process_join(smx_actor_t process, double timeout) // XBT_DEPRECATED_v328
{
- SIMIX_process_self()->join(process, timeout);
+ simgrid::kernel::actor::ActorImpl::self()->join(process, timeout);
}
void simcall_process_suspend(smx_actor_t process) // XBT_DEPRECATED_v328
e_smx_state_t simcall_process_sleep(double duration) // XBT_DEPRECATED_v329
{
- SIMIX_process_self()->sleep(duration);
- return SIMIX_DONE;
+ simgrid::kernel::actor::ActorImpl::self()->sleep(duration);
+ return simgrid::kernel::activity::State::DONE;
}
/**
* @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)
{
if (MC_is_active() || MC_record_replay_is_active()) {
/* the model-checker wants two separate simcalls */
- smx_activity_t comm = nullptr; /* MC needs the comm to be set to nullptr during the simcall */
+ simgrid::kernel::activity::ActivityImplPtr comm =
+ nullptr; /* MC needs the comm to be set to nullptr during the simcall */
comm = simcall_comm_isend(sender, mbox, task_size, rate,
src_buff, src_buff_size, match_fun, nullptr, copy_data_fun, data, 0);
- simcall_comm_wait(comm, timeout);
+ simcall_comm_wait(comm.get(), timeout);
comm = nullptr;
}
else {
/**
* @ingroup simix_comm_management
*/
-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*),
- void (*clean_fun)(void*),
- void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
- void* data, bool detached)
+simgrid::kernel::activity::ActivityImplPtr
+simcall_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff,
+ size_t src_buff_size, 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)
{
/* checking for infinite values */
xbt_assert(std::isfinite(task_size), "task_size is not finite!");
* @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)
{
if (MC_is_active() || MC_record_replay_is_active()) {
/* the model-checker wants two separate simcalls */
- smx_activity_t comm = nullptr; /* MC needs the comm to be set to nullptr during the simcall */
+ simgrid::kernel::activity::ActivityImplPtr comm =
+ nullptr; /* MC needs the comm to be set to nullptr during the simcall */
comm = simcall_comm_irecv(receiver, mbox, dst_buff, dst_buff_size,
match_fun, copy_data_fun, data, rate);
- simcall_comm_wait(comm, timeout);
+ simcall_comm_wait(comm.get(), timeout);
comm = nullptr;
}
else {
/**
* @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*),
- void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
- void* data, double rate)
+simgrid::kernel::activity::ActivityImplPtr
+simcall_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_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 rate)
{
xbt_assert(mbox, "No rendez-vous point defined for irecv");
/**
* @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)
+simgrid::kernel::activity::ActivityImplPtr
+simcall_comm_iprobe(smx_mailbox_t mbox, int type, bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+ void* data)
{
xbt_assert(mbox, "No rendez-vous point defined for iprobe");
/**
* @ingroup simix_comm_management
*/
-unsigned int simcall_comm_waitany(smx_activity_t comms[], size_t count, double timeout)
+unsigned int simcall_comm_waitany(simgrid::kernel::activity::ActivityImplPtr comms[], size_t count,
+ double timeout) // XBT_ATTRIB_DEPRECATED_v330
{
std::unique_ptr<simgrid::kernel::activity::CommImpl* []> rcomms(new simgrid::kernel::activity::CommImpl*[count]);
- std::transform(comms, comms + count, rcomms.get(), [](const smx_activity_t& comm) {
+ std::transform(comms, comms + count, rcomms.get(), [](const simgrid::kernel::activity::ActivityImplPtr& comm) {
return static_cast<simgrid::kernel::activity::CommImpl*>(comm.get());
});
return simcall_BODY_comm_waitany(rcomms.get(), count, timeout);
/**
* @ingroup simix_comm_management
*/
-int simcall_comm_testany(smx_activity_t comms[], size_t count)
+int simcall_comm_testany(simgrid::kernel::activity::ActivityImplPtr comms[], size_t count) // XBT_ATTRIB_DEPRECATED_v330
{
if (count == 0)
return -1;
std::unique_ptr<simgrid::kernel::activity::CommImpl* []> rcomms(new simgrid::kernel::activity::CommImpl*[count]);
- std::transform(comms, comms + count, rcomms.get(), [](const smx_activity_t& comm) {
+ std::transform(comms, comms + count, rcomms.get(), [](const simgrid::kernel::activity::ActivityImplPtr& comm) {
return static_cast<simgrid::kernel::activity::CommImpl*>(comm.get());
});
return simcall_BODY_comm_testany(rcomms.get(), count);
/**
* @ingroup simix_comm_management
*/
-void simcall_comm_wait(const smx_activity_t& comm, double timeout)
+void simcall_comm_wait(simgrid::kernel::activity::ActivityImpl* comm, double timeout)
{
xbt_assert(std::isfinite(timeout), "timeout is not finite!");
- simcall_BODY_comm_wait(static_cast<simgrid::kernel::activity::CommImpl*>(comm.get()), timeout);
+ simcall_BODY_comm_wait(static_cast<simgrid::kernel::activity::CommImpl*>(comm), timeout);
}
/**
* @ingroup simix_comm_management
*
*/
-bool simcall_comm_test(const smx_activity_t& comm)
+bool simcall_comm_test(simgrid::kernel::activity::ActivityImpl* comm)
{
- return simcall_BODY_comm_test(static_cast<simgrid::kernel::activity::CommImpl*>(comm.get()));
+ return simcall_BODY_comm_test(static_cast<simgrid::kernel::activity::CommImpl*>(comm));
}
/**
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(simgrid::kernel::activity::ActivityImpl* 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), timeout);
+}
+
+bool simcall_io_test(simgrid::kernel::activity::ActivityImpl* io)
+{
+ return simcall_BODY_io_test(static_cast<simgrid::kernel::activity::IoImpl*>(io));
}
void simcall_run_kernel(std::function<void()> const& code, simgrid::mc::SimcallInspector* t)
{
- SIMIX_process_self()->simcall.inspector_ = t;
+ simgrid::kernel::actor::ActorImpl::self()->simcall.inspector_ = t;
simcall_BODY_run_kernel(&code);
}
void simcall_run_blocking(std::function<void()> const& code, simgrid::mc::SimcallInspector* t = nullptr)
{
- SIMIX_process_self()->simcall.inspector_ = t;
+ simgrid::kernel::actor::ActorImpl::self()->simcall.inspector_ = t;
simcall_BODY_run_blocking(&code);
}
-/* 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. */
/**********************************************************************/
/*
{
smx_actor_t self = SIMIX_process_self();
simgrid::simix::marshal(&self->simcall, call, t...);
- if (self != simix_global->maestro_process) {
+ if (self != simix_global->maestro_) {
XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->get_cname(), SIMIX_simcall_name(self->simcall.call_),
(int)self->simcall.call_);
self->yield();
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.
def accessors(self):
res = []
res.append('')
- regex = re.compile(r"^boost::intrusive_ptr<(.*?)>(.*)$") # to compute the raw type
+ regex = re.compile(r"^boost::intrusive_ptr<(.*?)>(.*)$") # to compute the raw type
# Arguments getter/setters
for i in range(len(self.args)):
arg = self.args[i]
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')
{
smx_actor_t self = SIMIX_process_self();
simgrid::simix::marshal(&self->simcall, call, t...);
- if (self != simix_global->maestro_process) {
+ if (self != simix_global->maestro_) {
XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->get_cname(), SIMIX_simcall_name(self->simcall.call_),
(int)self->simcall.call_);
self->yield();
/* 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. */
#include "src/internal_config.h"
#include "src/simix/smx_private.hpp"
+#include "smpi/smpi.h"
#include "xbt/config.hpp"
#include <thread>
xbt_assert(simix_global->context_factory == nullptr);
#if HAVE_SMPI && (defined(__APPLE__) || defined(__NetBSD__))
+ smpi_init_options();
std::string priv = simgrid::config::get_value<std::string>("smpi/privatization");
if (context_factory_name == "thread" && (priv == "dlopen" || priv == "yes" || priv == "default" || priv == "1")) {
XBT_WARN("dlopen+thread broken on Apple and BSD. Switching to raw contexts.");
#endif
#if HAVE_SMPI && defined(__FreeBSD__)
+ smpi_init_options();
if (context_factory_name == "thread" && simgrid::config::get_value<std::string>("smpi/privatization") != "no") {
XBT_WARN("mmap broken on FreeBSD, but dlopen+thread broken too. Switching to dlopen+raw contexts.");
context_factory_name = "raw";
-/* 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 "simgrid/s4u/Host.hpp"
#include "smx_private.hpp"
+#include "src/kernel/EngineImpl.hpp"
#include "src/surf/xml/platf_private.hpp" // FIXME: KILLME. There must be a better way than mimicking XML here
#include <simgrid/engine.h>
#include <simgrid/s4u/Engine.hpp>
simgrid::s4u::Engine::get_instance()->register_default(code);
}
-/**
- * @brief Gets a #smx_actor_t code from the global table.
- *
- * Gets a code function from the global table. Returns nullptr if there are no function registered with the name.
- * This table is then used by #SIMIX_launch_application.
- * @param name the reference name of the function.
- * @return The #smx_actor_t or nullptr.
- */
-simgrid::simix::ActorCodeFactory& SIMIX_get_actor_code_factory(const std::string& name)
-{
- xbt_assert(simix_global,
- "SIMIX_global_init has to be called before SIMIX_get_actor_code_factory.");
-
- auto i = simix_global->registered_functions.find(name);
- if (i == simix_global->registered_functions.end())
- return simix_global->default_function;
- else
- return i->second;
-}
-
/** @brief Bypass the parser, get arguments, and set function to each process */
-
void SIMIX_process_set_function(const char* process_host, const char* process_function, xbt_dynar_t arguments,
double process_start_time, double process_kill_time) // XBT_ATTRIB_DEPRECATED_v329
{
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::kernel::actor::ActorCodeFactory& parse_code =
+ simgrid::kernel::EngineImpl::get_instance()->get_function(process_function);
xbt_assert(parse_code, "Function '%s' unknown", process_function);
- actor.function = process_function;
- actor.host = process_host;
- actor.kill_time = process_kill_time;
- actor.start_time = process_start_time;
- actor.on_failure = simgrid::kernel::routing::ActorOnFailure::DIE;
+ actor.function = process_function;
+ actor.host = process_host;
+ actor.kill_time = process_kill_time;
+ actor.start_time = process_start_time;
+ actor.restart_on_failure = false;
sg_platf_new_actor(&actor);
}
-
-namespace simgrid {
-namespace simix {
-
-void register_function(const std::string& name, const ActorCodeFactory& factory)
-{
- simix_global->registered_functions[name] = factory;
-}
-
-}
-}
-/* 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 (simgrid::simix::cfg_verbose_exit) {
XBT_INFO("CTRL-C pressed. The current status will be displayed before exit (disable that behavior with option "
"'debug/verbose-exit').");
- SIMIX_display_process_status();
+ simix_global->display_all_actor_status();
}
else {
XBT_INFO("CTRL-C pressed, exiting. Hiding the current process status since 'debug/verbose-exit' is set to false.");
} else if (siginfo->si_signo == SIGSEGV) {
fprintf(stderr, "Segmentation fault.\n");
#if HAVE_SMPI
- if (smpi_enabled() && smpi_privatize_global_variables == SmpiPrivStrategies::NONE) {
+ if (smpi_enabled() && smpi_cfg_privatization() == SmpiPrivStrategies::NONE) {
#if HAVE_PRIVATIZATION
fprintf(stderr, "Try to enable SMPI variable privatization with --cfg=smpi/privatization:yes.\n");
#else
actors_to_run.clear();
}
+/** Wake up all actors waiting for a Surf action to finish */
+void Global::wake_all_waiting_actors()
+{
+ for (auto const& model : all_existing_models) {
+ kernel::resource::Action* action;
+
+ XBT_DEBUG("Handling the failed actions (if any)");
+ while ((action = model->extract_failed_action())) {
+ XBT_DEBUG(" Handling Action %p", action);
+ if (action->get_activity() != nullptr)
+ kernel::activity::ActivityImplPtr(action->get_activity())->post();
+ }
+ XBT_DEBUG("Handling the terminated actions (if any)");
+ while ((action = model->extract_done_action())) {
+ XBT_DEBUG(" Handling Action %p", action);
+ if (action->get_activity() == nullptr)
+ XBT_DEBUG("probably vcpu's action %p, skip", action);
+ else
+ kernel::activity::ActivityImplPtr(action->get_activity())->post();
+ }
+ }
+}
+
+void Global::display_all_actor_status()
+{
+ XBT_INFO("%zu actors are still running, waiting for something.", process_list.size());
+ /* List the actors and their state */
+ XBT_INFO("Legend of the following listing: \"Actor <pid> (<name>@<host>): <status>\"");
+ for (auto const& kv : process_list) {
+ kernel::actor::ActorImpl* actor = kv.second;
+
+ if (actor->waiting_synchro) {
+ const char* synchro_description = "unknown";
+ // we don't care about the Activity type to get its name, use RawImpl
+ const char* name = boost::static_pointer_cast<kernel::activity::ActivityImpl_T<kernel::activity::RawImpl>>(
+ actor->waiting_synchro)
+ ->get_cname();
+
+ if (boost::dynamic_pointer_cast<kernel::activity::ExecImpl>(actor->waiting_synchro) != nullptr)
+ synchro_description = "execution";
+
+ if (boost::dynamic_pointer_cast<kernel::activity::CommImpl>(actor->waiting_synchro) != nullptr)
+ synchro_description = "communication";
+
+ if (boost::dynamic_pointer_cast<kernel::activity::SleepImpl>(actor->waiting_synchro) != nullptr)
+ synchro_description = "sleeping";
+
+ if (boost::dynamic_pointer_cast<kernel::activity::RawImpl>(actor->waiting_synchro) != nullptr)
+ synchro_description = "synchronization";
+
+ if (boost::dynamic_pointer_cast<kernel::activity::IoImpl>(actor->waiting_synchro) != nullptr)
+ synchro_description = "I/O";
+
+ XBT_INFO("Actor %ld (%s@%s): waiting for %s activity %p (%s) in state %d to finish", actor->get_pid(),
+ actor->get_cname(), actor->get_host()->get_cname(), synchro_description, actor->waiting_synchro.get(),
+ name, (int)actor->waiting_synchro->state_);
+ } else {
+ XBT_INFO("Actor %ld (%s@%s)", actor->get_pid(), actor->get_cname(), actor->get_host()->get_cname());
+ }
+ }
+}
+
config::Flag<double> cfg_breakpoint{
"debug/breakpoint", {"simix/breakpoint"}, "When non-negative, raise a SIGTRAP after given (simulated) time", -1.0};
} // namespace simix
} // namespace simgrid
-static simgrid::simix::ActorCode maestro_code;
+static simgrid::kernel::actor::ActorCode maestro_code;
void SIMIX_set_maestro(void (*code)(void*), void* data)
{
#ifdef _WIN32
surf_init(argc, argv); /* Initialize SURF structures */
simix_global.reset(new simgrid::simix::Global());
- simix_global->maestro_process = nullptr;
+ simix_global->maestro_ = nullptr;
SIMIX_context_mod_init();
// Either create a new context with maestro or create
/* 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"))
#endif
/* Kill all processes (but maestro) */
- simix_global->maestro_process->kill_all();
+ simix_global->maestro_->kill_all();
simix_global->run_all_actors();
simix_global->empty_trash();
#endif
/* Let's free maestro now */
- delete simix_global->maestro_process;
- simix_global->maestro_process = nullptr;
+ delete simix_global->maestro_;
+ simix_global->maestro_ = nullptr;
/* Finish context module and SURF */
SIMIX_context_mod_exit();
}
}
-/** Wake up all processes waiting for a Surf action to finish */
-static void SIMIX_wake_processes()
-{
- for (auto const& model : all_existing_models) {
- simgrid::kernel::resource::Action* action;
-
- XBT_DEBUG("Handling the failed actions (if any)");
- while ((action = model->extract_failed_action())) {
- XBT_DEBUG(" Handling Action %p",action);
- if (action->get_activity() != nullptr)
- simgrid::kernel::activity::ActivityImplPtr(action->get_activity())->post();
- }
- XBT_DEBUG("Handling the terminated actions (if any)");
- while ((action = model->extract_done_action())) {
- XBT_DEBUG(" Handling Action %p",action);
- if (action->get_activity() == nullptr)
- XBT_DEBUG("probably vcpu's action %p, skip", action);
- else
- simgrid::kernel::activity::ActivityImplPtr(action->get_activity())->post();
- }
- }
-}
-
/** Handle any pending timer. Returns if something was actually run. */
static bool SIMIX_execute_timers()
{
* Short proof: only maestro adds stuff to the actors_to_run array, so the execution order of user contexts do
* not impact its order.
*
- * Long proof: processes remain sorted through an arbitrary (implicit, complex but fixed) order in all cases.
+ * Long proof: actors remain sorted through an arbitrary (implicit, complex but fixed) order in all cases.
*
- * - if there is no kill during the simulation, processes remain sorted according by their PID.
+ * - if there is no kill during the simulation, actors remain sorted according by their PID.
* Rationale: This can be proved inductively.
* Assume that actors_to_run is sorted at a beginning of one round (it is at round 0: the deployment file
* is parsed linearly).
* Let's show that it is still so at the end of this round.
- * - if a process is added when being created, that's from maestro. It can be either at startup
+ * - if an actor is added when being created, that's from maestro. It can be either at startup
* time (and then in PID order), or in response to a process_create simcall. Since simcalls are handled
* in arbitrary order (inductive hypothesis), we are fine.
- * - If a process is added because it's getting killed, its subsequent actions shouldn't matter
- * - If a process gets added to actors_to_run because one of their blocking action constituting the meat
+ * - If an actor is added because it's getting killed, its subsequent actions shouldn't matter
+ * - If an actor gets added to actors_to_run because one of their blocking action constituting the meat
* of a simcall terminates, we're still good. Proof:
- * - You are added from ActorImpl::simcall_answer() only. When this function is called depends on the resource
- * kind (network, cpu, disk, whatever), but the same arguments hold. Let's take communications as an
- * example.
+ * - You are added from ActorImpl::simcall_answer() only. When this function is called depends on the
+ * resource kind (network, cpu, disk, whatever), but the same arguments hold. Let's take communications
+ * as an example.
* - For communications, this function is called from SIMIX_comm_finish().
* This function itself don't mess with the order since simcalls are handled in FIFO order.
* The function is called:
* This order is also fixed because it depends of the order in which the surf actions were
* added to the system, and only maestro can add stuff this way, through simcalls.
* We thus use the inductive hypothesis once again to conclude that the order in which synchros are
- * poped out of the set does not depend on the user code's execution order.
+ * popped out of the set does not depend on the user code's execution order.
* - because the communication terminated. In this case, synchros are served in the order given by
* set = model->states.done_action_set;
* while ((synchro = extract(set)))
* SIMIX_simcall_post((smx_synchro_t) synchro->data);
* and the argument is very similar to the previous one.
- * So, in any case, the orders of calls to SIMIX_comm_finish() do not depend on the order in which user
- * processes are executed.
- * So, in any cases, the orders of processes within actors_to_run do not depend on the order in which
- * user processes were executed previously.
+ * So, in any case, the orders of calls to CommImpl::finish() do not depend on the order in which user
+ * actors are executed.
+ * So, in any cases, the orders of actors within actors_to_run do not depend on the order in which
+ * user actors were executed previously.
* So, if there is no killing in the simulation, the simulation reproducibility is not jeopardized.
- * - If there is some process killings, the order is changed by this decision that comes from user-land
+ * - If there is some actor killings, the order is changed by this decision that comes from user-land
* But this decision may not have been motivated by a situation that were different because the simulation is
* not reproducible.
- * So, even the order change induced by the process killing is perfectly reproducible.
+ * So, even the order change induced by the actor killing is perfectly reproducible.
*
* So science works, bitches [http://xkcd.com/54/].
*
simix_global->execute_tasks();
do {
- SIMIX_wake_processes();
+ simix_global->wake_all_waiting_actors();
} while (simix_global->execute_tasks());
/* If only daemon processes remain, cancel their actions, mark them to die and reschedule them */
if (simix_global->process_list.size() == simix_global->daemons.size())
for (auto const& dmon : simix_global->daemons) {
XBT_DEBUG("Kill %s", dmon->get_cname());
- simix_global->maestro_process->kill(dmon);
+ simix_global->maestro_->kill(dmon);
}
}
again = SIMIX_execute_timers();
if (simix_global->execute_tasks())
again = true;
- SIMIX_wake_processes();
+ simix_global->wake_all_waiting_actors();
} while (again);
/* Clean actors to destroy */
XBT_DEBUG("### time %f, #processes %zu, #to_run %zu", time, simix_global->process_list.size(),
simix_global->actors_to_run.size());
-
} while (time > -1.0 || not simix_global->actors_to_run.empty());
if (not simix_global->process_list.empty()) {
-
if (simix_global->process_list.size() <= simix_global->daemons.size()) {
XBT_CRITICAL("Oops! Daemon actors cannot do any blocking activity (communications, synchronization, etc) "
"once the simulation is over. Please fix your on_exit() functions.");
} else {
XBT_CRITICAL("Oops! Deadlock or code not perfectly clean.");
}
- SIMIX_display_process_status();
+ simix_global->display_all_actor_status();
simgrid::s4u::Engine::on_deadlock();
xbt_abort();
}
return timer ? timer->get_date() : 0;
}
-void SIMIX_display_process_status()
+void SIMIX_display_process_status() // XBT_ATTRIB_DEPRECATED_v329
{
- int nbprocess = simix_global->process_list.size();
-
- XBT_INFO("%d processes are still running, waiting for something.", nbprocess);
- /* List the process and their state */
- XBT_INFO("Legend of the following listing: \"Process <pid> (<name>@<host>): <status>\"");
- for (auto const& kv : simix_global->process_list) {
- simgrid::kernel::actor::ActorImpl* actor = kv.second;
-
- if (actor->waiting_synchro) {
-
- const char* synchro_description = "unknown";
- // we don't care about the Activity type to get its name, use RawImpl
- const char* name =
- boost::static_pointer_cast<simgrid::kernel::activity::ActivityImpl_T<simgrid::kernel::activity::RawImpl>>(
- actor->waiting_synchro)
- ->get_cname();
-
- if (boost::dynamic_pointer_cast<simgrid::kernel::activity::ExecImpl>(actor->waiting_synchro) != nullptr)
- synchro_description = "execution";
-
- if (boost::dynamic_pointer_cast<simgrid::kernel::activity::CommImpl>(actor->waiting_synchro) != nullptr)
- synchro_description = "communication";
-
- if (boost::dynamic_pointer_cast<simgrid::kernel::activity::SleepImpl>(actor->waiting_synchro) != nullptr)
- synchro_description = "sleeping";
-
- if (boost::dynamic_pointer_cast<simgrid::kernel::activity::RawImpl>(actor->waiting_synchro) != nullptr)
- synchro_description = "synchronization";
-
- if (boost::dynamic_pointer_cast<simgrid::kernel::activity::IoImpl>(actor->waiting_synchro) != nullptr)
- synchro_description = "I/O";
-
- XBT_INFO("Actor %ld (%s@%s): waiting for %s activity %p (%s) in state %d to finish", actor->get_pid(),
- actor->get_cname(), actor->get_host()->get_cname(), synchro_description, actor->waiting_synchro.get(),
- name, (int)actor->waiting_synchro->state_);
- }
- else {
- XBT_INFO("Actor %ld (%s@%s)", actor->get_pid(), actor->get_cname(), actor->get_host()->get_cname());
- }
- }
+ simix_global->display_all_actor_status();
}
int SIMIX_is_maestro()
{
if (simix_global == nullptr) // SimDag
return true;
- simgrid::kernel::actor::ActorImpl* self = SIMIX_process_self();
- return self == nullptr || self == simix_global->maestro_process;
+ 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. */
*/
void empty_trash();
void run_all_actors();
+ void wake_all_waiting_actors();
+ void display_all_actor_status();
smx_context_factory_t context_factory = nullptr;
std::vector<kernel::actor::ActorImpl*> actors_to_run;
xbt_dynar_t actors_vector = xbt_dynar_new(sizeof(kernel::actor::ActorImpl*), nullptr);
xbt_dynar_t dead_actors_vector = xbt_dynar_new(sizeof(kernel::actor::ActorImpl*), nullptr);
#endif
- kernel::actor::ActorImpl* maestro_process = nullptr;
-
- // Maps function names to actor code:
- std::unordered_map<std::string, simix::ActorCodeFactory> registered_functions;
-
- // This might be used when no corresponding function name is registered:
- simix::ActorCodeFactory default_function;
+ kernel::actor::ActorImpl* maestro_ = nullptr;
std::mutex mutex;
-/* 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 running_processes = 0;
-void smpi_init_fortran_types(){
- if(simgrid::smpi::F2C::lookup() == nullptr){
- MPI_COMM_WORLD->add_f();
- MPI_BYTE->add_f();//MPI_BYTE
- MPI_CHAR->add_f();//MPI_CHARACTER
- if(sizeof(void*)==8) {
- MPI_C_BOOL->add_f();//MPI_LOGICAL
- MPI_INT->add_f();//MPI_INTEGER
- } else {
- MPI_C_BOOL->add_f();//MPI_LOGICAL
- MPI_LONG->add_f();//MPI_INTEGER
- }
- MPI_INT8_T->add_f();//MPI_INTEGER1
- MPI_INT16_T->add_f();//MPI_INTEGER2
- MPI_INT32_T->add_f();//MPI_INTEGER4
- MPI_INT64_T->add_f();//MPI_INTEGER8
- MPI_REAL->add_f();//MPI_REAL
- MPI_REAL4->add_f();//MPI_REAL4
- MPI_REAL8->add_f();//MPI_REAL8
- MPI_DOUBLE->add_f();//MPI_DOUBLE_PRECISION
- MPI_COMPLEX8->add_f();//MPI_COMPLEX
- MPI_COMPLEX16->add_f();//MPI_DOUBLE_COMPLEX
- if(sizeof(void*)==8)
- MPI_2INT->add_f();//MPI_2INTEGER
- else
- MPI_2LONG->add_f();//MPI_2INTEGER
- MPI_UINT8_T->add_f();//MPI_LOGICAL1
- MPI_UINT16_T->add_f();//MPI_LOGICAL2
- MPI_UINT32_T->add_f();//MPI_LOGICAL4
- MPI_UINT64_T->add_f();//MPI_LOGICAL8
- MPI_2FLOAT->add_f();//MPI_2REAL
- MPI_2DOUBLE->add_f();//MPI_2DOUBLE_PRECISION
- MPI_PTR->add_f();//MPI_AINT
- MPI_OFFSET->add_f();//MPI_OFFSET
- MPI_AINT->add_f();//MPI_COUNT
- MPI_REAL16->add_f();//MPI_REAL16
- MPI_PACKED->add_f();//MPI_PACKED
- MPI_COMPLEX8->add_f();//MPI_COMPLEX8
- MPI_COMPLEX16->add_f();//MPI_COMPLEX16
- MPI_COMPLEX32->add_f();//MPI_COMPLEX32
-
- MPI_MAX->add_f();
- MPI_MIN->add_f();
- MPI_MAXLOC->add_f();
- MPI_MINLOC->add_f();
- MPI_SUM->add_f();
- MPI_PROD->add_f();
- MPI_LAND->add_f();
- MPI_LOR->add_f();
- MPI_LXOR->add_f();
- MPI_BAND->add_f();
- MPI_BOR->add_f();
- MPI_BXOR->add_f();
-
- MPI_ERRORS_RETURN->add_f();
- MPI_ERRORS_ARE_FATAL->add_f();
- }
+void smpi_init_fortran_types()
+{
+ if (simgrid::smpi::F2C::lookup() == nullptr) {
+ MPI_COMM_WORLD->add_f();
+ MPI_BYTE->add_f(); // MPI_BYTE
+ MPI_CHAR->add_f(); // MPI_CHARACTER
+ if (sizeof(void*) == 8) {
+ MPI_C_BOOL->add_f(); // MPI_LOGICAL
+ MPI_INT->add_f(); // MPI_INTEGER
+ } else {
+ MPI_C_BOOL->add_f(); // MPI_LOGICAL
+ MPI_LONG->add_f(); // MPI_INTEGER
+ }
+ MPI_INT8_T->add_f(); // MPI_INTEGER1
+ MPI_INT16_T->add_f(); // MPI_INTEGER2
+ MPI_INT32_T->add_f(); // MPI_INTEGER4
+ MPI_INT64_T->add_f(); // MPI_INTEGER8
+ MPI_REAL->add_f(); // MPI_REAL
+ MPI_REAL4->add_f(); // MPI_REAL4
+ MPI_REAL8->add_f(); // MPI_REAL8
+ MPI_DOUBLE->add_f(); // MPI_DOUBLE_PRECISION
+ MPI_COMPLEX8->add_f(); // MPI_COMPLEX
+ MPI_COMPLEX16->add_f(); // MPI_DOUBLE_COMPLEX
+ if (sizeof(void*) == 8)
+ MPI_2INT->add_f(); // MPI_2INTEGER
+ else
+ MPI_2LONG->add_f(); // MPI_2INTEGER
+ MPI_UINT8_T->add_f(); // MPI_LOGICAL1
+ MPI_UINT16_T->add_f(); // MPI_LOGICAL2
+ MPI_UINT32_T->add_f(); // MPI_LOGICAL4
+ MPI_UINT64_T->add_f(); // MPI_LOGICAL8
+ MPI_2FLOAT->add_f(); // MPI_2REAL
+ MPI_2DOUBLE->add_f(); // MPI_2DOUBLE_PRECISION
+ MPI_PTR->add_f(); // MPI_AINT
+ MPI_OFFSET->add_f(); // MPI_OFFSET
+ MPI_AINT->add_f(); // MPI_COUNT
+ MPI_REAL16->add_f(); // MPI_REAL16
+ MPI_PACKED->add_f(); // MPI_PACKED
+ MPI_COMPLEX8->add_f(); // MPI_COMPLEX8
+ MPI_COMPLEX16->add_f(); // MPI_COMPLEX16
+ MPI_COMPLEX32->add_f(); // MPI_COMPLEX32
+
+ MPI_MAX->add_f();
+ MPI_MIN->add_f();
+ MPI_MAXLOC->add_f();
+ MPI_MINLOC->add_f();
+ MPI_SUM->add_f();
+ MPI_PROD->add_f();
+ MPI_LAND->add_f();
+ MPI_LOR->add_f();
+ MPI_LXOR->add_f();
+ MPI_BAND->add_f();
+ MPI_BOR->add_f();
+ MPI_BXOR->add_f();
+
+ MPI_ERRORS_RETURN->add_f();
+ MPI_ERRORS_ARE_FATAL->add_f();
+ }
}
extern "C" { // This should really use the C linkage to be usable from Fortran
-
-void mpi_init_(int* ierr) {
- smpi_init_fortran_types();
- *ierr = MPI_Init(nullptr, nullptr);
- running_processes++;
+void mpi_init_(int* ierr)
+{
+ smpi_init_fortran_types();
+ *ierr = MPI_Init(nullptr, nullptr);
+ running_processes++;
}
-void mpi_finalize_(int* ierr) {
- *ierr = MPI_Finalize();
- running_processes--;
+void mpi_finalize_(int* ierr)
+{
+ *ierr = MPI_Finalize();
+ running_processes--;
}
-void mpi_abort_(int* comm, int* errorcode, int* ierr) {
+void mpi_abort_(int* comm, int* errorcode, int* ierr)
+{
*ierr = MPI_Abort(simgrid::smpi::Comm::f2c(*comm), *errorcode);
}
-double mpi_wtime_() {
- return MPI_Wtime();
+double mpi_wtime_()
+{
+ return MPI_Wtime();
}
-double mpi_wtick_() {
+double mpi_wtick_()
+{
return MPI_Wtick();
}
-void mpi_group_incl_(int* group, int* n, int* ranks, int* group_out, int* ierr) {
+void mpi_group_incl_(int* group, int* n, int* ranks, int* group_out, int* ierr)
+{
MPI_Group tmp;
*ierr = MPI_Group_incl(simgrid::smpi::Group::f2c(*group), *n, ranks, &tmp);
}
}
-void mpi_initialized_(int* flag, int* ierr){
+void mpi_initialized_(int* flag, int* ierr)
+{
*ierr = MPI_Initialized(flag);
}
-void mpi_get_processor_name_(char *name, int *resultlen, int* ierr){
+void mpi_get_processor_name_(char* name, int* resultlen, int* ierr)
+{
//fortran does not handle string endings cleanly, so initialize everything before
memset(name, 0, MPI_MAX_PROCESSOR_NAME);
*ierr = MPI_Get_processor_name(name, resultlen);
}
-void mpi_get_count_(MPI_Status * status, int* datatype, int *count, int* ierr){
+void mpi_get_count_(MPI_Status* status, int* datatype, int* count, int* ierr)
+{
*ierr = MPI_Get_count(FORT_STATUS_IGNORE(status), simgrid::smpi::Datatype::f2c(*datatype), count);
}
-void mpi_attr_get_(int* comm, int* keyval, int* attr_value, int* flag, int* ierr ){
+void mpi_attr_get_(int* comm, int* keyval, int* attr_value, int* flag, int* ierr)
+{
int* value = nullptr;
*ierr = MPI_Attr_get(simgrid::smpi::Comm::f2c(*comm), *keyval, &value, flag);
if(*flag == 1)
*attr_value=*value;
}
-void mpi_error_string_(int* errorcode, char* string, int* resultlen, int* ierr){
+void mpi_error_string_(int* errorcode, char* string, int* resultlen, int* ierr)
+{
*ierr = MPI_Error_string(*errorcode, string, resultlen);
}
-void mpi_win_fence_( int* assert, int* win, int* ierr){
+void mpi_win_fence_(int* assert, int* win, int* ierr)
+{
*ierr = MPI_Win_fence(* assert, simgrid::smpi::Win::f2c(*win));
}
-void mpi_win_free_( int* win, int* ierr){
+void mpi_win_free_(int* win, int* ierr)
+{
MPI_Win tmp = simgrid::smpi::Win::f2c(*win);
*ierr = MPI_Win_free(&tmp);
if(*ierr == MPI_SUCCESS) {
}
}
-void mpi_win_create_( int *base, MPI_Aint* size, int* disp_unit, int* info, int* comm, int *win, int* ierr){
+void mpi_win_create_(int* base, MPI_Aint* size, int* disp_unit, int* info, int* comm, int* win, int* ierr)
+{
MPI_Win tmp;
*ierr = MPI_Win_create( static_cast<void*>(base), *size, *disp_unit, simgrid::smpi::Info::f2c(*info), simgrid::smpi::Comm::f2c(*comm),&tmp);
- if(*ierr == MPI_SUCCESS) {
- *win = tmp->add_f();
- }
+ if (*ierr == MPI_SUCCESS) {
+ *win = tmp->add_f();
+ }
}
-void mpi_win_post_(int* group, int assert, int* win, int* ierr){
+void mpi_win_post_(int* group, int assert, int* win, int* ierr)
+{
*ierr = MPI_Win_post(simgrid::smpi::Group::f2c(*group), assert, simgrid::smpi::Win::f2c(*win));
}
-void mpi_win_start_(int* group, int assert, int* win, int* ierr){
+void mpi_win_start_(int* group, int assert, int* win, int* ierr)
+{
*ierr = MPI_Win_start(simgrid::smpi::Group::f2c(*group), assert, simgrid::smpi::Win::f2c(*win));
}
-void mpi_win_complete_(int* win, int* ierr){
+void mpi_win_complete_(int* win, int* ierr)
+{
*ierr = MPI_Win_complete(simgrid::smpi::Win::f2c(*win));
}
-void mpi_win_wait_(int* win, int* ierr){
+void mpi_win_wait_(int* win, int* ierr)
+{
*ierr = MPI_Win_wait(simgrid::smpi::Win::f2c(*win));
}
-void mpi_win_set_name_ (int* win, char * name, int* ierr, int size){
+void mpi_win_set_name_(int* win, char* name, int* ierr, int size)
+{
//handle trailing blanks
while(name[size-1]==' ')
size--;
xbt_free(tname);
}
-void mpi_win_get_name_ (int* win, char * name, int* len, int* ierr){
+void mpi_win_get_name_(int* win, char* name, int* len, int* ierr)
+{
*ierr = MPI_Win_get_name(simgrid::smpi::Win::f2c(*win),name,len);
if(*len>0)
name[*len]=' ';//blank padding, not \0
}
-void mpi_win_allocate_( MPI_Aint* size, int* disp_unit, int* info, int* comm, void* base, int* win, int* ierr){
+void mpi_win_allocate_(MPI_Aint* size, int* disp_unit, int* info, int* comm, void* base, int* win, int* ierr)
+{
MPI_Win tmp;
*ierr = MPI_Win_allocate( *size, *disp_unit, simgrid::smpi::Info::f2c(*info), simgrid::smpi::Comm::f2c(*comm),static_cast<void*>(base),&tmp);
if(*ierr == MPI_SUCCESS) {
}
}
-void mpi_win_attach_(int* win, int* base, MPI_Aint* size, int* ierr){
+void mpi_win_attach_(int* win, int* base, MPI_Aint* size, int* ierr)
+{
*ierr = MPI_Win_attach(simgrid::smpi::Win::f2c(*win), static_cast<void*>(base), *size);
}
-void mpi_win_create_dynamic_( int* info, int* comm, int *win, int* ierr){
+void mpi_win_create_dynamic_(int* info, int* comm, int* win, int* ierr)
+{
MPI_Win tmp;
*ierr = MPI_Win_create_dynamic( simgrid::smpi::Info::f2c(*info), simgrid::smpi::Comm::f2c(*comm),&tmp);
if(*ierr == MPI_SUCCESS) {
}
}
-void mpi_win_detach_(int* win, int* base, int* ierr){
+void mpi_win_detach_(int* win, int* base, int* ierr)
+{
*ierr = MPI_Win_detach(simgrid::smpi::Win::f2c(*win), static_cast<void*>(base));
}
-void mpi_win_set_info_(int* win, int* info, int* ierr){
+void mpi_win_set_info_(int* win, int* info, int* ierr)
+{
*ierr = MPI_Win_set_info(simgrid::smpi::Win::f2c(*win), simgrid::smpi::Info::f2c(*info));
}
-void mpi_win_get_info_(int* win, int* info, int* ierr){
+void mpi_win_get_info_(int* win, int* info, int* ierr)
+{
MPI_Info tmp;
*ierr = MPI_Win_get_info(simgrid::smpi::Win::f2c(*win), &tmp);
- if(*ierr == MPI_SUCCESS) {
- *info = tmp->add_f();
- }
+ if (*ierr == MPI_SUCCESS) {
+ *info = tmp->add_f();
+ }
}
-void mpi_win_get_group_(int* win, int* group, int* ierr){
+void mpi_win_get_group_(int* win, int* group, int* ierr)
+{
MPI_Group tmp;
*ierr = MPI_Win_get_group(simgrid::smpi::Win::f2c(*win), &tmp);
- if(*ierr == MPI_SUCCESS) {
- *group = tmp->add_f();
- }
+ if (*ierr == MPI_SUCCESS) {
+ *group = tmp->add_f();
+ }
}
-void mpi_win_get_attr_(int* win, int* type_keyval, MPI_Aint* attribute_val, int* flag, int* ierr){
- MPI_Aint* value = nullptr;
+void mpi_win_get_attr_(int* win, int* type_keyval, MPI_Aint* attribute_val, int* flag, int* ierr)
+{
+ MPI_Aint* value = nullptr;
*ierr = MPI_Win_get_attr(simgrid::smpi::Win::f2c(*win), *type_keyval, &value, flag);
if (*flag == 1)
*attribute_val = *value;
}
-void mpi_win_set_attr_(int* win, int* type_keyval, MPI_Aint* att, int* ierr){
- MPI_Aint* val = (MPI_Aint*)xbt_malloc(sizeof(MPI_Aint));
- *val=*att;
+void mpi_win_set_attr_(int* win, int* type_keyval, MPI_Aint* att, int* ierr)
+{
+ MPI_Aint* val = (MPI_Aint*)xbt_malloc(sizeof(MPI_Aint));
+ *val = *att;
*ierr = MPI_Win_set_attr(simgrid::smpi::Win::f2c(*win), *type_keyval, val);
}
-void mpi_win_delete_attr_(int* win, int* comm_keyval, int* ierr){
+void mpi_win_delete_attr_(int* win, int* comm_keyval, int* ierr)
+{
*ierr = MPI_Win_delete_attr (simgrid::smpi::Win::f2c(*win), *comm_keyval);
}
-void mpi_win_create_keyval_(void* copy_fn, void* delete_fn, int* keyval, void* extra_state, int* ierr){
+void mpi_win_create_keyval_(void* copy_fn, void* delete_fn, int* keyval, void* extra_state, int* ierr)
+{
smpi_copy_fn _copy_fn={nullptr,nullptr,nullptr,nullptr,nullptr,(*(int*)copy_fn) == 0 ? nullptr : reinterpret_cast<MPI_Win_copy_attr_function_fort*>(copy_fn)};
smpi_delete_fn _delete_fn={nullptr,nullptr,nullptr,nullptr,nullptr,(*(int*)delete_fn) == 0 ? nullptr : reinterpret_cast<MPI_Win_delete_attr_function_fort*>(delete_fn)};
*ierr = simgrid::smpi::Keyval::keyval_create<simgrid::smpi::Win>(_copy_fn, _delete_fn, keyval, extra_state);
}
-void mpi_win_free_keyval_(int* keyval, int* ierr){
+void mpi_win_free_keyval_(int* keyval, int* ierr)
+{
*ierr = MPI_Win_free_keyval( keyval);
}
-void mpi_win_lock_(int* lock_type, int* rank, int* assert, int* win, int* ierr){
+void mpi_win_lock_(int* lock_type, int* rank, int* assert, int* win, int* ierr)
+{
*ierr = MPI_Win_lock(*lock_type, *rank, *assert, simgrid::smpi::Win::f2c(*win));
}
-void mpi_win_lock_all_(int* assert, int* win, int* ierr){
+void mpi_win_lock_all_(int* assert, int* win, int* ierr)
+{
*ierr = MPI_Win_lock_all(*assert, simgrid::smpi::Win::f2c(*win));
}
-void mpi_win_unlock_(int* rank, int* win, int* ierr){
+void mpi_win_unlock_(int* rank, int* win, int* ierr)
+{
*ierr = MPI_Win_unlock(*rank, simgrid::smpi::Win::f2c(*win));
}
-void mpi_win_unlock_all_(int* win, int* ierr){
+void mpi_win_unlock_all_(int* win, int* ierr)
+{
*ierr = MPI_Win_unlock_all(simgrid::smpi::Win::f2c(*win));
}
-void mpi_win_flush_(int* rank, int* win, int* ierr){
+void mpi_win_flush_(int* rank, int* win, int* ierr)
+{
*ierr = MPI_Win_flush(*rank, simgrid::smpi::Win::f2c(*win));
}
-void mpi_win_flush_local_(int* rank, int* win, int* ierr){
+void mpi_win_flush_local_(int* rank, int* win, int* ierr)
+{
*ierr = MPI_Win_flush_local(*rank, simgrid::smpi::Win::f2c(*win));
}
-void mpi_win_flush_all_(int* win, int* ierr){
+
+void mpi_win_flush_all_(int* win, int* ierr)
+{
*ierr = MPI_Win_flush_all(simgrid::smpi::Win::f2c(*win));
}
-void mpi_win_flush_local_all_(int* win, int* ierr){
+void mpi_win_flush_local_all_(int* win, int* ierr)
+{
*ierr = MPI_Win_flush_local_all(simgrid::smpi::Win::f2c(*win));
}
*ierr=MPI_SUCCESS;
}
-void mpi_info_create_( int *info, int* ierr){
+void mpi_info_create_(int* info, int* ierr)
+{
MPI_Info tmp;
*ierr = MPI_Info_create(&tmp);
if(*ierr == MPI_SUCCESS) {
}
}
-void mpi_info_set_( int *info, char *key, char *value, int* ierr, unsigned int keylen, unsigned int valuelen){
+void mpi_info_set_(int* info, char* key, char* value, int* ierr, unsigned int keylen, unsigned int valuelen)
+{
//handle trailing blanks
while(key[keylen-1]==' ')
keylen--;
xbt_free(tvalue);
}
-void mpi_info_get_ (int* info,char *key,int* valuelen, char *value, int *flag, int* ierr, unsigned int keylen ){
+void mpi_info_get_(int* info, char* key, int* valuelen, char* value, int* flag, int* ierr, unsigned int keylen)
+{
while(key[keylen-1]==' ')
keylen--;
while(*key==' '){//handle leading blanks
}
}
-void mpi_info_free_(int* info, int* ierr){
+void mpi_info_free_(int* info, int* ierr)
+{
MPI_Info tmp = simgrid::smpi::Info::f2c(*info);
*ierr = MPI_Info_free(&tmp);
if(*ierr == MPI_SUCCESS) {
}
}
-void mpi_get_( int *origin_addr, int* origin_count, int* origin_datatype, int *target_rank,
- MPI_Aint* target_disp, int *target_count, int* tarsmpi_type_f2c, int* win, int* ierr){
+void mpi_get_(int* origin_addr, int* origin_count, int* origin_datatype, int* target_rank, MPI_Aint* target_disp,
+ int* target_count, int* tarsmpi_type_f2c, int* win, int* ierr)
+{
*ierr = MPI_Get( static_cast<void*>(origin_addr),*origin_count, simgrid::smpi::Datatype::f2c(*origin_datatype),*target_rank,
*target_disp, *target_count, simgrid::smpi::Datatype::f2c(*tarsmpi_type_f2c), simgrid::smpi::Win::f2c(*win));
}
-void mpi_rget_( int *origin_addr, int* origin_count, int* origin_datatype, int *target_rank,
- MPI_Aint* target_disp, int *target_count, int* tarsmpi_type_f2c, int* win, int* request, int* ierr){
+void mpi_rget_(int* origin_addr, int* origin_count, int* origin_datatype, int* target_rank, MPI_Aint* target_disp,
+ int* target_count, int* tarsmpi_type_f2c, int* win, int* request, int* ierr)
+{
MPI_Request req;
*ierr = MPI_Rget( static_cast<void*>(origin_addr),*origin_count, simgrid::smpi::Datatype::f2c(*origin_datatype),*target_rank,
*target_disp, *target_count, simgrid::smpi::Datatype::f2c(*tarsmpi_type_f2c), simgrid::smpi::Win::f2c(*win), &req);
}
}
-void mpi_accumulate_( int *origin_addr, int* origin_count, int* origin_datatype, int *target_rank,
- MPI_Aint* target_disp, int *target_count, int* tarsmpi_type_f2c, int* op, int* win, int* ierr){
+void mpi_accumulate_(int* origin_addr, int* origin_count, int* origin_datatype, int* target_rank, MPI_Aint* target_disp,
+ int* target_count, int* tarsmpi_type_f2c, int* op, int* win, int* ierr)
+{
*ierr = MPI_Accumulate( static_cast<void *>(origin_addr),*origin_count, simgrid::smpi::Datatype::f2c(*origin_datatype),*target_rank,
*target_disp, *target_count, simgrid::smpi::Datatype::f2c(*tarsmpi_type_f2c), simgrid::smpi::Op::f2c(*op), simgrid::smpi::Win::f2c(*win));
}
-void mpi_raccumulate_( int *origin_addr, int* origin_count, int* origin_datatype, int *target_rank,
- MPI_Aint* target_disp, int *target_count, int* tarsmpi_type_f2c, int* op, int* win, int* request, int* ierr){
+void mpi_raccumulate_(int* origin_addr, int* origin_count, int* origin_datatype, int* target_rank,
+ MPI_Aint* target_disp, int* target_count, int* tarsmpi_type_f2c, int* op, int* win, int* request,
+ int* ierr)
+{
MPI_Request req;
*ierr = MPI_Raccumulate( static_cast<void *>(origin_addr),*origin_count, simgrid::smpi::Datatype::f2c(*origin_datatype),*target_rank,
*target_disp, *target_count, simgrid::smpi::Datatype::f2c(*tarsmpi_type_f2c), simgrid::smpi::Op::f2c(*op), simgrid::smpi::Win::f2c(*win),&req);
}
}
-void mpi_put_( int *origin_addr, int* origin_count, int* origin_datatype, int *target_rank,
- MPI_Aint* target_disp, int *target_count, int* tarsmpi_type_f2c, int* win, int* ierr){
+void mpi_put_(int* origin_addr, int* origin_count, int* origin_datatype, int* target_rank, MPI_Aint* target_disp,
+ int* target_count, int* tarsmpi_type_f2c, int* win, int* ierr)
+{
*ierr = MPI_Put( static_cast<void *>(origin_addr),*origin_count, simgrid::smpi::Datatype::f2c(*origin_datatype),*target_rank,
*target_disp, *target_count, simgrid::smpi::Datatype::f2c(*tarsmpi_type_f2c), simgrid::smpi::Win::f2c(*win));
}
-void mpi_rput_( int *origin_addr, int* origin_count, int* origin_datatype, int *target_rank,
- MPI_Aint* target_disp, int *target_count, int* tarsmpi_type_f2c, int* win, int* request, int* ierr){
+void mpi_rput_(int* origin_addr, int* origin_count, int* origin_datatype, int* target_rank, MPI_Aint* target_disp,
+ int* target_count, int* tarsmpi_type_f2c, int* win, int* request, int* ierr)
+{
MPI_Request req;
*ierr = MPI_Rput( static_cast<void *>(origin_addr),*origin_count, simgrid::smpi::Datatype::f2c(*origin_datatype),*target_rank,
*target_disp, *target_count, simgrid::smpi::Datatype::f2c(*tarsmpi_type_f2c), simgrid::smpi::Win::f2c(*win),&req);
}
}
-void mpi_fetch_and_op_( int *origin_addr, int* result_addr, int* datatype, int* target_rank, MPI_Aint* target_disp, int* op, int* win, int* ierr){
+void mpi_fetch_and_op_(int* origin_addr, int* result_addr, int* datatype, int* target_rank, MPI_Aint* target_disp,
+ int* op, int* win, int* ierr)
+{
*ierr = MPI_Fetch_and_op( static_cast<void *>(origin_addr),
static_cast<void *>(result_addr), simgrid::smpi::Datatype::f2c(*datatype),*target_rank,
*target_disp, simgrid::smpi::Op::f2c(*op), simgrid::smpi::Win::f2c(*win));
*target_disp, simgrid::smpi::Win::f2c(*win));
}
-void mpi_get_accumulate_(int *origin_addr, int* origin_count, int* origin_datatype, int* result_addr,
- int* result_count, int* result_datatype, int* target_rank, MPI_Aint* target_disp, int* target_count,
- int* target_datatype, int* op, int* win, int* ierr){
+void mpi_get_accumulate_(int* origin_addr, int* origin_count, int* origin_datatype, int* result_addr, int* result_count,
+ int* result_datatype, int* target_rank, MPI_Aint* target_disp, int* target_count,
+ int* target_datatype, int* op, int* win, int* ierr)
+{
*ierr =
MPI_Get_accumulate(static_cast<void*>(origin_addr), *origin_count, simgrid::smpi::Datatype::f2c(*origin_datatype),
static_cast<void*>(result_addr), *result_count, simgrid::smpi::Datatype::f2c(*result_datatype),
simgrid::smpi::Op::f2c(*op), simgrid::smpi::Win::f2c(*win));
}
-void mpi_rget_accumulate_(int *origin_addr, int* origin_count, int* origin_datatype, int* result_addr,
- int* result_count, int* result_datatype, int* target_rank, MPI_Aint* target_disp, int* target_count,
- int* target_datatype, int* op, int* win, int* request, int* ierr){
+void mpi_rget_accumulate_(int* origin_addr, int* origin_count, int* origin_datatype, int* result_addr,
+ int* result_count, int* result_datatype, int* target_rank, MPI_Aint* target_disp,
+ int* target_count, int* target_datatype, int* op, int* win, int* request, int* ierr)
+{
MPI_Request req;
*ierr = MPI_Rget_accumulate(static_cast<void*>(origin_addr), *origin_count,
simgrid::smpi::Datatype::f2c(*origin_datatype), static_cast<void*>(result_addr),
}
//following are automatically generated, and have to be checked
-void mpi_finalized_ (int * flag, int* ierr){
- *ierr = MPI_Finalized(flag);
+void mpi_finalized_(int* flag, int* ierr)
+{
+ *ierr = MPI_Finalized(flag);
}
-void mpi_init_thread_ (int* required, int *provided, int* ierr){
+void mpi_init_thread_(int* required, int* provided, int* ierr)
+{
smpi_init_fortran_types();
*ierr = MPI_Init_thread(nullptr, nullptr,*required, provided);
running_processes++;
}
-void mpi_query_thread_ (int *provided, int* ierr){
- *ierr = MPI_Query_thread(provided);
+void mpi_query_thread_(int* provided, int* ierr)
+{
+ *ierr = MPI_Query_thread(provided);
}
-void mpi_is_thread_main_ (int *flag, int* ierr){
-
- *ierr = MPI_Is_thread_main(flag);
+void mpi_is_thread_main_(int* flag, int* ierr)
+{
+ *ierr = MPI_Is_thread_main(flag);
}
-void mpi_address_ (void *location, MPI_Aint * address, int* ierr){
-
- *ierr = MPI_Address(location, address);
+void mpi_address_(void* location, MPI_Aint* address, int* ierr)
+{
+ *ierr = MPI_Address(location, address);
}
-void mpi_get_address_ (void *location, MPI_Aint * address, int* ierr){
-
- *ierr = MPI_Get_address(location, address);
+void mpi_get_address_(void* location, MPI_Aint* address, int* ierr)
+{
+ *ierr = MPI_Get_address(location, address);
}
-void mpi_pcontrol_ (int* level , int* ierr){
- *ierr = MPI_Pcontrol(*static_cast<const int*>(level));
+void mpi_pcontrol_(int* level, int* ierr)
+{
+ *ierr = MPI_Pcontrol(*static_cast<const int*>(level));
}
-void mpi_op_create_ (void * function, int* commute, int* op, int* ierr){
+void mpi_op_create_(void* function, int* commute, int* op, int* ierr)
+{
MPI_Op tmp;
- *ierr = MPI_Op_create(reinterpret_cast<MPI_User_function*>(function),*commute, &tmp);
- if(*ierr == MPI_SUCCESS) {
- tmp->set_fortran_op();
- *op = tmp->add_f();
- }
+ *ierr = MPI_Op_create(reinterpret_cast<MPI_User_function*>(function), *commute, &tmp);
+ if (*ierr == MPI_SUCCESS) {
+ tmp->set_fortran_op();
+ *op = tmp->add_f();
+ }
}
-void mpi_op_free_ (int* op, int* ierr){
+void mpi_op_free_(int* op, int* ierr)
+{
MPI_Op tmp= simgrid::smpi::Op::f2c(*op);
*ierr = MPI_Op_free(& tmp);
if(*ierr == MPI_SUCCESS) {
}
}
-void mpi_op_commutative_ (int* op, int* commute, int* ierr){
+void mpi_op_commutative_(int* op, int* commute, int* ierr)
+{
*ierr = MPI_Op_commutative(simgrid::smpi::Op::f2c(*op), commute);
}
-void mpi_group_free_ (int* group, int* ierr){
+void mpi_group_free_(int* group, int* ierr)
+{
MPI_Group tmp = simgrid::smpi::Group::f2c(*group);
if(tmp != MPI_COMM_WORLD->group() && tmp != MPI_GROUP_EMPTY){
simgrid::smpi::Group::unref(tmp);
*ierr = MPI_SUCCESS;
}
-void mpi_group_size_ (int* group, int *size, int* ierr){
-
- *ierr = MPI_Group_size(simgrid::smpi::Group::f2c(*group), size);
+void mpi_group_size_(int* group, int* size, int* ierr)
+{
+ *ierr = MPI_Group_size(simgrid::smpi::Group::f2c(*group), size);
}
-void mpi_group_rank_ (int* group, int *rank, int* ierr){
-
- *ierr = MPI_Group_rank(simgrid::smpi::Group::f2c(*group), rank);
+void mpi_group_rank_(int* group, int* rank, int* ierr)
+{
+ *ierr = MPI_Group_rank(simgrid::smpi::Group::f2c(*group), rank);
}
void mpi_group_translate_ranks_ (int* group1, int* n, int *ranks1, int* group2, int *ranks2, int* ierr)
{
-
*ierr = MPI_Group_translate_ranks(simgrid::smpi::Group::f2c(*group1), *n, ranks1, simgrid::smpi::Group::f2c(*group2), ranks2);
}
-void mpi_group_compare_ (int* group1, int* group2, int *result, int* ierr){
-
- *ierr = MPI_Group_compare(simgrid::smpi::Group::f2c(*group1), simgrid::smpi::Group::f2c(*group2), result);
+void mpi_group_compare_(int* group1, int* group2, int* result, int* ierr)
+{
+ *ierr = MPI_Group_compare(simgrid::smpi::Group::f2c(*group1), simgrid::smpi::Group::f2c(*group2), result);
}
-void mpi_group_union_ (int* group1, int* group2, int* newgroup, int* ierr){
- MPI_Group tmp;
- *ierr = MPI_Group_union(simgrid::smpi::Group::f2c(*group1), simgrid::smpi::Group::f2c(*group2), &tmp);
- if(*ierr == MPI_SUCCESS) {
- *newgroup = tmp->add_f();
- }
+void mpi_group_union_(int* group1, int* group2, int* newgroup, int* ierr)
+{
+ MPI_Group tmp;
+ *ierr = MPI_Group_union(simgrid::smpi::Group::f2c(*group1), simgrid::smpi::Group::f2c(*group2), &tmp);
+ if (*ierr == MPI_SUCCESS) {
+ *newgroup = tmp->add_f();
+ }
}
-void mpi_group_intersection_ (int* group1, int* group2, int* newgroup, int* ierr){
- MPI_Group tmp;
- *ierr = MPI_Group_intersection(simgrid::smpi::Group::f2c(*group1), simgrid::smpi::Group::f2c(*group2), &tmp);
- if(*ierr == MPI_SUCCESS) {
- *newgroup = tmp->add_f();
- }
+void mpi_group_intersection_(int* group1, int* group2, int* newgroup, int* ierr)
+{
+ MPI_Group tmp;
+ *ierr = MPI_Group_intersection(simgrid::smpi::Group::f2c(*group1), simgrid::smpi::Group::f2c(*group2), &tmp);
+ if (*ierr == MPI_SUCCESS) {
+ *newgroup = tmp->add_f();
+ }
}
-void mpi_group_difference_ (int* group1, int* group2, int* newgroup, int* ierr){
- MPI_Group tmp;
- *ierr = MPI_Group_difference(simgrid::smpi::Group::f2c(*group1), simgrid::smpi::Group::f2c(*group2), &tmp);
- if(*ierr == MPI_SUCCESS) {
- *newgroup = tmp->add_f();
- }
+void mpi_group_difference_(int* group1, int* group2, int* newgroup, int* ierr)
+{
+ MPI_Group tmp;
+ *ierr = MPI_Group_difference(simgrid::smpi::Group::f2c(*group1), simgrid::smpi::Group::f2c(*group2), &tmp);
+ if (*ierr == MPI_SUCCESS) {
+ *newgroup = tmp->add_f();
+ }
}
-void mpi_group_excl_ (int* group, int* n, int *ranks, int* newgroup, int* ierr){
+void mpi_group_excl_(int* group, int* n, int* ranks, int* newgroup, int* ierr)
+{
MPI_Group tmp;
- *ierr = MPI_Group_excl(simgrid::smpi::Group::f2c(*group), *n, ranks, &tmp);
- if(*ierr == MPI_SUCCESS) {
- *newgroup = tmp->add_f();
- }
+ *ierr = MPI_Group_excl(simgrid::smpi::Group::f2c(*group), *n, ranks, &tmp);
+ if (*ierr == MPI_SUCCESS) {
+ *newgroup = tmp->add_f();
+ }
}
void mpi_group_range_incl_ (int* group, int* n, int ranges[][3], int* newgroup, int* ierr)
{
MPI_Group tmp;
- *ierr = MPI_Group_range_incl(simgrid::smpi::Group::f2c(*group), *n, ranges, &tmp);
- if(*ierr == MPI_SUCCESS) {
- *newgroup = tmp->add_f();
- }
+ *ierr = MPI_Group_range_incl(simgrid::smpi::Group::f2c(*group), *n, ranges, &tmp);
+ if (*ierr == MPI_SUCCESS) {
+ *newgroup = tmp->add_f();
+ }
}
void mpi_group_range_excl_ (int* group, int* n, int ranges[][3], int* newgroup, int* ierr)
*ierr= MPI_File_write(reinterpret_cast<MPI_File>(*fh), buf, *count, simgrid::smpi::Datatype::f2c(*datatype), status);
}
+void smpi_execute_flops_(double* flops){
+ smpi_execute_flops(*flops);
+}
+
+void smpi_execute_flops_benched_(double* flops){
+ smpi_execute_flops_benched(*flops);
+}
+
+void smpi_execute_(double* duration){
+ smpi_execute(*duration);
+}
+
+void smpi_execute_benched_(double* duration){
+ smpi_execute_benched(*duration);
+}
+
} // extern "C"
-/* 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. */
}
void mpi_reduce_local_ (void *inbuf, void *inoutbuf, int* count, int* datatype, int* op, int* ierr){
-
*ierr = MPI_Reduce_local(inbuf, inoutbuf, *count, simgrid::smpi::Datatype::f2c(*datatype), simgrid::smpi::Op::f2c(*op));
}
-/* 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. */
void mpi_comm_create_(int* comm, int* group, int* newcomm, int* ierr) {
MPI_Comm tmp;
-
*ierr = MPI_Comm_create(simgrid::smpi::Comm::f2c(*comm),simgrid::smpi::Group::f2c(*group), &tmp);
if(*ierr == MPI_SUCCESS) {
*newcomm = tmp->add_f();
void mpi_comm_group_(int* comm, int* group_out, int* ierr) {
MPI_Group tmp;
-
*ierr = MPI_Comm_group(simgrid::smpi::Comm::f2c(*comm), &tmp);
if(*ierr == MPI_SUCCESS) {
*group_out = tmp->c2f();
}
void mpi_comm_delete_attr_ (int* comm, int* comm_keyval, int* ierr){
-
*ierr = MPI_Comm_delete_attr (simgrid::smpi::Comm::f2c(*comm), *comm_keyval);
}
}
void mpi_comm_compare_ (int* comm1, int* comm2, int *result, int* ierr){
-
*ierr = MPI_Comm_compare(simgrid::smpi::Comm::f2c(*comm1), simgrid::smpi::Comm::f2c(*comm2), result);
}
-/* 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. */
}
void mpi_type_delete_attr_ (int* type, int* type_keyval, int* ierr){
-
*ierr = MPI_Type_delete_attr ( simgrid::smpi::Datatype::f2c(*type), *type_keyval);
}
*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){
*datatype = tmp->c2f();
}
}
-
-
}
-/* 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__); \
WRAPPED_PMPI_CALL(int, MPI_File_create_errhandler,(MPI_File_errhandler_function *function, MPI_Errhandler *errhandler),(function, errhandler))
WRAPPED_PMPI_CALL_ERRHANDLER_FILE(int, MPI_File_set_errhandler,( MPI_File fh, MPI_Errhandler errhandler), (fh, errhandler))
WRAPPED_PMPI_CALL_ERRHANDLER_FILE(int, MPI_File_get_errhandler,( MPI_File fh, MPI_Errhandler *errhandler), (fh, errhandler))
-
+WRAPPED_PMPI_CALL_ERRHANDLER_FILE(int, MPI_File_set_view,(MPI_File fh, MPI_Offset disp, MPI_Datatype etype, MPI_Datatype filetype, const char *datarep, MPI_Info info), (fh, disp, etype, filetype, datarep, info))
+WRAPPED_PMPI_CALL_ERRHANDLER_FILE(int, MPI_File_get_view,(MPI_File fh, MPI_Offset *disp, MPI_Datatype *etype, MPI_Datatype *filetype, char *datarep), (fh, disp, etype, filetype, datarep))
/*
Unimplemented Calls - both PMPI and MPI calls are generated.
When implementing, please move ahead, swap UNIMPLEMENTED_WRAPPED_PMPI_CALL for WRAPPED_PMPI_CALL,
//UNIMPLEMENTED_WRAPPED_PMPI_CALL(MPI_File, MPI_File_f2c,(MPI_Fint file), (file))
UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_set_size,(MPI_File fh, MPI_Offset size), (fh, size))
UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_preallocate,(MPI_File fh, MPI_Offset size), (fh, size))
-UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_set_view,(MPI_File fh, MPI_Offset disp, MPI_Datatype etype, MPI_Datatype filetype, const char *datarep, MPI_Info info), (fh, disp, etype, filetype, datarep, info))
-UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_get_view,(MPI_File fh, MPI_Offset *disp, MPI_Datatype *etype, MPI_Datatype *filetype, char *datarep), (fh, disp, etype, filetype, datarep))
UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_iread_at,(MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype, MPI_Request *request), (fh, offset, buf, count, datatype, request))
UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_iwrite_at,(MPI_File fh, MPI_Offset offset, const void *buf,int count, MPI_Datatype datatype, MPI_Request *request), (fh, offset, buf, count, datatype, request))
UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_iread_at_all,(MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype, MPI_Request *request), (fh, offset, buf, count, datatype, request))
-/* 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 "simgrid/instr.h"
#include "simgrid/s4u/Engine.hpp"
#include "simgrid/s4u/Host.hpp"
+#include "simgrid/version.h"
#include "smpi_comm.hpp"
#include "smpi_datatype_derived.hpp"
#include "smpi_status.hpp"
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. */
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi);
-#define CHECK_ARGS(test, errcode, ...) \
- if (test) { \
- XBT_WARN(__VA_ARGS__); \
- return (errcode); \
- }
-
static const void* smpi_get_in_place_buf(const void* inplacebuf, const void* otherbuf,std::unique_ptr<unsigned char[]>& tmp_sendbuf, int count, MPI_Datatype datatype){
if (inplacebuf == MPI_IN_PLACE) {
tmp_sendbuf.reset(new unsigned char[count * datatype->get_extent()]);
int PMPI_Ibarrier(MPI_Comm comm, MPI_Request *request)
{
- if (comm == MPI_COMM_NULL)
- return MPI_ERR_COMM;
- if (request == nullptr)
- return MPI_ERR_ARG;
+ CHECK_COMM(1)
+ CHECK_REQUEST(2)
smpi_bench_end();
int rank = simgrid::s4u::this_actor::get_pid();
int PMPI_Ibcast(void *buf, int count, MPI_Datatype datatype,
int root, MPI_Comm comm, MPI_Request* request)
{
- if (comm == MPI_COMM_NULL)
- return MPI_ERR_COMM;
- if (buf == nullptr && count > 0)
- return MPI_ERR_BUFFER;
- if (datatype == MPI_DATATYPE_NULL || not datatype->is_valid())
- return MPI_ERR_TYPE;
- if (count < 0)
- return MPI_ERR_COUNT;
- if (root < 0 || root >= comm->size())
- return MPI_ERR_ROOT;
- if (request == nullptr)
- return MPI_ERR_ARG;
+ CHECK_COMM(5)
+ CHECK_BUFFER(1, buf, count)
+ CHECK_COUNT(2, count)
+ CHECK_TYPE(3, datatype)
+ CHECK_ROOT(4)
+ CHECK_REQUEST(6)
smpi_bench_end();
int rank = simgrid::s4u::this_actor::get_pid();
int PMPI_Igather(const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount,
MPI_Datatype recvtype, int root, MPI_Comm comm, MPI_Request* request)
{
- if (comm == MPI_COMM_NULL)
- return MPI_ERR_COMM;
- if ((sendbuf == nullptr && sendcount > 0) || ((comm->rank() == root) && recvbuf == nullptr && recvcount > 0))
- return MPI_ERR_BUFFER;
- if (((sendbuf != MPI_IN_PLACE && sendcount > 0) && (sendtype == MPI_DATATYPE_NULL)) ||
- ((comm->rank() == root) && (recvtype == MPI_DATATYPE_NULL)))
- return MPI_ERR_TYPE;
- if (((sendbuf != MPI_IN_PLACE) && (sendcount < 0)) || ((comm->rank() == root) && (recvcount < 0)))
- return MPI_ERR_COUNT;
- if (root < 0 || root >= comm->size())
- return MPI_ERR_ROOT;
- if (request == nullptr)
- return MPI_ERR_ARG;
+ CHECK_COMM(8)
+ if(sendbuf != MPI_IN_PLACE){
+ CHECK_BUFFER(1,sendbuf, sendcount)
+ CHECK_COUNT(2, sendcount)
+ CHECK_TYPE(3, sendtype)
+ }
+ if(comm->rank() == root){
+ CHECK_TYPE(6, recvtype)
+ CHECK_COUNT(5, recvcount)
+ CHECK_BUFFER(4, recvbuf, recvcount)
+ }
+ CHECK_ROOT(7)
+ CHECK_REQUEST(9)
smpi_bench_end();
const void* real_sendbuf = sendbuf;
int PMPI_Igatherv(const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, const int* recvcounts, const int* displs,
MPI_Datatype recvtype, int root, MPI_Comm comm, MPI_Request* request)
{
- if (comm == MPI_COMM_NULL)
- return MPI_ERR_COMM;
- if ((sendbuf == nullptr && sendcount > 0) || ((comm->rank() == root) && recvbuf == nullptr))
- return MPI_ERR_BUFFER;
- if (((sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
- ((comm->rank() == root) && (recvtype == MPI_DATATYPE_NULL)))
- return MPI_ERR_TYPE;
- if ((sendbuf != MPI_IN_PLACE) && (sendcount < 0))
- return MPI_ERR_COUNT;
- if ((comm->rank() == root) && (recvcounts == nullptr || displs == nullptr))
- return MPI_ERR_ARG;
- if (root < 0 || root >= comm->size())
- return MPI_ERR_ROOT;
- if (request == nullptr)
- return MPI_ERR_ARG;
+ CHECK_COMM(9)
+ CHECK_BUFFER(1, sendbuf, sendcount)
+ if(sendbuf != MPI_IN_PLACE){
+ CHECK_TYPE(3, sendtype)
+ CHECK_COUNT(2, sendcount)
+ }
+ if(comm->rank() == root){
+ CHECK_TYPE(6, recvtype)
+ CHECK_NULL(5, MPI_ERR_COUNT, recvcounts)
+ CHECK_NULL(6, MPI_ERR_ARG, displs)
+ }
+ CHECK_ROOT(8)
+ CHECK_REQUEST(10)
- for (int i = 0; i < comm->size(); i++) {
- if ((comm->rank() == root) && (recvcounts[i] < 0))
- return MPI_ERR_COUNT;
+ if (comm->rank() == root){
+ for (int i = 0; i < comm->size(); i++) {
+ CHECK_COUNT(5, recvcounts[i])
+ CHECK_BUFFER(4,recvbuf,recvcounts[i])
+ }
}
smpi_bench_end();
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 PMPI_Iallgather(const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount,
MPI_Datatype recvtype, MPI_Comm comm, MPI_Request* request)
{
- CHECK_ARGS(comm == MPI_COMM_NULL, MPI_ERR_COMM, "Iallgather: the communicator cannot be MPI_COMM_NULL");
- CHECK_ARGS(recvbuf == nullptr && recvcount > 0, MPI_ERR_BUFFER, "Iallgather: param 4 recvbuf cannot be NULL");
- CHECK_ARGS(sendbuf == nullptr && sendcount > 0, MPI_ERR_BUFFER,
- "Iallgather: param 1 sendbuf cannot be NULL when sendcound > 0");
- CHECK_ARGS((sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL), MPI_ERR_TYPE,
- "Iallgather: param 3 sendtype cannot be MPI_DATATYPE_NULL when sendbuff is not MPI_IN_PLACE");
- CHECK_ARGS(recvtype == MPI_DATATYPE_NULL, MPI_ERR_TYPE, "Iallgather: param 6 recvtype cannot be MPI_DATATYPE_NULL");
- CHECK_ARGS(recvcount < 0, MPI_ERR_COUNT, "Iallgather: param 5 recvcount cannot be negative");
- CHECK_ARGS((sendbuf != MPI_IN_PLACE) && (sendcount < 0), MPI_ERR_COUNT,
- "Iallgather: param 2 sendcount cannot be negative when sendbuf is not MPI_IN_PLACE");
- CHECK_ARGS(request == nullptr, MPI_ERR_ARG, "Iallgather: param 8 request cannot be NULL");
+ CHECK_COMM(7)
+ CHECK_BUFFER(1, sendbuf, sendcount)
+ CHECK_BUFFER(4, recvbuf, recvcount)
+ if(sendbuf != MPI_IN_PLACE){
+ CHECK_COUNT(2, sendcount)
+ CHECK_TYPE(3, sendtype)
+ }
+ CHECK_TYPE(6, recvtype)
+ CHECK_COUNT(5, recvcount)
+ CHECK_REQUEST(8)
smpi_bench_end();
if (sendbuf == MPI_IN_PLACE) {
int PMPI_Iallgatherv(const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, const int* recvcounts, const int* displs,
MPI_Datatype recvtype, MPI_Comm comm, MPI_Request* request)
{
- if (comm == MPI_COMM_NULL)
- return MPI_ERR_COMM;
- if (sendbuf == nullptr && sendcount > 0)
- return MPI_ERR_BUFFER;
- if (((sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) || (recvtype == MPI_DATATYPE_NULL))
- return MPI_ERR_TYPE;
- if ((sendbuf != MPI_IN_PLACE) && (sendcount < 0))
- return MPI_ERR_COUNT;
- if (recvcounts == nullptr || displs == nullptr)
- return MPI_ERR_ARG;
- if (request == nullptr)
- return MPI_ERR_ARG;
-
+ CHECK_COMM(8)
+ CHECK_BUFFER(1, sendbuf, sendcount)
+ if(sendbuf != MPI_IN_PLACE)
+ CHECK_TYPE(3, sendtype)
+ CHECK_TYPE(6, recvtype)
+ CHECK_NULL(5, MPI_ERR_COUNT, recvcounts)
+ CHECK_NULL(6, MPI_ERR_ARG, displs)
+ if(sendbuf != MPI_IN_PLACE)
+ CHECK_COUNT(2, sendcount)
+ CHECK_REQUEST(9)
for (int i = 0; i < comm->size(); i++) {
- if (recvcounts[i] < 0)
- return MPI_ERR_COUNT;
- else if (recvcounts[i] > 0 && recvbuf == nullptr)
- return MPI_ERR_BUFFER;
+ CHECK_COUNT(5, recvcounts[i])
+ CHECK_BUFFER(4, recvbuf, recvcounts[i])
}
smpi_bench_end();
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 PMPI_Iscatter(const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount,
MPI_Datatype recvtype, int root, MPI_Comm comm, MPI_Request* request)
{
- if (comm == MPI_COMM_NULL)
- return MPI_ERR_COMM;
- if (((comm->rank() == root) && (sendtype == MPI_DATATYPE_NULL || not sendtype->is_valid())) ||
- ((recvbuf != MPI_IN_PLACE) && (recvtype == MPI_DATATYPE_NULL || not recvtype->is_valid())))
- return MPI_ERR_TYPE;
- if (((comm->rank() == root) && (sendcount < 0)) || ((recvbuf != MPI_IN_PLACE) && (recvcount < 0)))
- return MPI_ERR_COUNT;
- if ((sendbuf == recvbuf) || ((comm->rank() == root) && sendcount > 0 && (sendbuf == nullptr)) ||
- (recvcount > 0 && recvbuf == nullptr))
- return MPI_ERR_BUFFER;
- if (root < 0 || root >= comm->size())
- return MPI_ERR_ROOT;
- if (request == nullptr)
- return MPI_ERR_ARG;
+ CHECK_COMM(8)
+ if(comm->rank() == root){
+ CHECK_BUFFER(1, sendbuf, sendcount)
+ CHECK_COUNT(2, sendcount)
+ CHECK_TYPE(3, sendtype)
+ }
+ if(recvbuf != MPI_IN_PLACE){
+ CHECK_BUFFER(4, recvbuf, recvcount)
+ CHECK_COUNT(5, recvcount)
+ CHECK_TYPE(6, recvtype)
+ }
+ CHECK_ROOT(8)
+ CHECK_REQUEST(9)
smpi_bench_end();
if (recvbuf == MPI_IN_PLACE) {
int PMPI_Iscatterv(const void* sendbuf, const int* sendcounts, const int* displs, MPI_Datatype sendtype, void* recvbuf, int recvcount,
MPI_Datatype recvtype, int root, MPI_Comm comm, MPI_Request* request)
{
- CHECK_ARGS(comm == MPI_COMM_NULL, MPI_ERR_COMM, "Iscatterv: the communicator cannot be MPI_COMM_NULL");
- CHECK_ARGS((comm->rank() == root) && (sendcounts == nullptr), MPI_ERR_ARG,
- "Iscatterv: param 2 sendcounts cannot be NULL on the root rank");
- CHECK_ARGS((comm->rank() == root) && (displs == nullptr), MPI_ERR_ARG,
- "Iscatterv: param 3 displs cannot be NULL on the root rank");
- CHECK_ARGS((comm->rank() == root) && (sendtype == MPI_DATATYPE_NULL), MPI_ERR_TYPE,
- "Iscatterv: The sendtype cannot be NULL on the root rank");
- CHECK_ARGS((recvbuf != MPI_IN_PLACE) && (recvtype == MPI_DATATYPE_NULL), MPI_ERR_TYPE,
- "Iscatterv: the recvtype cannot be NULL when not receiving in place");
- CHECK_ARGS(request == nullptr, MPI_ERR_ARG, "Iscatterv: param 10 request cannot be NULL");
- CHECK_ARGS(recvbuf != MPI_IN_PLACE && recvcount < 0, MPI_ERR_COUNT,
- "Iscatterv: When not receiving in place, the recvcount cannot be negative");
- CHECK_ARGS(root < 0, MPI_ERR_ROOT, "Iscatterv: root cannot be negative");
- CHECK_ARGS(root >= comm->size(), MPI_ERR_ROOT, "Iscatterv: root (=%d) is larger than communicator size (=%d)", root,
- comm->size());
-
+ CHECK_COMM(9)
+ if(recvbuf != MPI_IN_PLACE){
+ CHECK_BUFFER(4, recvbuf, recvcount)
+ CHECK_COUNT(5, recvcount)
+ CHECK_TYPE(7, recvtype)
+ }
+ CHECK_ROOT(9)
+ CHECK_REQUEST(10)
if (comm->rank() == root) {
+ CHECK_NULL(2, MPI_ERR_COUNT, sendcounts)
+ CHECK_NULL(3, MPI_ERR_ARG, displs)
+ CHECK_TYPE(4, sendtype)
+ for (int i = 0; i < comm->size(); i++){
+ CHECK_BUFFER(1, sendbuf, sendcounts[i])
+ CHECK_COUNT(2, sendcounts[i])
+ }
if (recvbuf == MPI_IN_PLACE) {
recvtype = sendtype;
recvcount = sendcounts[comm->rank()];
}
- for (int i = 0; i < comm->size(); i++)
- CHECK_ARGS(sendcounts[i] < 0, MPI_ERR_COUNT, "Iscatterv: sendcounts[%d]=%d but this cannot be negative", i,
- sendcounts[i]);
}
smpi_bench_end();
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);
int PMPI_Ireduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm, MPI_Request* request)
{
- if (comm == MPI_COMM_NULL)
- return MPI_ERR_COMM;
- if ((sendbuf == nullptr && count > 0) || ((comm->rank() == root) && recvbuf == nullptr))
- return MPI_ERR_BUFFER;
- if (datatype == MPI_DATATYPE_NULL || not datatype->is_valid())
- return MPI_ERR_TYPE;
- if (op == MPI_OP_NULL)
- return MPI_ERR_OP;
- if (request == nullptr)
- return MPI_ERR_ARG;
- if (root < 0 || root >= comm->size())
- return MPI_ERR_ROOT;
- if (count < 0)
- return MPI_ERR_COUNT;
+ CHECK_COMM(7)
+ CHECK_BUFFER(1, sendbuf, count)
+ if(comm->rank() == root)
+ CHECK_BUFFER(5, recvbuf, count)
+ CHECK_TYPE(4, datatype)
+ CHECK_COUNT(3, count)
+ CHECK_OP(5)
+ CHECK_ROOT(7)
+ CHECK_REQUEST(8)
smpi_bench_end();
int rank = simgrid::s4u::this_actor::get_pid();
int PMPI_Reduce_local(const void* inbuf, void* inoutbuf, int count, MPI_Datatype datatype, MPI_Op op)
{
- if (datatype == MPI_DATATYPE_NULL || not datatype->is_valid())
- return MPI_ERR_TYPE;
- if (op == MPI_OP_NULL)
- return MPI_ERR_OP;
- if (count < 0)
- return MPI_ERR_COUNT;
+ CHECK_BUFFER(1, inbuf, count)
+ CHECK_BUFFER(2, inoutbuf, count)
+ CHECK_TYPE(4, datatype)
+ CHECK_COUNT(3, count)
+ CHECK_OP(5)
smpi_bench_end();
op->apply(inbuf, inoutbuf, &count, datatype);
int PMPI_Iallreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm, MPI_Request *request)
{
- if (comm == MPI_COMM_NULL)
- return MPI_ERR_COMM;
- if ((sendbuf == nullptr && count > 0) || (recvbuf == nullptr))
- return MPI_ERR_BUFFER;
- if (datatype == MPI_DATATYPE_NULL || not datatype->is_valid())
- return MPI_ERR_TYPE;
- if (count < 0)
- return MPI_ERR_COUNT;
- if (op == MPI_OP_NULL)
- return MPI_ERR_OP;
- if (request == nullptr)
- return MPI_ERR_ARG;
+ CHECK_COMM(6)
+ CHECK_BUFFER(1, sendbuf, count)
+ CHECK_BUFFER(2, recvbuf, count)
+ CHECK_TYPE(4, datatype)
+ CHECK_COUNT(3, count)
+ CHECK_REQUEST(7)
+ CHECK_OP(5)
smpi_bench_end();
std::unique_ptr<unsigned char[]> tmp_sendbuf;
int PMPI_Iscan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm, MPI_Request* request)
{
- if (comm == MPI_COMM_NULL)
- return MPI_ERR_COMM;
- if (datatype == MPI_DATATYPE_NULL || not datatype->is_valid())
- return MPI_ERR_TYPE;
- if (op == MPI_OP_NULL)
- return MPI_ERR_OP;
- if (request == nullptr)
- return MPI_ERR_ARG;
- if (count < 0)
- return MPI_ERR_COUNT;
- if (sendbuf == nullptr || recvbuf == nullptr)
- return MPI_ERR_BUFFER;
+ CHECK_COMM(6)
+ CHECK_BUFFER(1,sendbuf,count)
+ CHECK_BUFFER(2,recvbuf,count)
+ CHECK_TYPE(4, datatype)
+ CHECK_COUNT(3, count)
+ CHECK_REQUEST(7)
+ CHECK_OP(5)
smpi_bench_end();
int rank = simgrid::s4u::this_actor::get_pid();
std::unique_ptr<unsigned char[]> tmp_sendbuf;
- const void* real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, count, datatype);;
+ const void* real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, count, datatype);
TRACE_smpi_comm_in(rank, request == MPI_REQUEST_IGNORED ? "PMPI_Scan" : "PMPI_Iscan",
new simgrid::instr::Pt2PtTIData(request == MPI_REQUEST_IGNORED ? "scan" : "iscan", -1,
}
int PMPI_Iexscan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm, MPI_Request* request){
- if (comm == MPI_COMM_NULL)
- return MPI_ERR_COMM;
- if (not datatype->is_valid())
- return MPI_ERR_TYPE;
- if (op == MPI_OP_NULL)
- return MPI_ERR_OP;
- if (request == nullptr)
- return MPI_ERR_ARG;
- if (count < 0)
- return MPI_ERR_COUNT;
- if (sendbuf == nullptr || recvbuf == nullptr)
- return MPI_ERR_BUFFER;
+ CHECK_COMM(6)
+ CHECK_BUFFER(1, sendbuf, count)
+ CHECK_BUFFER(2, recvbuf, count)
+ CHECK_TYPE(4, datatype)
+ CHECK_COUNT(3, count)
+ CHECK_REQUEST(7)
+ CHECK_OP(5)
smpi_bench_end();
int rank = simgrid::s4u::this_actor::get_pid();
std::unique_ptr<unsigned char[]> tmp_sendbuf;
- const void* real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, count, datatype);;
+ const void* real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, count, datatype);
TRACE_smpi_comm_in(rank, request == MPI_REQUEST_IGNORED ? "PMPI_Exscan" : "PMPI_Iexscan",
new simgrid::instr::Pt2PtTIData(request == MPI_REQUEST_IGNORED ? "exscan" : "iexscan", -1,
int PMPI_Ireduce_scatter(const void *sendbuf, void *recvbuf, const int *recvcounts, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm, MPI_Request *request)
{
- if (comm == MPI_COMM_NULL)
- return MPI_ERR_COMM;
- if ((sendbuf == nullptr) || (recvbuf == nullptr))
- return MPI_ERR_BUFFER;
- if (datatype == MPI_DATATYPE_NULL || not datatype->is_valid())
- return MPI_ERR_TYPE;
- if (op == MPI_OP_NULL)
- return MPI_ERR_OP;
- if (recvcounts == nullptr)
- return MPI_ERR_ARG;
- if (request == nullptr)
- return MPI_ERR_ARG;
-
- for (int i = 0; i < comm->size(); i++) { // copy data to avoid bad free
- if (recvcounts[i] < 0)
- return MPI_ERR_COUNT;
+ CHECK_COMM(6)
+ CHECK_TYPE(4, datatype)
+ CHECK_NULL(3, MPI_ERR_COUNT, recvcounts)
+ CHECK_REQUEST(7)
+ CHECK_OP(5)
+ for (int i = 0; i < comm->size(); i++) {
+ CHECK_COUNT(3, recvcounts[i])
+ CHECK_BUFFER(1, sendbuf, recvcounts[i])
+ CHECK_BUFFER(2, recvbuf, recvcounts[i])
}
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;
totalcount += recvcounts[i];
}
std::unique_ptr<unsigned char[]> tmp_sendbuf;
- const void* real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, totalcount, datatype);;
+ const void* real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, totalcount, datatype);
TRACE_smpi_comm_in(rank, request == MPI_REQUEST_IGNORED ? "PMPI_Reduce_scatter" : "PMPI_Ireduce_scatter",
new simgrid::instr::VarCollTIData(
int PMPI_Ireduce_scatter_block(const void* sendbuf, void* recvbuf, int recvcount, MPI_Datatype datatype, MPI_Op op,
MPI_Comm comm, MPI_Request* request)
{
- if (comm == MPI_COMM_NULL)
- return MPI_ERR_COMM;
- if (not datatype->is_valid())
- return MPI_ERR_TYPE;
- if (op == MPI_OP_NULL)
- return MPI_ERR_OP;
- if (recvcount < 0)
- return MPI_ERR_ARG;
- if (request == nullptr)
- return MPI_ERR_ARG;
+ CHECK_COMM(6)
+ CHECK_BUFFER(1, sendbuf, recvcount)
+ CHECK_BUFFER(2, recvbuf, recvcount)
+ CHECK_TYPE(4, datatype)
+ CHECK_COUNT(3, recvcount)
+ CHECK_REQUEST(7)
+ CHECK_OP(5)
smpi_bench_end();
int count = comm->size();
int PMPI_Ialltoall(const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount,
MPI_Datatype recvtype, MPI_Comm comm, MPI_Request* request)
{
- if (comm == MPI_COMM_NULL)
- return MPI_ERR_COMM;
- if ((sendbuf == nullptr && sendcount > 0) || (recvbuf == nullptr && recvcount > 0))
- return MPI_ERR_BUFFER;
- if ((sendbuf != MPI_IN_PLACE && sendtype == MPI_DATATYPE_NULL) || recvtype == MPI_DATATYPE_NULL)
- return MPI_ERR_TYPE;
- if ((sendbuf != MPI_IN_PLACE && sendcount < 0) || recvcount < 0)
- return MPI_ERR_COUNT;
- if (request == nullptr)
- return MPI_ERR_ARG;
+ CHECK_COMM(7)
+ CHECK_BUFFER(1, sendbuf, sendcount)
+ CHECK_BUFFER(4, recvbuf, recvcount)
+ if(sendbuf != MPI_IN_PLACE)
+ CHECK_TYPE(3, sendtype)
+ CHECK_TYPE(6, recvtype)
+ CHECK_COUNT(5, recvcount)
+ if(sendbuf != MPI_IN_PLACE)
+ CHECK_COUNT(2, sendcount)
+ CHECK_COUNT(5, recvcount)
+ CHECK_REQUEST(8)
smpi_bench_end();
int rank = simgrid::s4u::this_actor::get_pid();
return retval;
}
-int PMPI_Alltoallv(const void* sendbuf, const int* sendcounts, const int* senddisps, MPI_Datatype sendtype, void* recvbuf,
- const int* recvcounts, const int* recvdisps, MPI_Datatype recvtype, MPI_Comm comm)
+int PMPI_Alltoallv(const void* sendbuf, const int* sendcounts, const int* senddispls, MPI_Datatype sendtype, void* recvbuf,
+ const int* recvcounts, const int* recvdispls, MPI_Datatype recvtype, MPI_Comm comm)
{
- return PMPI_Ialltoallv(sendbuf, sendcounts, senddisps, sendtype, recvbuf, recvcounts, recvdisps, recvtype, comm, MPI_REQUEST_IGNORED);
+ return PMPI_Ialltoallv(sendbuf, sendcounts, senddispls, sendtype, recvbuf, recvcounts, recvdispls, recvtype, comm, MPI_REQUEST_IGNORED);
}
-int PMPI_Ialltoallv(const void* sendbuf, const int* sendcounts, const int* senddisps, MPI_Datatype sendtype, void* recvbuf,
- const int* recvcounts, const int* recvdisps, MPI_Datatype recvtype, MPI_Comm comm, MPI_Request* request)
+int PMPI_Ialltoallv(const void* sendbuf, const int* sendcounts, const int* senddispls, MPI_Datatype sendtype, void* recvbuf,
+ const int* recvcounts, const int* recvdispls, MPI_Datatype recvtype, MPI_Comm comm, MPI_Request* request)
{
- if (comm == MPI_COMM_NULL)
- return MPI_ERR_COMM;
- if (sendbuf == nullptr || recvbuf == nullptr)
- return MPI_ERR_BUFFER;
- if ((sendbuf != MPI_IN_PLACE && sendtype == MPI_DATATYPE_NULL) || recvtype == MPI_DATATYPE_NULL)
- return MPI_ERR_TYPE;
- if ((sendbuf != MPI_IN_PLACE && (sendcounts == nullptr || senddisps == nullptr)) || recvcounts == nullptr ||
- recvdisps == nullptr)
- return MPI_ERR_ARG;
- if (request == nullptr)
- return MPI_ERR_ARG;
+ CHECK_COMM(9)
+ if(sendbuf != MPI_IN_PLACE){
+ CHECK_NULL(2, MPI_ERR_COUNT, sendcounts)
+ CHECK_NULL(3, MPI_ERR_ARG, senddispls)
+ CHECK_TYPE(4, sendtype)
+ }
+ CHECK_TYPE(8, recvtype)
+ CHECK_NULL(6, MPI_ERR_COUNT, recvcounts)
+ CHECK_NULL(7, MPI_ERR_ARG, recvdispls)
+ CHECK_REQUEST(10)
int rank = simgrid::s4u::this_actor::get_pid();
int size = comm->size();
for (int i = 0; i < size; i++) {
- if (recvcounts[i] < 0 || (sendbuf != MPI_IN_PLACE && sendcounts[i] < 0))
- return MPI_ERR_COUNT;
+ if(sendbuf != MPI_IN_PLACE){
+ CHECK_BUFFER(1, sendbuf, sendcounts[i])
+ CHECK_COUNT(2, sendcounts[i])
+ }
+ CHECK_BUFFER(5, recvbuf, recvcounts[i])
+ CHECK_COUNT(6, recvcounts[i])
}
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;
- const int* real_senddisps = senddisps;
+ const int* real_senddispls = senddispls;
MPI_Datatype real_sendtype = sendtype;
int maxsize = 0;
for (int i = 0; i < size; i++) { // copy data to avoid bad free
recv_size += recvcounts[i] * dt_size_recv;
trace_recvcounts->push_back(recvcounts[i] * dt_size_recv);
- if (((recvdisps[i] + recvcounts[i]) * dt_size_recv) > maxsize)
- maxsize = (recvdisps[i] + recvcounts[i]) * dt_size_recv;
+ if (((recvdispls[i] + recvcounts[i]) * dt_size_recv) > maxsize)
+ maxsize = (recvdispls[i] + recvcounts[i]) * dt_size_recv;
}
std::unique_ptr<unsigned char[]> tmp_sendbuf;
std::unique_ptr<int[]> tmp_sendcounts;
- std::unique_ptr<int[]> tmp_senddisps;
+ std::unique_ptr<int[]> tmp_senddispls;
const void* real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, maxsize, MPI_CHAR);
if (sendbuf == MPI_IN_PLACE) {
tmp_sendcounts.reset(new int[size]);
std::copy(recvcounts, recvcounts + size, tmp_sendcounts.get());
real_sendcounts = tmp_sendcounts.get();
- tmp_senddisps.reset(new int[size]);
- std::copy(recvdisps, recvdisps + size, tmp_senddisps.get());
- real_senddisps = tmp_senddisps.get();
+ tmp_senddispls.reset(new int[size]);
+ std::copy(recvdispls, recvdispls + size, tmp_senddispls.get());
+ real_senddispls = tmp_senddispls.get();
real_sendtype = recvtype;
}
int retval;
if (request == MPI_REQUEST_IGNORED)
- retval = simgrid::smpi::colls::alltoallv(real_sendbuf, real_sendcounts, real_senddisps, real_sendtype, recvbuf,
- recvcounts, recvdisps, recvtype, comm);
+ retval = simgrid::smpi::colls::alltoallv(real_sendbuf, real_sendcounts, real_senddispls, real_sendtype, recvbuf,
+ recvcounts, recvdispls, recvtype, comm);
else
- retval = simgrid::smpi::colls::ialltoallv(real_sendbuf, real_sendcounts, real_senddisps, real_sendtype, recvbuf,
- recvcounts, recvdisps, recvtype, comm, request);
+ retval = simgrid::smpi::colls::ialltoallv(real_sendbuf, real_sendcounts, real_senddispls, real_sendtype, recvbuf,
+ recvcounts, recvdispls, recvtype, comm, request);
TRACE_smpi_comm_out(rank);
smpi_bench_begin();
return retval;
}
-int PMPI_Alltoallw(const void* sendbuf, const int* sendcounts, const int* senddisps, const MPI_Datatype* sendtypes, void* recvbuf,
- const int* recvcounts, const int* recvdisps, const MPI_Datatype* recvtypes, MPI_Comm comm)
+int PMPI_Alltoallw(const void* sendbuf, const int* sendcounts, const int* senddispls, const MPI_Datatype* sendtypes, void* recvbuf,
+ const int* recvcounts, const int* recvdispls, const MPI_Datatype* recvtypes, MPI_Comm comm)
{
- return PMPI_Ialltoallw(sendbuf, sendcounts, senddisps, sendtypes, recvbuf, recvcounts, recvdisps, recvtypes, comm, MPI_REQUEST_IGNORED);
+ return PMPI_Ialltoallw(sendbuf, sendcounts, senddispls, sendtypes, recvbuf, recvcounts, recvdispls, recvtypes, comm, MPI_REQUEST_IGNORED);
}
-int PMPI_Ialltoallw(const void* sendbuf, const int* sendcounts, const int* senddisps, const MPI_Datatype* sendtypes, void* recvbuf,
- const int* recvcounts, const int* recvdisps, const MPI_Datatype* recvtypes, MPI_Comm comm, MPI_Request* request)
+int PMPI_Ialltoallw(const void* sendbuf, const int* sendcounts, const int* senddispls, const MPI_Datatype* sendtypes, void* recvbuf,
+ const int* recvcounts, const int* recvdispls, const MPI_Datatype* recvtypes, MPI_Comm comm, MPI_Request* request)
{
- if (comm == MPI_COMM_NULL)
- return MPI_ERR_COMM;
- if (sendbuf == nullptr || recvbuf == nullptr)
- return MPI_ERR_BUFFER;
- if ((sendbuf != MPI_IN_PLACE && sendtypes == nullptr) || recvtypes == nullptr)
- return MPI_ERR_TYPE;
- if ((sendbuf != MPI_IN_PLACE && (sendcounts == nullptr || senddisps == nullptr)) || recvcounts == nullptr ||
- recvdisps == nullptr)
- return MPI_ERR_ARG;
- if (request == nullptr)
- return MPI_ERR_ARG;
-
- smpi_bench_end();
+ CHECK_COMM(9)
+ if(sendbuf != MPI_IN_PLACE){
+ CHECK_NULL(2, MPI_ERR_COUNT, sendcounts)
+ CHECK_NULL(3, MPI_ERR_ARG, senddispls)
+ CHECK_NULL(4, MPI_ERR_TYPE, sendtypes)
+ }
+ CHECK_NULL(6, MPI_ERR_COUNT, recvcounts)
+ CHECK_NULL(7, MPI_ERR_ARG, recvdispls)
+ CHECK_NULL(8, MPI_ERR_TYPE, recvtypes)
+ CHECK_REQUEST(10)
int rank = simgrid::s4u::this_actor::get_pid();
int size = comm->size();
for (int i = 0; i < size; i++) {
- if (recvcounts[i] < 0 || (sendbuf != MPI_IN_PLACE && sendcounts[i] < 0))
- return MPI_ERR_COUNT;
+ if(sendbuf != MPI_IN_PLACE){
+ CHECK_BUFFER(1, sendbuf, sendcounts[i])
+ CHECK_COUNT(2, sendcounts[i])
+ CHECK_TYPE(4, sendtypes[i])
+ }
+ CHECK_BUFFER(5, recvbuf, recvcounts[i])
+ CHECK_COUNT(6, recvcounts[i])
+ CHECK_TYPE(8, recvtypes[i])
}
+
+ 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>();
const int* real_sendcounts = sendcounts;
- const int* real_senddisps = senddisps;
+ const int* real_senddispls = senddispls;
const MPI_Datatype* real_sendtypes = sendtypes;
unsigned long maxsize = 0;
for (int i = 0; i < size; i++) { // copy data to avoid bad free
}
recv_size += recvcounts[i] * recvtypes[i]->size();
trace_recvcounts->push_back(recvcounts[i] * recvtypes[i]->size());
- if ((recvdisps[i] + (recvcounts[i] * recvtypes[i]->size())) > maxsize)
- maxsize = recvdisps[i] + (recvcounts[i] * recvtypes[i]->size());
+ if ((recvdispls[i] + (recvcounts[i] * recvtypes[i]->size())) > maxsize)
+ maxsize = recvdispls[i] + (recvcounts[i] * recvtypes[i]->size());
}
std::unique_ptr<unsigned char[]> tmp_sendbuf;
std::unique_ptr<int[]> tmp_sendcounts;
- std::unique_ptr<int[]> tmp_senddisps;
+ std::unique_ptr<int[]> tmp_senddispls;
std::unique_ptr<MPI_Datatype[]> tmp_sendtypes;
const void* real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, maxsize, MPI_CHAR);
if (sendbuf == MPI_IN_PLACE) {
tmp_sendcounts.reset(new int[size]);
std::copy(recvcounts, recvcounts + size, tmp_sendcounts.get());
real_sendcounts = tmp_sendcounts.get();
- tmp_senddisps.reset(new int[size]);
- std::copy(recvdisps, recvdisps + size, tmp_senddisps.get());
- real_senddisps = tmp_senddisps.get();
+ tmp_senddispls.reset(new int[size]);
+ std::copy(recvdispls, recvdispls + size, tmp_senddispls.get());
+ real_senddispls = tmp_senddispls.get();
tmp_sendtypes.reset(new MPI_Datatype[size]);
std::copy(recvtypes, recvtypes + size, tmp_sendtypes.get());
real_sendtypes = tmp_sendtypes.get();
int retval;
if (request == MPI_REQUEST_IGNORED)
- retval = simgrid::smpi::colls::alltoallw(real_sendbuf, real_sendcounts, real_senddisps, real_sendtypes, recvbuf,
- recvcounts, recvdisps, recvtypes, comm);
+ retval = simgrid::smpi::colls::alltoallw(real_sendbuf, real_sendcounts, real_senddispls, real_sendtypes, recvbuf,
+ recvcounts, recvdispls, recvtypes, comm);
else
- retval = simgrid::smpi::colls::ialltoallw(real_sendbuf, real_sendcounts, real_senddisps, real_sendtypes, recvbuf,
- recvcounts, recvdisps, recvtypes, comm, request);
+ retval = simgrid::smpi::colls::ialltoallw(real_sendbuf, real_sendcounts, real_senddispls, real_sendtypes, recvbuf,
+ recvcounts, recvdispls, recvtypes, comm, request);
TRACE_smpi_comm_out(rank);
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 PMPI_Comm_rank(MPI_Comm comm, int *rank)
{
- if (comm == MPI_COMM_NULL) {
- return MPI_ERR_COMM;
- } else if (rank == nullptr) {
- return MPI_ERR_ARG;
- } else {
- *rank = comm->rank();
- return MPI_SUCCESS;
- }
+ CHECK_COMM(1)
+ CHECK_NULL(2, MPI_ERR_ARG, rank)
+ *rank = comm->rank();
+ return MPI_SUCCESS;
}
int PMPI_Comm_size(MPI_Comm comm, int *size)
{
- if (comm == MPI_COMM_NULL) {
- return MPI_ERR_COMM;
- } else if (size == nullptr) {
- return MPI_ERR_ARG;
- } else {
- *size = comm->size();
- return MPI_SUCCESS;
- }
+ CHECK_COMM(1)
+ CHECK_NULL(2, MPI_ERR_ARG, size)
+ *size = comm->size();
+ return MPI_SUCCESS;
}
int PMPI_Comm_get_name (MPI_Comm comm, char* name, int* len)
{
- if (comm == MPI_COMM_NULL) {
- return MPI_ERR_COMM;
- } else if (name == nullptr || len == nullptr) {
- return MPI_ERR_ARG;
- } else {
- comm->get_name(name, len);
- return MPI_SUCCESS;
- }
+ CHECK_COMM(1)
+ CHECK_NULL(2, MPI_ERR_ARG, name)
+ CHECK_NULL(3, MPI_ERR_ARG, len)
+ comm->get_name(name, len);
+ return MPI_SUCCESS;
}
int PMPI_Comm_set_name (MPI_Comm comm, const char* name)
{
- if (comm == MPI_COMM_NULL) {
- return MPI_ERR_COMM;
- } else if (name == nullptr) {
- return MPI_ERR_ARG;
- } else {
- comm->set_name(name);
- return MPI_SUCCESS;
- }
+ CHECK_COMM(1)
+ CHECK_NULL(2, MPI_ERR_ARG, name)
+ comm->set_name(name);
+ return MPI_SUCCESS;
}
int PMPI_Comm_group(MPI_Comm comm, MPI_Group * group)
{
- if (comm == MPI_COMM_NULL) {
- return MPI_ERR_COMM;
- } else if (group == nullptr) {
- return MPI_ERR_ARG;
- } else {
- *group = comm->group();
- if (*group != MPI_COMM_WORLD->group() && *group != MPI_GROUP_NULL && *group != MPI_GROUP_EMPTY)
- (*group)->ref();
- return MPI_SUCCESS;
- }
+ CHECK_COMM(1)
+ CHECK_NULL(2, MPI_ERR_ARG, group)
+ *group = comm->group();
+ if (*group != MPI_COMM_WORLD->group() && *group != MPI_GROUP_NULL && *group != MPI_GROUP_EMPTY)
+ (*group)->ref();
+ return MPI_SUCCESS;
}
int PMPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result)
{
- if (comm1 == MPI_COMM_NULL || comm2 == MPI_COMM_NULL) {
- return MPI_ERR_COMM;
- } else if (result == nullptr) {
- return MPI_ERR_ARG;
+ CHECK_COMM2(1, comm1)
+ CHECK_COMM2(2, comm2)
+ CHECK_NULL(3, MPI_ERR_ARG, result)
+ if (comm1 == comm2) { /* Same communicators means same groups */
+ *result = MPI_IDENT;
} else {
- if (comm1 == comm2) { /* Same communicators means same groups */
- *result = MPI_IDENT;
- } else {
- *result = comm1->group()->compare(comm2->group());
- if (*result == MPI_IDENT) {
- *result = MPI_CONGRUENT;
- }
+ *result = comm1->group()->compare(comm2->group());
+ if (*result == MPI_IDENT) {
+ *result = MPI_CONGRUENT;
}
- return MPI_SUCCESS;
}
+ return MPI_SUCCESS;
}
int PMPI_Comm_dup(MPI_Comm comm, MPI_Comm * newcomm)
{
- if (comm == MPI_COMM_NULL) {
- return MPI_ERR_COMM;
- } else if (newcomm == nullptr) {
- return MPI_ERR_ARG;
- } else {
- return comm->dup(newcomm);
- }
+ CHECK_COMM(1)
+ CHECK_NULL(2, MPI_ERR_ARG, newcomm)
+ return comm->dup(newcomm);
}
int PMPI_Comm_dup_with_info(MPI_Comm comm, MPI_Info info, MPI_Comm * newcomm)
{
- if (comm == MPI_COMM_NULL) {
- return MPI_ERR_COMM;
- } else if (newcomm == nullptr) {
- return MPI_ERR_ARG;
- } else {
- comm->dup_with_info(info, newcomm);
- return MPI_SUCCESS;
- }
+ CHECK_COMM(1)
+ CHECK_NULL(2, MPI_ERR_ARG, newcomm)
+ comm->dup_with_info(info, newcomm);
+ return MPI_SUCCESS;
}
int PMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm)
{
- if (comm == MPI_COMM_NULL) {
- return MPI_ERR_COMM;
- } else if (group == MPI_GROUP_NULL) {
- return MPI_ERR_GROUP;
- } else if (newcomm == nullptr) {
- return MPI_ERR_ARG;
- } else if (group->rank(simgrid::s4u::this_actor::get_pid()) == MPI_UNDEFINED) {
+ CHECK_COMM(1)
+ CHECK_GROUP(2, group)
+ CHECK_NULL(3, MPI_ERR_ARG, newcomm)
+ if (group->rank(simgrid::s4u::this_actor::get_pid()) == MPI_UNDEFINED) {
*newcomm= MPI_COMM_NULL;
return MPI_SUCCESS;
}else{
int PMPI_Comm_free(MPI_Comm * comm)
{
- if (comm == nullptr) {
- return MPI_ERR_ARG;
- } else if (*comm == MPI_COMM_NULL) {
- return MPI_ERR_COMM;
- } else {
- simgrid::smpi::Comm::destroy(*comm);
- *comm = MPI_COMM_NULL;
- return MPI_SUCCESS;
- }
+ CHECK_NULL(1, MPI_ERR_ARG, comm)
+ CHECK_COMM2(1, *comm)
+ simgrid::smpi::Comm::destroy(*comm);
+ *comm = MPI_COMM_NULL;
+ return MPI_SUCCESS;
}
int PMPI_Comm_disconnect(MPI_Comm * comm)
{
/* TODO: wait until all communication in comm are done */
- if (comm == nullptr) {
- return MPI_ERR_ARG;
- } else if (*comm == MPI_COMM_NULL) {
- return MPI_ERR_COMM;
- } else {
- simgrid::smpi::Comm::destroy(*comm);
- *comm = MPI_COMM_NULL;
- return MPI_SUCCESS;
- }
+ CHECK_NULL(1, MPI_ERR_ARG, comm)
+ CHECK_COMM2(1, *comm)
+ simgrid::smpi::Comm::destroy(*comm);
+ *comm = MPI_COMM_NULL;
+ return MPI_SUCCESS;
}
int PMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm* comm_out)
{
- int retval = 0;
+ CHECK_NULL(4, MPI_ERR_ARG, comm_out)
+ CHECK_COMM2(1, comm)
smpi_bench_end();
-
- if (comm_out == nullptr) {
- retval = MPI_ERR_ARG;
- } else if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
- } else {
- *comm_out = comm->split(color, key);
- retval = MPI_SUCCESS;
- }
+ *comm_out = comm->split(color, key);
smpi_bench_begin();
-
- return retval;
+ return MPI_SUCCESS;
}
int PMPI_Comm_split_type(MPI_Comm comm, int split_type, int key, MPI_Info info, MPI_Comm *newcomm)
{
- int retval = 0;
+ CHECK_COMM(1)
+ CHECK_NULL(5, MPI_ERR_ARG, newcomm)
smpi_bench_end();
-
- if (newcomm == nullptr) {
- retval = MPI_ERR_ARG;
- } else if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
- } else {
- *newcomm = comm->split_type(split_type, key, info);
- retval = MPI_SUCCESS;
- }
+ *newcomm = comm->split_type(split_type, key, info);
smpi_bench_begin();
-
- return retval;
+ return MPI_SUCCESS;
}
int PMPI_Comm_create_group(MPI_Comm comm, MPI_Group group, int, MPI_Comm* comm_out)
{
- int retval = 0;
+ CHECK_COMM(1)
+ CHECK_GROUP(2, group)
+ CHECK_NULL(5, MPI_ERR_ARG, comm_out)
smpi_bench_end();
-
- if (comm_out == nullptr) {
- retval = MPI_ERR_ARG;
- } else if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
- } else {
- retval = MPI_Comm_create(comm, group, comm_out);
- }
+ int retval = MPI_Comm_create(comm, group, comm_out);
smpi_bench_begin();
-
return retval;
}
int PMPI_Comm_get_info(MPI_Comm comm, MPI_Info* info)
{
- if (comm == MPI_COMM_NULL) {
- return MPI_ERR_WIN;
- } else {
- *info = comm->info();
- return MPI_SUCCESS;
- }
+ CHECK_COMM(1)
+ CHECK_NULL(2, MPI_ERR_ARG, info)
+ *info = comm->info();
+ return MPI_SUCCESS;
}
int PMPI_Comm_set_info(MPI_Comm comm, MPI_Info info)
{
- if (comm == MPI_COMM_NULL) {
- return MPI_ERR_TYPE;
- } else {
- comm->set_info(info);
- return MPI_SUCCESS;
- }
+ CHECK_COMM(1)
+ comm->set_info(info);
+ return MPI_SUCCESS;
}
int PMPI_Comm_delete_attr (MPI_Comm comm, int comm_keyval)
}
int PMPI_Attr_delete(MPI_Comm comm, int keyval) {
+ CHECK_COMM(1)
if(keyval == MPI_TAG_UB||keyval == MPI_HOST||keyval == MPI_IO ||keyval == MPI_WTIME_IS_GLOBAL||keyval == MPI_APPNUM
||keyval == MPI_UNIVERSE_SIZE||keyval == MPI_LASTUSEDCODE)
return MPI_ERR_ARG;
- else if (comm==MPI_COMM_NULL)
- return MPI_ERR_COMM;
else
return comm->attr_delete<simgrid::smpi::Comm>(keyval);
}
static int last_used_code = MPI_ERR_LASTCODE;
static int universe_size;
- if (comm==MPI_COMM_NULL){
- *flag = 0;
- return MPI_ERR_COMM;
- }
+ CHECK_NULL(4, MPI_ERR_ARG, flag)
+ *flag = 0;
+ CHECK_COMM(1)
switch (keyval) {
case MPI_HOST:
}
int PMPI_Attr_put(MPI_Comm comm, int keyval, void* attr_value) {
+ CHECK_COMM(1)
if(keyval == MPI_TAG_UB||keyval == MPI_HOST||keyval == MPI_IO ||keyval == MPI_WTIME_IS_GLOBAL||keyval == MPI_APPNUM
||keyval == MPI_UNIVERSE_SIZE||keyval == MPI_LASTUSEDCODE)
return MPI_ERR_ARG;
- else if (comm==MPI_COMM_NULL)
- return MPI_ERR_COMM;
else
- return comm->attr_put<simgrid::smpi::Comm>(keyval, attr_value);
+ return comm->attr_put<simgrid::smpi::Comm>(keyval, attr_value);
}
int PMPI_Errhandler_free(MPI_Errhandler* errhandler){
- if (errhandler==nullptr){
- return MPI_ERR_ARG;
- }
+ CHECK_NULL(1, MPI_ERR_ARG, errhandler)
simgrid::smpi::Errhandler::unref(*errhandler);
return MPI_SUCCESS;
}
int PMPI_Errhandler_create(MPI_Handler_function* function, MPI_Errhandler* errhandler){
+ CHECK_NULL(2, MPI_ERR_ARG, errhandler)
*errhandler=new simgrid::smpi::Errhandler(function);
return MPI_SUCCESS;
}
int PMPI_Errhandler_get(MPI_Comm comm, MPI_Errhandler* errhandler){
- if (comm == nullptr) {
- return MPI_ERR_COMM;
- } else if (errhandler==nullptr){
- return MPI_ERR_ARG;
- }
+ CHECK_COMM(1)
+ CHECK_NULL(1, MPI_ERR_ARG, errhandler)
*errhandler=comm->errhandler();
return MPI_SUCCESS;
}
int PMPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler errhandler){
- if (comm == nullptr) {
- return MPI_ERR_COMM;
- } else if (errhandler==nullptr){
- return MPI_ERR_ARG;
- }
+ CHECK_COMM(1)
+ CHECK_NULL(1, MPI_ERR_ARG, errhandler)
comm->set_errhandler(errhandler);
return MPI_SUCCESS;
}
int PMPI_Comm_call_errhandler(MPI_Comm comm,int errorcode){
- if (comm == nullptr) {
- return MPI_ERR_COMM;
- }
- comm->errhandler()->call(comm, errorcode);
+ CHECK_COMM(1)
+ 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. */
#include "smpi_file.hpp"
#include "smpi_datatype.hpp"
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi);
+#define CHECK_RDONLY(fh) \
+ if ((fh)->flags() & MPI_MODE_RDONLY) \
+ return MPI_ERR_AMODE;
+#define CHECK_WRONLY(fh) \
+ if ((fh)->flags() & MPI_MODE_WRONLY) \
+ return MPI_ERR_AMODE;
+#define PASS_ZEROCOUNT(count) \
+ if ((count) == 0) { \
+ status->count = 0; \
+ return MPI_SUCCESS; \
+ }
+
+#define CHECK_FILE_INPUTS \
+ CHECK_FILE(1, fh) \
+ CHECK_BUFFER(2, buf, count) \
+ CHECK_COUNT(3, count) \
+ CHECK_TYPE(4, datatype) \
+
+#define CHECK_FILE_INPUT_OFFSET \
+ CHECK_FILE(1, fh) \
+ CHECK_BUFFER(2, buf, count) \
+ CHECK_OFFSET(3, offset) \
+ CHECK_COUNT(4, count) \
+ CHECK_TYPE(5, datatype) \
+
extern MPI_Errhandler SMPI_default_File_Errhandler;
int PMPI_File_open(MPI_Comm comm, const char *filename, int amode, MPI_Info info, MPI_File *fh){
- if (comm == MPI_COMM_NULL)
- return MPI_ERR_COMM;
- if (filename == nullptr)
- return MPI_ERR_FILE;
+ CHECK_COMM(1)
+ CHECK_NULL(2, MPI_ERR_FILE, filename)
if (amode < 0)
return MPI_ERR_AMODE;
smpi_bench_end();
}
int PMPI_File_close(MPI_File *fh){
- if (fh==nullptr)
- return MPI_ERR_ARG;
+ CHECK_NULL(2, MPI_ERR_ARG, fh)
smpi_bench_end();
int ret = simgrid::smpi::File::close(fh);
*fh = MPI_FILE_NULL;
smpi_bench_begin();
return ret;
}
-#define CHECK_FILE(fh) \
- if ((fh) == MPI_FILE_NULL) \
- return MPI_ERR_FILE;
-#define CHECK_BUFFER(buf, count) \
- if ((buf) == nullptr && (count) > 0) \
- return MPI_ERR_BUFFER;
-#define CHECK_COUNT(count) \
- if ((count) < 0) \
- return MPI_ERR_COUNT;
-#define CHECK_OFFSET(offset) \
- if ((offset) < 0) \
- return MPI_ERR_DISP;
-#define CHECK_DATATYPE(datatype, count) \
- if ((datatype) == MPI_DATATYPE_NULL && (count) > 0) \
- return MPI_ERR_TYPE;
-#define CHECK_STATUS(status) \
- if ((status) == nullptr) \
- return MPI_ERR_ARG;
-#define CHECK_FLAGS(fh) \
- if ((fh)->flags() & MPI_MODE_SEQUENTIAL) \
- return MPI_ERR_AMODE;
-#define CHECK_RDONLY(fh) \
- if ((fh)->flags() & MPI_MODE_RDONLY) \
- return MPI_ERR_AMODE;
-
-#define PASS_ZEROCOUNT(count) \
- if ((count) == 0) { \
- status->count = 0; \
- return MPI_SUCCESS; \
- }
int PMPI_File_seek(MPI_File fh, MPI_Offset offset, int whence){
- CHECK_FILE(fh);
+ CHECK_FILE(1, fh)
smpi_bench_end();
int ret = fh->seek(offset,whence);
smpi_bench_begin();
return ret;
-
}
int PMPI_File_seek_shared(MPI_File fh, MPI_Offset offset, int whence){
- CHECK_FILE(fh)
+ CHECK_FILE(1, fh)
smpi_bench_end();
int ret = fh->seek_shared(offset,whence);
smpi_bench_begin();
return ret;
-
}
int PMPI_File_get_position(MPI_File fh, MPI_Offset* offset){
- if (offset==nullptr)
- return MPI_ERR_DISP;
+ CHECK_FILE(1, fh)
+ CHECK_NULL(2, MPI_ERR_DISP, offset)
smpi_bench_end();
int ret = fh->get_position(offset);
smpi_bench_begin();
}
int PMPI_File_get_position_shared(MPI_File fh, MPI_Offset* offset){
- CHECK_FILE(fh)
- if (offset==nullptr)
- return MPI_ERR_DISP;
+ CHECK_FILE(1, fh)
+ CHECK_NULL(2, MPI_ERR_DISP, offset)
smpi_bench_end();
int ret = fh->get_position_shared(offset);
smpi_bench_begin();
}
int PMPI_File_read(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){
- CHECK_FILE(fh)
- CHECK_BUFFER(buf, count)
- CHECK_COUNT(count)
- CHECK_DATATYPE(datatype, count)
- CHECK_STATUS(status)
- CHECK_FLAGS(fh)
+ CHECK_FILE_INPUTS
+ CHECK_WRONLY(fh)
PASS_ZEROCOUNT(count)
smpi_bench_end();
int rank_traced = simgrid::s4u::this_actor::get_pid();
}
int PMPI_File_read_shared(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){
- CHECK_FILE(fh)
- CHECK_BUFFER(buf, count)
- CHECK_COUNT(count)
- CHECK_DATATYPE(datatype, count)
- CHECK_STATUS(status)
- CHECK_FLAGS(fh)
+ CHECK_FILE_INPUTS
+ CHECK_WRONLY(fh)
PASS_ZEROCOUNT(count)
smpi_bench_end();
int rank_traced = simgrid::s4u::this_actor::get_pid();
}
int PMPI_File_write(MPI_File fh, const void *buf, int count,MPI_Datatype datatype, MPI_Status *status){
- CHECK_FILE(fh)
- CHECK_BUFFER(buf, count)
- CHECK_COUNT(count)
- CHECK_DATATYPE(datatype, count)
- CHECK_STATUS(status)
- CHECK_FLAGS(fh)
+ CHECK_FILE_INPUTS
CHECK_RDONLY(fh)
PASS_ZEROCOUNT(count)
smpi_bench_end();
}
int PMPI_File_write_shared(MPI_File fh, const void *buf, int count,MPI_Datatype datatype, MPI_Status *status){
- CHECK_FILE(fh)
- CHECK_BUFFER(buf, count)
- CHECK_COUNT(count)
- CHECK_DATATYPE(datatype, count)
- CHECK_STATUS(status)
- CHECK_FLAGS(fh)
+ CHECK_FILE_INPUTS
CHECK_RDONLY(fh)
PASS_ZEROCOUNT(count)
smpi_bench_end();
}
int PMPI_File_read_all(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){
- CHECK_FILE(fh)
- CHECK_BUFFER(buf, count)
- CHECK_COUNT(count)
- CHECK_DATATYPE(datatype, count)
- CHECK_STATUS(status)
- CHECK_FLAGS(fh)
+ CHECK_FILE_INPUTS
+ CHECK_WRONLY(fh)
smpi_bench_end();
int rank_traced = simgrid::s4u::this_actor::get_pid();
TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - read_all", count * datatype->size()));
}
int PMPI_File_read_ordered(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){
- CHECK_FILE(fh)
- CHECK_BUFFER(buf, count)
- CHECK_COUNT(count)
- CHECK_DATATYPE(datatype, count)
- CHECK_STATUS(status)
- CHECK_FLAGS(fh)
+ CHECK_FILE_INPUTS
+ CHECK_WRONLY(fh)
smpi_bench_end();
int rank_traced = simgrid::s4u::this_actor::get_pid();
TRACE_smpi_comm_in(rank_traced, __func__,
}
int PMPI_File_write_all(MPI_File fh, const void *buf, int count,MPI_Datatype datatype, MPI_Status *status){
- CHECK_FILE(fh)
- CHECK_BUFFER(buf, count)
- CHECK_COUNT(count)
- CHECK_DATATYPE(datatype, count)
- CHECK_STATUS(status)
- CHECK_FLAGS(fh)
+ CHECK_FILE_INPUTS
CHECK_RDONLY(fh)
smpi_bench_end();
int rank_traced = simgrid::s4u::this_actor::get_pid();
}
int PMPI_File_write_ordered(MPI_File fh, const void *buf, int count,MPI_Datatype datatype, MPI_Status *status){
- CHECK_FILE(fh)
- CHECK_BUFFER(buf, count)
- CHECK_COUNT(count)
- CHECK_DATATYPE(datatype, count)
- CHECK_STATUS(status)
- CHECK_FLAGS(fh)
+ CHECK_FILE_INPUTS
CHECK_RDONLY(fh)
smpi_bench_end();
int rank_traced = simgrid::s4u::this_actor::get_pid();
}
int PMPI_File_read_at(MPI_File fh, MPI_Offset offset, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){
- CHECK_FILE(fh)
- CHECK_BUFFER(buf, count)
- CHECK_OFFSET(offset)
- CHECK_COUNT(count)
- CHECK_DATATYPE(datatype, count)
- CHECK_STATUS(status)
- CHECK_FLAGS(fh)
+ CHECK_FILE_INPUTS
+ CHECK_WRONLY(fh)
PASS_ZEROCOUNT(count);
smpi_bench_end();
int rank_traced = simgrid::s4u::this_actor::get_pid();
}
int PMPI_File_read_at_all(MPI_File fh, MPI_Offset offset, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){
- CHECK_FILE(fh)
- CHECK_BUFFER(buf, count)
- CHECK_OFFSET(offset)
- CHECK_COUNT(count)
- CHECK_DATATYPE(datatype, count)
- CHECK_STATUS(status)
- CHECK_FLAGS(fh)
+ CHECK_FILE_INPUT_OFFSET
+ CHECK_WRONLY(fh)
smpi_bench_end();
int rank_traced = simgrid::s4u::this_actor::get_pid();
TRACE_smpi_comm_in(rank_traced, __func__,
}
int PMPI_File_write_at(MPI_File fh, MPI_Offset offset, const void *buf, int count,MPI_Datatype datatype, MPI_Status *status){
- CHECK_FILE(fh)
- CHECK_BUFFER(buf, count)
- CHECK_OFFSET(offset)
- CHECK_COUNT(count)
- CHECK_DATATYPE(datatype, count)
- CHECK_STATUS(status)
- CHECK_FLAGS(fh)
+ CHECK_FILE_INPUT_OFFSET
CHECK_RDONLY(fh)
PASS_ZEROCOUNT(count);
smpi_bench_end();
}
int PMPI_File_write_at_all(MPI_File fh, MPI_Offset offset, const void *buf, int count,MPI_Datatype datatype, MPI_Status *status){
- CHECK_FILE(fh)
- CHECK_BUFFER(buf, count)
- CHECK_OFFSET(offset)
- CHECK_COUNT(count)
- CHECK_DATATYPE(datatype, count)
- CHECK_STATUS(status)
- CHECK_FLAGS(fh)
+ CHECK_FILE_INPUT_OFFSET
CHECK_RDONLY(fh)
smpi_bench_end();
int rank_traced = simgrid::s4u::this_actor::get_pid();
return ret;
}
+int PMPI_File_set_view(MPI_File fh, MPI_Offset disp, MPI_Datatype etype, MPI_Datatype filetype, const char *datarep, MPI_Info info){
+ CHECK_FILE(1, fh)
+ if(not ((fh->flags() & MPI_MODE_SEQUENTIAL) && (disp == MPI_DISPLACEMENT_CURRENT)))
+ CHECK_OFFSET(2, disp)
+ CHECK_TYPE(3, etype)
+ CHECK_TYPE(4, filetype)
+ smpi_bench_end();
+ int ret = fh->set_view(disp, etype, filetype, datarep, info);
+ smpi_bench_begin();
+ return ret;
+}
+
+int PMPI_File_get_view(MPI_File fh, MPI_Offset *disp, MPI_Datatype *etype, MPI_Datatype *filetype, char *datarep){
+ CHECK_FILE(1, fh)
+ CHECK_NULL(2, MPI_ERR_ARG, disp)
+ CHECK_NULL(3, MPI_ERR_ARG, etype)
+ CHECK_NULL(4, MPI_ERR_ARG, filetype)
+ smpi_bench_end();
+ int ret = fh->get_view(disp, etype, filetype, datarep);
+ smpi_bench_begin();
+ return ret;
+}
+
int PMPI_File_get_info(MPI_File fh, MPI_Info* info)
{
- CHECK_FILE(fh)
+ CHECK_FILE(1, fh)
*info = fh->info();
return MPI_SUCCESS;
}
int PMPI_File_set_info(MPI_File fh, MPI_Info info)
{
- CHECK_FILE(fh)
+ CHECK_FILE(1, fh)
fh->set_info(info);
return MPI_SUCCESS;
}
int PMPI_File_get_size(MPI_File fh, MPI_Offset* size)
{
- CHECK_FILE(fh)
+ CHECK_FILE(1, fh)
*size = fh->size();
return MPI_SUCCESS;
}
int PMPI_File_get_amode(MPI_File fh, int* amode)
{
- CHECK_FILE(fh)
+ CHECK_FILE(1, fh)
*amode = fh->flags();
return MPI_SUCCESS;
}
int PMPI_File_get_group(MPI_File fh, MPI_Group* group)
{
- CHECK_FILE(fh)
+ CHECK_FILE(1, fh)
*group = fh->comm()->group();
return MPI_SUCCESS;
}
int PMPI_File_sync(MPI_File fh)
{
- CHECK_FILE(fh)
+ CHECK_FILE(1, fh)
fh->sync();
return MPI_SUCCESS;
}
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. */
int PMPI_Group_free(MPI_Group * group)
{
- if (group == nullptr) {
- return MPI_ERR_ARG;
- } else {
- if(*group != MPI_COMM_WORLD->group() && *group != MPI_GROUP_EMPTY)
- simgrid::smpi::Group::unref(*group);
- *group = MPI_GROUP_NULL;
- return MPI_SUCCESS;
- }
+ CHECK_NULL(1, MPI_ERR_ARG, group)
+ if(*group != MPI_COMM_WORLD->group() && *group != MPI_GROUP_EMPTY)
+ simgrid::smpi::Group::unref(*group);
+ *group = MPI_GROUP_NULL;
+ return MPI_SUCCESS;
}
int PMPI_Group_size(MPI_Group group, int *size)
{
- if (group == MPI_GROUP_NULL) {
- return MPI_ERR_GROUP;
- } else if (size == nullptr) {
- return MPI_ERR_ARG;
- } else {
- *size = group->size();
- return MPI_SUCCESS;
- }
+ CHECK_GROUP(1, group)
+ CHECK_NULL(2, MPI_ERR_ARG, size)
+ *size = group->size();
+ return MPI_SUCCESS;
}
int PMPI_Group_rank(MPI_Group group, int *rank)
{
- if (group == MPI_GROUP_NULL) {
- return MPI_ERR_GROUP;
- } else if (rank == nullptr) {
- return MPI_ERR_ARG;
- } else {
- *rank = group->rank(simgrid::s4u::this_actor::get_pid());
- return MPI_SUCCESS;
- }
+ CHECK_GROUP(1, group)
+ CHECK_NULL(2, MPI_ERR_ARG, rank)
+ *rank = group->rank(simgrid::s4u::this_actor::get_pid());
+ return MPI_SUCCESS;
}
int PMPI_Group_translate_ranks(MPI_Group group1, int n, const int *ranks1, MPI_Group group2, int *ranks2)
{
- if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
- return MPI_ERR_GROUP;
- } else {
- for (int i = 0; i < n; i++) {
- if(ranks1[i]==MPI_PROC_NULL){
- ranks2[i]=MPI_PROC_NULL;
- }else{
- simgrid::s4u::Actor* actor = group1->actor(ranks1[i]);
- ranks2[i] = group2->rank(actor);
- }
+ CHECK_GROUP(1, group1)
+ CHECK_GROUP(4, group2)
+ for (int i = 0; i < n; i++) {
+ if(ranks1[i]==MPI_PROC_NULL){
+ ranks2[i]=MPI_PROC_NULL;
+ }else{
+ simgrid::s4u::Actor* actor = group1->actor(ranks1[i]);
+ ranks2[i] = group2->rank(actor);
}
- return MPI_SUCCESS;
}
+ return MPI_SUCCESS;
}
int PMPI_Group_compare(MPI_Group group1, MPI_Group group2, int *result)
{
- if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
- return MPI_ERR_GROUP;
- } else if (result == nullptr) {
- return MPI_ERR_ARG;
- } else {
- *result = group1->compare(group2);
- return MPI_SUCCESS;
- }
+ CHECK_GROUP(1, group1)
+ CHECK_GROUP(2, group2)
+ CHECK_NULL(3, MPI_ERR_ARG, result)
+ *result = group1->compare(group2);
+ return MPI_SUCCESS;
}
int PMPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group * newgroup)
{
-
- if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
- return MPI_ERR_GROUP;
- } else if (newgroup == nullptr) {
- return MPI_ERR_ARG;
- } else {
- return group1->group_union(group2, newgroup);
- }
+ CHECK_GROUP(1, group1)
+ CHECK_GROUP(2, group2)
+ CHECK_NULL(3, MPI_ERR_ARG, newgroup)
+ return group1->group_union(group2, newgroup);
}
int PMPI_Group_intersection(MPI_Group group1, MPI_Group group2, MPI_Group * newgroup)
{
-
- if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
- return MPI_ERR_GROUP;
- } else if (newgroup == nullptr) {
- return MPI_ERR_ARG;
- } else {
- return group1->intersection(group2,newgroup);
- }
+ CHECK_GROUP(1, group1)
+ CHECK_GROUP(2, group2)
+ CHECK_NULL(3, MPI_ERR_ARG, newgroup)
+ return group1->intersection(group2,newgroup);
}
int PMPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group * newgroup)
{
- if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
- return MPI_ERR_GROUP;
- } else if (newgroup == nullptr) {
- return MPI_ERR_ARG;
- } else {
- return group1->difference(group2,newgroup);
- }
+ CHECK_GROUP(1, group1)
+ CHECK_GROUP(2, group2)
+ CHECK_NULL(3, MPI_ERR_ARG, newgroup)
+ return group1->difference(group2,newgroup);
}
int PMPI_Group_incl(MPI_Group group, int n, const int *ranks, MPI_Group * newgroup)
{
- if (group == MPI_GROUP_NULL) {
- return MPI_ERR_GROUP;
- } else if (newgroup == nullptr) {
- return MPI_ERR_ARG;
- } else {
- return group->incl(n, ranks, newgroup);
- }
+ CHECK_GROUP(1, group)
+ CHECK_NULL(4, MPI_ERR_ARG, newgroup)
+ return group->incl(n, ranks, newgroup);
}
int PMPI_Group_excl(MPI_Group group, int n, const int *ranks, MPI_Group * newgroup)
{
- if (group == MPI_GROUP_NULL) {
- return MPI_ERR_GROUP;
- } else if (newgroup == nullptr) {
- return MPI_ERR_ARG;
+ CHECK_GROUP(1, group)
+ CHECK_NULL(4, MPI_ERR_ARG, newgroup)
+ if (n == 0) {
+ *newgroup = group;
+ if (group != MPI_COMM_WORLD->group() && group != MPI_COMM_SELF->group() && group != MPI_GROUP_EMPTY)
+ group->ref();
+ return MPI_SUCCESS;
+ } else if (n == group->size()) {
+ *newgroup = MPI_GROUP_EMPTY;
+ return MPI_SUCCESS;
} else {
- if (n == 0) {
- *newgroup = group;
- if (group != MPI_COMM_WORLD->group() && group != MPI_COMM_SELF->group() && group != MPI_GROUP_EMPTY)
- group->ref();
- return MPI_SUCCESS;
- } else if (n == group->size()) {
- *newgroup = MPI_GROUP_EMPTY;
- return MPI_SUCCESS;
- } else {
- return group->excl(n,ranks,newgroup);
- }
+ return group->excl(n,ranks,newgroup);
}
}
int PMPI_Group_range_incl(MPI_Group group, int n, int ranges[][3], MPI_Group * newgroup)
{
- if (group == MPI_GROUP_NULL) {
- return MPI_ERR_GROUP;
- } else if (newgroup == nullptr) {
- return MPI_ERR_ARG;
+ CHECK_GROUP(1, group)
+ CHECK_NULL(4, MPI_ERR_ARG, newgroup)
+ if (n == 0) {
+ *newgroup = MPI_GROUP_EMPTY;
+ return MPI_SUCCESS;
} else {
- if (n == 0) {
- *newgroup = MPI_GROUP_EMPTY;
- return MPI_SUCCESS;
- } else {
- return group->range_incl(n,ranges,newgroup);
- }
+ return group->range_incl(n,ranges,newgroup);
}
}
int PMPI_Group_range_excl(MPI_Group group, int n, int ranges[][3], MPI_Group * newgroup)
{
- if (group == MPI_GROUP_NULL) {
- return MPI_ERR_GROUP;
- } else if (newgroup == nullptr) {
- return MPI_ERR_ARG;
+ CHECK_GROUP(1, group)
+ CHECK_NULL(4, MPI_ERR_ARG, newgroup)
+ if (n == 0) {
+ *newgroup = group;
+ if (group != MPI_COMM_WORLD->group() && group != MPI_COMM_SELF->group() &&
+ group != MPI_GROUP_EMPTY)
+ group->ref();
+ return MPI_SUCCESS;
} else {
- if (n == 0) {
- *newgroup = group;
- if (group != MPI_COMM_WORLD->group() && group != MPI_COMM_SELF->group() &&
- group != MPI_GROUP_EMPTY)
- group->ref();
- return MPI_SUCCESS;
- } else {
- return group->range_excl(n,ranges,newgroup);
- }
+ return group->range_excl(n,ranges,newgroup);
}
}
-/* 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. */
/* PMPI User level calls */
int PMPI_Info_create( MPI_Info *info){
- if (info == nullptr)
- return MPI_ERR_ARG;
+ CHECK_NULL(1, MPI_ERR_ARG, info)
*info = new simgrid::smpi::Info();
return MPI_SUCCESS;
}
int PMPI_Info_set( MPI_Info info, const char *key, const char *value){
- if (info == nullptr || key == nullptr || value == nullptr)
- return MPI_ERR_ARG;
+ CHECK_INFO(1, info)
+ CHECK_NULL(2, MPI_ERR_INFO_KEY, key)
+ CHECK_NULL(3, MPI_ERR_INFO_VALUE, value)
info->set(key, value);
return MPI_SUCCESS;
}
int PMPI_Info_free( MPI_Info *info){
- if (info == nullptr || *info==nullptr)
- return MPI_ERR_ARG;
+ CHECK_NULL(1, MPI_ERR_ARG, info)
+ CHECK_INFO(1, *info)
simgrid::smpi::Info::unref(*info);
*info=MPI_INFO_NULL;
return MPI_SUCCESS;
}
int PMPI_Info_get(MPI_Info info, const char *key,int valuelen, char *value, int *flag){
- *flag=false;
- if (info == nullptr || valuelen <0)
+ CHECK_INFO(1, info)
+ if (valuelen <0)
return MPI_ERR_ARG;
- if (key == nullptr)
- return MPI_ERR_INFO_KEY;
- if (value == nullptr)
- return MPI_ERR_INFO_VALUE;
+ CHECK_NULL(2, MPI_ERR_INFO_KEY, key)
+ CHECK_NULL(3, MPI_ERR_INFO_VALUE, value)
+ CHECK_NULL(4, MPI_ERR_ARG, flag)
+ *flag=false;
return info->get(key, valuelen, value, flag);
}
int PMPI_Info_dup(MPI_Info info, MPI_Info *newinfo){
- if (info == nullptr || newinfo==nullptr)
- return MPI_ERR_ARG;
+ CHECK_INFO(1, info)
+ CHECK_NULL(2, MPI_ERR_ARG, newinfo)
*newinfo = new simgrid::smpi::Info(info);
return MPI_SUCCESS;
}
int PMPI_Info_delete(MPI_Info info, const char *key){
- if (info == nullptr || key==nullptr)
- return MPI_ERR_ARG;
+ CHECK_INFO(1, info)
+ CHECK_NULL(2, MPI_ERR_INFO_KEY, key)
return info->remove(key);
}
int PMPI_Info_get_nkeys( MPI_Info info, int *nkeys){
- if (info == nullptr || nkeys==nullptr)
- return MPI_ERR_ARG;
+ CHECK_INFO(1, info)
+ CHECK_NULL(2, MPI_ERR_ARG, nkeys)
return info->get_nkeys(nkeys);
}
int PMPI_Info_get_nthkey( MPI_Info info, int n, char *key){
- if (info == nullptr || key==nullptr || n<0 || n> MPI_MAX_INFO_KEY)
+ CHECK_INFO(1, info)
+ CHECK_NULL(2, MPI_ERR_INFO_KEY, key)
+ if (n<0 || n> MPI_MAX_INFO_KEY)
return MPI_ERR_ARG;
return info->get_nthkey(n, key);
}
int PMPI_Info_get_valuelen( MPI_Info info, const char *key, int *valuelen, int *flag){
*flag=false;
- if (info == nullptr)
- return MPI_ERR_ARG;
- if (key == nullptr)
- return MPI_ERR_INFO_KEY;
- if (valuelen == nullptr)
- return MPI_ERR_INFO_VALUE;
+ CHECK_INFO(1, info)
+ CHECK_NULL(2, MPI_ERR_INFO_KEY, key)
+ CHECK_NULL(2, MPI_ERR_INFO_VALUE, valuelen)
return info->get_valuelen(key, valuelen, flag);
}
-/* 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_Op_create(MPI_User_function * function, int commute, MPI_Op * op)
{
- if (function == nullptr || op == nullptr) {
- return MPI_ERR_ARG;
- } else {
- *op = new simgrid::smpi::Op(function, (commute!=0));
- return MPI_SUCCESS;
- }
+ CHECK_NULL(1, MPI_ERR_ARG, function)
+ CHECK_NULL(3, MPI_ERR_ARG, op)
+ *op = new simgrid::smpi::Op(function, (commute!=0));
+ return MPI_SUCCESS;
}
int PMPI_Op_free(MPI_Op * op)
{
- if (op == nullptr) {
- return MPI_ERR_ARG;
- } else if (*op == MPI_OP_NULL) {
- return MPI_ERR_OP;
- } else {
- simgrid::smpi::Op::unref(op);
- *op = MPI_OP_NULL;
- return MPI_SUCCESS;
- }
+ CHECK_NULL(1, MPI_ERR_ARG, op)
+ CHECK_MPI_NULL(1, MPI_OP_NULL, MPI_ERR_OP, *op)
+ simgrid::smpi::Op::unref(op);
+ *op = MPI_OP_NULL;
+ return MPI_SUCCESS;
}
int PMPI_Op_commutative(MPI_Op op, int* commute){
- if (op == MPI_OP_NULL) {
- return MPI_ERR_OP;
- } else if (commute==nullptr){
- return MPI_ERR_ARG;
- } else {
- *commute = op->is_commutative();
- return MPI_SUCCESS;
- }
+ CHECK_OP(1)
+ CHECK_NULL(1, MPI_ERR_ARG, commute)
+ *commute = op->is_commutative();
+ return MPI_SUCCESS;
}
MPI_Op PMPI_Op_f2c(MPI_Fint op){
-/* 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. */
return (actor == nullptr) ? MPI_UNDEFINED : actor->get_pid();
}
+#define CHECK_SEND_INPUTS\
+ CHECK_BUFFER(1, buf, count)\
+ CHECK_COUNT(2, count)\
+ CHECK_TYPE(3, datatype)\
+ CHECK_PROC(4, dst)\
+ CHECK_RANK(4, dst, comm)\
+ CHECK_TAG(5, tag)\
+ CHECK_COMM(6)\
+
+#define CHECK_ISEND_INPUTS\
+ CHECK_REQUEST(7)\
+ *request = MPI_REQUEST_NULL;\
+ CHECK_SEND_INPUTS
+
+#define CHECK_IRECV_INPUTS\
+ CHECK_REQUEST(7)\
+ *request = MPI_REQUEST_NULL;\
+ CHECK_BUFFER(1, buf, count)\
+ CHECK_COUNT(2, count)\
+ CHECK_TYPE(3, datatype)\
+ CHECK_PROC(4, src)\
+ if(src!=MPI_ANY_SOURCE)\
+ CHECK_RANK(4, src, comm)\
+ CHECK_TAG(5, tag)\
+ CHECK_COMM(6)
/* PMPI User level calls */
int PMPI_Send_init(const void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request * request)
{
- int retval = 0;
+ CHECK_ISEND_INPUTS
smpi_bench_end();
- if (request == nullptr) {
- retval = MPI_ERR_ARG;
- } else if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
- } else if (datatype==MPI_DATATYPE_NULL || not datatype->is_valid()) {
- retval = MPI_ERR_TYPE;
- } else if (dst == MPI_PROC_NULL) {
- retval = MPI_SUCCESS;
- } else {
- *request = simgrid::smpi::Request::send_init(buf, count, datatype, dst, tag, comm);
- retval = MPI_SUCCESS;
- }
+ *request = simgrid::smpi::Request::send_init(buf, count, datatype, dst, tag, comm);
smpi_bench_begin();
- if (retval != MPI_SUCCESS && request != nullptr)
- *request = MPI_REQUEST_NULL;
- return retval;
+
+ return MPI_SUCCESS;
}
int PMPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Request * request)
{
- int retval = 0;
+ CHECK_IRECV_INPUTS
smpi_bench_end();
- if (request == nullptr) {
- retval = MPI_ERR_ARG;
- } else if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
- } else if (datatype==MPI_DATATYPE_NULL || not datatype->is_valid()) {
- retval = MPI_ERR_TYPE;
- } else if (src == MPI_PROC_NULL) {
- retval = MPI_SUCCESS;
- } else {
- *request = simgrid::smpi::Request::recv_init(buf, count, datatype, src, tag, comm);
- retval = MPI_SUCCESS;
- }
+ *request = simgrid::smpi::Request::recv_init(buf, count, datatype, src, tag, comm);
smpi_bench_begin();
- if (retval != MPI_SUCCESS && request != nullptr)
- *request = MPI_REQUEST_NULL;
- return retval;
+ return MPI_SUCCESS;
}
int PMPI_Rsend_init(const void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm,
int PMPI_Ssend_init(const void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request)
{
- int retval = 0;
+ CHECK_ISEND_INPUTS
+ int retval = 0;
smpi_bench_end();
- if (request == nullptr) {
- retval = MPI_ERR_ARG;
- } else if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
- } else if (datatype==MPI_DATATYPE_NULL || not datatype->is_valid()) {
- retval = MPI_ERR_TYPE;
- } else if (dst == MPI_PROC_NULL) {
- retval = MPI_SUCCESS;
- } else {
- *request = simgrid::smpi::Request::ssend_init(buf, count, datatype, dst, tag, comm);
- retval = MPI_SUCCESS;
- }
+ *request = simgrid::smpi::Request::ssend_init(buf, count, datatype, dst, tag, comm);
+ retval = MPI_SUCCESS;
+
smpi_bench_begin();
- if (retval != MPI_SUCCESS && request != nullptr)
- *request = MPI_REQUEST_NULL;
return retval;
}
int retval = 0;
smpi_bench_end();
- if (request == nullptr || *request == MPI_REQUEST_NULL) {
+ CHECK_REQUEST(1)
+ if ( *request == MPI_REQUEST_NULL) {
retval = MPI_ERR_REQUEST;
} else {
MPI_Request req = *request;
int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Request * request)
{
- int retval = 0;
+ CHECK_IRECV_INPUTS
smpi_bench_end();
-
- if (request == nullptr) {
- retval = MPI_ERR_ARG;
- } else if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
- } else if (src == MPI_PROC_NULL) {
- *request = MPI_REQUEST_NULL;
- retval = MPI_SUCCESS;
- } else if (src!=MPI_ANY_SOURCE && (src >= comm->group()->size() || src <0)){
- retval = MPI_ERR_RANK;
- } else if ((count < 0) || (buf==nullptr && count > 0)) {
- retval = MPI_ERR_COUNT;
- } else if (datatype==MPI_DATATYPE_NULL || not datatype->is_valid()) {
- retval = MPI_ERR_TYPE;
- } else if(tag<0 && tag != MPI_ANY_TAG){
- retval = MPI_ERR_TAG;
- } else {
-
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
-
- TRACE_smpi_comm_in(my_proc_id, __func__,
- new simgrid::instr::Pt2PtTIData("irecv", src,
- datatype->is_replayable() ? count : count * datatype->size(),
- tag, simgrid::smpi::Datatype::encode(datatype)));
-
- *request = simgrid::smpi::Request::irecv(buf, count, datatype, src, tag, comm);
- retval = MPI_SUCCESS;
-
- TRACE_smpi_comm_out(my_proc_id);
- }
-
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ TRACE_smpi_comm_in(my_proc_id, __func__,
+ new simgrid::instr::Pt2PtTIData("irecv", src,
+ datatype->is_replayable() ? count : count * datatype->size(),
+ tag, simgrid::smpi::Datatype::encode(datatype)));
+ *request = simgrid::smpi::Request::irecv(buf, count, datatype, src, tag, comm);
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
- if (retval != MPI_SUCCESS && request != nullptr)
- *request = MPI_REQUEST_NULL;
- return retval;
+ return MPI_SUCCESS;
}
int PMPI_Isend(const void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request * request)
{
- int retval = 0;
+ CHECK_ISEND_INPUTS
smpi_bench_end();
- if (request == nullptr) {
- retval = MPI_ERR_ARG;
- } else if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
- } else if (dst == MPI_PROC_NULL) {
- *request = MPI_REQUEST_NULL;
- retval = MPI_SUCCESS;
- } else if (dst >= comm->group()->size() || dst <0){
- retval = MPI_ERR_RANK;
- } else if ((count < 0) || (buf==nullptr && count > 0)) {
- retval = MPI_ERR_COUNT;
- } else if (datatype==MPI_DATATYPE_NULL || not datatype->is_valid()) {
- retval = MPI_ERR_TYPE;
- } else if(tag<0 && tag != MPI_ANY_TAG){
- retval = MPI_ERR_TAG;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- int trace_dst = getPid(comm, dst);
- TRACE_smpi_comm_in(my_proc_id, __func__,
- new simgrid::instr::Pt2PtTIData("isend", dst,
- datatype->is_replayable() ? count : count * datatype->size(),
- tag, simgrid::smpi::Datatype::encode(datatype)));
-
- TRACE_smpi_send(my_proc_id, my_proc_id, trace_dst, tag, count * datatype->size());
-
- *request = simgrid::smpi::Request::isend(buf, count, datatype, dst, tag, comm);
- retval = MPI_SUCCESS;
-
- TRACE_smpi_comm_out(my_proc_id);
- }
-
+ int retval = 0;
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ int trace_dst = getPid(comm, dst);
+ TRACE_smpi_comm_in(my_proc_id, __func__,
+ new simgrid::instr::Pt2PtTIData("isend", dst,
+ datatype->is_replayable() ? count : count * datatype->size(),
+ tag, simgrid::smpi::Datatype::encode(datatype)));
+ TRACE_smpi_send(my_proc_id, my_proc_id, trace_dst, tag, count * datatype->size());
+ *request = simgrid::smpi::Request::isend(buf, count, datatype, dst, tag, comm);
+ retval = MPI_SUCCESS;
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
- if (retval != MPI_SUCCESS && request!=nullptr)
- *request = MPI_REQUEST_NULL;
+
return retval;
}
int PMPI_Issend(const void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request)
{
- int retval = 0;
+ CHECK_ISEND_INPUTS
smpi_bench_end();
- if (request == nullptr) {
- retval = MPI_ERR_ARG;
- } else if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
- } else if (dst == MPI_PROC_NULL) {
- *request = MPI_REQUEST_NULL;
- retval = MPI_SUCCESS;
- } else if (dst >= comm->group()->size() || dst <0){
- retval = MPI_ERR_RANK;
- } else if ((count < 0)|| (buf==nullptr && count > 0)) {
- retval = MPI_ERR_COUNT;
- } else if (datatype==MPI_DATATYPE_NULL || not datatype->is_valid()) {
- retval = MPI_ERR_TYPE;
- } else if(tag<0 && tag != MPI_ANY_TAG){
- retval = MPI_ERR_TAG;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- int trace_dst = getPid(comm, dst);
- TRACE_smpi_comm_in(my_proc_id, __func__,
- new simgrid::instr::Pt2PtTIData("ISsend", dst,
- datatype->is_replayable() ? count : count * datatype->size(),
- tag, simgrid::smpi::Datatype::encode(datatype)));
- TRACE_smpi_send(my_proc_id, my_proc_id, trace_dst, tag, count * datatype->size());
-
- *request = simgrid::smpi::Request::issend(buf, count, datatype, dst, tag, comm);
- retval = MPI_SUCCESS;
-
- TRACE_smpi_comm_out(my_proc_id);
- }
-
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ int trace_dst = getPid(comm, dst);
+ TRACE_smpi_comm_in(my_proc_id, __func__,
+ new simgrid::instr::Pt2PtTIData("ISsend", dst,
+ datatype->is_replayable() ? count : count * datatype->size(),
+ tag, simgrid::smpi::Datatype::encode(datatype)));
+ TRACE_smpi_send(my_proc_id, my_proc_id, trace_dst, tag, count * datatype->size());
+ *request = simgrid::smpi::Request::issend(buf, count, datatype, dst, tag, comm);
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
- if (retval != MPI_SUCCESS && request!=nullptr)
- *request = MPI_REQUEST_NULL;
- return retval;
+ return MPI_SUCCESS;
}
int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status * status)
{
int retval = 0;
+ CHECK_BUFFER(1, buf, count)
+ CHECK_COUNT(2, count)
+ CHECK_TYPE(3, datatype)
+ CHECK_TAG(5, tag)
+ CHECK_COMM(6)
+
smpi_bench_end();
- if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
- } else if (src == MPI_PROC_NULL) {
+ if (src == MPI_PROC_NULL) {
if(status != MPI_STATUS_IGNORE){
simgrid::smpi::Status::empty(status);
status->MPI_SOURCE = MPI_PROC_NULL;
retval = MPI_SUCCESS;
} else if (src!=MPI_ANY_SOURCE && (src >= comm->group()->size() || src <0)){
retval = MPI_ERR_RANK;
- } else if ((count < 0) || (buf==nullptr && count > 0)) {
- retval = MPI_ERR_COUNT;
- } else if (datatype==MPI_DATATYPE_NULL || not datatype->is_valid()) {
- retval = MPI_ERR_TYPE;
- } else if(tag<0 && tag != MPI_ANY_TAG){
- retval = MPI_ERR_TAG;
} else {
int my_proc_id = simgrid::s4u::this_actor::get_pid();
TRACE_smpi_comm_in(my_proc_id, __func__,
int PMPI_Send(const void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm)
{
- int retval = 0;
+ CHECK_SEND_INPUTS
smpi_bench_end();
-
- if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
- } else if (dst == MPI_PROC_NULL) {
- retval = MPI_SUCCESS;
- } else if (dst >= comm->group()->size() || dst <0){
- retval = MPI_ERR_RANK;
- } else if ((count < 0) || (buf == nullptr && count > 0)) {
- retval = MPI_ERR_COUNT;
- } else if (datatype==MPI_DATATYPE_NULL || not datatype->is_valid()) {
- retval = MPI_ERR_TYPE;
- } else if(tag < 0 && tag != MPI_ANY_TAG){
- retval = MPI_ERR_TAG;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- int dst_traced = getPid(comm, dst);
- TRACE_smpi_comm_in(my_proc_id, __func__,
- new simgrid::instr::Pt2PtTIData("send", dst,
- datatype->is_replayable() ? count : count * datatype->size(),
- tag, simgrid::smpi::Datatype::encode(datatype)));
- if (not TRACE_smpi_view_internals()) {
- TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, tag, count * datatype->size());
- }
-
- simgrid::smpi::Request::send(buf, count, datatype, dst, tag, comm);
- retval = MPI_SUCCESS;
-
- TRACE_smpi_comm_out(my_proc_id);
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ int dst_traced = getPid(comm, dst);
+ TRACE_smpi_comm_in(my_proc_id, __func__,
+ new simgrid::instr::Pt2PtTIData("send", dst,
+ datatype->is_replayable() ? count : count * datatype->size(),
+ tag, simgrid::smpi::Datatype::encode(datatype)));
+ if (not TRACE_smpi_view_internals()) {
+ TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, tag, count * datatype->size());
}
-
+ simgrid::smpi::Request::send(buf, count, datatype, dst, tag, comm);
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
- return retval;
+ return MPI_SUCCESS;
}
int PMPI_Rsend(const void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm)
int PMPI_Bsend(const void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm)
{
- int retval = 0;
+ CHECK_SEND_INPUTS
smpi_bench_end();
-
- if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
- } else if (dst == MPI_PROC_NULL) {
- retval = MPI_SUCCESS;
- } else if (dst >= comm->group()->size() || dst <0){
- retval = MPI_ERR_RANK;
- } else if ((count < 0) || (buf == nullptr && count > 0)) {
- retval = MPI_ERR_COUNT;
- } else if (datatype==MPI_DATATYPE_NULL || not datatype->is_valid()) {
- retval = MPI_ERR_TYPE;
- } else if(tag < 0 && tag != MPI_ANY_TAG){
- retval = MPI_ERR_TAG;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- int dst_traced = getPid(comm, dst);
- int bsend_buf_size = 0;
- void* bsend_buf = nullptr;
- smpi_process()->bsend_buffer(&bsend_buf, &bsend_buf_size);
- int size = datatype->get_extent() * count;
- if(bsend_buf==nullptr || bsend_buf_size < size + MPI_BSEND_OVERHEAD )
- return MPI_ERR_BUFFER;
- TRACE_smpi_comm_in(my_proc_id, __func__,
- new simgrid::instr::Pt2PtTIData("bsend", dst,
- datatype->is_replayable() ? count : count * datatype->size(),
- tag, simgrid::smpi::Datatype::encode(datatype)));
- if (not TRACE_smpi_view_internals()) {
- TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, tag, count * datatype->size());
- }
-
- simgrid::smpi::Request::bsend(buf, count, datatype, dst, tag, comm);
- retval = MPI_SUCCESS;
-
- TRACE_smpi_comm_out(my_proc_id);
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ int dst_traced = getPid(comm, dst);
+ int bsend_buf_size = 0;
+ void* bsend_buf = nullptr;
+ smpi_process()->bsend_buffer(&bsend_buf, &bsend_buf_size);
+ int size = datatype->get_extent() * count;
+ if(bsend_buf==nullptr || bsend_buf_size < size + MPI_BSEND_OVERHEAD )
+ return MPI_ERR_BUFFER;
+ TRACE_smpi_comm_in(my_proc_id, __func__,
+ new simgrid::instr::Pt2PtTIData("bsend", dst,
+ datatype->is_replayable() ? count : count * datatype->size(),
+ tag, simgrid::smpi::Datatype::encode(datatype)));
+ if (not TRACE_smpi_view_internals()) {
+ TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, tag, count * datatype->size());
}
-
+ simgrid::smpi::Request::bsend(buf, count, datatype, dst, tag, comm);
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
- return retval;
+ return MPI_SUCCESS;
}
int PMPI_Ibsend(const void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request)
{
- int retval = 0;
+ CHECK_ISEND_INPUTS
smpi_bench_end();
- if (request == nullptr) {
- retval = MPI_ERR_ARG;
- } else if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
- } else if (dst == MPI_PROC_NULL) {
- *request = MPI_REQUEST_NULL;
- retval = MPI_SUCCESS;
- } else if (dst >= comm->group()->size() || dst <0){
- retval = MPI_ERR_RANK;
- } else if ((count < 0) || (buf==nullptr && count > 0)) {
- retval = MPI_ERR_COUNT;
- } else if (datatype==MPI_DATATYPE_NULL || not datatype->is_valid()) {
- retval = MPI_ERR_TYPE;
- } else if(tag<0 && tag != MPI_ANY_TAG){
- retval = MPI_ERR_TAG;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- int trace_dst = getPid(comm, dst);
- int bsend_buf_size = 0;
- void* bsend_buf = nullptr;
- smpi_process()->bsend_buffer(&bsend_buf, &bsend_buf_size);
- int size = datatype->get_extent() * count;
- if(bsend_buf==nullptr || bsend_buf_size < size + MPI_BSEND_OVERHEAD )
- return MPI_ERR_BUFFER;
- TRACE_smpi_comm_in(my_proc_id, __func__,
- new simgrid::instr::Pt2PtTIData("ibsend", dst,
- datatype->is_replayable() ? count : count * datatype->size(),
- tag, simgrid::smpi::Datatype::encode(datatype)));
-
- TRACE_smpi_send(my_proc_id, my_proc_id, trace_dst, tag, count * datatype->size());
-
- *request = simgrid::smpi::Request::ibsend(buf, count, datatype, dst, tag, comm);
- retval = MPI_SUCCESS;
-
- TRACE_smpi_comm_out(my_proc_id);
- }
-
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ int trace_dst = getPid(comm, dst);
+ int bsend_buf_size = 0;
+ void* bsend_buf = nullptr;
+ smpi_process()->bsend_buffer(&bsend_buf, &bsend_buf_size);
+ int size = datatype->get_extent() * count;
+ if(bsend_buf==nullptr || bsend_buf_size < size + MPI_BSEND_OVERHEAD )
+ return MPI_ERR_BUFFER;
+ TRACE_smpi_comm_in(my_proc_id, __func__,
+ new simgrid::instr::Pt2PtTIData("ibsend", dst,
+ datatype->is_replayable() ? count : count * datatype->size(),
+ tag, simgrid::smpi::Datatype::encode(datatype)));
+ TRACE_smpi_send(my_proc_id, my_proc_id, trace_dst, tag, count * datatype->size());
+ *request = simgrid::smpi::Request::ibsend(buf, count, datatype, dst, tag, comm);
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
- if (retval != MPI_SUCCESS && request!=nullptr)
- *request = MPI_REQUEST_NULL;
- return retval;
+ return MPI_SUCCESS;
}
int PMPI_Bsend_init(const void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request)
{
-
- int retval = 0;
+ CHECK_ISEND_INPUTS
smpi_bench_end();
- if (request == nullptr) {
- retval = MPI_ERR_ARG;
- } else if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
- } else if (datatype==MPI_DATATYPE_NULL || not datatype->is_valid()) {
- retval = MPI_ERR_TYPE;
- } else if (dst == MPI_PROC_NULL) {
- retval = MPI_SUCCESS;
+ int retval = 0;
+ int bsend_buf_size = 0;
+ void* bsend_buf = nullptr;
+ smpi_process()->bsend_buffer(&bsend_buf, &bsend_buf_size);
+ if( bsend_buf==nullptr || bsend_buf_size < datatype->get_extent() * count + MPI_BSEND_OVERHEAD ) {
+ retval = MPI_ERR_BUFFER;
} else {
- int bsend_buf_size = 0;
- void* bsend_buf = nullptr;
- smpi_process()->bsend_buffer(&bsend_buf, &bsend_buf_size);
- if( bsend_buf==nullptr || bsend_buf_size < datatype->get_extent() * count + MPI_BSEND_OVERHEAD ) {
- retval = MPI_ERR_BUFFER;
- } else {
- *request = simgrid::smpi::Request::bsend_init(buf, count, datatype, dst, tag, comm);
- retval = MPI_SUCCESS;
- }
+ *request = simgrid::smpi::Request::bsend_init(buf, count, datatype, dst, tag, comm);
+ retval = MPI_SUCCESS;
}
smpi_bench_begin();
- if (retval != MPI_SUCCESS && request != nullptr)
- *request = MPI_REQUEST_NULL;
return retval;
}
-int PMPI_Ssend(const void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) {
- int retval = 0;
+int PMPI_Ssend(const void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm)
+{
+ CHECK_SEND_INPUTS
smpi_bench_end();
-
- if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
- } else if (dst == MPI_PROC_NULL) {
- retval = MPI_SUCCESS;
- } else if (dst >= comm->group()->size() || dst <0){
- retval = MPI_ERR_RANK;
- } else if ((count < 0) || (buf==nullptr && count > 0)) {
- retval = MPI_ERR_COUNT;
- } else if (datatype==MPI_DATATYPE_NULL || not datatype->is_valid()) {
- retval = MPI_ERR_TYPE;
- } else if(tag<0 && tag != MPI_ANY_TAG){
- retval = MPI_ERR_TAG;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- int dst_traced = getPid(comm, dst);
- TRACE_smpi_comm_in(my_proc_id, __func__,
- new simgrid::instr::Pt2PtTIData("Ssend", dst,
- datatype->is_replayable() ? count : count * datatype->size(),
- tag, simgrid::smpi::Datatype::encode(datatype)));
- TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, tag, count * datatype->size());
-
- simgrid::smpi::Request::ssend(buf, count, datatype, dst, tag, comm);
- retval = MPI_SUCCESS;
-
- TRACE_smpi_comm_out(my_proc_id);
- }
-
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ int dst_traced = getPid(comm, dst);
+ TRACE_smpi_comm_in(my_proc_id, __func__,
+ new simgrid::instr::Pt2PtTIData("Ssend", dst,
+ datatype->is_replayable() ? count : count * datatype->size(),
+ tag, simgrid::smpi::Datatype::encode(datatype)));
+ TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, tag, count * datatype->size());
+ simgrid::smpi::Request::ssend(buf, count, datatype, dst, tag, comm);
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
- return retval;
+ return MPI_SUCCESS;
}
int PMPI_Sendrecv(const void* sendbuf, int sendcount, MPI_Datatype sendtype, int dst, int sendtag, void* recvbuf,
int recvcount, MPI_Datatype recvtype, int src, int recvtag, MPI_Comm comm, MPI_Status* status)
{
int retval = 0;
-
+ CHECK_BUFFER(1, sendbuf, sendcount)
+ CHECK_COUNT(2, sendcount)
+ CHECK_TYPE(3, sendtype)
+ CHECK_TAG(5, sendtag)
+ CHECK_BUFFER(6, recvbuf, recvcount)
+ CHECK_COUNT(7, recvcount)
+ CHECK_TYPE(8, recvtype)
+ CHECK_TAG(10, recvtag)
+ CHECK_COMM(11)
smpi_bench_end();
- if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
- } else if (not sendtype->is_valid() || not recvtype->is_valid()) {
- retval = MPI_ERR_TYPE;
- } else if (src == MPI_PROC_NULL) {
+ if (src == MPI_PROC_NULL) {
if(status!=MPI_STATUS_IGNORE){
simgrid::smpi::Status::empty(status);
status->MPI_SOURCE = MPI_PROC_NULL;
if(dst != MPI_PROC_NULL)
simgrid::smpi::Request::send(sendbuf, sendcount, sendtype, dst, sendtag, comm);
retval = MPI_SUCCESS;
- }else if (dst == MPI_PROC_NULL){
+ } else if (dst == MPI_PROC_NULL){
simgrid::smpi::Request::recv(recvbuf, recvcount, recvtype, src, recvtag, comm, status);
retval = MPI_SUCCESS;
- }else if (dst >= comm->group()->size() || dst <0 ||
+ } else if (dst >= comm->group()->size() || dst <0 ||
(src!=MPI_ANY_SOURCE && (src >= comm->group()->size() || src <0))){
retval = MPI_ERR_RANK;
- } else if ((sendcount < 0 || recvcount<0) ||
- (sendbuf==nullptr && sendcount > 0) || (recvbuf==nullptr && recvcount>0)) {
- retval = MPI_ERR_COUNT;
- } else if((sendtag<0 && sendtag != MPI_ANY_TAG)||(recvtag<0 && recvtag != MPI_ANY_TAG)){
- retval = MPI_ERR_TAG;
} else {
int my_proc_id = simgrid::s4u::this_actor::get_pid();
int dst_traced = getPid(comm, dst);
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__,
MPI_Comm comm, MPI_Status* status)
{
int retval = 0;
- if (datatype==MPI_DATATYPE_NULL || not datatype->is_valid()) {
- return MPI_ERR_TYPE;
- } else if (count < 0) {
- return MPI_ERR_COUNT;
- } else {
- int size = datatype->get_extent() * count;
- 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){
- simgrid::smpi::Datatype::copy(recvbuf, count, datatype, buf, count, datatype);
- }
- xbt_free(recvbuf);
-
- }
+ CHECK_BUFFER(1, buf, count)
+ CHECK_COUNT(2, count)
+ 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){
+ simgrid::smpi::Datatype::copy(recvbuf, count, datatype, buf, count, datatype);
+ }
+ xbt_free(recvbuf);
return retval;
}
int my_proc_id = ((*request)->comm() != MPI_COMM_NULL) ? simgrid::s4u::this_actor::get_pid() : -1;
TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("test"));
-
retval = simgrid::smpi::Request::test(request,status, flag);
TRACE_smpi_comm_out(my_proc_id);
int PMPI_Testany(int count, MPI_Request requests[], int *index, int *flag, MPI_Status * status)
{
int retval = 0;
-
+ CHECK_COUNT(1, count)
smpi_bench_end();
if (index == nullptr || flag == nullptr) {
retval = MPI_ERR_ARG;
int PMPI_Testall(int count, MPI_Request* requests, int* flag, MPI_Status* statuses)
{
int retval = 0;
-
+ CHECK_COUNT(1, count)
smpi_bench_end();
if (flag == nullptr) {
retval = MPI_ERR_ARG;
int PMPI_Testsome(int incount, MPI_Request requests[], int* outcount, int* indices, MPI_Status status[])
{
int retval = 0;
-
+ CHECK_COUNT(1, incount)
smpi_bench_end();
if (outcount == nullptr) {
retval = MPI_ERR_ARG;
int retval = 0;
smpi_bench_end();
- if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
- } else if (source == MPI_PROC_NULL) {
+ CHECK_COMM(6)
+ CHECK_TAG(2, tag)
+ if (source == MPI_PROC_NULL) {
if (status != MPI_STATUS_IGNORE){
simgrid::smpi::Status::empty(status);
status->MPI_SOURCE = MPI_PROC_NULL;
int PMPI_Iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* status) {
int retval = 0;
smpi_bench_end();
-
+ CHECK_COMM(6)
+ CHECK_TAG(2, tag)
if (flag == nullptr) {
retval = MPI_ERR_ARG;
- } else if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
} else if (source == MPI_PROC_NULL) {
*flag=true;
if (status != MPI_STATUS_IGNORE){
simgrid::smpi::Status::empty(status);
- if (request == nullptr) {
- retval = MPI_ERR_ARG;
- } else if (*request == MPI_REQUEST_NULL) {
+ CHECK_NULL(1, MPI_ERR_ARG, request)
+ if (*request == MPI_REQUEST_NULL) {
retval = MPI_SUCCESS;
} else {
// for tracing, save the handle which might get overridden before we can use the helper on it
int PMPI_Waitall(int count, MPI_Request requests[], MPI_Status status[])
{
smpi_bench_end();
-
+ CHECK_COUNT(1, count)
// for tracing, save the handles which might get overridden before we can use the helper on it
std::vector<MPI_Request> savedreqs(requests, requests + count);
for (MPI_Request& req : savedreqs) {
int PMPI_Waitsome(int incount, MPI_Request requests[], int *outcount, int *indices, MPI_Status status[])
{
int retval = 0;
-
+ CHECK_COUNT(1, incount)
smpi_bench_end();
if (outcount == nullptr) {
retval = MPI_ERR_ARG;
int retval = 0;
smpi_bench_end();
+ CHECK_REQUEST(1)
if (*request == MPI_REQUEST_NULL) {
retval = MPI_ERR_REQUEST;
} else {
-/* 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. */
* MPIR_Topo_Type field, and replace the MPI_Topology field by an union)*/
int PMPI_Cart_create(MPI_Comm comm_old, int ndims, const int* dims, const int* periodic, int reorder, MPI_Comm* comm_cart) {
- if (comm_old == MPI_COMM_NULL){
- return MPI_ERR_COMM;
- } else if (ndims < 0 || (ndims > 0 && (dims == nullptr || periodic == nullptr)) || comm_cart == nullptr) {
- return MPI_ERR_ARG;
+ CHECK_COMM2(1, comm_old)
+ if (ndims > 0){
+ CHECK_NULL(3, MPI_ERR_ARG, dims)
+ CHECK_NULL(4, MPI_ERR_ARG, periodic)
+ CHECK_NULL(6, MPI_ERR_ARG, comm_cart)
+ }
+ CHECK_NEGATIVE(2, MPI_ERR_ARG, ndims)
+ for (int i = 0; i < ndims; i++)
+ CHECK_NEGATIVE(2, MPI_ERR_ARG, dims[i])
+ 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 {
- for (int i = 0; i < ndims; i++)
- if (dims[i] < 0)
- return MPI_ERR_ARG;
-
- 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 {
- xbt_assert((*comm_cart)->topo() == topo);
- }
- return MPI_SUCCESS;
+ xbt_assert((*comm_cart)->topo() == topo);
}
+ return MPI_SUCCESS;
}
int PMPI_Cart_rank(MPI_Comm comm, const int* coords, int* rank) {
- if(comm == MPI_COMM_NULL || comm->topo() == nullptr) {
- return MPI_ERR_TOPOLOGY;
- }
- if (coords == nullptr) {
- return MPI_SUCCESS;
- }
+ CHECK_COMM(1)
+ CHECK_NULL(1, MPI_ERR_TOPOLOGY, comm->topo())
+ CHECK_NULL(2, MPI_SUCCESS, coords)
MPIR_Cart_Topology topo = static_cast<MPIR_Cart_Topology>(comm->topo());
if (topo==nullptr) {
return MPI_ERR_ARG;
}
int PMPI_Cart_shift(MPI_Comm comm, int direction, int displ, int* source, int* dest) {
- if(comm == MPI_COMM_NULL || comm->topo() == nullptr) {
- return MPI_ERR_TOPOLOGY;
- }
- if (source == nullptr || dest == nullptr || direction < 0 ) {
- return MPI_ERR_ARG;
- }
+ CHECK_COMM(1)
+ CHECK_NULL(1, MPI_ERR_TOPOLOGY, comm->topo())
+ CHECK_NEGATIVE(3, MPI_ERR_ARG, direction)
+ CHECK_NULL(4, MPI_ERR_ARG, source)
+ CHECK_NULL(5, MPI_ERR_ARG, dest)
MPIR_Cart_Topology topo = static_cast<MPIR_Cart_Topology>(comm->topo());
if (topo==nullptr) {
return MPI_ERR_ARG;
}
int PMPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int* coords) {
- if(comm == MPI_COMM_NULL || comm->topo() == nullptr) {
- return MPI_ERR_TOPOLOGY;
- }
- if (rank < 0 || rank >= comm->size()) {
- return MPI_ERR_RANK;
- }
- if (maxdims < 0) {
- return MPI_ERR_ARG;
- }
+ CHECK_COMM(1)
+ CHECK_NULL(1, MPI_ERR_TOPOLOGY, comm->topo())
+ CHECK_NEGATIVE(3, MPI_ERR_ARG, maxdims)
+ CHECK_RANK(2, rank, comm)
if(maxdims==0 || coords == nullptr) {
return MPI_SUCCESS;
}
if(dims == nullptr || periods == nullptr || coords == nullptr){
return MPI_SUCCESS;
}
- if(comm == nullptr || comm->topo() == nullptr) {
- return MPI_ERR_TOPOLOGY;
- }
- if(maxdims <= 0) {
- return MPI_ERR_ARG;
- }
+ CHECK_COMM(1)
+ CHECK_NULL(1, MPI_ERR_TOPOLOGY, comm->topo())
+ CHECK_NEGATIVE(3, MPI_ERR_ARG, maxdims)
MPIR_Cart_Topology topo = static_cast<MPIR_Cart_Topology>(comm->topo());
if (topo==nullptr) {
return MPI_ERR_ARG;
}
int PMPI_Cartdim_get(MPI_Comm comm, int* ndims) {
- if (comm == MPI_COMM_NULL || comm->topo() == nullptr) {
- return MPI_ERR_TOPOLOGY;
- }
- if (ndims == nullptr) {
- return MPI_ERR_ARG;
- }
+ CHECK_COMM(1)
+ CHECK_NULL(1, MPI_ERR_TOPOLOGY, comm->topo())
+ CHECK_NULL(2, MPI_ERR_ARG, ndims)
MPIR_Cart_Topology topo = static_cast<MPIR_Cart_Topology>(comm->topo());
if (topo==nullptr) {
return MPI_ERR_ARG;
}
int PMPI_Dims_create(int nnodes, int ndims, int* dims) {
- if(dims == nullptr) {
- return MPI_SUCCESS;
- }
+ CHECK_NULL(3, MPI_SUCCESS, dims)
if (ndims < 1 || nnodes < 1) {
return MPI_ERR_DIMS;
}
}
int PMPI_Cart_sub(MPI_Comm comm, const int* remain_dims, MPI_Comm* comm_new) {
- if(comm == MPI_COMM_NULL || comm->topo() == nullptr) {
- return MPI_ERR_TOPOLOGY;
- }
- if (comm_new == nullptr) {
- return MPI_ERR_ARG;
- }
+ CHECK_COMM(1)
+ CHECK_NULL(1, MPI_ERR_TOPOLOGY, comm->topo())
+ CHECK_NULL(3, MPI_ERR_ARG, comm_new)
MPIR_Cart_Topology topo = static_cast<MPIR_Cart_Topology>(comm->topo());
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. */
int PMPI_Type_size(MPI_Datatype datatype, int *size)
{
- if (datatype == MPI_DATATYPE_NULL) {
- return MPI_ERR_TYPE;
- } else if (size == nullptr) {
- return MPI_ERR_ARG;
- } else {
- *size = static_cast<int>(datatype->size());
- return MPI_SUCCESS;
- }
+ CHECK_MPI_NULL(1, MPI_DATATYPE_NULL, MPI_ERR_TYPE, datatype)
+ CHECK_NULL(2, MPI_ERR_ARG, size)
+ *size = static_cast<int>(datatype->size());
+ return MPI_SUCCESS;
}
int PMPI_Type_size_x(MPI_Datatype datatype, MPI_Count *size)
{
- if (datatype == MPI_DATATYPE_NULL) {
- return MPI_ERR_TYPE;
- } else if (size == nullptr) {
- return MPI_ERR_ARG;
- } else {
- *size = static_cast<MPI_Count>(datatype->size());
- return MPI_SUCCESS;
- }
+ CHECK_MPI_NULL(1, MPI_DATATYPE_NULL, MPI_ERR_TYPE, datatype)
+ CHECK_NULL(2, MPI_ERR_ARG, size)
+ *size = static_cast<MPI_Count>(datatype->size());
+ return MPI_SUCCESS;
}
int PMPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent)
{
- if (datatype == MPI_DATATYPE_NULL) {
- return MPI_ERR_TYPE;
- } else if (lb == nullptr || extent == nullptr) {
- return MPI_ERR_ARG;
- } else {
- return datatype->extent(lb, extent);
- }
+ CHECK_MPI_NULL(1, MPI_DATATYPE_NULL, MPI_ERR_TYPE, datatype)
+ CHECK_NULL(2, MPI_ERR_ARG, lb)
+ CHECK_NULL(3, MPI_ERR_ARG, extent)
+ return datatype->extent(lb, extent);
}
int PMPI_Type_get_true_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent)
int PMPI_Type_extent(MPI_Datatype datatype, MPI_Aint * extent)
{
- if (datatype == MPI_DATATYPE_NULL) {
- return MPI_ERR_TYPE;
- } else if (extent == nullptr) {
- return MPI_ERR_ARG;
- } else {
- *extent = datatype->get_extent();
- return MPI_SUCCESS;
- }
+ CHECK_MPI_NULL(1, MPI_DATATYPE_NULL, MPI_ERR_TYPE, datatype)
+ CHECK_NULL(2, MPI_ERR_ARG, extent)
+ *extent = datatype->get_extent();
+ return MPI_SUCCESS;
}
int PMPI_Type_lb(MPI_Datatype datatype, MPI_Aint * disp)
{
- if (datatype == MPI_DATATYPE_NULL) {
- return MPI_ERR_TYPE;
- } else if (disp == nullptr) {
- return MPI_ERR_ARG;
- } else {
- *disp = datatype->lb();
- return MPI_SUCCESS;
- }
+ CHECK_MPI_NULL(1, MPI_DATATYPE_NULL, MPI_ERR_TYPE, datatype)
+ CHECK_NULL(2, MPI_ERR_ARG, disp)
+ *disp = datatype->lb();
+ return MPI_SUCCESS;
}
int PMPI_Type_ub(MPI_Datatype datatype, MPI_Aint * disp)
{
- if (datatype == MPI_DATATYPE_NULL) {
- return MPI_ERR_TYPE;
- } else if (disp == nullptr) {
- return MPI_ERR_ARG;
- } else {
- *disp = datatype->ub();
- return MPI_SUCCESS;
- }
+ CHECK_MPI_NULL(1, MPI_DATATYPE_NULL, MPI_ERR_TYPE, datatype)
+ CHECK_NULL(2, MPI_ERR_ARG, disp)
+ *disp = datatype->ub();
+ return MPI_SUCCESS;
}
int PMPI_Type_dup(MPI_Datatype datatype, MPI_Datatype *newtype){
int retval = MPI_SUCCESS;
- if (datatype == MPI_DATATYPE_NULL) {
- retval=MPI_ERR_TYPE;
- } else {
- *newtype = new simgrid::smpi::Datatype(datatype, &retval);
- //error when duplicating, free the new datatype
- if(retval!=MPI_SUCCESS){
- simgrid::smpi::Datatype::unref(*newtype);
- *newtype = MPI_DATATYPE_NULL;
- }
+ CHECK_MPI_NULL(1, MPI_DATATYPE_NULL, MPI_ERR_TYPE, datatype)
+ *newtype = new simgrid::smpi::Datatype(datatype, &retval);
+ //error when duplicating, free the new datatype
+ if(retval!=MPI_SUCCESS){
+ simgrid::smpi::Datatype::unref(*newtype);
+ *newtype = MPI_DATATYPE_NULL;
}
return retval;
}
int PMPI_Type_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_type) {
- if (old_type == MPI_DATATYPE_NULL) {
- return MPI_ERR_TYPE;
- } else if (count<0){
- return MPI_ERR_COUNT;
- } else {
- return simgrid::smpi::Datatype::create_contiguous(count, old_type, 0, new_type);
- }
+ CHECK_COUNT(1, count)
+ CHECK_MPI_NULL(2, MPI_DATATYPE_NULL, MPI_ERR_TYPE, old_type)
+ CHECK_NULL(3, MPI_ERR_ARG, new_type)
+ return simgrid::smpi::Datatype::create_contiguous(count, old_type, 0, new_type);
}
int PMPI_Type_commit(MPI_Datatype* datatype) {
- if (datatype == nullptr || *datatype == MPI_DATATYPE_NULL) {
- return MPI_ERR_TYPE;
- } else {
- (*datatype)->commit();
- return MPI_SUCCESS;
- }
+ CHECK_NULL(1, MPI_ERR_ARG, datatype)
+ CHECK_MPI_NULL(1, MPI_DATATYPE_NULL, MPI_ERR_TYPE, (*datatype))
+ (*datatype)->commit();
+ return MPI_SUCCESS;
}
int PMPI_Type_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
- if (old_type == MPI_DATATYPE_NULL) {
- return MPI_ERR_TYPE;
- } else if (count<0){
- return MPI_ERR_COUNT;
- } else if(blocklen<0){
- return MPI_ERR_ARG;
- } else {
- return simgrid::smpi::Datatype::create_vector(count, blocklen, stride, old_type, new_type);
- }
+ CHECK_COUNT(1, count)
+ CHECK_NEGATIVE(2, MPI_ERR_ARG, blocklen)
+ CHECK_MPI_NULL(4, MPI_DATATYPE_NULL, MPI_ERR_TYPE, old_type)
+ return simgrid::smpi::Datatype::create_vector(count, blocklen, stride, old_type, new_type);
}
int PMPI_Type_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
- if (old_type == MPI_DATATYPE_NULL) {
- return MPI_ERR_TYPE;
- } else if (count<0){
- return MPI_ERR_COUNT;
- } else if(blocklen<0){
- return MPI_ERR_ARG;
- } else {
- return simgrid::smpi::Datatype::create_hvector(count, blocklen, stride, old_type, new_type);
- }
+ CHECK_COUNT(1, count)
+ CHECK_NEGATIVE(2, MPI_ERR_ARG, blocklen)
+ CHECK_MPI_NULL(4, MPI_DATATYPE_NULL, MPI_ERR_TYPE, old_type)
+ return simgrid::smpi::Datatype::create_hvector(count, blocklen, stride, old_type, new_type);
}
int PMPI_Type_create_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
}
int PMPI_Type_indexed(int count, const int* blocklens, const int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
- if (old_type == MPI_DATATYPE_NULL) {
- return MPI_ERR_TYPE;
- } else if (count<0){
- return MPI_ERR_COUNT;
- } else {
- return simgrid::smpi::Datatype::create_indexed(count, blocklens, indices, old_type, new_type);
- }
+ CHECK_COUNT(1, count)
+ CHECK_MPI_NULL(4, MPI_DATATYPE_NULL, MPI_ERR_TYPE, old_type)
+ return simgrid::smpi::Datatype::create_indexed(count, blocklens, indices, old_type, new_type);
}
int PMPI_Type_create_indexed(int count, const int* blocklens, const int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
- if (old_type == MPI_DATATYPE_NULL) {
- return MPI_ERR_TYPE;
- } else if (count<0){
- return MPI_ERR_COUNT;
- } else {
- return simgrid::smpi::Datatype::create_indexed(count, blocklens, indices, old_type, new_type);
- }
+ CHECK_COUNT(1, count)
+ CHECK_MPI_NULL(4, MPI_DATATYPE_NULL, MPI_ERR_TYPE, old_type)
+ return simgrid::smpi::Datatype::create_indexed(count, blocklens, indices, old_type, new_type);
}
int PMPI_Type_create_indexed_block(int count, int blocklength, const int* indices, MPI_Datatype old_type,
MPI_Datatype* new_type)
{
- if (old_type == MPI_DATATYPE_NULL) {
- return MPI_ERR_TYPE;
- } else if (count<0){
- return MPI_ERR_COUNT;
- } else {
- int* blocklens=static_cast<int*>(xbt_malloc(blocklength*count*sizeof(int)));
- for (int i = 0; i < count; i++)
- blocklens[i]=blocklength;
- int retval = simgrid::smpi::Datatype::create_indexed(count, blocklens, indices, old_type, new_type);
- xbt_free(blocklens);
- return retval;
- }
+ CHECK_COUNT(1, count)
+ CHECK_MPI_NULL(4, MPI_DATATYPE_NULL, MPI_ERR_TYPE, old_type)
+ int* blocklens=static_cast<int*>(xbt_malloc(blocklength*count*sizeof(int)));
+ for (int i = 0; i < count; i++)
+ blocklens[i]=blocklength;
+ int retval = simgrid::smpi::Datatype::create_indexed(count, blocklens, indices, old_type, new_type);
+ xbt_free(blocklens);
+ return retval;
}
int PMPI_Type_hindexed(int count, const int* blocklens, const MPI_Aint* indices, MPI_Datatype old_type,
MPI_Datatype* new_type)
{
- if (old_type == MPI_DATATYPE_NULL) {
- return MPI_ERR_TYPE;
- } else if (count<0){
- return MPI_ERR_COUNT;
- } else {
- return simgrid::smpi::Datatype::create_hindexed(count, blocklens, indices, old_type, new_type);
- }
+ CHECK_COUNT(1, count)
+ CHECK_MPI_NULL(4, MPI_DATATYPE_NULL, MPI_ERR_TYPE, old_type)
+ return simgrid::smpi::Datatype::create_hindexed(count, blocklens, indices, old_type, new_type);
}
int PMPI_Type_create_hindexed(int count, const int* blocklens, const MPI_Aint* indices, MPI_Datatype old_type,
int PMPI_Type_create_hindexed_block(int count, int blocklength, const MPI_Aint* indices, MPI_Datatype old_type,
MPI_Datatype* new_type) {
- if (old_type == MPI_DATATYPE_NULL) {
- return MPI_ERR_TYPE;
- } else if (count<0){
- return MPI_ERR_COUNT;
- } else {
- int* blocklens=(int*)xbt_malloc(blocklength*count*sizeof(int));
- for (int i = 0; i < count; i++)
- blocklens[i] = blocklength;
- int retval = simgrid::smpi::Datatype::create_hindexed(count, blocklens, indices, old_type, new_type);
- xbt_free(blocklens);
- return retval;
- }
+ CHECK_COUNT(1, count)
+ CHECK_MPI_NULL(4, MPI_DATATYPE_NULL, MPI_ERR_TYPE, old_type)
+ int* blocklens=(int*)xbt_malloc(blocklength*count*sizeof(int));
+ for (int i = 0; i < count; i++)
+ blocklens[i] = blocklength;
+ int retval = simgrid::smpi::Datatype::create_hindexed(count, blocklens, indices, old_type, new_type);
+ xbt_free(blocklens);
+ return retval;
}
int PMPI_Type_struct(int count, const int* blocklens, const MPI_Aint* indices, const MPI_Datatype* old_types,
MPI_Datatype* new_type)
{
- if (count<0){
- return MPI_ERR_COUNT;
- } else {
- for(int i=0; i<count; i++)
- if(old_types[i]==MPI_DATATYPE_NULL)
- return MPI_ERR_TYPE;
- return simgrid::smpi::Datatype::create_struct(count, blocklens, indices, old_types, new_type);
- }
+ CHECK_COUNT(1, count)
+ for(int i=0; i<count; i++)
+ CHECK_MPI_NULL(4, MPI_DATATYPE_NULL, MPI_ERR_TYPE, old_types[i])
+ return simgrid::smpi::Datatype::create_struct(count, blocklens, indices, old_types, new_type);
}
int PMPI_Type_create_struct(int count, const int* blocklens, const MPI_Aint* indices, const MPI_Datatype* old_types,
int PMPI_Type_create_subarray(int ndims, const int* array_of_sizes,
const int* array_of_subsizes, const int* array_of_starts,
int order, MPI_Datatype oldtype, MPI_Datatype *newtype) {
- if (ndims<0){
- return MPI_ERR_COUNT;
- } else if (ndims==0){
+ CHECK_NEGATIVE(1, MPI_ERR_COUNT, ndims)
+ if (ndims==0){
*newtype = MPI_DATATYPE_NULL;
return MPI_SUCCESS;
} else if (ndims==1){
}
int PMPI_Type_create_resized(MPI_Datatype oldtype,MPI_Aint lb, MPI_Aint extent, MPI_Datatype *newtype){
- if (oldtype == MPI_DATATYPE_NULL) {
- return MPI_ERR_TYPE;
- }
+ CHECK_MPI_NULL(1, MPI_DATATYPE_NULL, MPI_ERR_TYPE, oldtype)
return simgrid::smpi::Datatype::create_resized(oldtype, lb, extent, newtype);
}
int PMPI_Type_set_name(MPI_Datatype datatype, const char * name)
{
- if (datatype == MPI_DATATYPE_NULL) {
- return MPI_ERR_TYPE;
- } else if (name == nullptr) {
- return MPI_ERR_ARG;
- } else {
- datatype->set_name(name);
- return MPI_SUCCESS;
- }
+ CHECK_MPI_NULL(1, MPI_DATATYPE_NULL, MPI_ERR_TYPE, datatype)
+ CHECK_NULL(2, MPI_ERR_ARG, name)
+ datatype->set_name(name);
+ return MPI_SUCCESS;
}
int PMPI_Type_get_name(MPI_Datatype datatype, char * name, int* len)
{
- if (datatype == MPI_DATATYPE_NULL) {
- return MPI_ERR_TYPE;
- } else if (name == nullptr) {
- return MPI_ERR_ARG;
- } else {
- datatype->get_name(name, len);
- return MPI_SUCCESS;
- }
+ CHECK_MPI_NULL(1, MPI_DATATYPE_NULL, MPI_ERR_TYPE, datatype)
+ CHECK_NULL(2, MPI_ERR_ARG, name)
+ datatype->get_name(name, len);
+ return MPI_SUCCESS;
}
MPI_Datatype PMPI_Type_f2c(MPI_Fint datatype){
int PMPI_Type_get_attr (MPI_Datatype type, int type_keyval, void *attribute_val, int* flag)
{
- if (type==MPI_DATATYPE_NULL)
- return MPI_ERR_TYPE;
- else
- return type->attr_get<simgrid::smpi::Datatype>(type_keyval, attribute_val, flag);
+ CHECK_MPI_NULL(1, MPI_DATATYPE_NULL, MPI_ERR_TYPE, type)
+ return type->attr_get<simgrid::smpi::Datatype>(type_keyval, attribute_val, flag);
}
int PMPI_Type_set_attr (MPI_Datatype type, int type_keyval, void *attribute_val)
{
- if (type==MPI_DATATYPE_NULL)
- return MPI_ERR_TYPE;
- else
- return type->attr_put<simgrid::smpi::Datatype>(type_keyval, attribute_val);
+ CHECK_MPI_NULL(1, MPI_DATATYPE_NULL, MPI_ERR_TYPE, type)
+ return type->attr_put<simgrid::smpi::Datatype>(type_keyval, attribute_val);
}
int PMPI_Type_delete_attr (MPI_Datatype type, int type_keyval)
{
- if (type==MPI_DATATYPE_NULL)
- return MPI_ERR_TYPE;
- else
- return type->attr_delete<simgrid::smpi::Datatype>(type_keyval);
+ CHECK_MPI_NULL(1, MPI_DATATYPE_NULL, MPI_ERR_TYPE, type)
+ return type->attr_delete<simgrid::smpi::Datatype>(type_keyval);
}
int PMPI_Type_create_keyval(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval,
}
int PMPI_Unpack(const void* inbuf, int incount, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm) {
- if(incount<0 || outcount < 0){
- return MPI_ERR_COUNT;
- } else if (inbuf==nullptr || outbuf==nullptr){
- return MPI_ERR_ARG;
- } else if (type == MPI_DATATYPE_NULL || not type->is_valid()){
- return MPI_ERR_TYPE;
- } else if(comm==MPI_COMM_NULL){
- return MPI_ERR_COMM;
- } else{
- return type->unpack(inbuf, incount, position, outbuf,outcount, comm);
- }
+ CHECK_NEGATIVE(2, MPI_ERR_COUNT, incount)
+ CHECK_NEGATIVE(5, MPI_ERR_COUNT, outcount)
+ CHECK_BUFFER(1, inbuf, incount)
+ CHECK_BUFFER(4, outbuf, outcount)
+ CHECK_TYPE(6, type)
+ CHECK_COMM(7)
+ return type->unpack(inbuf, incount, position, outbuf,outcount, comm);
}
int PMPI_Pack(const void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm) {
- if(incount<0){
- return MPI_ERR_COUNT;
- } else if(inbuf==nullptr || outbuf==nullptr || outcount < 0){
- return MPI_ERR_ARG;
- } else if (type == MPI_DATATYPE_NULL || not type->is_valid()){
- return MPI_ERR_TYPE;
- } else if(comm==MPI_COMM_NULL){
- return MPI_ERR_COMM;
- } else {
- return type->pack(inbuf == MPI_BOTTOM ? nullptr : inbuf, incount, outbuf, outcount, position, comm);
- }
+ CHECK_NEGATIVE(2, MPI_ERR_COUNT, incount)
+ CHECK_NEGATIVE(5, MPI_ERR_COUNT, outcount)
+ CHECK_BUFFER(1, inbuf, incount)
+ CHECK_BUFFER(4, outbuf, outcount)
+ CHECK_TYPE(6, type)
+ CHECK_COMM(7)
+ return type->pack(inbuf == MPI_BOTTOM ? nullptr : inbuf, incount, outbuf, outcount, position, comm);
}
int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) {
- if(incount<0){
- return MPI_ERR_COUNT;
- } else if (datatype == MPI_DATATYPE_NULL || not datatype->is_valid()){
- return MPI_ERR_TYPE;
- } else if(comm==MPI_COMM_NULL){
- return MPI_ERR_COMM;
- } else {
- *size=incount*datatype->size();
- return MPI_SUCCESS;
- }
+ CHECK_NEGATIVE(1, MPI_ERR_COUNT, incount)
+ CHECK_TYPE(2, datatype)
+ CHECK_COMM(3)
+ *size=incount*datatype->size();
+ 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. */
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi);
+#define CHECK_RMA\
+ CHECK_BUFFER(1, origin_addr, origin_count)\
+ CHECK_COUNT(2, origin_count)\
+ CHECK_TYPE(3, origin_datatype)\
+ CHECK_PROC(4, target_rank)\
+ CHECK_NEGATIVE(4, MPI_ERR_RANK, target_rank)\
+ CHECK_COUNT(6, target_count)\
+ CHECK_TYPE(7, target_datatype)
/* PMPI User level calls */
int PMPI_Win_create( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, MPI_Win *win){
int retval = 0;
+ CHECK_COMM(5)
+ CHECK_NEGATIVE(2, MPI_ERR_OTHER, size)
+ CHECK_NEGATIVE(3, MPI_ERR_OTHER, disp_unit)
smpi_bench_end();
- if (comm == MPI_COMM_NULL) {
- retval= MPI_ERR_COMM;
- }else if ((base == nullptr && size != 0) || disp_unit <= 0 || size < 0 ){
+ if (base == nullptr && size != 0){
retval= MPI_ERR_OTHER;
}else{
*win = new simgrid::smpi::Win( base, size, disp_unit, info, comm);
}
int PMPI_Win_allocate( MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, void *base, MPI_Win *win){
- int retval = 0;
+ CHECK_COMM(5)
+ CHECK_NEGATIVE(2, MPI_ERR_OTHER, size)
+ CHECK_NEGATIVE(3, MPI_ERR_OTHER, disp_unit)
+ void* ptr = xbt_malloc(size);
+ if(ptr==nullptr)
+ return MPI_ERR_NO_MEM;
smpi_bench_end();
- if (comm == MPI_COMM_NULL) {
- retval= MPI_ERR_COMM;
- }else if (disp_unit <= 0 || size < 0 ){
- retval= MPI_ERR_OTHER;
- }else{
- void* ptr = xbt_malloc(size);
- if(ptr==nullptr)
- return MPI_ERR_NO_MEM;
- *static_cast<void**>(base) = ptr;
- *win = new simgrid::smpi::Win( ptr, size, disp_unit, info, comm,1);
- retval = MPI_SUCCESS;
- }
+ *static_cast<void**>(base) = ptr;
+ *win = new simgrid::smpi::Win( ptr, size, disp_unit, info, comm,1);
smpi_bench_begin();
- return retval;
+ return MPI_SUCCESS;
}
int PMPI_Win_allocate_shared( MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, void *base, MPI_Win *win){
- int retval = 0;
- smpi_bench_end();
- if (comm == MPI_COMM_NULL) {
- retval= MPI_ERR_COMM;
- }else if (disp_unit <= 0 || size < 0 ){
- retval= MPI_ERR_OTHER;
- }else{
- void* ptr = nullptr;
- int rank = comm->rank();
- if(rank==0){
- ptr = xbt_malloc(size*comm->size());
- if(ptr==nullptr)
- return MPI_ERR_NO_MEM;
- }
-
- simgrid::smpi::colls::bcast(&ptr, sizeof(void*), MPI_BYTE, 0, comm);
- simgrid::smpi::colls::barrier(comm);
-
- *static_cast<void**>(base) = (char*)ptr+rank*size;
- *win = new simgrid::smpi::Win( ptr, size, disp_unit, info, comm,rank==0);
- retval = MPI_SUCCESS;
+ CHECK_COMM(5)
+ CHECK_NEGATIVE(2, MPI_ERR_OTHER, size)
+ CHECK_NEGATIVE(3, MPI_ERR_OTHER, disp_unit)
+ void* ptr = nullptr;
+ int rank = comm->rank();
+ if(rank==0){
+ ptr = xbt_malloc(size*comm->size());
+ if(ptr==nullptr)
+ return MPI_ERR_NO_MEM;
}
+ smpi_bench_end();
+ simgrid::smpi::colls::bcast(&ptr, sizeof(void*), MPI_BYTE, 0, comm);
+ simgrid::smpi::colls::barrier(comm);
+ *static_cast<void**>(base) = (char*)ptr+rank*size;
+ *win = new simgrid::smpi::Win( ptr, size, disp_unit, info, comm,rank==0);
smpi_bench_begin();
- return retval;
+ return MPI_SUCCESS;
}
int PMPI_Win_create_dynamic( MPI_Info info, MPI_Comm comm, MPI_Win *win){
- int retval = 0;
+ CHECK_COMM(2)
smpi_bench_end();
- if (comm == MPI_COMM_NULL) {
- retval= MPI_ERR_COMM;
- }else{
- *win = new simgrid::smpi::Win(info, comm);
- retval = MPI_SUCCESS;
- }
+ *win = new simgrid::smpi::Win(info, comm);
smpi_bench_begin();
- return retval;
+ return MPI_SUCCESS;
}
int PMPI_Win_attach(MPI_Win win, void *base, MPI_Aint size){
- int retval = 0;
+ CHECK_WIN(1, win)
+ CHECK_NEGATIVE(3, MPI_ERR_OTHER, size)
+ if (base == nullptr && size != 0)
+ return MPI_ERR_OTHER;
smpi_bench_end();
- if(win == MPI_WIN_NULL){
- retval = MPI_ERR_WIN;
- } else if ((base == nullptr && size != 0) || size < 0 ){
- retval= MPI_ERR_OTHER;
- }else{
- retval = win->attach(base, size);
- }
+ int retval = win->attach(base, size);
smpi_bench_begin();
return retval;
}
int PMPI_Win_detach(MPI_Win win, const void* base)
{
- int retval = 0;
+ CHECK_WIN(1, win)
+ CHECK_NULL(2, MPI_ERR_OTHER, base)
smpi_bench_end();
- if(win == MPI_WIN_NULL){
- retval = MPI_ERR_WIN;
- } else if (base == nullptr){
- retval= MPI_ERR_OTHER;
- }else{
- retval = win->detach(base);
- }
+ int retval = win->detach(base);
smpi_bench_begin();
return retval;
}
-
int PMPI_Win_free( MPI_Win* win){
- int retval = 0;
+ CHECK_NULL(1, MPI_ERR_WIN, win)
+ CHECK_WIN(1, (*win))
smpi_bench_end();
- if (win == nullptr || *win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- }else{
- delete *win;
- retval=MPI_SUCCESS;
- }
+ delete *win;
smpi_bench_begin();
- return retval;
+ return MPI_SUCCESS;
}
int PMPI_Win_set_name(MPI_Win win, const char * name)
{
- if (win == MPI_WIN_NULL) {
- return MPI_ERR_TYPE;
- } else if (name == nullptr) {
- return MPI_ERR_ARG;
- } else {
- win->set_name(name);
- return MPI_SUCCESS;
- }
+ CHECK_WIN(1, win)
+ CHECK_NULL(2, MPI_ERR_ARG, name)
+ win->set_name(name);
+ return MPI_SUCCESS;
}
int PMPI_Win_get_name(MPI_Win win, char * name, int* len)
{
- if (win == MPI_WIN_NULL) {
- return MPI_ERR_WIN;
- } else if (name == nullptr) {
- return MPI_ERR_ARG;
- } else {
- win->get_name(name, len);
- return MPI_SUCCESS;
- }
+ CHECK_WIN(1, win)
+ CHECK_NULL(2, MPI_ERR_ARG, name)
+ win->get_name(name, len);
+ return MPI_SUCCESS;
}
int PMPI_Win_get_info(MPI_Win win, MPI_Info* info)
{
- if (win == MPI_WIN_NULL) {
- return MPI_ERR_WIN;
- } else {
- *info = win->info();
- return MPI_SUCCESS;
- }
+ CHECK_WIN(1, win)
+ CHECK_NULL(2, MPI_ERR_ARG, info)
+ *info = win->info();
+ return MPI_SUCCESS;
}
int PMPI_Win_set_info(MPI_Win win, MPI_Info info)
{
- if (win == MPI_WIN_NULL) {
- return MPI_ERR_TYPE;
- } else {
- win->set_info(info);
- return MPI_SUCCESS;
- }
+ CHECK_WIN(1, win)
+ win->set_info(info);
+ return MPI_SUCCESS;
}
int PMPI_Win_get_group(MPI_Win win, MPI_Group * group){
- if (win == MPI_WIN_NULL) {
- return MPI_ERR_WIN;
- }else {
- win->get_group(group);
- (*group)->ref();
- return MPI_SUCCESS;
- }
+ CHECK_WIN(1, win)
+ win->get_group(group);
+ (*group)->ref();
+ return MPI_SUCCESS;
}
int PMPI_Win_fence( int assert, MPI_Win win){
- int retval = 0;
+ CHECK_WIN(2, win)
smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_fence"));
- retval = win->fence(assert);
- TRACE_smpi_comm_out(my_proc_id);
- }
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_fence"));
+ int retval = win->fence(assert);
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
return retval;
}
int PMPI_Get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win){
+ CHECK_RMA
+ CHECK_WIN(8, win)
+
int retval = 0;
smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else if (target_rank == MPI_PROC_NULL) {
- retval = MPI_SUCCESS;
- } else if (target_rank <0){
- retval = MPI_ERR_RANK;
- } else if (win->dynamic()==0 && target_disp <0){
+ if (win->dynamic()==0 && target_disp <0){
//in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
retval = MPI_ERR_ARG;
- } else if ((origin_count < 0 || target_count < 0) ||
- (origin_addr==nullptr && origin_count > 0)){
- retval = MPI_ERR_COUNT;
- } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
- ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
- retval = MPI_ERR_TYPE;
} else {
int my_proc_id = simgrid::s4u::this_actor::get_pid();
MPI_Group group;
retval = win->get( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count,
target_datatype);
-
TRACE_smpi_comm_out(my_proc_id);
}
smpi_bench_begin();
int PMPI_Rget( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win, MPI_Request* request){
+ if(target_rank==MPI_PROC_NULL)
+ *request = MPI_REQUEST_NULL;
+ CHECK_RMA
+ CHECK_WIN(8, win)
+ CHECK_NULL(9, MPI_ERR_ARG, request)
+
int retval = 0;
smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else if (target_rank == MPI_PROC_NULL) {
- *request = MPI_REQUEST_NULL;
- retval = MPI_SUCCESS;
- } else if (target_rank <0){
- retval = MPI_ERR_RANK;
- } else if (win->dynamic()==0 && target_disp <0){
+ if (win->dynamic()==0 && target_disp <0){
//in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
retval = MPI_ERR_ARG;
- } else if ((origin_count < 0 || target_count < 0) ||
- (origin_addr==nullptr && origin_count > 0)){
- retval = MPI_ERR_COUNT;
- } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
- ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
- retval = MPI_ERR_TYPE;
- } else if(request == nullptr){
- retval = MPI_ERR_REQUEST;
} else {
int my_proc_id = simgrid::s4u::this_actor::get_pid();
MPI_Group group;
int PMPI_Put(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win){
+ CHECK_RMA
+ CHECK_WIN(8, win)
+
int retval = 0;
smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else if (target_rank == MPI_PROC_NULL) {
- retval = MPI_SUCCESS;
- } else if (target_rank <0){
- retval = MPI_ERR_RANK;
- } else if (win->dynamic()==0 && target_disp <0){
+ if (win->dynamic()==0 && target_disp <0){
//in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
retval = MPI_ERR_ARG;
- } else if ((origin_count < 0 || target_count < 0) ||
- (origin_addr==nullptr && origin_count > 0)){
- retval = MPI_ERR_COUNT;
- } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
- ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
- retval = MPI_ERR_TYPE;
} else {
int my_proc_id = simgrid::s4u::this_actor::get_pid();
MPI_Group group;
int PMPI_Rput(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win, MPI_Request* request){
+ if(target_rank==MPI_PROC_NULL)
+ *request = MPI_REQUEST_NULL;
+ CHECK_RMA
+ CHECK_WIN(8, win)
+ CHECK_NULL(9, MPI_ERR_ARG, request)
int retval = 0;
smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else if (target_rank == MPI_PROC_NULL) {
- *request = MPI_REQUEST_NULL;
- retval = MPI_SUCCESS;
- } else if (target_rank <0){
- retval = MPI_ERR_RANK;
- } else if (win->dynamic()==0 && target_disp <0){
+ if (win->dynamic()==0 && target_disp <0){
//in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
retval = MPI_ERR_ARG;
- } else if ((origin_count < 0 || target_count < 0) ||
- (origin_addr==nullptr && origin_count > 0)){
- retval = MPI_ERR_COUNT;
- } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
- ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
- retval = MPI_ERR_TYPE;
- } else if(request == nullptr){
- retval = MPI_ERR_REQUEST;
} else {
int my_proc_id = simgrid::s4u::this_actor::get_pid();
MPI_Group group;
int PMPI_Accumulate(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){
+ CHECK_RMA
+ CHECK_OP(8)
+ CHECK_WIN(9, win)
+
int retval = 0;
smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else if (target_rank == MPI_PROC_NULL) {
- retval = MPI_SUCCESS;
- } else if (target_rank <0){
- retval = MPI_ERR_RANK;
- } else if (win->dynamic()==0 && target_disp <0){
+ if (win->dynamic()==0 && target_disp <0){
//in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
retval = MPI_ERR_ARG;
- } else if ((origin_count < 0 || target_count < 0) ||
- (origin_addr==nullptr && origin_count > 0)){
- retval = MPI_ERR_COUNT;
- } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
- ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
- retval = MPI_ERR_TYPE;
- } else if (op == MPI_OP_NULL) {
- retval = MPI_ERR_OP;
} else {
int my_proc_id = simgrid::s4u::this_actor::get_pid();
MPI_Group group;
int PMPI_Raccumulate(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win, MPI_Request* request){
+ if(target_rank==MPI_PROC_NULL)
+ *request = MPI_REQUEST_NULL;
+ CHECK_RMA
+ CHECK_OP(8)
+ CHECK_WIN(9, win)
+ CHECK_NULL(10, MPI_ERR_ARG, request)
+
int retval = 0;
smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else if (target_rank == MPI_PROC_NULL) {
- *request = MPI_REQUEST_NULL;
- retval = MPI_SUCCESS;
- } else if (target_rank <0){
- retval = MPI_ERR_RANK;
- } else if (win->dynamic()==0 && target_disp <0){
+ if (win->dynamic()==0 && target_disp <0){
//in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
retval = MPI_ERR_ARG;
- } else if ((origin_count < 0 || target_count < 0) ||
- (origin_addr==nullptr && origin_count > 0)){
- retval = MPI_ERR_COUNT;
- } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) ||
- ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) {
- retval = MPI_ERR_TYPE;
- } else if (op == MPI_OP_NULL) {
- retval = MPI_ERR_OP;
- } else if(request == nullptr){
- retval = MPI_ERR_REQUEST;
} else {
int my_proc_id = simgrid::s4u::this_actor::get_pid();
MPI_Group group;
int PMPI_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_Win win){
+ if (op != MPI_NO_OP)
+ CHECK_BUFFER(1, origin_addr, origin_count)
+ CHECK_COUNT(2, origin_count)
+ if(origin_count>0)
+ CHECK_TYPE(3, origin_datatype)
+ CHECK_BUFFER(4, result_addr, result_count)
+ CHECK_COUNT(5, result_count)
+ CHECK_TYPE(6, result_datatype)
+ CHECK_PROC(7, target_rank)
+ CHECK_NEGATIVE(7, MPI_ERR_RANK, target_rank)
+ CHECK_COUNT(9, target_count)
+ CHECK_TYPE(10, target_datatype)
+ CHECK_OP(11)
+ CHECK_WIN(12, win)
int retval = 0;
smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else if (target_rank == MPI_PROC_NULL) {
- retval = MPI_SUCCESS;
- } else if (target_rank <0){
- retval = MPI_ERR_RANK;
- } else if (win->dynamic()==0 && target_disp <0){
+ if (win->dynamic()==0 && target_disp <0){
//in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
retval = MPI_ERR_ARG;
- } else if ((origin_count < 0 || target_count < 0 || result_count <0) ||
- (origin_addr==nullptr && origin_count > 0 && op != MPI_NO_OP) ||
- (result_addr==nullptr && result_count > 0)){
- retval = MPI_ERR_COUNT;
- } else if (((target_datatype == MPI_DATATYPE_NULL) || (result_datatype == MPI_DATATYPE_NULL)) ||
- (((origin_datatype != MPI_DATATYPE_NULL) && (not origin_datatype->is_valid())) || (not target_datatype->is_valid()) || (not result_datatype->is_valid()))) {
- retval = MPI_ERR_TYPE;
- } else if (op == MPI_OP_NULL) {
- retval = MPI_ERR_OP;
} else {
int my_proc_id = simgrid::s4u::this_actor::get_pid();
MPI_Group group;
int PMPI_Rget_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_Win win, MPI_Request* request){
+ if(target_rank==MPI_PROC_NULL)
+ *request = MPI_REQUEST_NULL;
+ CHECK_BUFFER(1, origin_addr, origin_count)
+ CHECK_COUNT(2, origin_count)
+ CHECK_TYPE(3, origin_datatype)
+ CHECK_BUFFER(4, result_addr, result_count)
+ CHECK_COUNT(5, result_count)
+ CHECK_TYPE(6, result_datatype)
+ CHECK_PROC(7, target_rank)
+ CHECK_NEGATIVE(7, MPI_ERR_RANK, target_rank)
+ CHECK_COUNT(9, target_count)
+ CHECK_TYPE(10, target_datatype)
+ CHECK_OP(11)
+ CHECK_WIN(12, win)
+ CHECK_NULL(10, MPI_ERR_ARG, request)
int retval = 0;
smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else if (target_rank == MPI_PROC_NULL) {
- *request = MPI_REQUEST_NULL;
- retval = MPI_SUCCESS;
- } else if (target_rank <0){
- retval = MPI_ERR_RANK;
- } else if (win->dynamic()==0 && target_disp <0){
+ if (win->dynamic()==0 && target_disp <0){
//in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
retval = MPI_ERR_ARG;
- } else if ((origin_count < 0 || target_count < 0 || result_count <0) ||
- (origin_addr==nullptr && origin_count > 0 && op != MPI_NO_OP) ||
- (result_addr==nullptr && result_count > 0)){
- retval = MPI_ERR_COUNT;
- } else if (((target_datatype == MPI_DATATYPE_NULL) || (result_datatype == MPI_DATATYPE_NULL)) ||
- (((origin_datatype != MPI_DATATYPE_NULL) && (not origin_datatype->is_valid())) || (not target_datatype->is_valid()) || (not result_datatype->is_valid()))) {
- retval = MPI_ERR_TYPE;
- } else if (op == MPI_OP_NULL) {
- retval = MPI_ERR_OP;
- } else if(request == nullptr){
- retval = MPI_ERR_REQUEST;
} else {
int my_proc_id = simgrid::s4u::this_actor::get_pid();
MPI_Group group;
int PMPI_Compare_and_swap(const void* origin_addr, void* compare_addr, void* result_addr, MPI_Datatype datatype,
int target_rank, MPI_Aint target_disp, MPI_Win win)
{
+ CHECK_NULL(1, MPI_ERR_BUFFER, origin_addr)
+ CHECK_NULL(2, MPI_ERR_BUFFER, compare_addr)
+ CHECK_NULL(3, MPI_ERR_BUFFER, result_addr)
+ CHECK_TYPE(4, datatype)
+ CHECK_PROC(5, target_rank)
+ CHECK_NEGATIVE(5, MPI_ERR_RANK, target_rank)
+ CHECK_WIN(6, win)
int retval = 0;
smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else if (target_rank == MPI_PROC_NULL) {
- retval = MPI_SUCCESS;
- } else if (target_rank <0){
- retval = MPI_ERR_RANK;
- } else if (win->dynamic()==0 && target_disp <0){
+ if (win->dynamic()==0 && target_disp <0){
//in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address
retval = MPI_ERR_ARG;
- } else if (origin_addr==nullptr || result_addr==nullptr || compare_addr==nullptr){
- retval = MPI_ERR_COUNT;
- } else if ((datatype == MPI_DATATYPE_NULL) || (not datatype->is_valid())) {
- retval = MPI_ERR_TYPE;
} else {
int my_proc_id = simgrid::s4u::this_actor::get_pid();
MPI_Group group;
}
int PMPI_Win_post(MPI_Group group, int assert, MPI_Win win){
- int retval = 0;
+ CHECK_GROUP(1, group)
+ CHECK_WIN(2, win)
smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else if (group==MPI_GROUP_NULL){
- retval = MPI_ERR_GROUP;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_post"));
- retval = win->post(group,assert);
- TRACE_smpi_comm_out(my_proc_id);
- }
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_post"));
+ int retval = win->post(group,assert);
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
return retval;
}
int PMPI_Win_start(MPI_Group group, int assert, MPI_Win win){
- int retval = 0;
+ CHECK_GROUP(1, group)
+ CHECK_WIN(2, win)
smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else if (group==MPI_GROUP_NULL){
- retval = MPI_ERR_GROUP;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_start"));
- retval = win->start(group,assert);
- TRACE_smpi_comm_out(my_proc_id);
- }
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_start"));
+ int retval = win->start(group,assert);
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
return retval;
}
int PMPI_Win_complete(MPI_Win win){
- int retval = 0;
+ CHECK_WIN(1, win)
smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_complete"));
-
- retval = win->complete();
-
- TRACE_smpi_comm_out(my_proc_id);
- }
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_complete"));
+ int retval = win->complete();
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
return retval;
}
int PMPI_Win_wait(MPI_Win win){
- int retval = 0;
+ CHECK_WIN(1, win)
smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_wait"));
-
- retval = win->wait();
-
- TRACE_smpi_comm_out(my_proc_id);
- }
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_wait"));
+ int retval = win->wait();
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
return retval;
}
int PMPI_Win_lock(int lock_type, int rank, int assert, MPI_Win win){
+ CHECK_PROC(2, rank)
+ CHECK_WIN(4, win)
int retval = 0;
smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else if (lock_type != MPI_LOCK_EXCLUSIVE &&
- lock_type != MPI_LOCK_SHARED) {
+ if (lock_type != MPI_LOCK_EXCLUSIVE &&
+ lock_type != MPI_LOCK_SHARED) {
retval = MPI_ERR_LOCKTYPE;
- } else if (rank == MPI_PROC_NULL){
- retval = MPI_SUCCESS;
} else {
int my_proc_id = simgrid::s4u::this_actor::get_pid();
TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_lock"));
}
int PMPI_Win_unlock(int rank, MPI_Win win){
- int retval = 0;
+ CHECK_PROC(1, rank)
+ CHECK_WIN(2, win)
smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else if (rank == MPI_PROC_NULL){
- retval = MPI_SUCCESS;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_unlock"));
- retval = win->unlock(rank);
- TRACE_smpi_comm_out(my_proc_id);
- }
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_unlock"));
+ int retval = win->unlock(rank);
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
return retval;
}
int PMPI_Win_lock_all(int assert, MPI_Win win){
- int retval = 0;
+ CHECK_WIN(2, win)
smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_lock_all"));
- retval = win->lock_all(assert);
- TRACE_smpi_comm_out(my_proc_id);
- }
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_lock_all"));
+ int retval = win->lock_all(assert);
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
return retval;
}
int PMPI_Win_unlock_all(MPI_Win win){
- int retval = 0;
+ CHECK_WIN(1, win)
smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_unlock_all"));
- retval = win->unlock_all();
- TRACE_smpi_comm_out(my_proc_id);
- }
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_unlock_all"));
+ int retval = win->unlock_all();
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
return retval;
}
int PMPI_Win_flush(int rank, MPI_Win win){
- int retval = 0;
+ CHECK_PROC(1, rank)
+ CHECK_WIN(2, win)
smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else if (rank == MPI_PROC_NULL){
- retval = MPI_SUCCESS;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_flush"));
- retval = win->flush(rank);
- TRACE_smpi_comm_out(my_proc_id);
- }
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_flush"));
+ int retval = win->flush(rank);
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
return retval;
}
int PMPI_Win_flush_local(int rank, MPI_Win win){
- int retval = 0;
- smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else if (rank == MPI_PROC_NULL){
- retval = MPI_SUCCESS;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_flush_local"));
- retval = win->flush_local(rank);
- TRACE_smpi_comm_out(my_proc_id);
- }
+ CHECK_PROC(1, rank)
+ CHECK_WIN(2, win) smpi_bench_end();
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_flush_local"));
+ int retval = win->flush_local(rank);
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
return retval;
}
int PMPI_Win_flush_all(MPI_Win win){
- int retval = 0;
+ CHECK_WIN(1, win)
smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_flush_all"));
- retval = win->flush_all();
- TRACE_smpi_comm_out(my_proc_id);
- }
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_flush_all"));
+ int retval = win->flush_all();
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
return retval;
}
int PMPI_Win_flush_local_all(MPI_Win win){
- int retval = 0;
+ CHECK_WIN(1, win)
smpi_bench_end();
- if (win == MPI_WIN_NULL) {
- retval = MPI_ERR_WIN;
- } else {
- int my_proc_id = simgrid::s4u::this_actor::get_pid();
- TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_flush_local_all"));
- retval = win->flush_local_all();
- TRACE_smpi_comm_out(my_proc_id);
- }
+ int my_proc_id = simgrid::s4u::this_actor::get_pid();
+ TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Win_flush_local_all"));
+ int retval = win->flush_local_all();
+ TRACE_smpi_comm_out(my_proc_id);
smpi_bench_begin();
return retval;
}
int PMPI_Win_shared_query (MPI_Win win, int rank, MPI_Aint* size, int* disp_unit, void* baseptr)
{
- if (win==MPI_WIN_NULL)
- return MPI_ERR_TYPE;
- else
- return win->shared_query(rank, size, disp_unit, baseptr);
+ CHECK_WIN(1, win)
+ return win->shared_query(rank, size, disp_unit, baseptr);
}
int PMPI_Win_get_attr (MPI_Win win, int keyval, void *attribute_val, int* flag)
{
static MPI_Aint size;
static MPI_Aint disp_unit;
- if (win==MPI_WIN_NULL)
- return MPI_ERR_TYPE;
- else{
+ CHECK_WIN(1, win)
switch (keyval) {
- case MPI_WIN_BASE :
- *static_cast<void**>(attribute_val) = win->base();
- *flag = 1;
+ case MPI_WIN_BASE:
+ *static_cast<void**>(attribute_val) = win->base();
+ *flag = 1;
return MPI_SUCCESS;
- case MPI_WIN_SIZE :
- size = win->size();
- *static_cast<MPI_Aint**>(attribute_val) = &size;
- *flag = 1;
+ case MPI_WIN_SIZE:
+ size = win->size();
+ *static_cast<MPI_Aint**>(attribute_val) = &size;
+ *flag = 1;
return MPI_SUCCESS;
- case MPI_WIN_DISP_UNIT :
- disp_unit=win->disp_unit();
- *static_cast<MPI_Aint**>(attribute_val) = &disp_unit;
- *flag = 1;
+ case MPI_WIN_DISP_UNIT:
+ disp_unit = win->disp_unit();
+ *static_cast<MPI_Aint**>(attribute_val) = &disp_unit;
+ *flag = 1;
return MPI_SUCCESS;
default:
- return win->attr_get<simgrid::smpi::Win>(keyval, attribute_val, flag);
+ return win->attr_get<simgrid::smpi::Win>(keyval, attribute_val, flag);
}
}
-}
-
int PMPI_Win_set_attr (MPI_Win win, int type_keyval, void *attribute_val)
{
- if (win==MPI_WIN_NULL)
- return MPI_ERR_TYPE;
- else
- return win->attr_put<simgrid::smpi::Win>(type_keyval, attribute_val);
+ CHECK_WIN(1, win)
+ return win->attr_put<simgrid::smpi::Win>(type_keyval, attribute_val);
}
int PMPI_Win_delete_attr (MPI_Win win, int type_keyval)
{
- if (win==MPI_WIN_NULL)
- return MPI_ERR_TYPE;
- else
- return win->attr_delete<simgrid::smpi::Win>(type_keyval);
+ CHECK_WIN(1, win)
+ return win->attr_delete<simgrid::smpi::Win>(type_keyval);
}
int PMPI_Win_create_keyval(MPI_Win_copy_attr_function* copy_fn, MPI_Win_delete_attr_function* delete_fn, int* keyval,
}
int PMPI_Win_get_errhandler(MPI_Win win, MPI_Errhandler* errhandler){
- if (win == nullptr) {
- return MPI_ERR_WIN;
- } else if (errhandler==nullptr){
+ CHECK_WIN(1, win)
+ if (errhandler==nullptr){
return MPI_ERR_ARG;
}
*errhandler=win->errhandler();
}
int PMPI_Win_set_errhandler(MPI_Win win, MPI_Errhandler errhandler){
- if (win == nullptr) {
- return MPI_ERR_WIN;
- } else if (errhandler==nullptr){
+ CHECK_WIN(1, win)
+ if (errhandler==nullptr){
return MPI_ERR_ARG;
}
win->set_errhandler(errhandler);
}
int PMPI_Win_call_errhandler(MPI_Win win,int errorcode){
- if (win == nullptr) {
- return MPI_ERR_WIN;
- }
- win->errhandler()->call(win, errorcode);
+ CHECK_WIN(1, win)
+ 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
MPI_Datatype rdtype,
MPI_Comm comm)
{
- int i, size, rank;
- char *psnd, *prcv;
- int nreqs;
- ptrdiff_t sext, rext;
- MPI_Request *preq;
- size = comm->size();
- rank = comm->rank();
- MPI_Request* ireqs = new MPI_Request[size * 2];
- XBT_DEBUG(
- "coll:tuned:alltoallv_intra_basic_linear rank %d", rank);
-
- sext=sdtype->get_extent();
- rext=rdtype->get_extent();
-
- /* Simple optimization - handle send to self first */
- psnd = ((char *) sbuf) + (sdisps[rank] * sext);
- prcv = ((char *) rbuf) + (rdisps[rank] * rext);
- if (0 != scounts[rank]) {
- Datatype::copy(psnd, scounts[rank], sdtype,
- prcv, rcounts[rank], rdtype);
- }
-
- /* If only one process, we're done. */
- if (1 == size) {
- return MPI_SUCCESS;
- }
-
- /* Now, initiate all send/recv to/from others. */
- nreqs = 0;
- preq = ireqs;
-
- /* Post all receives first */
- for (i = 0; i < size; ++i) {
- if (i == rank) {
- continue;
- }
-
- prcv = ((char *) rbuf) + (rdisps[i] * rext);
-
- *preq = Request::irecv_init(prcv, rcounts[i], rdtype,
- i, COLL_TAG_ALLTOALLV, comm
- );
- preq++;
- ++nreqs;
-
- }
+ int size = comm->size();
+ int rank = comm->rank();
+ XBT_DEBUG("coll:tuned:alltoallv_intra_basic_linear rank %d", rank);
+
+ ptrdiff_t sext = sdtype->get_extent();
+ ptrdiff_t rext = rdtype->get_extent();
+
+ /* Simple optimization - handle send to self first */
+ char* psnd = ((char*)sbuf) + (sdisps[rank] * sext);
+ char* prcv = ((char*)rbuf) + (rdisps[rank] * rext);
+ if (0 != scounts[rank]) {
+ Datatype::copy(psnd, scounts[rank], sdtype, prcv, rcounts[rank], rdtype);
+ }
+
+ /* If only one process, we're done. */
+ if (1 == size) {
+ return MPI_SUCCESS;
+ }
- /* Now post all sends */
- for (i = 0; i < size; ++i) {
- if (i == rank) {
- continue;
- }
+ /* Now, initiate all send/recv to/from others. */
+ MPI_Request* ireqs = new MPI_Request[size * 2];
+ int nreqs = 0;
+ MPI_Request* preq = ireqs;
- psnd = ((char *) sbuf) + (sdisps[i] * sext);
- *preq=Request::isend_init(psnd, scounts[i], sdtype,
- i, COLL_TAG_ALLTOALLV, comm
- );
- preq++;
- ++nreqs;
+ /* Post all receives first */
+ for (int i = 0; i < size; ++i) {
+ if (i == rank) {
+ continue;
}
- /* Start your engines. This will never return an error. */
- Request::startall(nreqs, ireqs);
+ prcv = ((char*)rbuf) + (rdisps[i] * rext);
- /* Wait for them all. If there's an error, note that we don't care
- * what the error was -- just that there *was* an error. The PML
- * will finish all requests, even if one or more of them fail.
- * i.e., by the end of this call, all the requests are free-able.
- * So free them anyway -- even if there was an error, and return the
- * error after we free everything. */
- Request::waitall(nreqs, ireqs,
- MPI_STATUSES_IGNORE);
+ *preq = Request::irecv_init(prcv, rcounts[i], rdtype, i, COLL_TAG_ALLTOALLV, comm);
+ preq++;
+ ++nreqs;
+ }
- /* Free the requests. */
- for (i = 0; i < nreqs; ++i) {
- if(ireqs[i]!=MPI_REQUEST_NULL)
- Request::unref(&ireqs[i]);
+ /* Now post all sends */
+ for (int i = 0; i < size; ++i) {
+ if (i == rank) {
+ continue;
}
- delete[] ireqs;
- return MPI_SUCCESS;
+ psnd = ((char*)sbuf) + (sdisps[i] * sext);
+ *preq = Request::isend_init(psnd, scounts[i], sdtype, i, COLL_TAG_ALLTOALLV, comm);
+ preq++;
+ ++nreqs;
+ }
+
+ /* Start your engines. This will never return an error. */
+ Request::startall(nreqs, ireqs);
+
+ /* Wait for them all. If there's an error, note that we don't care
+ * what the error was -- just that there *was* an error. The PML
+ * will finish all requests, even if one or more of them fail.
+ * i.e., by the end of this call, all the requests are free-able.
+ * So free them anyway -- even if there was an error, and return the
+ * error after we free everything. */
+ Request::waitall(nreqs, ireqs, MPI_STATUSES_IGNORE);
+
+ /* Free the requests. */
+ for (int i = 0; i < nreqs; ++i) {
+ if (ireqs[i] != MPI_REQUEST_NULL)
+ Request::unref(&ireqs[i]);
+ }
+ delete[] ireqs;
+
+ 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
-/* 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. */
XBT_PRIVATE double smpi_mpi_wtime();
XBT_PRIVATE void smpi_mpi_init();
+enum class SharedMallocType { NONE, LOCAL, GLOBAL };
+enum class SmpiPrivStrategies { NONE = 0, MMAP = 1, DLOPEN = 2, DEFAULT = DLOPEN };
+
+XBT_PRIVATE double smpi_cfg_host_speed();
+XBT_PRIVATE bool smpi_cfg_simulate_computation();
+XBT_PRIVATE SharedMallocType smpi_cfg_shared_malloc();
+XBT_PRIVATE double smpi_cfg_cpu_thresh();
+XBT_PRIVATE SmpiPrivStrategies smpi_cfg_privatization();
+XBT_PRIVATE int smpi_cfg_async_small_thresh();
+XBT_PRIVATE int smpi_cfg_detached_send_thresh();
+XBT_PRIVATE bool smpi_cfg_grow_injected_times();
+XBT_PRIVATE double smpi_cfg_iprobe_cpu_usage();
+XBT_PRIVATE bool smpi_cfg_trace_call_location();
+XBT_PRIVATE bool smpi_cfg_trace_call_use_absolute_path();
+XBT_PRIVATE std::string smpi_cfg_comp_adjustment_file();
+XBT_PRIVATE std::string smpi_cfg_papi_events_file();
+XBT_PRIVATE double smpi_cfg_auto_shared_malloc_thresh();
+
// utilities
-extern XBT_PRIVATE double smpi_cpu_threshold;
-extern XBT_PRIVATE double smpi_host_speed;
extern XBT_PRIVATE char* smpi_data_exe_start; // start of the data+bss segment of the executable
extern XBT_PRIVATE int smpi_data_exe_size; // size of the data+bss segment of the executable
-enum class SharedMallocType { NONE, LOCAL, GLOBAL };
-extern XBT_PRIVATE SharedMallocType smpi_cfg_shared_malloc; // Whether to activate shared malloc
-
XBT_PRIVATE void smpi_switch_data_segment(simgrid::s4u::ActorPtr actor);
XBT_PRIVATE void smpi_prepare_global_memory_segment();
void mpi_file_read_(int* fh, void* buf, int* count, int* datatype, MPI_Status* status, int* ierr);
void mpi_file_write_(int* fh, void* buf, int* count, int* datatype, MPI_Status* status, int* ierr);
void smpi_init_fortran_types();
+void smpi_execute_flops_(double* flops);
+void smpi_execute_flops_benched_(double* flops);
+void smpi_execute_(double* duration);
+void smpi_execute_benched_(double* duration);
} // extern "C"
+XBT_PRIVATE int smpi_temp_shm_get();
+XBT_PRIVATE void* smpi_temp_shm_mmap(int fd, size_t size);
+
struct s_smpi_privatization_region_t {
void* address;
int file_descriptor;
/** @brief Returns the last call location (filename, linenumber). Process-specific. */
XBT_PUBLIC smpi_trace_call_location_t* smpi_trace_get_call_location();
-enum class SmpiPrivStrategies { NONE = 0, MMAP = 1, DLOPEN = 2, DEFAULT = DLOPEN };
-
-extern XBT_PRIVATE SmpiPrivStrategies smpi_privatize_global_variables;
-
XBT_PRIVATE void private_execute_flops(double flops);
+
+#define CHECK_ARGS(test, errcode, ...) \
+ if (test) { \
+ if((errcode) != MPI_SUCCESS) \
+ XBT_WARN(__VA_ARGS__); \
+ return (errcode); \
+ }
+
+#define CHECK_MPI_NULL(num, val, err, ptr) \
+ CHECK_ARGS((ptr) == (val), (err), \
+ "%s: param %d %s cannot be %s", __func__, (num), _XBT_STRINGIFY(ptr), _XBT_STRINGIFY(val));
+#define CHECK_NULL(num,err,buf) \
+ CHECK_ARGS((buf) == nullptr, (err), \
+ "%s: param %d %s cannot be NULL", __func__, (num), _XBT_STRINGIFY(buf));
+#define CHECK_NEGATIVE(num, err, val) \
+ CHECK_ARGS((val) < 0, (err), \
+ "%s: param %d %s cannot be negative", __func__, (num), _XBT_STRINGIFY(val));
+#define CHECK_COMM2(num, comm) \
+ CHECK_MPI_NULL((num), MPI_COMM_NULL, MPI_ERR_COMM, (comm))
+#define CHECK_COMM(num) \
+ CHECK_COMM2((num), comm)
+#define CHECK_REQUEST(num) \
+ CHECK_ARGS(request == nullptr, MPI_ERR_REQUEST, \
+ "%s: param %d request cannot be NULL",__func__, (num));
+#define CHECK_BUFFER(num,buf,count) \
+ CHECK_ARGS((buf) == nullptr && (count) > 0, MPI_ERR_BUFFER, \
+ "%s: param %d %s cannot be NULL if %s > 0",__func__, (num), _XBT_STRINGIFY(buf), _XBT_STRINGIFY(count));
+#define CHECK_COUNT(num, count) \
+ CHECK_NEGATIVE((num), MPI_ERR_COUNT, (count))
+#define CHECK_TYPE(num, datatype) \
+ CHECK_ARGS(((datatype) == MPI_DATATYPE_NULL|| not (datatype)->is_valid()), MPI_ERR_TYPE, \
+ "%s: param %d %s cannot be MPI_DATATYPE_NULL or invalid", __func__, (num), _XBT_STRINGIFY(datatype));
+#define CHECK_OP(num) \
+ CHECK_MPI_NULL((num), MPI_OP_NULL, MPI_ERR_OP, op)
+#define CHECK_ROOT(num)\
+ CHECK_ARGS((root < 0 || root >= comm->size()), MPI_ERR_ROOT, \
+ "%s: param %d root (=%d) cannot be negative or larger than communicator size (=%d)", __func__, (num), \
+ root, comm->size());
+#define CHECK_PROC(num,proc) \
+ CHECK_MPI_NULL((num), MPI_PROC_NULL, MPI_SUCCESS, (proc))
+#define CHECK_INFO(num,info) \
+ CHECK_MPI_NULL((num), MPI_INFO_NULL, MPI_ERR_INFO, (info))
+#define CHECK_TAG(num,tag) \
+ CHECK_ARGS(((tag) < 0 && (tag) != MPI_ANY_TAG), MPI_ERR_TAG, \
+ "%s: param %d %s (=%d) cannot be negative", __func__, (num), _XBT_STRINGIFY(tag), (tag));
+#define CHECK_FILE(num, fh) \
+ CHECK_MPI_NULL((num), MPI_FILE_NULL, MPI_ERR_FILE, (fh))
+#define CHECK_OFFSET(num, offset) \
+ CHECK_NEGATIVE((num), MPI_ERR_DISP, (offset))
+#define CHECK_GROUP(num, group) \
+ CHECK_MPI_NULL((num), MPI_GROUP_NULL, MPI_ERR_GROUP, (group))
+#define CHECK_WIN(num, win) \
+ CHECK_MPI_NULL((num), MPI_WIN_NULL, MPI_ERR_WIN, (win))
+#define CHECK_RANK(num, rank, comm) \
+ CHECK_ARGS(((rank) >= (comm)->group()->size() || (rank) <0), MPI_ERR_RANK, \
+ "%s: param %d %s (=%d) cannot be < 0 or > %d", __func__, (num), _XBT_STRINGIFY(rank), \
+ (rank), (comm)->group()->size() );
#endif
-/* 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. */
int papi_event_set_;
papi_counter_t papi_counter_data_;
#endif
+
public:
static simgrid::xbt::Extension<simgrid::s4u::Actor, ActorExt> EXTENSION_ID;
/* 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
--- /dev/null
+/* 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. */
+
+#ifndef SMPI_CONFIG_HPP
+#define SMPI_CONFIG_HPP
+
+#include "src/internal_config.h" // HAVE_PAPI
+#include <xbt/config.hpp>
+
+XBT_PRIVATE void smpi_check_options();
+/********************************** Configuration of SMPI **************************************/
+extern XBT_PRIVATE simgrid::config::Flag<double> _smpi_cfg_host_speed;
+extern XBT_PRIVATE simgrid::config::Flag<bool> _smpi_cfg_simulate_computation;
+extern XBT_PRIVATE simgrid::config::Flag<std::string> _smpi_cfg_shared_malloc_string;
+extern XBT_PRIVATE simgrid::config::Flag<double> _smpi_cfg_cpu_thresh;
+extern XBT_PRIVATE simgrid::config::Flag<std::string> _smpi_cfg_privatization_string;
+extern XBT_PRIVATE simgrid::config::Flag<int> _smpi_cfg_async_small_thresh;
+extern XBT_PRIVATE simgrid::config::Flag<int> _smpi_cfg_detached_send_thresh;
+extern XBT_PRIVATE simgrid::config::Flag<bool> _smpi_cfg_grow_injected_times;
+extern XBT_PRIVATE simgrid::config::Flag<double> _smpi_cfg_iprobe_cpu_usage;
+extern XBT_PRIVATE simgrid::config::Flag<bool> _smpi_cfg_trace_call_use_absolute_path;
+extern XBT_PRIVATE simgrid::config::Flag<bool> _smpi_cfg_trace_call_location;
+extern XBT_PRIVATE simgrid::config::Flag<std::string> _smpi_cfg_comp_adjustment_file;
+#if HAVE_PAPI
+extern XBT_PRIVATE simgrid::config::Flag<std::string> _smpi_cfg_papi_events_file;
+#endif
+extern XBT_PRIVATE simgrid::config::Flag<double> _smpi_cfg_auto_shared_malloc_thresh;
+#endif
-/* 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
void call(MPI_File file, int errorcode);
static void unref(Errhandler* errhandler);
static Errhandler* f2c(int id);
-
};
-
}
}
-#endif
\ No newline at end of file
+#endif
/* 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
MPI_Win win_;
char* list_;
MPI_Errhandler errhandler_;
+ MPI_Datatype etype_;
+ MPI_Datatype filetype_;
+ std::string datarep_;
public:
File(MPI_Comm comm, const char *filename, int amode, MPI_Info info);
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, 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 read(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status);
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);
};
int size = comm_->size();
int rank = comm_-> rank();
MPI_Offset min_offset = file_->tell();
- MPI_Offset max_offset = (min_offset + count * datatype->size());//cheating, as we don't care about exact data location, we can skip extent
+ MPI_Offset max_offset = min_offset + count * datatype->get_extent();//cheating, as we don't care about exact data location, we can skip extent
MPI_Offset* min_offsets = new MPI_Offset[size];
MPI_Offset* max_offsets = new MPI_Offset[size];
simgrid::smpi::colls::allgather(&min_offset, 1, MPI_OFFSET, min_offsets, 1, MPI_OFFSET, comm_);
delete[] min_offsets;
delete[] max_offsets;
//contiguous. Just have each proc perform its read
- status->count=count * datatype->size();
+ if(status != MPI_STATUS_IGNORE)
+ status->count=count * datatype->size();
return T(this,buf,count,datatype, status);
}
//Set buf value to avoid copying dumb data
simgrid::smpi::colls::alltoallv(sendbuf, send_sizes, send_disps, MPI_BYTE, buf, recv_sizes, recv_disps, MPI_BYTE,
comm_);
- status->count=count * datatype->size();
+ if(status!=MPI_STATUS_IGNORE)
+ status->count=count * datatype->size();
smpi_free_tmp_buffer(sendbuf);
delete[] send_sizes;
delete[] recv_sizes;
-/* 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
std::vector<int> index_to_rank_map_;
int refcount_ = 1; /* refcount_: start > 0 so that this group never gets freed */
+
public:
Group() = default;
explicit Group(int size) : size_(size), rank_to_actor_map_(size, nullptr), index_to_rank_map_(size, MPI_UNDEFINED) {}
-/* 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. */
bool truncated_;
size_t real_size_;
MPI_Comm comm_;
- smx_activity_t action_;
+ simgrid::kernel::activity::ActivityImplPtr action_;
unsigned flags_;
bool detached_;
MPI_Request detached_sender_;
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. */
MC_ignore_heap(timer_, xbt_os_timer_size());
#if HAVE_PAPI
- if (not simgrid::config::get_value<std::string>("smpi/papi-events").empty()) {
+ if (not smpi_cfg_papi_events_file().empty()) {
// TODO: Implement host/process/thread based counters. This implementation
// just always takes the values passed via "default", like this:
// "default:COUNTER1:COUNTER2:COUNTER3;".
ActorExt::~ActorExt()
{
+ if (info_env_ != MPI_INFO_NULL)
+ simgrid::smpi::Info::unref(info_env_);
if (comm_self_ != MPI_COMM_NULL)
simgrid::smpi::Comm::destroy(comm_self_);
if (comm_intra_ != MPI_COMM_NULL)
if (ext->initialized())
return;
- if (smpi_privatize_global_variables == SmpiPrivStrategies::MMAP) {
+ if (smpi_cfg_privatization() == SmpiPrivStrategies::MMAP) {
/* Now using the segment index of this process */
ext->set_privatized_region(smpi_init_global_memory_segment_process());
/* Done at the process's creation */
-/* 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. */
"Minimum time to inject inside a call to MPI_Wtime(), gettimeofday() and clock_gettime()",
1e-8 /* Documented to be 10 ns */);
-double smpi_cpu_threshold = -1;
-double smpi_host_speed;
-
-SharedMallocType smpi_cfg_shared_malloc = SharedMallocType::GLOBAL;
double smpi_total_benched_time = 0;
// Private execute_flops used by smpi_execute and smpi_execute_benched
void smpi_execute(double duration)
{
- if (duration >= smpi_cpu_threshold) {
+ if (duration >= smpi_cfg_cpu_thresh()) {
XBT_DEBUG("Sleep for %g to handle real computation time", duration);
- double flops = duration * smpi_host_speed;
+ double flops = duration * smpi_cfg_host_speed();
int rank = simgrid::s4u::this_actor::get_pid();
TRACE_smpi_computing_in(rank, flops);
} else {
XBT_DEBUG("Real computation took %g while option smpi/cpu-threshold is set to %g => ignore it", duration,
- smpi_cpu_threshold);
+ smpi_cfg_cpu_thresh());
}
}
smpi_bench_begin();
}
+void smpi_execute_flops_benched(double flops) {
+ smpi_bench_end();
+ smpi_execute_flops(flops);
+ smpi_bench_begin();
+}
+
void smpi_bench_begin()
{
- if (smpi_privatize_global_variables == SmpiPrivStrategies::MMAP) {
+ if (smpi_cfg_privatization() == SmpiPrivStrategies::MMAP) {
smpi_switch_data_segment(simgrid::s4u::Actor::self());
}
return;
#if HAVE_PAPI
- if (not simgrid::config::get_value<std::string>("smpi/papi-events").empty()) {
+ if (not smpi_cfg_papi_events_file().empty()) {
int event_set = smpi_process()->papi_event_set();
// PAPI_start sets everything to 0! See man(3) PAPI_start
if (PAPI_LOW_LEVEL_INITED == PAPI_is_initialized() && PAPI_start(event_set) != PAPI_OK) {
double smpi_adjust_comp_speed(){
double speedup=1;
- if (simgrid::config::get_value<std::string>("smpi/comp-adjustment-file")[0] != '\0') {
-
+ if (smpi_cfg_comp_adjustment_file()[0] != '\0') {
smpi_trace_call_location_t* loc = smpi_process()->call_location();
std::string key = loc->get_composed_key();
std::unordered_map<std::string, double>::const_iterator it = location2speedup.find(key);
* An MPI function has been called and now is the right time to update
* our PAPI counters for this process.
*/
- if (not simgrid::config::get_value<std::string>("smpi/papi-events").empty()) {
+ if (not smpi_cfg_papi_events_file().empty()) {
papi_counter_t& counter_data = smpi_process()->papi_counters();
int event_set = smpi_process()->papi_event_set();
std::vector<long long> event_values = std::vector<long long>(counter_data.size());
// Maybe we need to artificially speed up or slow down our computation based on our statistical analysis.
// Simulate the benchmarked computation unless disabled via command-line argument
- if (simgrid::config::get_value<bool>("smpi/simulate-computation")) {
+ if (smpi_cfg_simulate_computation()) {
smpi_execute(xbt_os_timer_elapsed(timer)/smpi_adjust_comp_speed());
}
#if HAVE_PAPI
- if (not simgrid::config::get_value<std::string>("smpi/papi-events").empty() && TRACE_smpi_is_enabled()) {
- container_t container =
+ if (not smpi_cfg_papi_events_file().empty() && TRACE_smpi_is_enabled()) {
+ 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();
loc->previous_filename = loc->filename;
loc->previous_linenumber = loc->linenumber;
- if(not simgrid::config::get_value<bool>("smpi/trace-call-use-absolute-path"))
+ if(not smpi_cfg_trace_call_use_absolute_path())
loc->filename = simgrid::xbt::Path(file).get_base_name();
else
loc->filename = file;
}
/** 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);
}
--- /dev/null
+/* 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. */
+#include "mc/mc.h"
+#include "include/xbt/config.hpp"
+#include "private.hpp"
+#include "smpi_coll.hpp"
+#include "smpi_config.hpp"
+#include "src/simix/smx_private.hpp"
+#include <cfloat> /* DBL_MAX */
+#include <boost/algorithm/string.hpp> /* trim */
+#include <boost/tokenizer.hpp>
+
+#if SIMGRID_HAVE_MC
+#include "src/mc/mc_config.hpp"
+#endif
+
+#if defined(__APPLE__)
+# include <AvailabilityMacros.h>
+# ifndef MAC_OS_X_VERSION_10_12
+# define MAC_OS_X_VERSION_10_12 101200
+# endif
+constexpr bool HAVE_WORKING_MMAP = (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12);
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__sun) || defined(__HAIKU__)
+constexpr bool HAVE_WORKING_MMAP = false;
+#else
+constexpr bool HAVE_WORKING_MMAP = true;
+#endif
+
+bool _smpi_options_initialized=false;
+SharedMallocType _smpi_cfg_shared_malloc = SharedMallocType::GLOBAL;
+SmpiPrivStrategies _smpi_cfg_privatization = SmpiPrivStrategies::NONE;
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_config, smpi, "Logging specific to SMPI (config)");
+
+simgrid::config::Flag<double> _smpi_cfg_host_speed{
+ "smpi/host-speed", "Speed of the host running the simulation (in flop/s). "
+ "Used to bench the operations.", 20000.0,
+ [](const double& val) { xbt_assert(val > 0.0, "Invalid value (%f) for 'smpi/host-speed': it must be positive.", val); }};
+
+simgrid::config::Flag<bool> _smpi_cfg_simulate_computation{
+ "smpi/simulate-computation", "Whether the computational part of the simulated application should be simulated.",
+ true};
+simgrid::config::Flag<std::string> _smpi_cfg_shared_malloc_string{
+ "smpi/shared-malloc", "Whether SMPI_SHARED_MALLOC is enabled. Disable it for debugging purposes.", "global",
+ [](const std::string& val) {
+ if ((val == "yes") || (val == "1") || (val == "on") || (val == "global")) {
+ _smpi_cfg_shared_malloc = SharedMallocType::GLOBAL;
+ } else if (val == "local") {
+ _smpi_cfg_shared_malloc = SharedMallocType::LOCAL;
+ } else if ((val == "no") || (val == "0") || (val == "off")) {
+ _smpi_cfg_shared_malloc = SharedMallocType::NONE;
+ } else {
+ xbt_die("Invalid value '%s' for option smpi/shared-malloc. Possible values: 'on' or 'global', 'local', 'off'",
+ val.c_str());
+ }
+ } };
+
+simgrid::config::Flag<double> _smpi_cfg_cpu_threshold{
+ "smpi/cpu-threshold", "Minimal computation time (in seconds) not discarded, or -1 for infinity.", 1e-6,
+ [](const double& val){
+ if (val < 0)
+ _smpi_cfg_cpu_threshold = DBL_MAX;
+ }};
+
+simgrid::config::Flag<int> _smpi_cfg_async_small_thresh{"smpi/async-small-thresh",
+ "Maximal size of messages that are to be sent asynchronously, without waiting for the receiver",
+ 0};
+simgrid::config::Flag<int> _smpi_cfg_detached_send_thresh{"smpi/send-is-detached-thresh",
+ "Threshold of message size where MPI_Send stops behaving like MPI_Isend and becomes MPI_Ssend",
+ 65536};
+simgrid::config::Flag<bool> _smpi_cfg_grow_injected_times{"smpi/grow-injected-times",
+ "Whether we want to make the injected time in MPI_Iprobe and MPI_Test grow, to "
+ "allow faster simulation. This can make simulation less precise, though.",
+ true};
+simgrid::config::Flag<double> _smpi_cfg_iprobe_cpu_usage{"smpi/iprobe-cpu-usage",
+ "Maximum usage of CPUs by MPI_Iprobe() calls. We've observed that MPI_Iprobes "
+ "consume significantly less power than the maximum of a specific application. "
+ "This value is then (Iprobe_Usage/Max_Application_Usage).",
+ 1.0};
+
+simgrid::config::Flag<bool> _smpi_cfg_trace_call_location{"smpi/trace-call-location",
+ "Should filename and linenumber of MPI calls be traced?", false};
+simgrid::config::Flag<bool> _smpi_cfg_trace_call_use_absolute_path{"smpi/trace-call-use-absolute-path",
+ "Should filenames for trace-call tracing be absolute or not?", false};
+simgrid::config::Flag<std::string> _smpi_cfg_comp_adjustment_file{"smpi/comp-adjustment-file",
+ "A file containing speedups or slowdowns for some parts of the code.",
+ "", [](const std::string& filename){
+ if (not filename.empty()) {
+ std::ifstream fstream(filename);
+ xbt_assert(fstream.is_open(), "Could not open file %s. Does it exist?", filename.c_str());
+ std::string line;
+ typedef boost::tokenizer<boost::escaped_list_separator<char>> Tokenizer;
+ std::getline(fstream, line); // Skip the header line
+ while (std::getline(fstream, line)) {
+ Tokenizer tok(line);
+ Tokenizer::iterator it = tok.begin();
+ Tokenizer::iterator end = std::next(tok.begin());
+ std::string location = *it;
+ boost::trim(location);
+ location2speedup.insert(std::pair<std::string, double>(location, std::stod(*end)));
+ }
+ }
+ }};
+
+#if HAVE_PAPI
+ simgrid::config::Flag<std::string> _smpi_cfg_papi_events_file{"smpi/papi-events",
+ "This switch enables tracking the specified counters with PAPI", ""};
+#endif
+
+simgrid::config::Flag<double> _smpi_cfg_auto_shared_malloc_thresh("smpi/auto-shared-malloc-thresh",
+ "Threshold size for the automatic sharing of memory",
+ 0);
+
+double smpi_cfg_host_speed(){
+ return _smpi_cfg_host_speed;
+}
+
+bool smpi_cfg_simulate_computation(){
+ return _smpi_cfg_simulate_computation;
+}
+
+SharedMallocType smpi_cfg_shared_malloc(){
+ return _smpi_cfg_shared_malloc;
+}
+
+double smpi_cfg_cpu_thresh(){
+ return _smpi_cfg_cpu_threshold;
+}
+
+SmpiPrivStrategies smpi_cfg_privatization(){
+ return _smpi_cfg_privatization;
+}
+
+int smpi_cfg_async_small_thresh(){
+ return _smpi_cfg_async_small_thresh;
+}
+
+int smpi_cfg_detached_send_thresh(){
+ return _smpi_cfg_detached_send_thresh;
+}
+
+bool smpi_cfg_grow_injected_times(){
+ return _smpi_cfg_grow_injected_times;
+}
+
+double smpi_cfg_iprobe_cpu_usage(){
+ return _smpi_cfg_iprobe_cpu_usage;
+}
+
+bool smpi_cfg_trace_call_location(){
+ return _smpi_cfg_trace_call_location;
+}
+
+bool smpi_cfg_trace_call_use_absolute_path(){
+ return _smpi_cfg_trace_call_use_absolute_path;
+}
+
+std::string smpi_cfg_comp_adjustment_file(){
+ return _smpi_cfg_comp_adjustment_file;
+}
+#if HAVE_PAPI
+std::string smpi_cfg_papi_events_file(){
+ return _smpi_cfg_papi_events_file;
+}
+#endif
+double smpi_cfg_auto_shared_malloc_thresh(){
+ return _smpi_cfg_auto_shared_malloc_thresh;
+}
+
+void smpi_init_options(){
+ // return if already called
+ if(_smpi_options_initialized)
+ return;
+ simgrid::config::declare_flag<bool>("smpi/display-timing", "Whether we should display the timing after simulation.", false);
+ simgrid::config::declare_flag<bool>("smpi/keep-temps", "Whether we should keep the generated temporary files.", false);
+
+ simgrid::config::declare_flag<std::string>("smpi/coll-selector", "Which collective selector to use", "default");
+ simgrid::config::declare_flag<std::string>("smpi/gather", "Which collective to use for gather", "");
+ simgrid::config::declare_flag<std::string>("smpi/allgather", "Which collective to use for allgather", "");
+ simgrid::config::declare_flag<std::string>("smpi/barrier", "Which collective to use for barrier", "");
+ simgrid::config::declare_flag<std::string>("smpi/reduce_scatter", "Which collective to use for reduce_scatter", "");
+ simgrid::config::declare_flag<std::string>("smpi/scatter", "Which collective to use for scatter", "");
+ simgrid::config::declare_flag<std::string>("smpi/allgatherv", "Which collective to use for allgatherv", "");
+ simgrid::config::declare_flag<std::string>("smpi/allreduce", "Which collective to use for allreduce", "");
+ simgrid::config::declare_flag<std::string>("smpi/alltoall", "Which collective to use for alltoall", "");
+ simgrid::config::declare_flag<std::string>("smpi/alltoallv", "Which collective to use for alltoallv", "");
+ simgrid::config::declare_flag<std::string>("smpi/bcast", "Which collective to use for bcast", "");
+ simgrid::config::declare_flag<std::string>("smpi/reduce", "Which collective to use for reduce", "");
+
+ const char* default_privatization = std::getenv("SMPI_PRIVATIZATION");
+ if (default_privatization == nullptr)
+ default_privatization = "no";
+
+
+ simgrid::config::declare_flag<std::string>( "smpi/privatization",
+ "How we should privatize global variable at runtime (no, yes, mmap, dlopen).",
+ default_privatization, [](const std::string& smpi_privatize_option){
+ if (smpi_privatize_option == "no" || smpi_privatize_option == "0")
+ _smpi_cfg_privatization = SmpiPrivStrategies::NONE;
+ else if (smpi_privatize_option == "yes" || smpi_privatize_option == "1")
+ _smpi_cfg_privatization = SmpiPrivStrategies::DEFAULT;
+ else if (smpi_privatize_option == "mmap")
+ _smpi_cfg_privatization = SmpiPrivStrategies::MMAP;
+ else if (smpi_privatize_option == "dlopen")
+ _smpi_cfg_privatization = SmpiPrivStrategies::DLOPEN;
+ else
+ xbt_die("Invalid value for smpi/privatization: '%s'", smpi_privatize_option.c_str());
+
+ if (not SMPI_switch_data_segment) {
+ XBT_DEBUG("Running without smpi_main(); disable smpi/privatization.");
+ _smpi_cfg_privatization = SmpiPrivStrategies::NONE;
+ }
+ if (not HAVE_WORKING_MMAP && _smpi_cfg_privatization == SmpiPrivStrategies::MMAP) {
+ XBT_INFO("mmap privatization is broken on this platform, switching to dlopen privatization instead.");
+ _smpi_cfg_privatization = SmpiPrivStrategies::DLOPEN;
+ }
+ });
+
+ simgrid::config::declare_flag<std::string>("smpi/privatize-libs",
+ "Add libraries (; separated) to privatize (libgfortran for example)."
+ "You need to provide the full names of the files (libgfortran.so.4), or its full path",
+ "");
+ simgrid::config::declare_flag<double>("smpi/shared-malloc-blocksize",
+ "Size of the bogus file which will be created for global shared allocations",
+ 1UL << 20);
+ simgrid::config::declare_flag<std::string>("smpi/shared-malloc-hugepage",
+ "Path to a mounted hugetlbfs, to use huge pages with shared malloc.",
+ "");
+
+ simgrid::config::declare_flag<std::string>(
+ "smpi/os", "Small messages timings (MPI_Send minimum time for small messages)", "0:0:0:0:0");
+ simgrid::config::declare_flag<std::string>(
+ "smpi/ois", "Small messages timings (MPI_Isend minimum time for small messages)", "0:0:0:0:0");
+ simgrid::config::declare_flag<std::string>(
+ "smpi/or", "Small messages timings (MPI_Recv minimum time for small messages)", "0:0:0:0:0");
+ simgrid::config::alias("smpi/display-timing", {"smpi/display_timing"});
+ simgrid::config::alias("smpi/coll-selector", {"smpi/coll_selector"});
+ simgrid::config::alias("smpi/simulate-computation", {"smpi/simulate_computation"});
+ simgrid::config::alias("smpi/shared-malloc", {"smpi/use_shared_malloc", "smpi/use-shared-malloc"});
+ simgrid::config::alias("smpi/host-speed", {"smpi/running_power", "smpi/running-power"});
+ simgrid::config::alias("smpi/cpu-threshold", {"smpi/cpu_threshold"});
+ simgrid::config::alias("smpi/async-small-thresh", {"smpi/async_small_thres", "smpi/async_small_thresh"});
+ simgrid::config::alias("smpi/send-is-detached-thresh", {"smpi/send_is_detached_thres", "smpi/send_is_detached_thresh"});
+ simgrid::config::alias("smpi/privatization", {"smpi/privatize_global_variables", "smpi/privatize-global-variables"});
+ simgrid::config::alias("smpi/reduce_scatter", {"smpi/reduce-scatter"});
+ _smpi_options_initialized=true;
+}
+
+void smpi_check_options()
+{
+#if SIMGRID_HAVE_MC
+ if (MC_is_active()) {
+ if (_sg_mc_buffering == "zero")
+ simgrid::config::set_value<int>("smpi/send-is-detached-thresh", 0);
+ else if (_sg_mc_buffering == "infty")
+ simgrid::config::set_value<int>("smpi/send-is-detached-thresh", INT_MAX);
+ else
+ THROW_IMPOSSIBLE;
+ }
+#endif
+
+ xbt_assert(smpi_cfg_async_small_thresh() <= smpi_cfg_detached_send_thresh(),
+ "smpi/async-small-thresh (=%d) should be smaller or equal to smpi/send-is-detached-thresh (=%d)",
+ smpi_cfg_async_small_thresh(),
+ smpi_cfg_detached_send_thresh());
+
+ if (simgrid::config::is_default("smpi/host-speed") && not MC_is_active()) {
+ XBT_INFO("You did not set the power of the host running the simulation. "
+ "The timings will certainly not be accurate. "
+ "Use the option \"--cfg=smpi/host-speed:<flops>\" to set its value. "
+ "Check "
+ "https://simgrid.org/doc/latest/Configuring_SimGrid.html#automatic-benchmarking-of-smpi-code for more "
+ "information.");
+ }
+
+ simgrid::smpi::colls::set_collectives();
+ simgrid::smpi::colls::smpi_coll_cleanup_callback = nullptr;
+}
+
-/* 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. */
#include "smpi_coll.hpp"
#include "smpi_f2c.hpp"
#include "smpi_host.hpp"
+#include "smpi_config.hpp"
#include "src/kernel/activity/CommImpl.hpp"
#include "src/simix/smx_private.hpp"
#include "src/smpi/include/smpi_actor.hpp"
#include "xbt/config.hpp"
#include <algorithm>
-#include <boost/algorithm/string.hpp> /* trim_right / trim_left */
+#include <boost/algorithm/string.hpp> /* split */
#include <boost/tokenizer.hpp>
-#include <cfloat> /* DBL_MAX */
#include <cinttypes>
#include <cstdint> /* intmax_t */
#include <dlfcn.h>
#include <fstream>
#include <sys/stat.h>
-#if SIMGRID_HAVE_MC
-#include "src/mc/mc_config.hpp"
-#endif
-
#if SG_HAVE_SENDFILE
#include <sys/sendfile.h>
#endif
#include <link.h>
#endif
-#if defined(__APPLE__)
-# include <AvailabilityMacros.h>
-# ifndef MAC_OS_X_VERSION_10_12
-# define MAC_OS_X_VERSION_10_12 101200
-# endif
-constexpr bool HAVE_WORKING_MMAP = (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12);
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__sun) || defined(__HAIKU__)
-constexpr bool HAVE_WORKING_MMAP = false;
-#else
-constexpr bool HAVE_WORKING_MMAP = true;
-#endif
-
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_kernel, smpi, "Logging specific to SMPI (kernel)");
#if SMPI_IFORT
static void (*saved_callback)(smx_activity_t, void*, size_t);
saved_callback = callback;
smpi_comm_copy_data_callback = [](simgrid::kernel::activity::CommImpl* comm, void* buff, size_t size) {
- saved_callback(smx_activity_t(comm), buff, size);
+ saved_callback(comm, buff, size);
};
}
-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.");
}
XBT_DEBUG("Copy the data over");
if(smpi_is_shared(buff, src_private_blocks, &src_offset)) {
src_private_blocks = shift_and_frame_private_blocks(src_private_blocks, src_offset, buff_size);
- if (src_private_blocks.size()==1 && (src_private_blocks[0].second - src_private_blocks[0].first)==buff_size){//simple shared malloc ... return.
- XBT_DEBUG("Sender %p is shared. Let's ignore it.", buff);
+ if (src_private_blocks.size()==0){//simple shared malloc ... return.
+ XBT_VERB("Sender is shared. Let's ignore it.");
smpi_cleanup_comm_after_copy(comm, buff);
return;
}
}
if (smpi_is_shared((char*)comm->dst_buff_, dst_private_blocks, &dst_offset)) {
dst_private_blocks = shift_and_frame_private_blocks(dst_private_blocks, dst_offset, buff_size);
- if (src_private_blocks.size()==1 && (src_private_blocks[0].second - src_private_blocks[0].first)==buff_size){//simple shared malloc ... return.
- XBT_DEBUG("Receiver %p is shared. Let's ignore it.", (char*)comm->dst_buff_);
+ if (dst_private_blocks.size()==0){//simple shared malloc ... return.
+ XBT_VERB("Receiver is shared. Let's ignore it.");
smpi_cleanup_comm_after_copy(comm, buff);
return;
}
auto private_blocks = merge_private_blocks(src_private_blocks, dst_private_blocks);
check_blocks(private_blocks, buff_size);
void* tmpbuff=buff;
- if ((smpi_privatize_global_variables == SmpiPrivStrategies::MMAP) &&
+ if ((smpi_cfg_privatization() == SmpiPrivStrategies::MMAP) &&
(static_cast<char*>(buff) >= smpi_data_exe_start) &&
(static_cast<char*>(buff) < smpi_data_exe_start + smpi_data_exe_size)) {
XBT_DEBUG("Privatization : We are copying from a zone inside global memory... Saving data to temp buffer !");
memcpy_private(tmpbuff, buff, private_blocks);
}
- if ((smpi_privatize_global_variables == SmpiPrivStrategies::MMAP) &&
+ if ((smpi_cfg_privatization() == SmpiPrivStrategies::MMAP) &&
((char*)comm->dst_buff_ >= smpi_data_exe_start) &&
((char*)comm->dst_buff_ < smpi_data_exe_start + smpi_data_exe_size)) {
XBT_DEBUG("Privatization : We are copying to a zone inside global memory - Switch data segment");
/* nothing done in this version */
}
-static void smpi_check_options()
-{
-#if SIMGRID_HAVE_MC
- if (MC_is_active()) {
- if (_sg_mc_buffering == "zero")
- simgrid::config::set_value<int>("smpi/send-is-detached-thresh", 0);
- else if (_sg_mc_buffering == "infty")
- simgrid::config::set_value<int>("smpi/send-is-detached-thresh", INT_MAX);
- else
- THROW_IMPOSSIBLE;
- }
-#endif
-
- xbt_assert(simgrid::config::get_value<int>("smpi/async-small-thresh") <=
- simgrid::config::get_value<int>("smpi/send-is-detached-thresh"),
- "smpi/async-small-thresh (=%d) should be smaller or equal to smpi/send-is-detached-thresh (=%d)",
- simgrid::config::get_value<int>("smpi/async-small-thresh"),
- simgrid::config::get_value<int>("smpi/send-is-detached-thresh"));
-
- if (simgrid::config::is_default("smpi/host-speed") && not MC_is_active()) {
- XBT_INFO("You did not set the power of the host running the simulation. "
- "The timings will certainly not be accurate. "
- "Use the option \"--cfg=smpi/host-speed:<flops>\" to set its value. "
- "Check "
- "https://simgrid.org/doc/latest/Configuring_SimGrid.html#automatic-benchmarking-of-smpi-code for more "
- "information.");
- }
-
- xbt_assert(simgrid::config::get_value<double>("smpi/cpu-threshold") >= 0,
- "The 'smpi/cpu-threshold' option cannot have negative values [anymore]. If you want to discard "
- "the simulation of any computation, please use 'smpi/simulate-computation:no' instead.");
-}
-
int smpi_enabled() {
return MPI_COMM_WORLD != MPI_COMM_UNINITIALIZED;
}
// the configuration as given by the user (counter data as a pair of (counter_name, counter_counter))
// and the (computed) event_set.
- if (not simgrid::config::get_value<std::string>("smpi/papi-events").empty()) {
+ if (not smpi_cfg_papi_events_file().empty()) {
if (PAPI_library_init(PAPI_VER_CURRENT) != PAPI_VER_CURRENT)
XBT_ERROR("Could not initialize PAPI library; is it correctly installed and linked?"
" Expected version is %u", PAPI_VER_CURRENT);
typedef boost::tokenizer<boost::char_separator<char>> Tokenizer;
boost::char_separator<char> separator_units(";");
- std::string str = simgrid::config::get_value<std::string>("smpi/papi-events");
+ std::string str = smpi_cfg_papi_events_file();
Tokenizer tokens(str, separator_units);
// Iterate over all the computational units. This could be processes, hosts, threads, ranks... You name it.
}
// NOTE: We cannot use a map here, as we must obey the order of the counters
- // This is important for PAPI: We need to map the values of counters back
- // to the event_names (so, when PAPI_read() has finished)!
+ // This is important for PAPI: We need to map the values of counters back to the event_names (so, when PAPI_read()
+ // has finished)!
papi_counter_t counters2values;
- // Iterate over all counters that were specified for this specific
- // unit.
- // Note that we need to remove the name of the unit
- // (that could also be the "default" value), which always comes first.
- // Hence, we start at ++(events.begin())!
+ // Iterate over all counters that were specified for this specific unit.
+ // Note that we need to remove the name of the unit (that could also be the "default" value), which always comes
+ // first. Hence, we start at ++(events.begin())!
for (Tokenizer::iterator events_it = ++(event_tokens.begin()); events_it != event_tokens.end(); ++events_it) {
-
int event_code = PAPI_NULL;
char* event_name = const_cast<char*>((*events_it).c_str());
if (PAPI_event_name_to_code(event_name, &event_code) != PAPI_OK) {
counters2values.push_back(
// We cannot just pass *events_it, as this is of type const basic_string
- std::make_pair<std::string, long long>(std::string(*events_it), 0));
+ std::make_pair(std::string(*events_it), 0LL));
}
std::string unit_name = *(event_tokens.begin());
#endif
}
-static void smpi_init_options(){
- // return if already called
- if (smpi_cpu_threshold > -1)
- return;
- simgrid::smpi::colls::set_collectives();
- simgrid::smpi::colls::smpi_coll_cleanup_callback = nullptr;
- smpi_cpu_threshold = simgrid::config::get_value<double>("smpi/cpu-threshold");
- if (smpi_cpu_threshold < 0)
- smpi_cpu_threshold = DBL_MAX;
-
- smpi_host_speed = simgrid::config::get_value<double>("smpi/host-speed");
- std::string smpi_privatize_option = simgrid::config::get_value<std::string>("smpi/privatization");
- if (smpi_privatize_option == "no" || smpi_privatize_option == "0")
- smpi_privatize_global_variables = SmpiPrivStrategies::NONE;
- else if (smpi_privatize_option == "yes" || smpi_privatize_option == "1")
- smpi_privatize_global_variables = SmpiPrivStrategies::DEFAULT;
- else if (smpi_privatize_option == "mmap")
- smpi_privatize_global_variables = SmpiPrivStrategies::MMAP;
- else if (smpi_privatize_option == "dlopen")
- smpi_privatize_global_variables = SmpiPrivStrategies::DLOPEN;
- else
- xbt_die("Invalid value for smpi/privatization: '%s'", smpi_privatize_option.c_str());
-
- if (not SMPI_switch_data_segment) {
- XBT_DEBUG("Running without smpi_main(); disable smpi/privatization.");
- smpi_privatize_global_variables = SmpiPrivStrategies::NONE;
- }
- if (not HAVE_WORKING_MMAP && smpi_privatize_global_variables == SmpiPrivStrategies::MMAP) {
- XBT_INFO("mmap privatization is broken on this platform, switching to dlopen privatization instead.");
- smpi_privatize_global_variables = SmpiPrivStrategies::DLOPEN;
- }
- std::string val = simgrid::config::get_value<std::string>("smpi/shared-malloc");
- if ((val == "yes") || (val == "1") || (val == "on") || (val == "global")) {
- smpi_cfg_shared_malloc = SharedMallocType::GLOBAL;
- } else if (val == "local") {
- smpi_cfg_shared_malloc = SharedMallocType::LOCAL;
- } else if ((val == "no") || (val == "0") || (val == "off")) {
- smpi_cfg_shared_malloc = SharedMallocType::NONE;
- } else {
- xbt_die("Invalid value '%s' for option smpi/shared-malloc. Possible values: 'on' or 'global', 'local', 'off'",
- val.c_str());
- }
-}
typedef std::function<int(int argc, char *argv[])> smpi_entry_point_type;
typedef int (* smpi_c_entry_point_type)(int argc, char **argv);
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) {
}
}
- simix_global->default_function = [executable, fdin_size](std::vector<std::string> args) {
+ simgrid::s4u::Engine::get_instance()->register_default([executable, fdin_size](std::vector<std::string> args) {
return std::function<void()>([executable, fdin_size, args] {
static std::size_t rank = 0;
// Copy the dynamic library:
xbt_assert(entry_point, "Could not resolve entry point");
smpi_run_entry_point(entry_point, executable, args);
});
- };
+ });
}
static void smpi_init_privatization_no_dlopen(const std::string& executable)
{
- if (smpi_privatize_global_variables == SmpiPrivStrategies::MMAP)
+ if (smpi_cfg_privatization() == SmpiPrivStrategies::MMAP)
smpi_prepare_global_memory_segment();
// Load the dynamic library and resolve the entry point:
smpi_entry_point_type entry_point = smpi_resolve_function(handle);
xbt_assert(entry_point, "main not found in %s", executable.c_str());
- if (smpi_privatize_global_variables == SmpiPrivStrategies::MMAP)
+ if (smpi_cfg_privatization() == SmpiPrivStrategies::MMAP)
smpi_backup_global_memory_segment();
// Execute the same entry point for each simulated process:
- simix_global->default_function = [entry_point, executable](std::vector<std::string> args) {
+ simgrid::s4u::Engine::get_instance()->register_default([entry_point, executable](std::vector<std::string> args) {
return std::function<void()>(
[entry_point, executable, args] { smpi_run_entry_point(entry_point, executable, args); });
- };
+ });
}
int smpi_main(const char* executable, int argc, char* argv[])
* configuration tools */
return 0;
}
-
+
+ SMPI_switch_data_segment = &smpi_switch_data_segment;
+ smpi_init_options();
TRACE_global_init();
SIMIX_global_init(&argc, argv);
auto engine = simgrid::s4u::Engine::get_instance();
- SMPI_switch_data_segment = &smpi_switch_data_segment;
+
sg_storage_file_system_init();
// parse the platform file: get the host list
engine->load_platform(argv[1]);
SIMIX_comm_set_copy_data_callback(smpi_comm_copy_buffer_callback);
- smpi_init_options();
- if (smpi_privatize_global_variables == SmpiPrivStrategies::DLOPEN)
+ if (smpi_cfg_privatization() == SmpiPrivStrategies::DLOPEN)
smpi_init_privatization_dlopen(executable);
else
smpi_init_privatization_no_dlopen(executable);
+ simgrid::smpi::colls::set_collectives();
+ simgrid::smpi::colls::smpi_coll_cleanup_callback = nullptr;
+
SMPI_init();
/* 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++;
});
if (MC_is_active()) {
MC_run();
} else {
-
SIMIX_run();
xbt_os_walltimer_stop(global_timer);
// Called either directly from the user code, or from the code called by smpirun
void SMPI_init(){
+ smpi_init_options();
simgrid::s4u::Actor::on_creation.connect([](simgrid::s4u::Actor& actor) {
if (not actor.is_daemon())
actor.extension_set<simgrid::smpi::ActorExt>(new simgrid::smpi::ActorExt(&actor));
for (auto const& host : simgrid::s4u::Engine::get_instance()->get_all_hosts())
host->extension_set(new simgrid::smpi::Host(host));
- smpi_init_options();
if (not MC_is_active()) {
global_timer = xbt_os_timer_new();
xbt_os_walltimer_start(global_timer);
}
-
- std::string filename = simgrid::config::get_value<std::string>("smpi/comp-adjustment-file");
- if (not filename.empty()) {
- std::ifstream fstream(filename);
- xbt_assert(fstream.is_open(), "Could not open file %s. Does it exist?", filename.c_str());
-
- std::string line;
- typedef boost::tokenizer<boost::escaped_list_separator<char>> Tokenizer;
- std::getline(fstream, line); // Skip the header line
- while (std::getline(fstream, line)) {
- Tokenizer tok(line);
- Tokenizer::iterator it = tok.begin();
- Tokenizer::iterator end = std::next(tok.begin());
-
- std::string location = *it;
- boost::trim(location);
- location2speedup.insert(std::pair<std::string, double>(location, std::stod(*end)));
- }
- }
smpi_init_papi();
smpi_check_options();
}
xbt_os_timer_free(global_timer);
}
- if (smpi_privatize_global_variables == SmpiPrivStrategies::MMAP)
+ if (smpi_cfg_privatization() == SmpiPrivStrategies::MMAP)
smpi_destroy_global_memory_segments();
if (simgrid::smpi::F2C::lookup() != nullptr)
simgrid::smpi::F2C::delete_lookup();
-/* 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) {
#define asan_safe_memcpy(dest, src, n) memcpy((dest), (src), (n))
#endif
+/**
+ * @brief Uses shm_open to get a temporary shm, and returns its file descriptor.
+ */
+int smpi_temp_shm_get()
+{
+ constexpr unsigned VAL_MASK = 0xffffffffUL;
+ static unsigned prev_val = VAL_MASK;
+ char shmname[32]; // cannot be longer than PSHMNAMLEN = 31 on macOS (shm_open raises ENAMETOOLONG otherwise)
+ int fd;
+
+ for (unsigned i = (prev_val + 1) & VAL_MASK; i != prev_val; i = (i + 1) & VAL_MASK) {
+ snprintf(shmname, sizeof(shmname), "/smpi-buffer-%016x", i);
+ fd = shm_open(shmname, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
+ if (fd != -1 || errno != EEXIST) {
+ prev_val = i;
+ break;
+ }
+ }
+ if (fd < 0) {
+ if (errno == EMFILE) {
+ xbt_die("Impossible to create temporary file for memory mapping: %s\n\
+The shm_open() system call failed with the EMFILE error code (too many files). \n\n\
+This means that you reached the system limits concerning the amount of files per process. \
+This is not a surprise if you are trying to virtualize many processes on top of SMPI. \
+Don't panic -- you should simply increase your system limits and try again. \n\n\
+First, check what your limits are:\n\
+ cat /proc/sys/fs/file-max # Gives you the system-wide limit\n\
+ ulimit -Hn # Gives you the per process hard limit\n\
+ ulimit -Sn # Gives you the per process soft limit\n\
+ cat /proc/self/limits # Displays any per-process limitation (including the one given above)\n\n\
+If one of these values is less than the amount of MPI processes that you try to run, then you got the explanation of this error. \
+Ask the Internet about tutorials on how to increase the files limit such as: https://rtcamp.com/tutorials/linux/increase-open-files-limit/",
+ strerror(errno));
+ }
+ xbt_die("Impossible to create temporary file for memory mapping. shm_open: %s", strerror(errno));
+ }
+ XBT_DEBUG("Got temporary shm %s (fd = %d)", shmname, fd);
+ if (shm_unlink(shmname) < 0)
+ XBT_WARN("Could not early unlink %s. shm_unlink: %s", shmname, strerror(errno));
+ return fd;
+}
+
+/**
+ * @brief Mmap a region of size bytes from temporary shm with file descriptor fd.
+ */
+void* smpi_temp_shm_mmap(int fd, size_t size)
+{
+ struct stat st;
+ if (fstat(fd, &st) != 0)
+ xbt_die("Could not stat fd %d: %s", fd, strerror(errno));
+ if (static_cast<off_t>(size) > st.st_size && ftruncate(fd, static_cast<off_t>(size)) != 0)
+ xbt_die("Could not truncate fd %d to %zu: %s", fd, size, strerror(errno));
+ void* mem = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (mem == MAP_FAILED) {
+ xbt_die("Failed to map fd %d with size %zu: %s\n"
+ "If you are running a lot of ranks, you may be exceeding the amount of mappings allowed per process.\n"
+ "On Linux systems, change this value with sudo sysctl -w vm.max_map_count=newvalue (default value: 65536)\n"
+ "Please see "
+ "https://simgrid.org/doc/latest/Configuring_SimGrid.html#configuring-the-user-code-virtualization for more "
+ "information.",
+ fd, size, strerror(errno));
+ }
+ return mem;
+}
+
/** Map a given SMPI privatization segment (make a SMPI process active)
*
* When doing a state restoration, the state of the restored variables might not be consistent with the state of the
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();
// Initializes the memory mapping for a single process and returns the privatization region
smpi_privatization_region_t smpi_init_global_memory_segment_process()
{
- int file_descriptor;
- void* address = nullptr;
- char path[24];
- int status;
-
- constexpr unsigned VAL_MASK = 0xffffffU;
- static unsigned prev_val = VAL_MASK;
- for (unsigned i = (prev_val + 1) & VAL_MASK; i != prev_val; i = (i + 1) & VAL_MASK) {
- snprintf(path, sizeof(path), "/smpi-buffer-%06x", i);
- file_descriptor = shm_open(path, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
- if (file_descriptor != -1 || errno != EEXIST) {
- prev_val = i;
- break;
- }
- }
- if (file_descriptor < 0) {
- if (errno == EMFILE) {
- xbt_die("Impossible to create temporary file for memory mapping: %s\n\
-The open() system call failed with the EMFILE error code (too many files). \n\n\
-This means that you reached the system limits concerning the amount of files per process. \
-This is not a surprise if you are trying to virtualize many processes on top of SMPI. \
-Don't panic -- you should simply increase your system limits and try again. \n\n\
-First, check what your limits are:\n\
- cat /proc/sys/fs/file-max # Gives you the system-wide limit\n\
- ulimit -Hn # Gives you the per process hard limit\n\
- ulimit -Sn # Gives you the per process soft limit\n\
- cat /proc/self/limits # Displays any per-process limitation (including the one given above)\n\n\
-If one of these values is less than the amount of MPI processes that you try to run, then you got the explanation of this error. \
-Ask the Internet about tutorials on how to increase the files limit such as: https://rtcamp.com/tutorials/linux/increase-open-files-limit/",
- strerror(errno));
- }
- xbt_die("Impossible to create temporary file for memory mapping: %s", strerror(errno));
- }
-
- status = ftruncate(file_descriptor, smpi_data_exe_size);
- if (status)
- xbt_die("Impossible to set the size of the temporary file for memory mapping");
-
- /* Ask for a free region */
- address = mmap(nullptr, smpi_data_exe_size, PROT_RW, MAP_SHARED, file_descriptor, 0);
- if (address == MAP_FAILED)
- xbt_die("Couldn't find a free region for memory mapping");
+ int file_descriptor = smpi_temp_shm_get();
- status = shm_unlink(path);
- if (status)
- xbt_die("Impossible to unlink temporary file for memory mapping");
+ // ask for a free region
+ void* address = smpi_temp_shm_mmap(file_descriptor, smpi_data_exe_size);
// initialize the values
asan_safe_memcpy(address, smpi_data_exe_copy, smpi_data_exe_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. */
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&)
{
- if (simgrid::config::get_value<bool>("smpi/simulate-computation")) {
+ 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. */
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_shared, smpi, "Logging specific to SMPI (shared memory macros)");
-#define PTR_STRLEN (2 + 2 * sizeof(void*) + 1)
-
namespace{
/** Some location in the source code
*
calls.clear();
}
-static size_t shm_size(int fd) {
- struct stat st;
-
- if(fstat(fd, &st) < 0) {
- xbt_die("Could not stat fd %d: %s", fd, strerror(errno));
- }
- return static_cast<size_t>(st.st_size);
-}
-
#ifndef WIN32
-static void* shm_map(int fd, size_t size, shared_data_key_type* data) {
- char loc[PTR_STRLEN];
+static void* shm_map(int fd, size_t size, shared_data_key_type* data)
+{
+ void* mem = smpi_temp_shm_mmap(fd, size);
shared_metadata_t meta;
-
- if(size > shm_size(fd) && (ftruncate(fd, static_cast<off_t>(size)) < 0)) {
- xbt_die("Could not truncate fd %d to %zu: %s", fd, size, strerror(errno));
- }
-
- void* mem = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
- if(mem == MAP_FAILED) {
- xbt_die("Failed to map fd %d with size %zu: %s\n"
- "If you are running a lot of ranks, you may be exceeding the amount of mappings allowed per process.\n"
- "On Linux systems, change this value with sudo sysctl -w vm.max_map_count=newvalue (default value: 65536)\n"
- "Please see "
- "https://simgrid.org/doc/latest/Configuring_SimGrid.html#configuring-the-user-code-virtualization for more "
- "information.",
- fd, size, strerror(errno));
- }
- snprintf(loc, PTR_STRLEN, "%p", mem);
meta.size = size;
meta.data = data;
meta.allocated_ptr = mem;
auto data = res.first;
if (res.second) {
// The new element was inserted.
- // Generate a shared memory name from the address of the shared_data:
- char shmname[32]; // cannot be longer than PSHMNAMLEN = 31 on macOS (shm_open raises ENAMETOOLONG otherwise)
- snprintf(shmname, 31, "/shmalloc%p", &*data);
- int fd = shm_open(shmname, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
- if (fd < 0) {
- if (errno == EEXIST)
- xbt_die("Please cleanup /dev/shm/%s", shmname);
- else
- xbt_die("An unhandled error occurred while opening %s. shm_open: %s", shmname, strerror(errno));
- }
- data->second.fd = fd;
+ int fd = smpi_temp_shm_get();
+ data->second.fd = fd;
data->second.count = 1;
mem = shm_map(fd, size, &*data);
- if (shm_unlink(shmname) < 0) {
- XBT_WARN("Could not early unlink %s. shm_unlink: %s", shmname, strerror(errno));
- }
- XBT_DEBUG("Mapping %s at %p through %d", shmname, mem, fd);
} else {
mem = shm_map(data->second.fd, size, &*data);
data->second.count++;
}
- XBT_DEBUG("Shared malloc %zu in %p (metadata at %p)", size, mem, &*data);
+ XBT_DEBUG("Shared malloc %zu in %p through %d (metadata at %p)", size, mem, data->second.fd, &*data);
return mem;
}
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",
return mem;
}
-
-void *smpi_shared_malloc_intercept(size_t size, const char *file, int line) {
- if( simgrid::config::get_value<double>("smpi/auto-shared-malloc-thresh") == 0 || size < simgrid::config::get_value<double>("smpi/auto-shared-malloc-thresh"))
+void* smpi_shared_malloc_intercept(size_t size, const char* file, int line)
+{
+ if( smpi_cfg_auto_shared_malloc_thresh() == 0 || size < smpi_cfg_auto_shared_malloc_thresh())
return ::operator new(size);
else
return smpi_shared_malloc(size, file, line);
}
-void* smpi_shared_calloc_intercept(size_t num_elm, size_t elem_size, const char* file, int line){
- if( simgrid::config::get_value<double>("smpi/auto-shared-malloc-thresh") == 0 || elem_size*num_elm < simgrid::config::get_value<double>("smpi/auto-shared-malloc-thresh")){
+void* smpi_shared_calloc_intercept(size_t num_elm, size_t elem_size, const char* file, int line)
+{
+ if( smpi_cfg_auto_shared_malloc_thresh() == 0 || elem_size*num_elm < smpi_cfg_auto_shared_malloc_thresh()){
void* ptr = ::operator new(elem_size*num_elm);
memset(ptr, 0, elem_size*num_elm);
return ptr;
} else
return smpi_shared_malloc(elem_size*num_elm, file, line);
-
}
-void *smpi_shared_malloc(size_t size, const char *file, int line) {
- if (size > 0 && smpi_cfg_shared_malloc == SharedMallocType::LOCAL) {
+void* smpi_shared_malloc(size_t size, const char* file, int line)
+{
+ if (size > 0 && smpi_cfg_shared_malloc() == SharedMallocType::LOCAL) {
return smpi_shared_malloc_local(size, file, line);
- } else if (smpi_cfg_shared_malloc == SharedMallocType::GLOBAL) {
+ } else if (smpi_cfg_shared_malloc() == SharedMallocType::GLOBAL) {
int nb_shared_blocks = 1;
size_t shared_block_offsets[2] = {0, size};
return smpi_shared_malloc_partial(size, shared_block_offsets, nb_shared_blocks);
private_blocks.clear(); // being paranoid
if (allocs_metadata.empty())
return 0;
- if (smpi_cfg_shared_malloc == SharedMallocType::LOCAL || smpi_cfg_shared_malloc == SharedMallocType::GLOBAL) {
+ if (smpi_cfg_shared_malloc() == SharedMallocType::LOCAL || smpi_cfg_shared_malloc() == SharedMallocType::GLOBAL) {
auto low = allocs_metadata.lower_bound(ptr);
if (low != allocs_metadata.end() && low->first == ptr) {
private_blocks = low->second.private_blocks;
void smpi_shared_free(void *ptr)
{
- if (smpi_cfg_shared_malloc == SharedMallocType::LOCAL) {
- char loc[PTR_STRLEN];
- snprintf(loc, PTR_STRLEN, "%p", ptr);
+ if (smpi_cfg_shared_malloc() == SharedMallocType::LOCAL) {
auto meta = allocs_metadata.find(ptr);
if (meta == allocs_metadata.end()) {
::operator delete(ptr);
XBT_DEBUG("Shared free - Local - no removal - of %p, count = %d", ptr, data->count);
}
- } else if (smpi_cfg_shared_malloc == SharedMallocType::GLOBAL) {
+ } else if (smpi_cfg_shared_malloc() == SharedMallocType::GLOBAL) {
auto meta = allocs_metadata.find(ptr);
if (meta != allocs_metadata.end()){
meta->second.data->second.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);
}
int Comm::dup(MPI_Comm* newcomm){
- if (smpi_privatize_global_variables == SmpiPrivStrategies::MMAP) {
+ if (smpi_cfg_privatization() == SmpiPrivStrategies::MMAP) {
// we need to switch as the called function may silently touch global variables
smpi_switch_data_segment(s4u::Actor::self());
}
(*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;
}
}
smpi_process()->set_replaying(false);
}
- if (smpi_privatize_global_variables == SmpiPrivStrategies::MMAP) {
+ if (smpi_cfg_privatization() == SmpiPrivStrategies::MMAP) {
// we need to switch as the called function may silently touch global variables
smpi_switch_data_segment(s4u::Actor::self());
}
allgather__ring(&leader, 1, MPI_INT , leaders_map, 1, MPI_INT, this);
- if (smpi_privatize_global_variables == SmpiPrivStrategies::MMAP) {
+ if (smpi_cfg_privatization() == SmpiPrivStrategies::MMAP) {
// we need to switch as the called function may silently touch global variables
smpi_switch_data_segment(s4u::Actor::self());
}
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);
}
bcast__scatter_LR_allgather(&(is_uniform_),1, MPI_INT, 0, comm_intra );
- if (smpi_privatize_global_variables == SmpiPrivStrategies::MMAP) {
+ if (smpi_cfg_privatization() == SmpiPrivStrategies::MMAP) {
// we need to switch as the called function may silently touch global variables
smpi_switch_data_segment(s4u::Actor::self());
}
}
}
-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;
}
}
-Datatype::~Datatype(){
+Datatype::~Datatype()
+{
xbt_assert(refcount_ >= 0);
if(flags_ & DT_FLAG_PREDEFINED)
xbt_free(name_);
}
-void Datatype::ref(){
-
+void Datatype::ref()
+{
refcount_++;
#if SIMGRID_HAVE_MC
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;
return MPI_SUCCESS;
}
-int Datatype::copy(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
- void *recvbuf, int recvcount, MPI_Datatype recvtype){
-
-// FIXME Handle the case of a partial shared malloc.
+int Datatype::copy(const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount,
+ MPI_Datatype recvtype)
+{
+ // FIXME Handle the case of a partial shared malloc.
- if (smpi_privatize_global_variables == SmpiPrivStrategies::MMAP) {
+ if (smpi_cfg_privatization() == SmpiPrivStrategies::MMAP) {
smpi_switch_data_segment(simgrid::s4u::Actor::self());
}
/* First check if we really have something to do */
if(smpi_is_shared(sendbuf,private_blocks,&offset)
&& (private_blocks.size()==1
&& (private_blocks[0].second - private_blocks[0].first)==(unsigned long)(sendcount * sendtype->get_extent()))){
+ XBT_VERB("sendbuf is shared. Ignoring copies");
return 0;
}
if(smpi_is_shared(recvbuf,private_blocks,&offset)
&& (private_blocks.size()==1
&& (private_blocks[0].second - private_blocks[0].first)==(unsigned long)(recvcount * recvtype->get_extent()))){
+ XBT_VERB("recvbuf is shared. Ignoring copies");
return 0;
}
recvtype->unserialize(sendbuf, recvbuf, count / recvtype->size(), MPI_REPLACE);
} else if (not(recvtype->flags() & DT_FLAG_DERIVED)) {
sendtype->serialize(sendbuf, recvbuf, count / sendtype->size());
- }else{
-
+ } else {
void * buf_tmp = xbt_malloc(count);
sendtype->serialize( sendbuf, buf_tmp,count/sendtype->size());
return MPI_SUCCESS;
}
-Datatype* Datatype::f2c(int id){
+Datatype* Datatype::f2c(int id)
+{
return static_cast<Datatype*>(F2C::f2c(id));
}
-
-
-}
-}
-
+} // namespace smpi
+} // namespace simgrid
/* 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. */
#include "smpi_file.hpp"
#include "smpi_status.hpp"
+#include "simgrid/s4u/Disk.hpp"
+#include "simgrid/s4u/Host.hpp"
#include "simgrid/plugins/file_system.h"
#define FP_SIZE sizeof(MPI_Offset)
namespace smpi{
File::File(MPI_Comm comm, const char *filename, int amode, MPI_Info info): comm_(comm), flags_(amode), info_(info) {
- file_= new simgrid::s4u::File(filename, nullptr);
+ 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");
+
+ size_t found=fullname.find('/');
+ //in case no fullpath is provided ... just pick the first mountpoint.
+ if(found==std::string::npos){
+ auto disk = simgrid::s4u::Host::current()->get_disks().front();
+ std::string mount;
+ if (disk->get_host() != simgrid::s4u::Host::current())
+ mount = disk->extension<simgrid::s4u::FileSystemDiskExt>()->get_mount_point(disk->get_host());
+ else
+ mount = disk->extension<simgrid::s4u::FileSystemDiskExt>()->get_mount_point();
+ XBT_DEBUG("No absolute path given for file opening, use '%s'", mount.c_str());
+ mount.append("/");
+ fullname.insert(0, mount);
+ }
+
+ file_= new simgrid::s4u::File(fullname, nullptr);
list_=nullptr;
if (comm_->rank() == 0) {
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);
fh->file_->seek(position+movesize, SEEK_SET);
}
XBT_VERB("Position after read in MPI_File %s : %llu",fh->file_->get_path(), fh->file_->tell());
- status->count=count*datatype->size();
+ if(status != MPI_STATUS_IGNORE)
+ status->count=count*datatype->size();
return MPI_SUCCESS;
}
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);
}
XBT_VERB("Position after write in MPI_File %s : %llu",fh->file_->get_path(), fh->file_->tell());
- status->count=count*datatype->size();
+ if(status != MPI_STATUS_IGNORE)
+ status->count=count*datatype->size();
return MPI_SUCCESS;
}
return ret;
}
+ 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);
+ seek_shared(0,MPI_SEEK_SET);
+ return MPI_SUCCESS;
+ }
+
+ 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 MPI_SUCCESS;
+ }
+
int File::size(){
return file_->size();
}
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. */
}
delete[] to_exclude;
return MPI_SUCCESS;
-
}
static bool is_rank_in_range(int rank, int first, int last)
-/* 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. */
void Op::apply(const void* invec, void* inoutvec, const int* len, MPI_Datatype datatype)
{
- if (smpi_privatize_global_variables == SmpiPrivStrategies::MMAP) {
+ if (smpi_cfg_privatization() == SmpiPrivStrategies::MMAP) {
// we need to switch as the called function may silently touch global variables
XBT_DEBUG("Applying operation, switch to the right data frame ");
smpi_switch_data_segment(simgrid::s4u::Actor::self());
-/* 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)
message, this, buf_, size_, src_, dst_, tag_, flags_);
}
-
/* factories, to hide the internal flags from the caller */
MPI_Request Request::bsend_init(const void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm)
{
-
return new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, simgrid::s4u::this_actor::get_pid(),
comm->group()->actor(dst)->get_pid(), tag, comm,
MPI_REQ_PERSISTENT | MPI_REQ_SEND | MPI_REQ_PREPARED | MPI_REQ_BSEND);
MPI_Request Request::send_init(const void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm)
{
-
return new Request(buf == MPI_BOTTOM ? nullptr : buf, count, datatype, simgrid::s4u::this_actor::get_pid(),
comm->group()->actor(dst)->get_pid(), tag, comm,
MPI_REQ_PERSISTENT | MPI_REQ_SEND | MPI_REQ_PREPARED);
simgrid::smpi::ActorExt* process = smpi_process_remote(simgrid::s4u::Actor::by_pid(dst_));
- int async_small_thresh = simgrid::config::get_value<int>("smpi/async-small-thresh");
-
simgrid::s4u::MutexPtr mut = process->mailboxes_mutex();
- if (async_small_thresh != 0 || (flags_ & MPI_REQ_RMA) != 0)
+ if (smpi_cfg_async_small_thresh() != 0 || (flags_ & MPI_REQ_RMA) != 0)
mut->lock();
- if (async_small_thresh == 0 && (flags_ & MPI_REQ_RMA) == 0) {
+ if (smpi_cfg_async_small_thresh() == 0 && (flags_ & MPI_REQ_RMA) == 0) {
mailbox = process->mailbox();
- } else if (((flags_ & MPI_REQ_RMA) != 0) || static_cast<int>(size_) < async_small_thresh) {
+ } else if (((flags_ & MPI_REQ_RMA) != 0) || static_cast<int>(size_) < smpi_cfg_async_small_thresh()) {
//We have to check both mailboxes (because SSEND messages are sent to the large mbox).
//begin with the more appropriate one : the small one.
mailbox = process->mailbox_small();
XBT_DEBUG("Is there a corresponding send already posted in the small mailbox %s (in case of SSEND)?",
mailbox->get_cname());
- smx_activity_t action = mailbox->iprobe(0, &match_recv, static_cast<void*>(this));
+ simgrid::kernel::activity::ActivityImplPtr action = mailbox->iprobe(0, &match_recv, static_cast<void*>(this));
if (action == nullptr) {
mailbox = process->mailbox();
} else {
mailbox = process->mailbox_small();
XBT_DEBUG("Is there a corresponding send already posted the small mailbox?");
- smx_activity_t action = mailbox->iprobe(0, &match_recv, static_cast<void*>(this));
+ simgrid::kernel::activity::ActivityImplPtr action = mailbox->iprobe(0, &match_recv, static_cast<void*>(this));
if (action == nullptr) {
XBT_DEBUG("No, nothing in the permanent receive mailbox");
process->replaying() ? &smpi_comm_null_copy_buffer_callback : smpi_comm_copy_data_callback, this, -1.0);
XBT_DEBUG("recv simcall posted");
- if (async_small_thresh != 0 || (flags_ & MPI_REQ_RMA) != 0)
+ if (smpi_cfg_async_small_thresh() != 0 || (flags_ & MPI_REQ_RMA) != 0)
mut->unlock();
} else { /* the RECV flag was not set, so this is a send */
simgrid::smpi::ActorExt* process = smpi_process_remote(simgrid::s4u::Actor::by_pid(dst_));
void* buf = buf_;
if ((flags_ & MPI_REQ_SSEND) == 0 &&
((flags_ & MPI_REQ_RMA) != 0 || (flags_ & MPI_REQ_BSEND) != 0 ||
- static_cast<int>(size_) < simgrid::config::get_value<int>("smpi/send-is-detached-thresh"))) {
+ static_cast<int>(size_) < smpi_cfg_detached_send_thresh())) {
void *oldbuf = nullptr;
detached_ = true;
XBT_DEBUG("Send request %p is detached", this);
if (not(old_type_->flags() & DT_FLAG_DERIVED)) {
oldbuf = buf_;
if (not process->replaying() && oldbuf != nullptr && size_ != 0) {
- if ((smpi_privatize_global_variables != SmpiPrivStrategies::NONE) &&
+ if ((smpi_cfg_privatization() != SmpiPrivStrategies::NONE) &&
(static_cast<char*>(buf_) >= smpi_data_exe_start) &&
(static_cast<char*>(buf_) < smpi_data_exe_start + smpi_data_exe_size)) {
XBT_DEBUG("Privatization : We are sending from a zone inside global memory. Switch data segment ");
XBT_DEBUG("sending size of %zu : sleep %f ", size_, sleeptime);
}
- int async_small_thresh = simgrid::config::get_value<int>("smpi/async-small-thresh");
-
simgrid::s4u::MutexPtr mut = process->mailboxes_mutex();
- if (async_small_thresh != 0 || (flags_ & MPI_REQ_RMA) != 0)
+ if (smpi_cfg_async_small_thresh() != 0 || (flags_ & MPI_REQ_RMA) != 0)
mut->lock();
- if (not(async_small_thresh != 0 || (flags_ & MPI_REQ_RMA) != 0)) {
+ if (not(smpi_cfg_async_small_thresh() != 0 || (flags_ & MPI_REQ_RMA) != 0)) {
mailbox = process->mailbox();
- } else if (((flags_ & MPI_REQ_RMA) != 0) || static_cast<int>(size_) < async_small_thresh) { // eager mode
+ } else if (((flags_ & MPI_REQ_RMA) != 0) || static_cast<int>(size_) < smpi_cfg_async_small_thresh()) { // eager mode
mailbox = process->mailbox();
XBT_DEBUG("Is there a corresponding recv already posted in the large mailbox %s?", mailbox->get_cname());
- smx_activity_t action = mailbox->iprobe(1, &match_send, static_cast<void*>(this));
+ simgrid::kernel::activity::ActivityImplPtr action = mailbox->iprobe(1, &match_send, static_cast<void*>(this));
if (action == nullptr) {
if ((flags_ & MPI_REQ_SSEND) == 0) {
mailbox = process->mailbox_small();
smpi_process()->get_tracing_category());
}
- if (async_small_thresh != 0 || ((flags_ & MPI_REQ_RMA) != 0))
+ if (smpi_cfg_async_small_thresh() != 0 || ((flags_ & MPI_REQ_RMA) != 0))
mut->unlock();
}
}
if (((*request)->flags_ & MPI_REQ_PREPARED) == 0) {
if ((*request)->action_ != nullptr && (*request)->cancelled_ != 1){
try{
- *flag = simcall_comm_test((*request)->action_);
+ *flag = simcall_comm_test((*request)->action_.get());
} catch (const Exception&) {
*flag = 0;
return ret;
nsleeps=1;//reset the number of sleeps we will do next time
if (*request != MPI_REQUEST_NULL && ((*request)->flags_ & MPI_REQ_PERSISTENT) == 0)
*request = MPI_REQUEST_NULL;
- } else if (simgrid::config::get_value<bool>("smpi/grow-injected-times")) {
+ } else if (smpi_cfg_grow_injected_times()) {
nsleeps++;
}
}
// This can speed up the execution of certain applications by an order of magnitude, such as HPL
static int nsleeps = 1;
double speed = s4u::this_actor::get_host()->get_speed();
- double maxrate = simgrid::config::get_value<double>("smpi/iprobe-cpu-usage");
+ double maxrate = smpi_cfg_iprobe_cpu_usage();
MPI_Request request = new Request(nullptr, 0, MPI_CHAR,
source == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : comm->group()->actor(source)->get_pid(),
simgrid::s4u::this_actor::get_pid(), tag, comm, MPI_REQ_PERSISTENT | MPI_REQ_RECV);
request->print_request("New iprobe");
// We have to test both mailboxes as we don't know if we will receive one or another
- if (simgrid::config::get_value<int>("smpi/async-small-thresh") > 0) {
+ if (smpi_cfg_async_small_thresh() > 0) {
mailbox = smpi_process()->mailbox_small();
XBT_DEBUG("Trying to probe the perm recv mailbox");
request->action_ = mailbox->iprobe(0, &match_recv, static_cast<void*>(request));
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_);
}
else {
*flag = 0;
- if (simgrid::config::get_value<bool>("smpi/grow-injected-times"))
+ if (smpi_cfg_grow_injected_times())
nsleeps++;
}
unref(&request);
// FIXME Handle the case of a partial shared malloc.
if (((req->flags_ & MPI_REQ_ACCUMULATE) != 0) ||
(datatype->flags() & DT_FLAG_DERIVED)) { // && (not smpi_is_shared(req->old_buf_))){
-
- if (not smpi_process()->replaying() && smpi_privatize_global_variables != SmpiPrivStrategies::NONE &&
+ if (not smpi_process()->replaying() && smpi_cfg_privatization() != SmpiPrivStrategies::NONE &&
static_cast<char*>(req->old_buf_) >= smpi_data_exe_start &&
static_cast<char*>(req->old_buf_) < smpi_data_exe_start + smpi_data_exe_size) {
XBT_VERB("Privatization : We are unserializing to a zone in global memory Switch data segment ");
if ((*request)->action_ != nullptr){
try{
// this is not a detached send
- simcall_comm_wait((*request)->action_, -1.0);
+ simcall_comm_wait((*request)->action_.get(), -1.0);
} catch (const Exception&) {
XBT_VERB("Request cancelled");
}
return count;
}
-MPI_Request Request::f2c(int id) {
+MPI_Request Request::f2c(int id)
+{
char key[KEY_SIZE];
if(id==MPI_FORTRAN_REQUEST_NULL)
return static_cast<MPI_Request>(MPI_REQUEST_NULL);
}
}
-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;
if(req != MPI_REQUEST_NULL && req->action_ != nullptr) {
return MPI_SUCCESS;
}
-int Request::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){
-
+int Request::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)
+{
*request = new Request();
(*request)->flags_ |= MPI_REQ_GENERALIZED;
(*request)->flags_ |= MPI_REQ_PERSISTENT;
return MPI_SUCCESS;
}
-int Request::grequest_complete( MPI_Request request){
+int Request::grequest_complete(MPI_Request request)
+{
if ((!(request->flags_ & MPI_REQ_GENERALIZED)) || request->generalized_funcs->mutex==NULL)
return MPI_ERR_REQUEST;
request->generalized_funcs->mutex->lock();
-/* 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
******************************************************************************/
newSize *= dims[i];
}
if(rank >= newSize) {
- *comm_cart = MPI_COMM_NULL;
+ if(comm_cart != nullptr)
+ *comm_cart = MPI_COMM_NULL;
return;
}
- oldGroup = comm_old->group();
- newGroup = new Group(newSize);
- for (int i = 0 ; i < newSize ; i++) {
- newGroup->set_mapping(oldGroup->actor(i), i);
- }
nnodes_ = newSize;
position_[i] = rank / nranks;
rank = rank % nranks;
}
-
- *comm_cart = new Comm(newGroup, this);
+
+ if(comm_cart != nullptr){
+ oldGroup = comm_old->group();
+ newGroup = new Group(newSize);
+ for (int i = 0 ; i < newSize ; i++) {
+ newGroup->set_mapping(oldGroup->actor(i), i);
+ }
+ *comm_cart = new Comm(newGroup, this);
+ }
} else {
- if (rank == 0) {
- *comm_cart = new Comm(new Group(MPI_COMM_SELF->group()), this);
- } else {
- *comm_cart = MPI_COMM_NULL;
+ if(comm_cart != nullptr){
+ if (rank == 0) {
+ MPI_Group group = new Group(MPI_COMM_SELF->group());
+ *comm_cart = new Comm(group, this);
+ } else {
+ *comm_cart = MPI_COMM_NULL;
+ }
}
}
- setComm(*comm_cart);
+ if(comm_cart != nullptr)
+ setComm(*comm_cart);
}
Topo_Cart* Topo_Cart::sub(const int remain_dims[], MPI_Comm *newcomm) {
}
}
}
- Topo_Cart* res = new Topo_Cart(getComm(), newNDims, newDims, newPeriodic, 0, newcomm);
+
+ //split into several communicators
+ int color = 0;
+ for (int i = 0; i < oldNDims; i++) {
+ if (not remain_dims[i]) {
+ color = (color * dims_[i] + position_[i]);
+ }
+ }
+ Topo_Cart* res;
+ if (newNDims == 0){
+ res = new Topo_Cart(getComm(), newNDims, newDims, newPeriodic, 0, newcomm);
+ } else {
+ *newcomm = getComm()->split(color, getComm()->rank());
+ res = new Topo_Cart(getComm(), newNDims, newDims, newPeriodic, 0, nullptr);
+ res->setComm(*newcomm);
+ }
delete[] newDims;
delete[] newPeriodic;
return res;
/* 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 ?
recv_win->requests_->push_back(rreq);
rreq->start();
recv_win->mut_->unlock();
-
- }else{
+ } else {
XBT_DEBUG("Entering MPI_Put from myself to myself, rank %d", target_rank);
Datatype::copy(origin_addr, origin_count, origin_datatype, recv_addr, target_count, target_datatype);
if(request!=nullptr)
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()){
requests_->push_back(rreq);
mut_->unlock();
}
-
- }else{
+ } else {
Datatype::copy(send_addr, target_count, target_datatype, origin_addr, origin_count, origin_datatype);
if(request!=nullptr)
*request=MPI_REQUEST_NULL;
}
-
return MPI_SUCCESS;
}
-
int Win::accumulate(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Request* request)
{
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 ?
Request::wait(&req, MPI_STATUS_IGNORE);
send_win->atomic_mut_->unlock();
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(){
+MPI_Errhandler Win::errhandler()
+{
+ if (errhandler_ != MPI_ERRHANDLER_NULL)
+ errhandler_->ref();
return errhandler_;
}
-void Win::set_errhandler(MPI_Errhandler errhandler){
- errhandler_=errhandler;
- if(errhandler_!= MPI_ERRHANDLER_NULL)
- errhandler->ref();
-}
-
-}
-}
+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();
+}
+} // 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);
}
if (!done) {
done = true;
simgrid::s4u::Exec::on_completion.connect([](simgrid::s4u::Actor const& actor, simgrid::s4u::Exec const& exec) {
-
simgrid::smpi::plugin::lb.record_actor_computation(actor, exec.get_cost());
});
-/* 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"
list_add_not_empty CMDLINE "${LINKARGS}"
eval $(list_get CMDLINE)
-if [ "x$VERBOSE" = x1 -o "x$show" = x1 ] ; then
+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.
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.
# Do not remove, this variable may be used by user code (e.g. StarPU)
export SMPI_GLOBAL_SIZE=${NUMPROCS}
-if [ -n "${KEEP}" ] ; then
+if [ -n "${KEEP}" -a -z "${QUIET}" ] ; then
echo ${EXEC} ${PRIVATIZE} ${TRACEOPTIONS} ${SIMOPTS} ${PLATFORMTMP} ${APPLICATIONTMP}
if [ ${HOSTFILETMP} = 1 ] ; then
echo "Generated hostfile ${HOSTFILE} kept."
#!/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. */
HostImpl::~HostImpl()
{
- /* All processes should be gone when the host is turned off (by the end of the simulation). */
+ /* All actors should be gone when the host is turned off (by the end of the simulation). */
if (not actor_list_.empty()) {
std::string msg = std::string("Shutting down host, but it's not empty:");
- for (auto const& process : actor_list_)
- msg += "\n\t" + std::string(process.get_name());
+ for (auto const& actor : actor_list_)
+ msg += "\n\t" + std::string(actor.get_name());
- SIMIX_display_process_status();
+ simix_global->display_all_actor_status();
xbt_die("%s", msg.c_str());
}
for (auto const& arg : actors_at_boot_)
}
// 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"
-#include "src/surf/PropertyHolder.hpp"
#include "src/surf/StorageImpl.hpp"
#include "src/surf/cpu_interface.hpp"
#include "src/surf/network_interface.hpp"
+#include <xbt/PropertyHolder.hpp>
#include <vector>
* @brief SURF Host interface class
* @details An host represents a machine with a aggregation of a Cpu, a RoutingEdge and a Storage
*/
-class XBT_PRIVATE HostImpl : public simgrid::surf::PropertyHolder {
+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?
+ s4u::Host* piface_ = nullptr; // we must have a pointer there because the VM wants to change the piface in its ctor
+ 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. */
#include "simgrid/kernel/resource/Resource.hpp"
#include "simgrid/s4u/Io.hpp"
#include "simgrid/s4u/Storage.hpp"
-#include "src/surf/PropertyHolder.hpp"
#include "surf_interface.hpp"
+#include "xbt/PropertyHolder.hpp"
#include <map>
* @brief SURF storage interface class
* @details A Storage represent a storage unit (e.g.: hard drive, usb key)
*/
-class StorageImpl : public Resource, public surf::PropertyHolder {
+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;
};
std::unordered_map<std::string, IBNode> active_nodes;
std::unordered_map<NetworkAction*, std::pair<IBNode*, IBNode*>> active_comms;
-
};
} // 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. */
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. */
#include "simgrid/kernel/resource/Resource.hpp"
#include "simgrid/s4u/Link.hpp"
#include "src/kernel/lmm/maxmin.hpp"
-#include "src/surf/PropertyHolder.hpp"
+#include <xbt/PropertyHolder.hpp>
#include <list>
#include <unordered_map>
* @brief SURF network link interface class
* @details A Link represents the link between two [hosts](@ref simgrid::surf::HostImpl)
*/
-class LinkImpl : public Resource, public surf::PropertyHolder {
+class LinkImpl : public Resource, public xbt::PropertyHolder {
bool currently_destroying_ = false;
s4u::Link piface_;
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. */
/* While not all is buffered and there remain space in the buffers */
while (flow->buffered_bytes_ < flow->total_bytes_ && sock->GetTxAvailable() > 0) {
-
// Send at most 1040 bytes (data size in a TCP packet), as ns-3 seems to not split correctly by itself
uint32_t toWrite = std::min({flow->remaining_, sock->GetTxAvailable(), std::uint32_t(1040)});
+
if (toWrite == 0) { // buffer full
XBT_DEBUG("%f: buffer full on flow %p (still %u to go)", ns3::Simulator::Now().GetSeconds(), flow,
flow->remaining_);
-/* 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)
{
+ static double last_warned_latency = sg_surf_precision;
+ if (link->latency != 0.0 && link->latency < last_warned_latency) {
+ XBT_WARN("Latency for link %s is smaller than surf/precision (%g < %g)."
+ " For more accuracy, consider setting \"--cfg=surf/precision:%g\".",
+ link_name.c_str(), link->latency, sg_surf_precision, link->latency);
+ last_warned_latency = link->latency;
+ }
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::kernel::actor::ActorCodeFactory& factory =
+ simgrid::kernel::EngineImpl::get_instance()->get_function(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;
double kill_time = actor->kill_time;
- bool auto_restart = actor->on_failure != simgrid::kernel::routing::ActorOnFailure::DIE;
+ bool auto_restart = actor->restart_on_failure;
std::string actor_name = actor->args[0];
- simgrid::simix::ActorCode code = factory(std::move(actor->args));
+ simgrid::kernel::actor::ActorCode code = factory(std::move(actor->args));
std::shared_ptr<std::unordered_map<std::string, std::string>> properties(actor->properties);
simgrid::kernel::actor::ProcessArg* arg =
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");
- for (auto kv = props->begin(); kv != props->end(); ++kv)
- current_routing->get_iface()->set_property(kv->first, kv->second);
+ if (props)
+ current_routing->set_properties(*props);
}
/**
}
/** @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. */
#include "simgrid/sg_config.hpp"
#include "src/kernel/resource/profile/FutureEvtSet.hpp"
#include "src/kernel/resource/profile/Profile.hpp"
-#include "src/simgrid/version.h"
#include "src/surf/HostImpl.hpp"
#include "src/surf/xml/platf.hpp"
#include "src/xbt_modinter.h" /* whether initialization was already done */
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});
}
return -1;
}
-void sg_version_check(int lib_version_major, int lib_version_minor, int lib_version_patch)
-{
- if ((lib_version_major != SIMGRID_VERSION_MAJOR) || (lib_version_minor != SIMGRID_VERSION_MINOR)) {
- fprintf(stderr, "FATAL ERROR: Your program was compiled with SimGrid version %d.%d.%d, "
- "and then linked against SimGrid %d.%d.%d. Please fix this.\n",
- lib_version_major, lib_version_minor, lib_version_patch, SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR,
- SIMGRID_VERSION_PATCH);
- abort();
- }
- if (lib_version_patch != SIMGRID_VERSION_PATCH) {
- if (SIMGRID_VERSION_PATCH > 89 || lib_version_patch > 89) {
- fprintf(
- stderr,
- "FATAL ERROR: Your program was compiled with SimGrid version %d.%d.%d, "
- "and then linked against SimGrid %d.%d.%d. \n"
- "One of them is a development version, and should not be mixed with the stable release. Please fix this.\n",
- lib_version_major, lib_version_minor, lib_version_patch, SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR,
- SIMGRID_VERSION_PATCH);
- abort();
- }
- fprintf(stderr, "Warning: Your program was compiled with SimGrid version %d.%d.%d, "
- "and then linked against SimGrid %d.%d.%d. Proceeding anyway.\n",
- lib_version_major, lib_version_minor, lib_version_patch, SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR,
- SIMGRID_VERSION_PATCH);
- }
-}
-
-void sg_version_get(int* ver_major, int* ver_minor, int* ver_patch)
-{
- *ver_major = SIMGRID_VERSION_MAJOR;
- *ver_minor = SIMGRID_VERSION_MINOR;
- *ver_patch = SIMGRID_VERSION_PATCH;
-}
-
-void sg_version()
-{
- XBT_HELP("This program was linked against %s (git: %s), found in %s.", SIMGRID_VERSION_STRING, SIMGRID_GIT_VERSION,
- SIMGRID_INSTALL_PREFIX);
-
-#if SIMGRID_HAVE_MC
- XBT_HELP(" Model-checking support compiled in.");
-#else
- XBT_HELP(" Model-checking support disabled at compilation.");
-#endif
-
-#if SIMGRID_HAVE_NS3
- XBT_HELP(" ns-3 support compiled in.");
-#else
- XBT_HELP(" ns-3 support disabled at compilation.");
-#endif
-
-#if SIMGRID_HAVE_JEDULE
- XBT_HELP(" Jedule support compiled in.");
-#else
- XBT_HELP(" Jedule support disabled at compilation.");
-#endif
-
-#if SIMGRID_HAVE_LUA
- XBT_HELP(" Lua support compiled in.");
-#else
- XBT_HELP(" Lua support disabled at compilation.");
-#endif
-
-#if SIMGRID_HAVE_MALLOCATOR
- XBT_HELP(" Mallocator support compiled in.");
-#else
- XBT_HELP(" Mallocator support disabled at compilation.");
-#endif
-
- XBT_HELP("\nTo cite SimGrid in a publication, please use:\n"
- " Henri Casanova, Arnaud Giersch, Arnaud Legrand, Martin Quinson, Frédéric Suter. \n"
- " Versatile, Scalable, and Accurate Simulation of Distributed Applications and Platforms. \n"
- " Journal of Parallel and Distributed Computing, Elsevier, 2014, 74 (10), pp.2899-2917.\n"
- "The pdf file and a BibTeX entry for LaTeX users can be found at http://hal.inria.fr/hal-01017319");
-}
void surf_init(int *argc, char **argv)
{
{
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 element;
};
-enum class ActorOnFailure { DIE, RESTART }; // FIXME: move to a better namespace
-
class ActorCreationArgs {
public:
std::vector<std::string> args;
const char* function = nullptr;
double start_time = 0.0;
double kill_time = 0.0;
- ActorOnFailure on_failure;
+ bool restart_on_failure = false;
};
class ZoneCreationArgs {
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;
static std::vector<double> surf_parse_get_all_speeds(char* speeds, const char* entity_kind, const std::string& id)
{
-
std::vector<double> speed_per_pstate;
if (strchr(speeds, ',') == nullptr){
switch (A_surfxml_actor_on___failure) {
case AU_surfxml_actor_on___failure:
case A_surfxml_actor_on___failure_DIE:
- actor.on_failure = simgrid::kernel::routing::ActorOnFailure::DIE;
+ actor.restart_on_failure = false;
break;
case A_surfxml_actor_on___failure_RESTART:
- actor.on_failure = simgrid::kernel::routing::ActorOnFailure::RESTART;
+ actor.restart_on_failure = true;
break;
default:
surf_parse_error("Invalid on failure behavior");
-/* 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. */
-#include "PropertyHolder.hpp"
+#include <xbt/PropertyHolder.hpp>
#include <map>
namespace simgrid {
-namespace surf {
+namespace xbt {
/** @brief Return the property associated to the provided key (or nullptr if not existing) */
const char* PropertyHolder::get_property(const std::string& key) const
template void PropertyHolder::set_properties(const std::map<std::string, std::string>& properties);
template void PropertyHolder::set_properties(const std::unordered_map<std::string, std::string>& properties);
-} /* namespace surf */
-} /* namespace simgrid */
+} // namespace xbt
+} // namespace simgrid
/* 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. */
TEST_CASE("xbt::config: Configuration support", "config")
{
-
SECTION("Alloc and free a config set")
{
auto temp = simgrid_config;
/* 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. */
* if such a file exists.
* */
struct mdesc {
-
/** @brief Mutex locking the access to the heap */
pthread_mutex_t mutex;
/* @brief Instrumentation */
struct mstats heapstats;
-
};
/* Bits to look at in the malloc descriptor flags word */
/* 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. */
+#include "simgrid/engine.h" /* simgrid_get_clock */
#include "simgrid/host.h"
-#include "simgrid/msg.h" /* MSG_get_clock */
#include "src/xbt/log_private.hpp"
#include "xbt/sysdep.h"
#include <algorithm>
#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;
show_string(ev->functionName);
break;
case 'd': /* date; LOG4J compliant */
- show_double(MSG_get_clock());
+ show_double(simgrid_get_clock());
break;
case 'r': /* application age; LOG4J compliant */
- show_double(MSG_get_clock());
+ show_double(simgrid_get_clock());
break;
case 'm': { /* user-provided message; LOG4J compliant */
int sz;
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. */
#include "xbt/sysdep.h"
#include "src/xbt/log_private.hpp"
-#include "simgrid/host.h" /* sg_host_self_get_name */
-#include "simgrid/msg.h" /* MSG_get_clock */
+#include "simgrid/engine.h" /* simgrid_get_clock */
+#include "simgrid/host.h" /* sg_host_self_get_name */
#include <cstdio>
extern const char *xbt_log_priority_names[8];
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;
}
/* Display the date */
- len = snprintf(p, rem_size, "%f] ", MSG_get_clock());
+ len = snprintf(p, rem_size, "%f] ", simgrid_get_clock());
check_overflow(len);
/* Display file position if not INFO */
/* 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. */
TEST_CASE("xbt::str: String Handling", "xbt_str")
{
-
SECTION("Test the function xbt_str_split_quoted")
{
test_split_quoted("Empty", "", {});
/* 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. */
-$ ${bindir:=.}/examples/deprecated/msg/app-masterworker/app-masterworker ${srcdir:=.}/examples/platforms/small_platform.lua ${srcdir:=.}/examples/deprecated/msg/app-masterworker/app-masterworker_d.xml
-> [Tremblay:master:(1) 0.000000] [msg_app_masterworker/INFO] Got 5 workers and 20 tasks to process
-> [Tremblay:master:(1) 0.000000] [msg_app_masterworker/INFO] Sending "Task_0" (of 20) to mailbox "worker-0"
-> [Tremblay:master:(1) 0.002265] [msg_app_masterworker/INFO] Sending "Task_1" (of 20) to mailbox "worker-1"
-> [Tremblay:master:(1) 0.171420] [msg_app_masterworker/INFO] Sending "Task_2" (of 20) to mailbox "worker-2"
-> [Tremblay:master:(1) 0.329817] [msg_app_masterworker/INFO] Sending "Task_3" (of 20) to mailbox "worker-3"
-> [Tremblay:master:(1) 0.453549] [msg_app_masterworker/INFO] Sending "Task_4" (of 20) to mailbox "worker-4"
-> [Tremblay:master:(1) 0.586168] [msg_app_masterworker/INFO] Sending "Task_5" (of 20) to mailbox "worker-0"
-> [Tremblay:master:(1) 0.588433] [msg_app_masterworker/INFO] Sending "Task_6" (of 20) to mailbox "worker-1"
-> [Tremblay:master:(1) 0.995917] [msg_app_masterworker/INFO] Sending "Task_7" (of 20) to mailbox "worker-2"
-> [Tremblay:master:(1) 1.154314] [msg_app_masterworker/INFO] Sending "Task_8" (of 20) to mailbox "worker-3"
-> [Tremblay:master:(1) 1.608379] [msg_app_masterworker/INFO] Sending "Task_9" (of 20) to mailbox "worker-4"
-> [Tremblay:master:(1) 1.749885] [msg_app_masterworker/INFO] Sending "Task_10" (of 20) to mailbox "worker-0"
-> [Tremblay:master:(1) 1.752150] [msg_app_masterworker/INFO] Sending "Task_11" (of 20) to mailbox "worker-1"
-> [Tremblay:master:(1) 1.921304] [msg_app_masterworker/INFO] Sending "Task_12" (of 20) to mailbox "worker-2"
-> [Tremblay:master:(1) 2.079701] [msg_app_masterworker/INFO] Sending "Task_13" (of 20) to mailbox "worker-3"
-> [Tremblay:master:(1) 2.763209] [msg_app_masterworker/INFO] Sending "Task_14" (of 20) to mailbox "worker-4"
-> [Tremblay:master:(1) 2.913601] [msg_app_masterworker/INFO] Sending "Task_15" (of 20) to mailbox "worker-0"
-> [Tremblay:master:(1) 2.915867] [msg_app_masterworker/INFO] Sending "Task_16" (of 20) to mailbox "worker-1"
-> [Tremblay:master:(1) 3.085021] [msg_app_masterworker/INFO] Sending "Task_17" (of 20) to mailbox "worker-2"
-> [Tremblay:master:(1) 3.243418] [msg_app_masterworker/INFO] Sending "Task_18" (of 20) to mailbox "worker-3"
-> [Tremblay:master:(1) 3.918038] [msg_app_masterworker/INFO] Sending "Task_19" (of 20) to mailbox "worker-4"
-> [Tremblay:master:(1) 4.077318] [msg_app_masterworker/INFO] All tasks have been dispatched. Let's tell everybody the computation is over.
-> [Tremblay:worker:(2) 4.077513] [msg_app_masterworker/INFO] I'm done. See you!
-> [Jupiter:worker:(3) 4.096528] [msg_app_masterworker/INFO] I'm done. See you!
-> [Fafard:worker:(4) 4.122236] [msg_app_masterworker/INFO] I'm done. See you!
-> [Ginette:worker:(5) 4.965689] [msg_app_masterworker/INFO] I'm done. See you!
-> [Bourassa:worker:(6) 5.133855] [msg_app_masterworker/INFO] I'm done. See you!
-> [5.133855] [msg_app_masterworker/INFO] Simulation time 5.13386
+$ ${bindir:=.}/examples/s4u/app-masterworkers/s4u-app-masterworkers-fun ${srcdir:=.}/examples/platforms/small_platform.lua ${srcdir:=.}/examples/s4u/app-masterworkers/s4u-app-masterworkers_d.xml
+> [Tremblay:master:(1) 0.000000] [s4u_app_masterworker/INFO] Got 5 workers and 20 tasks to process
+> [Tremblay:master:(1) 0.000000] [s4u_app_masterworker/INFO] Sending task 0 of 20 to mailbox 'Tremblay'
+> [Tremblay:master:(1) 0.002265] [s4u_app_masterworker/INFO] Sending task 1 of 20 to mailbox 'Jupiter'
+> [Tremblay:master:(1) 0.171420] [s4u_app_masterworker/INFO] Sending task 2 of 20 to mailbox 'Fafard'
+> [Tremblay:master:(1) 0.329817] [s4u_app_masterworker/INFO] Sending task 3 of 20 to mailbox 'Ginette'
+> [Tremblay:master:(1) 0.453549] [s4u_app_masterworker/INFO] Sending task 4 of 20 to mailbox 'Bourassa'
+> [Tremblay:master:(1) 0.586168] [s4u_app_masterworker/INFO] Sending task 5 of 20 to mailbox 'Tremblay'
+> [Tremblay:master:(1) 0.588433] [s4u_app_masterworker/INFO] Sending task 6 of 20 to mailbox 'Jupiter'
+> [Tremblay:master:(1) 0.995917] [s4u_app_masterworker/INFO] Sending task 7 of 20 to mailbox 'Fafard'
+> [Tremblay:master:(1) 1.154314] [s4u_app_masterworker/INFO] Sending task 8 of 20 to mailbox 'Ginette'
+> [Tremblay:master:(1) 1.608379] [s4u_app_masterworker/INFO] Sending task 9 of 20 to mailbox 'Bourassa'
+> [Tremblay:master:(1) 1.749885] [s4u_app_masterworker/INFO] Sending task 10 of 20 to mailbox 'Tremblay'
+> [Tremblay:master:(1) 1.752150] [s4u_app_masterworker/INFO] Sending task 11 of 20 to mailbox 'Jupiter'
+> [Tremblay:master:(1) 1.921304] [s4u_app_masterworker/INFO] Sending task 12 of 20 to mailbox 'Fafard'
+> [Tremblay:master:(1) 2.079701] [s4u_app_masterworker/INFO] Sending task 13 of 20 to mailbox 'Ginette'
+> [Tremblay:master:(1) 2.763209] [s4u_app_masterworker/INFO] Sending task 14 of 20 to mailbox 'Bourassa'
+> [Tremblay:master:(1) 2.913601] [s4u_app_masterworker/INFO] Sending task 15 of 20 to mailbox 'Tremblay'
+> [Tremblay:master:(1) 2.915867] [s4u_app_masterworker/INFO] Sending task 16 of 20 to mailbox 'Jupiter'
+> [Tremblay:master:(1) 3.085021] [s4u_app_masterworker/INFO] Sending task 17 of 20 to mailbox 'Fafard'
+> [Tremblay:master:(1) 3.243418] [s4u_app_masterworker/INFO] Sending task 18 of 20 to mailbox 'Ginette'
+> [Tremblay:master:(1) 3.918038] [s4u_app_masterworker/INFO] Sending task 19 of 20 to mailbox 'Bourassa'
+> [Tremblay:master:(1) 4.077318] [s4u_app_masterworker/INFO] All tasks have been dispatched. Request all workers to stop.
+> [Tremblay:worker:(2) 4.077513] [s4u_app_masterworker/INFO] Exiting now.
+> [Jupiter:worker:(3) 4.096528] [s4u_app_masterworker/INFO] Exiting now.
+> [Fafard:worker:(4) 4.122236] [s4u_app_masterworker/INFO] Exiting now.
+> [Ginette:worker:(5) 4.965689] [s4u_app_masterworker/INFO] Exiting now.
+> [Bourassa:worker:(6) 5.133855] [s4u_app_masterworker/INFO] Exiting now.
+> [5.133855] [s4u_app_masterworker/INFO] Simulation is over
-$ ${bindir:=.}/teshsuite/msg/app-token-ring/app-token-ring ${srcdir:=.}/examples/platforms/routing_cluster.lua "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${bindir:=.}/examples/s4u/app-token-ring/s4u-app-token-ring ${srcdir:=.}/examples/platforms/routing_cluster.lua "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (0:maestro@) Number of hosts '6'
> [ 0.000000] (1:0@host1) Host "0" send 'Token' to Host "1"
> [ 0.017354] (2:1@host2) Host "1" received "Token"
endforeach()
# MC-independent C++ binaries
-foreach(x random-bug)
+foreach(x random-bug mutex-handling)
add_executable (${x} EXCLUDE_FROM_ALL ${x}/${x}.cpp)
target_link_libraries(${x} simgrid)
set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.cpp)
endforeach()
-add_executable (without-mutex-handling EXCLUDE_FROM_ALL mutex-handling/mutex-handling.c)
+add_executable (without-mutex-handling EXCLUDE_FROM_ALL mutex-handling/mutex-handling.cpp)
target_link_libraries(without-mutex-handling simgrid)
set_target_properties(without-mutex-handling PROPERTIES COMPILE_FLAGS -DDISABLE_THE_MUTEX=1)
set_target_properties(without-mutex-handling PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mutex-handling)
add_dependencies(tests without-mutex-handling)
-foreach(x mutex-handling)
- add_executable (${x} EXCLUDE_FROM_ALL ${x}/${x}.c)
- target_link_libraries(${x} simgrid)
- set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
- add_dependencies(tests ${x})
-
- set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
- set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.c)
-endforeach()
-
set(teshsuite_src ${teshsuite_src} PARENT_SCOPE)
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/random-bug/random-bug-nocrash.tesh
${CMAKE_CURRENT_SOURCE_DIR}/random-bug/random-bug-replay.tesh
${CMAKE_CURRENT_SOURCE_DIR}/mutex-handling/without-mutex-handling.tesh PARENT_SCOPE)
-set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/mutex-handling/mutex-handling_d.xml PARENT_SCOPE)
IF(SIMGRID_HAVE_MC)
ADD_TESH(tesh-mc-dwarf --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/mc/dwarf --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/mc/dwarf dwarf.tesh)
-/* 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());
}
+++ /dev/null
-/* Copyright (c) 2015-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. */
-
-/* In this test, we have two senders sending one message to a common receiver.
- * The receiver should be able to see any ordering between the two messages.
- * If we model-check the application with assertions on a specific order of
- * the messages (see the assertions in the receiver code), it should fail
- * because both ordering are possible.
- *
- * If the senders sends the message directly, the current version of the MC
- * finds that the ordering may differ and the MC find a counter-example.
- *
- * However, if the senders send the message in a mutex, the MC always let
- * the first process take the mutex because it thinks that the effect of
- * a mutex is purely local: the ordering of the messages is always the same
- * and the MC does not find the counter-example.
- */
-
-#include "simgrid/modelchecker.h"
-#include "simgrid/msg.h"
-#include <xbt/synchro.h>
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
-
-#define BOX_NAME "box"
-
-#ifndef DISABLE_THE_MUTEX
-static sg_mutex_t mutex = NULL;
-#endif
-
-static int receiver(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
-{
- msg_task_t task = NULL;
-
- MSG_task_receive(&task, BOX_NAME);
- MC_assert(strcmp(MSG_task_get_name(task), "X") == 0);
- MSG_task_destroy(task);
-
- MSG_task_receive(&task, BOX_NAME);
- MC_assert(strcmp(MSG_task_get_name(task), "Y") == 0);
- MSG_task_destroy(task);
-
- return 0;
-}
-
-static int sender(int argc, char *argv[])
-{
- xbt_assert(argc == 2);
- char* message_name = argv[1];
-#ifndef DISABLE_THE_MUTEX
- sg_mutex_lock(mutex);
-#endif
- MSG_task_send(MSG_task_create(message_name, 0.0, 0.0, NULL), BOX_NAME);
-#ifndef DISABLE_THE_MUTEX
- sg_mutex_unlock(mutex);
-#endif
- return 0;
-}
-
-int main(int argc, char *argv[])
-{
- MSG_init(&argc, argv);
- xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
- "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
-
- MSG_create_environment(argv[1]);
- MSG_function_register("receiver", receiver);
- MSG_function_register("sender", sender);
-
- MSG_launch_application(argv[2]);
-#ifndef DISABLE_THE_MUTEX
- mutex = sg_mutex_init();
-#endif
- msg_error_t res = MSG_main();
-#ifndef DISABLE_THE_MUTEX
- sg_mutex_destroy(mutex);
- mutex = NULL;
-#endif
- XBT_INFO("Simulation time %g", MSG_get_clock());
-
- return res != MSG_OK;
-}
--- /dev/null
+/* 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. */
+
+/* In this test, we have two senders sending one message to a common receiver.
+ * The receiver should be able to see any ordering between the two messages.
+ * If we model-check the application with assertions on a specific order of
+ * the messages (see the assertions in the receiver code), it should fail
+ * because both ordering are possible.
+ *
+ * If the senders sends the message directly, the current version of the MC
+ * finds that the ordering may differ and the MC find a counter-example.
+ *
+ * However, if the senders send the message in a mutex, the MC always let
+ * the first process take the mutex because it thinks that the effect of
+ * a mutex is purely local: the ordering of the messages is always the same
+ * and the MC does not find the counter-example.
+ */
+
+#include "simgrid/modelchecker.h"
+#include "simgrid/s4u/Engine.hpp"
+#include "simgrid/s4u/Host.hpp"
+#include "simgrid/s4u/Mailbox.hpp"
+#include "simgrid/s4u/Mutex.hpp"
+#include <xbt/synchro.h>
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
+
+static int receiver(const char* box_name)
+{
+ auto mb = simgrid::s4u::Mailbox::by_name(box_name);
+ const int* payload;
+
+ payload = static_cast<int*>(mb->get());
+ MC_assert(*payload == 1);
+ delete payload;
+
+ payload = static_cast<int*>(mb->get());
+ MC_assert(*payload == 2);
+ delete payload;
+
+ return 0;
+}
+
+static int sender(const char* box_name, simgrid::s4u::MutexPtr mutex, int value)
+{
+ int* payload = new int(value);
+ auto mb = simgrid::s4u::Mailbox::by_name(box_name);
+
+ if (mutex)
+ mutex->lock();
+
+ mb->put(static_cast<void*>(payload), 8);
+
+ if (mutex)
+ mutex->unlock();
+
+ return 0;
+}
+
+int main(int argc, char* argv[])
+{
+ simgrid::s4u::Engine e(&argc, argv);
+ xbt_assert(argc > 1, "Usage: %s platform_file\n"
+ "\tExample: %s msg_platform.xml\n",
+ argv[0], argv[0]);
+
+ simgrid::s4u::MutexPtr mutex;
+#ifndef DISABLE_THE_MUTEX
+ mutex = simgrid::s4u::Mutex::create();
+#endif
+
+ e.load_platform(argv[1]);
+ simgrid::s4u::Actor::create("receiver", simgrid::s4u::Host::by_name("Jupiter"), receiver, "box");
+ simgrid::s4u::Actor::create("sender", simgrid::s4u::Host::by_name("Boivin"), sender, "box", mutex, 1);
+ simgrid::s4u::Actor::create("sender", simgrid::s4u::Host::by_name("Fafard"), sender, "box", mutex, 2);
+
+ e.run();
+ XBT_INFO("Simulation time %g", e.get_clock());
+
+ return 0;
+}
#!/usr/bin/env tesh
! expect return 1
-! output ignore
+! output display
$ ${bindir:=.}/../../../bin/simgrid-mc ${bindir:=.}/mutex-handling ${srcdir:=.}/examples/platforms/small_platform.xml ${srcdir:=.}/teshsuite/mc/mutex-handling/mutex-handling_d.xml
+++ /dev/null
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
-<platform version="4.1">
- <actor host="Tremblay" function="receiver"/>
- <actor host="Boivin" function="sender">
- <argument value="X"/>
- </actor>
- <actor host="Fafard" function="sender">
- <argument value="Y"/>
- </actor>
-</platform>
#!/usr/bin/env tesh
! expect return 1
-! output ignore
+! output display
! timeout 30
$ ${bindir:=.}/../../../bin/simgrid-mc ${bindir:=.}/without-mutex-handling ${srcdir:=.}/examples/platforms/small_platform.xml ${srcdir:=.}/teshsuite/mc/mutex-handling/mutex-handling_d.xml
-/* 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. */
# C examples
-foreach(x app-pingpong app-token-ring
+foreach(x app-token-ring
async-wait async-waitall async-waitany
cloud-capping cloud-migration cloud-two-tasks cloud-simple
get_sender host_on_off host_on_off_recv
task-priority
plugin-hostload
trace_integration)
- add_executable (${x} EXCLUDE_FROM_ALL ${x}/${x}.c)
- target_link_libraries(${x} simgrid)
- set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
- add_dependencies(tests ${x})
+ if(enable_msg)
+ add_executable (${x} EXCLUDE_FROM_ALL ${x}/${x}.c)
+ target_link_libraries(${x} simgrid)
+ set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
+ add_dependencies(tests ${x})
+ endif()
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.c)
# CPP examples
foreach(x task_destroy_cancel task_listen_from task_progress host_on_off_processes)
- add_executable (${x} EXCLUDE_FROM_ALL ${x}/${x}.cpp)
- target_link_libraries(${x} simgrid)
- set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
- add_dependencies(tests ${x})
+ if(enable_msg)
+ add_executable (${x} EXCLUDE_FROM_ALL ${x}/${x}.cpp)
+ target_link_libraries(${x} simgrid)
+ set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
+ add_dependencies(tests ${x})
+ endif()
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.cpp)
endforeach()
-add_executable (bittorrent EXCLUDE_FROM_ALL app-bittorrent/bittorrent.c app-bittorrent/bittorrent-messages.c app-bittorrent/bittorrent-peer.c app-bittorrent/tracker.c app-bittorrent/connection.c)
-target_link_libraries(bittorrent simgrid)
-set_target_properties(bittorrent PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/app-bittorrent)
-add_dependencies(tests bittorrent)
+if(enable_msg)
+ add_executable (bittorrent EXCLUDE_FROM_ALL app-bittorrent/bittorrent.c app-bittorrent/bittorrent-messages.c app-bittorrent/bittorrent-peer.c app-bittorrent/tracker.c app-bittorrent/connection.c)
+ target_link_libraries(bittorrent simgrid)
+ set_target_properties(bittorrent PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/app-bittorrent)
+ add_dependencies(tests bittorrent)
+endif()
foreach (file bittorrent connection bittorrent-messages bittorrent-peer tracker)
set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/${file}.c ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/${file}.h)
endforeach()
-add_executable (chainsend EXCLUDE_FROM_ALL app-chainsend/chainsend.c app-chainsend/iterator.c app-chainsend/common.c app-chainsend/messages.c app-chainsend/broadcaster.c app-chainsend/peer.c)
-target_link_libraries(chainsend simgrid)
-set_target_properties(chainsend PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/app-chainsend)
-add_dependencies(tests chainsend)
+if(enable_msg)
+ add_executable (chainsend EXCLUDE_FROM_ALL app-chainsend/chainsend.c app-chainsend/iterator.c app-chainsend/common.c app-chainsend/messages.c app-chainsend/broadcaster.c app-chainsend/peer.c)
+ target_link_libraries(chainsend simgrid)
+ set_target_properties(chainsend PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/app-chainsend)
+ add_dependencies(tests chainsend)
+endif()
foreach (file common iterator messages broadcaster peer)
set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/app-chainsend/${file}.c ${CMAKE_CURRENT_SOURCE_DIR}/app-chainsend/${file}.h)
endforeach()
set(bin_files ${bin_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/generate.py PARENT_SCOPE)
set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/app-bittorrent_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/app-chainsend/app-chainsend_d.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/app-pingpong/app-pingpong_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait2_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait3_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp1-c1s1-c3s2.xml
${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp2.5-hbp1.5.xml PARENT_SCOPE)
-foreach(x
- async-wait async-waitall async-waitany
- app-bittorrent app-chainsend app-pingpong app-token-ring
+if(enable_msg)
+ foreach(x
+ async-wait async-waitall
+ app-bittorrent app-chainsend app-token-ring
cloud-capping cloud-migration cloud-two-tasks cloud-simple
energy-pstate
host_on_off host_on_off_processes host_on_off_recv
task-priority
plugin-hostload
trace_integration)
- ADD_TESH_FACTORIES(tesh-msg-${x} "raw"
- --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
- --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/msg/${x}
- --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x}
- ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x}/${x}.tesh)
-endforeach()
+
+ ADD_TESH_FACTORIES(tesh-msg-${x} "raw"
+ --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
+ --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/msg/${x}
+ --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x}
+ ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x}/${x}.tesh)
+ endforeach()
-ADD_TESH_FACTORIES(tesh-app-bittorrent-parallel "raw" --cfg contexts/nthreads:4 ${CONTEXTS_SYNCHRO} --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/msg/app-bittorrent --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/app-bittorrent app-bittorrent.tesh)
+ ADD_TESH_FACTORIES(tesh-app-bittorrent-parallel "raw" --cfg contexts/nthreads:4 ${CONTEXTS_SYNCHRO} --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/msg/app-bittorrent --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/app-bittorrent app-bittorrent.tesh)
+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) 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[]);
+++ /dev/null
-/* Copyright (c) 2007-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. */
-
-#include "simgrid/msg.h"
-
-#include <stdio.h> /* snprintf */
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_app_pingpong, "Messages specific for this msg example");
-
-static int pinger(int argc, char* argv[])
-{
- xbt_assert(argc == 2, "The pinger function one argument from the XML deployment file");
- XBT_INFO("Ping -> %s", argv[1]);
- xbt_assert(MSG_host_by_name(argv[1]) != NULL, "Unknown host %s. Stopping Now! ", argv[1]);
-
- /* - Do the ping with a 1-Byte task (latency bound) ... */
- double now = MSG_get_clock();
- msg_task_t ping_task = MSG_task_create("small communication (latency bound)", 0.0, 1, &now);
- MSG_task_send(ping_task, argv[1]);
-
- /* - ... then wait for the (large) pong */
- msg_task_t pong_task = NULL;
- int a = MSG_task_receive(&pong_task, MSG_host_get_name(MSG_host_self()));
- xbt_assert(a == MSG_OK, "Unexpected behavior");
-
- double sender_time = *((double*)(MSG_task_get_data(pong_task)));
- double communication_time = MSG_get_clock() - sender_time;
- XBT_INFO("Task received : %s", MSG_task_get_name(pong_task));
- MSG_task_destroy(pong_task);
- XBT_INFO("Pong time (bandwidth bound): %.3f", communication_time);
-
- return 0;
-}
-
-static int ponger(int argc, char* argv[])
-{
- xbt_assert(argc == 2, "The ponger function one argument from the XML deployment file");
- XBT_INFO("Pong -> %s", argv[1]);
- xbt_assert(MSG_host_by_name(argv[1]) != NULL, "Unknown host %s. Stopping Now! ", argv[1]);
-
- /* - Receive the (small) ping first ....*/
- msg_task_t ping_task = NULL;
- int a = MSG_task_receive(&ping_task, MSG_host_get_name(MSG_host_self()));
- xbt_assert(a == MSG_OK, "Unexpected behavior");
-
- double sender_time = *((double*)(MSG_task_get_data(ping_task)));
- double communication_time = MSG_get_clock() - sender_time;
- XBT_INFO("Task received : %s", MSG_task_get_name(ping_task));
- MSG_task_destroy(ping_task);
- XBT_INFO(" Ping time (latency bound) %f", communication_time);
-
- /* - ... Then send a 1GB pong back (bandwidth bound) */
- double now = MSG_get_clock();
- msg_task_t pong_task = MSG_task_create("large communication (bandwidth bound)", 0.0, 1e9, &now);
- XBT_INFO("task_bw->data = %.3f", *((double*)MSG_task_get_data(pong_task)));
- MSG_task_send(pong_task, argv[1]);
-
- return 0;
-}
-
-int main(int argc, char* argv[])
-{
- MSG_init(&argc, argv);
-
- xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
- "\tExample: %s ../../platforms/small_platform.xml app-pingpong_d.xml\n",
- argv[0], argv[0]);
-
- MSG_create_environment(argv[1]); /* - Load the platform description */
-
- MSG_function_register("pinger", pinger); /* - Register the functions to be executed by the processes */
- MSG_function_register("ponger", ponger);
-
- MSG_launch_application(argv[2]); /* - Deploy the application */
-
- msg_error_t res = MSG_main(); /* - Run the simulation */
-
- XBT_INFO("Total simulation time: %.3f", MSG_get_clock());
- return res != MSG_OK;
-}
-/* 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
--- /dev/null
+foreach(example borken-context corrupt-stack)
+ set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${example}/${example}.tesh
+ ${CMAKE_CURRENT_SOURCE_DIR}/${example}/${example}_d.xml)
+ set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${example}/${example}.py)
+
+ if(enable_python)
+ ADD_TESH_FACTORIES(tesh-python-${example} "thread;ucontext;raw;boost"
+ --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
+ --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
+ --setenv pythoncmd=${PYTHON_EXECUTABLE}
+ --setenv LD_LIBRARY_PATH=${TESH_LIBRARY_PATH}
+ --setenv PYTHONPATH=${CMAKE_BINARY_DIR}/lib
+ --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
+ ${example}.tesh)
+ endif()
+endforeach()
+
+set(tesh_files ${tesh_files} PARENT_SCOPE)
+set(examples_src ${examples_src} PARENT_SCOPE)
--- /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.
+
+# First failing example for bug #9 on Framagit (Python bindings crashing)
+#
+# A heavy operation is added after e.run() (here, it's "import gc"). Note that
+# the failure only occurs when the actor "sender" starts first, and the
+# scheduling is interlaced: sender starts, receiver starts, sender terminates,
+# receiver terminates.
+
+import sys
+from simgrid import Engine, this_actor
+
+def sender():
+ this_actor.sleep_for(3)
+ this_actor.info("Goodbye now!")
+
+def receiver():
+ this_actor.sleep_for(5)
+ this_actor.info("Five seconds elapsed")
+
+if __name__ == '__main__':
+ e = Engine(sys.argv)
+
+ e.load_platform(sys.argv[1]) # Load the platform description
+
+ # Register the classes representing the actors
+ e.register_actor("sender", sender)
+ e.register_actor("receiver", receiver)
+
+ e.load_deployment(sys.argv[2])
+
+ e.run()
+ this_actor.info("Dummy import...")
+ import gc
+ gc.collect()
+ this_actor.info("done.")
--- /dev/null
+#!/usr/bin/env tesh
+
+$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${bindir:=.}/borken-context.py ${platfdir}/small_platform_fatpipe.xml borken-context_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 3.000000] (1:sender@Tremblay) Goodbye now!
+> [ 5.000000] (2:receiver@Ruby) Five seconds elapsed
+> [ 5.000000] (0:maestro@) Dummy import...
+> [ 5.000000] (0:maestro@) done.
--- /dev/null
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
+<platform version="4.1">
+ <actor host="Tremblay" function="sender"/>
+ <actor host="Ruby" function="receiver"/>
+</platform>
--- /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.
+
+# Second failing example for bug #9 on Framagit (Python bindings crashing)
+#
+# An intricate recursion is used to make the crash happen.
+
+import sys
+from simgrid import Engine, this_actor
+
+def do_sleep1(i, dur):
+ if i > 0:
+ this_actor.info("1-Iter {:d}".format(i))
+ do_sleep3(i - 1, dur)
+ this_actor.sleep_for(dur)
+ this_actor.info("1-Mid ({:d})".format(i))
+ do_sleep3(int(i / 2), dur)
+ this_actor.info("1-Done ({:d})".format(i))
+
+def do_sleep3(i, dur):
+ if i > 0:
+ this_actor.info("3-Iter {:d}".format(i))
+ do_sleep5(i - 1, dur)
+ this_actor.sleep_for(dur)
+ this_actor.info("3-Mid ({:d})".format(i))
+ do_sleep5(int(i / 2), dur)
+ this_actor.info("3-Done ({:d})".format(i))
+
+def do_sleep5(i, dur):
+ if i > 0:
+ this_actor.info("5-Iter {:d}".format(i))
+ do_sleep1(i - 1, dur)
+ this_actor.sleep_for(dur)
+ this_actor.info("5-Mid ({:d})".format(i))
+ do_sleep1(int(i / 2), dur)
+ this_actor.info("5-Done ({:d})".format(i))
+
+def sleeper1():
+ do_sleep1(16, 1)
+
+def sleeper3():
+ do_sleep3(6, 3)
+
+def sleeper5():
+ do_sleep5(4, 5)
+
+if __name__ == '__main__':
+ e = Engine(sys.argv)
+
+ e.load_platform(sys.argv[1]) # Load the platform description
+
+ # Register the classes representing the actors
+ e.register_actor("sleeper1", sleeper1)
+ e.register_actor("sleeper3", sleeper3)
+ e.register_actor("sleeper5", sleeper5)
+
+ e.load_deployment(sys.argv[2])
+
+ e.run()
+ this_actor.info("Finalize!")
--- /dev/null
+#!/usr/bin/env tesh
+
+$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${bindir:=.}/corrupt-stack.py ${platfdir}/small_platform_fatpipe.xml corrupt-stack_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 0.000000] (1:sleeper3@Ruby) 3-Iter 6
+> [ 0.000000] (1:sleeper3@Ruby) 5-Iter 5
+> [ 0.000000] (1:sleeper3@Ruby) 1-Iter 4
+> [ 0.000000] (1:sleeper3@Ruby) 3-Iter 3
+> [ 0.000000] (1:sleeper3@Ruby) 5-Iter 2
+> [ 0.000000] (1:sleeper3@Ruby) 1-Iter 1
+> [ 0.000000] (2:sleeper1@Tremblay) 1-Iter 16
+> [ 0.000000] (2:sleeper1@Tremblay) 3-Iter 15
+> [ 0.000000] (2:sleeper1@Tremblay) 5-Iter 14
+> [ 0.000000] (2:sleeper1@Tremblay) 1-Iter 13
+> [ 0.000000] (2:sleeper1@Tremblay) 3-Iter 12
+> [ 0.000000] (2:sleeper1@Tremblay) 5-Iter 11
+> [ 0.000000] (2:sleeper1@Tremblay) 1-Iter 10
+> [ 0.000000] (2:sleeper1@Tremblay) 3-Iter 9
+> [ 0.000000] (2:sleeper1@Tremblay) 5-Iter 8
+> [ 0.000000] (2:sleeper1@Tremblay) 1-Iter 7
+> [ 0.000000] (2:sleeper1@Tremblay) 3-Iter 6
+> [ 0.000000] (2:sleeper1@Tremblay) 5-Iter 5
+> [ 0.000000] (2:sleeper1@Tremblay) 1-Iter 4
+> [ 0.000000] (2:sleeper1@Tremblay) 3-Iter 3
+> [ 0.000000] (2:sleeper1@Tremblay) 5-Iter 2
+> [ 0.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [ 0.000000] (3:sleeper5@Java) 5-Iter 4
+> [ 0.000000] (3:sleeper5@Java) 1-Iter 3
+> [ 0.000000] (3:sleeper5@Java) 3-Iter 2
+> [ 0.000000] (3:sleeper5@Java) 5-Iter 1
+> [ 1.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [ 1.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [ 2.000000] (2:sleeper1@Tremblay) 5-Mid (2)
+> [ 2.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [ 3.000000] (1:sleeper3@Ruby) 1-Mid (1)
+> [ 3.000000] (1:sleeper3@Ruby) 1-Done (1)
+> [ 3.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [ 3.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [ 3.000000] (2:sleeper1@Tremblay) 5-Done (2)
+> [ 4.000000] (2:sleeper1@Tremblay) 3-Mid (3)
+> [ 4.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [ 5.000000] (3:sleeper5@Java) 5-Mid (1)
+> [ 5.000000] (3:sleeper5@Java) 5-Done (1)
+> [ 5.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [ 5.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [ 5.000000] (2:sleeper1@Tremblay) 3-Done (3)
+> [ 6.000000] (1:sleeper3@Ruby) 5-Mid (2)
+> [ 6.000000] (1:sleeper3@Ruby) 1-Iter 1
+> [ 6.000000] (2:sleeper1@Tremblay) 1-Mid (4)
+> [ 6.000000] (2:sleeper1@Tremblay) 3-Iter 2
+> [ 6.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [ 7.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [ 7.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [ 8.000000] (2:sleeper1@Tremblay) 3-Mid (2)
+> [ 8.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [ 9.000000] (1:sleeper3@Ruby) 1-Mid (1)
+> [ 9.000000] (1:sleeper3@Ruby) 1-Done (1)
+> [ 9.000000] (1:sleeper3@Ruby) 5-Done (2)
+> [ 9.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [ 9.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [ 9.000000] (2:sleeper1@Tremblay) 3-Done (2)
+> [ 9.000000] (2:sleeper1@Tremblay) 1-Done (4)
+> [ 10.000000] (3:sleeper5@Java) 3-Mid (2)
+> [ 10.000000] (3:sleeper5@Java) 5-Iter 1
+> [ 10.000000] (2:sleeper1@Tremblay) 5-Mid (5)
+> [ 10.000000] (2:sleeper1@Tremblay) 1-Iter 2
+> [ 10.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [ 11.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [ 11.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [ 12.000000] (1:sleeper3@Ruby) 3-Mid (3)
+> [ 12.000000] (1:sleeper3@Ruby) 5-Iter 1
+> [ 12.000000] (2:sleeper1@Tremblay) 1-Mid (2)
+> [ 12.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [ 13.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [ 13.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [ 13.000000] (2:sleeper1@Tremblay) 1-Done (2)
+> [ 13.000000] (2:sleeper1@Tremblay) 5-Done (5)
+> [ 14.000000] (2:sleeper1@Tremblay) 3-Mid (6)
+> [ 14.000000] (2:sleeper1@Tremblay) 5-Iter 3
+> [ 14.000000] (2:sleeper1@Tremblay) 1-Iter 2
+> [ 14.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [ 15.000000] (3:sleeper5@Java) 5-Mid (1)
+> [ 15.000000] (3:sleeper5@Java) 5-Done (1)
+> [ 15.000000] (3:sleeper5@Java) 3-Done (2)
+> [ 15.000000] (1:sleeper3@Ruby) 5-Mid (1)
+> [ 15.000000] (1:sleeper3@Ruby) 5-Done (1)
+> [ 15.000000] (1:sleeper3@Ruby) 3-Done (3)
+> [ 15.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [ 15.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [ 16.000000] (2:sleeper1@Tremblay) 1-Mid (2)
+> [ 16.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [ 17.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [ 17.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [ 17.000000] (2:sleeper1@Tremblay) 1-Done (2)
+> [ 18.000000] (1:sleeper3@Ruby) 1-Mid (4)
+> [ 18.000000] (1:sleeper3@Ruby) 3-Iter 2
+> [ 18.000000] (1:sleeper3@Ruby) 5-Iter 1
+> [ 18.000000] (2:sleeper1@Tremblay) 5-Mid (3)
+> [ 18.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [ 19.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [ 19.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [ 19.000000] (2:sleeper1@Tremblay) 5-Done (3)
+> [ 19.000000] (2:sleeper1@Tremblay) 3-Done (6)
+> [ 20.000000] (3:sleeper5@Java) 1-Mid (3)
+> [ 20.000000] (3:sleeper5@Java) 3-Iter 1
+> [ 20.000000] (2:sleeper1@Tremblay) 1-Mid (7)
+> [ 20.000000] (2:sleeper1@Tremblay) 3-Iter 3
+> [ 20.000000] (2:sleeper1@Tremblay) 5-Iter 2
+> [ 20.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [ 21.000000] (1:sleeper3@Ruby) 5-Mid (1)
+> [ 21.000000] (1:sleeper3@Ruby) 5-Done (1)
+> [ 21.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [ 21.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [ 22.000000] (2:sleeper1@Tremblay) 5-Mid (2)
+> [ 22.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [ 23.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [ 23.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [ 23.000000] (2:sleeper1@Tremblay) 5-Done (2)
+> [ 24.000000] (1:sleeper3@Ruby) 3-Mid (2)
+> [ 24.000000] (1:sleeper3@Ruby) 5-Iter 1
+> [ 24.000000] (2:sleeper1@Tremblay) 3-Mid (3)
+> [ 24.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [ 25.000000] (3:sleeper5@Java) 3-Mid (1)
+> [ 25.000000] (3:sleeper5@Java) 3-Done (1)
+> [ 25.000000] (3:sleeper5@Java) 1-Done (3)
+> [ 25.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [ 25.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [ 25.000000] (2:sleeper1@Tremblay) 3-Done (3)
+> [ 25.000000] (2:sleeper1@Tremblay) 1-Done (7)
+> [ 26.000000] (2:sleeper1@Tremblay) 5-Mid (8)
+> [ 26.000000] (2:sleeper1@Tremblay) 1-Iter 4
+> [ 26.000000] (2:sleeper1@Tremblay) 3-Iter 3
+> [ 26.000000] (2:sleeper1@Tremblay) 5-Iter 2
+> [ 26.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [ 27.000000] (1:sleeper3@Ruby) 5-Mid (1)
+> [ 27.000000] (1:sleeper3@Ruby) 5-Done (1)
+> [ 27.000000] (1:sleeper3@Ruby) 3-Done (2)
+> [ 27.000000] (1:sleeper3@Ruby) 1-Done (4)
+> [ 27.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [ 27.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [ 28.000000] (2:sleeper1@Tremblay) 5-Mid (2)
+> [ 28.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [ 29.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [ 29.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [ 29.000000] (2:sleeper1@Tremblay) 5-Done (2)
+> [ 30.000000] (3:sleeper5@Java) 5-Mid (4)
+> [ 30.000000] (3:sleeper5@Java) 1-Iter 2
+> [ 30.000000] (3:sleeper5@Java) 3-Iter 1
+> [ 30.000000] (1:sleeper3@Ruby) 5-Mid (5)
+> [ 30.000000] (1:sleeper3@Ruby) 1-Iter 2
+> [ 30.000000] (1:sleeper3@Ruby) 3-Iter 1
+> [ 30.000000] (2:sleeper1@Tremblay) 3-Mid (3)
+> [ 30.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [ 31.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [ 31.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [ 31.000000] (2:sleeper1@Tremblay) 3-Done (3)
+> [ 32.000000] (2:sleeper1@Tremblay) 1-Mid (4)
+> [ 32.000000] (2:sleeper1@Tremblay) 3-Iter 2
+> [ 32.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [ 33.000000] (1:sleeper3@Ruby) 3-Mid (1)
+> [ 33.000000] (1:sleeper3@Ruby) 3-Done (1)
+> [ 33.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [ 33.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [ 34.000000] (2:sleeper1@Tremblay) 3-Mid (2)
+> [ 34.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [ 35.000000] (3:sleeper5@Java) 3-Mid (1)
+> [ 35.000000] (3:sleeper5@Java) 3-Done (1)
+> [ 35.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [ 35.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [ 35.000000] (2:sleeper1@Tremblay) 3-Done (2)
+> [ 35.000000] (2:sleeper1@Tremblay) 1-Done (4)
+> [ 35.000000] (2:sleeper1@Tremblay) 5-Done (8)
+> [ 36.000000] (1:sleeper3@Ruby) 1-Mid (2)
+> [ 36.000000] (1:sleeper3@Ruby) 3-Iter 1
+> [ 36.000000] (2:sleeper1@Tremblay) 3-Mid (9)
+> [ 36.000000] (2:sleeper1@Tremblay) 5-Iter 4
+> [ 36.000000] (2:sleeper1@Tremblay) 1-Iter 3
+> [ 36.000000] (2:sleeper1@Tremblay) 3-Iter 2
+> [ 36.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [ 37.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [ 37.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [ 38.000000] (2:sleeper1@Tremblay) 3-Mid (2)
+> [ 38.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [ 39.000000] (1:sleeper3@Ruby) 3-Mid (1)
+> [ 39.000000] (1:sleeper3@Ruby) 3-Done (1)
+> [ 39.000000] (1:sleeper3@Ruby) 1-Done (2)
+> [ 39.000000] (1:sleeper3@Ruby) 5-Done (5)
+> [ 39.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [ 39.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [ 39.000000] (2:sleeper1@Tremblay) 3-Done (2)
+> [ 40.000000] (3:sleeper5@Java) 1-Mid (2)
+> [ 40.000000] (3:sleeper5@Java) 3-Iter 1
+> [ 40.000000] (2:sleeper1@Tremblay) 1-Mid (3)
+> [ 40.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [ 41.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [ 41.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [ 41.000000] (2:sleeper1@Tremblay) 1-Done (3)
+> [ 42.000000] (1:sleeper3@Ruby) 3-Mid (6)
+> [ 42.000000] (1:sleeper3@Ruby) 5-Iter 3
+> [ 42.000000] (1:sleeper3@Ruby) 1-Iter 2
+> [ 42.000000] (1:sleeper3@Ruby) 3-Iter 1
+> [ 42.000000] (2:sleeper1@Tremblay) 5-Mid (4)
+> [ 42.000000] (2:sleeper1@Tremblay) 1-Iter 2
+> [ 42.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [ 43.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [ 43.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [ 44.000000] (2:sleeper1@Tremblay) 1-Mid (2)
+> [ 44.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [ 45.000000] (3:sleeper5@Java) 3-Mid (1)
+> [ 45.000000] (3:sleeper5@Java) 3-Done (1)
+> [ 45.000000] (3:sleeper5@Java) 1-Done (2)
+> [ 45.000000] (3:sleeper5@Java) 5-Done (4)
+> [ 45.000000] (1:sleeper3@Ruby) 3-Mid (1)
+> [ 45.000000] (1:sleeper3@Ruby) 3-Done (1)
+> [ 45.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [ 45.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [ 45.000000] (2:sleeper1@Tremblay) 1-Done (2)
+> [ 45.000000] (2:sleeper1@Tremblay) 5-Done (4)
+> [ 45.000000] (2:sleeper1@Tremblay) 3-Done (9)
+> [ 46.000000] (2:sleeper1@Tremblay) 1-Mid (10)
+> [ 46.000000] (2:sleeper1@Tremblay) 3-Iter 5
+> [ 46.000000] (2:sleeper1@Tremblay) 5-Iter 4
+> [ 46.000000] (2:sleeper1@Tremblay) 1-Iter 3
+> [ 46.000000] (2:sleeper1@Tremblay) 3-Iter 2
+> [ 46.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [ 47.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [ 47.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [ 48.000000] (1:sleeper3@Ruby) 1-Mid (2)
+> [ 48.000000] (1:sleeper3@Ruby) 3-Iter 1
+> [ 48.000000] (2:sleeper1@Tremblay) 3-Mid (2)
+> [ 48.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [ 49.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [ 49.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [ 49.000000] (2:sleeper1@Tremblay) 3-Done (2)
+> [ 50.000000] (2:sleeper1@Tremblay) 1-Mid (3)
+> [ 50.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [ 51.000000] (1:sleeper3@Ruby) 3-Mid (1)
+> [ 51.000000] (1:sleeper3@Ruby) 3-Done (1)
+> [ 51.000000] (1:sleeper3@Ruby) 1-Done (2)
+> [ 51.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [ 51.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [ 51.000000] (2:sleeper1@Tremblay) 1-Done (3)
+> [ 52.000000] (2:sleeper1@Tremblay) 5-Mid (4)
+> [ 52.000000] (2:sleeper1@Tremblay) 1-Iter 2
+> [ 52.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [ 53.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [ 53.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [ 54.000000] (1:sleeper3@Ruby) 5-Mid (3)
+> [ 54.000000] (1:sleeper3@Ruby) 1-Iter 1
+> [ 54.000000] (2:sleeper1@Tremblay) 1-Mid (2)
+> [ 54.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [ 55.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [ 55.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [ 55.000000] (2:sleeper1@Tremblay) 1-Done (2)
+> [ 55.000000] (2:sleeper1@Tremblay) 5-Done (4)
+> [ 56.000000] (2:sleeper1@Tremblay) 3-Mid (5)
+> [ 56.000000] (2:sleeper1@Tremblay) 5-Iter 2
+> [ 56.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [ 57.000000] (1:sleeper3@Ruby) 1-Mid (1)
+> [ 57.000000] (1:sleeper3@Ruby) 1-Done (1)
+> [ 57.000000] (1:sleeper3@Ruby) 5-Done (3)
+> [ 57.000000] (1:sleeper3@Ruby) 3-Done (6)
+> [ 57.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [ 57.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [ 58.000000] (2:sleeper1@Tremblay) 5-Mid (2)
+> [ 58.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [ 59.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [ 59.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [ 59.000000] (2:sleeper1@Tremblay) 5-Done (2)
+> [ 59.000000] (2:sleeper1@Tremblay) 3-Done (5)
+> [ 59.000000] (2:sleeper1@Tremblay) 1-Done (10)
+> [ 60.000000] (2:sleeper1@Tremblay) 5-Mid (11)
+> [ 60.000000] (2:sleeper1@Tremblay) 1-Iter 5
+> [ 60.000000] (2:sleeper1@Tremblay) 3-Iter 4
+> [ 60.000000] (2:sleeper1@Tremblay) 5-Iter 3
+> [ 60.000000] (2:sleeper1@Tremblay) 1-Iter 2
+> [ 60.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [ 61.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [ 61.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [ 62.000000] (2:sleeper1@Tremblay) 1-Mid (2)
+> [ 62.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [ 63.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [ 63.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [ 63.000000] (2:sleeper1@Tremblay) 1-Done (2)
+> [ 64.000000] (2:sleeper1@Tremblay) 5-Mid (3)
+> [ 64.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [ 65.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [ 65.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [ 65.000000] (2:sleeper1@Tremblay) 5-Done (3)
+> [ 66.000000] (2:sleeper1@Tremblay) 3-Mid (4)
+> [ 66.000000] (2:sleeper1@Tremblay) 5-Iter 2
+> [ 66.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [ 67.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [ 67.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [ 68.000000] (2:sleeper1@Tremblay) 5-Mid (2)
+> [ 68.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [ 69.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [ 69.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [ 69.000000] (2:sleeper1@Tremblay) 5-Done (2)
+> [ 69.000000] (2:sleeper1@Tremblay) 3-Done (4)
+> [ 70.000000] (2:sleeper1@Tremblay) 1-Mid (5)
+> [ 70.000000] (2:sleeper1@Tremblay) 3-Iter 2
+> [ 70.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [ 71.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [ 71.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [ 72.000000] (2:sleeper1@Tremblay) 3-Mid (2)
+> [ 72.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [ 73.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [ 73.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [ 73.000000] (2:sleeper1@Tremblay) 3-Done (2)
+> [ 73.000000] (2:sleeper1@Tremblay) 1-Done (5)
+> [ 73.000000] (2:sleeper1@Tremblay) 5-Done (11)
+> [ 74.000000] (2:sleeper1@Tremblay) 3-Mid (12)
+> [ 74.000000] (2:sleeper1@Tremblay) 5-Iter 6
+> [ 74.000000] (2:sleeper1@Tremblay) 1-Iter 5
+> [ 74.000000] (2:sleeper1@Tremblay) 3-Iter 4
+> [ 74.000000] (2:sleeper1@Tremblay) 5-Iter 3
+> [ 74.000000] (2:sleeper1@Tremblay) 1-Iter 2
+> [ 74.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [ 75.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [ 75.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [ 76.000000] (2:sleeper1@Tremblay) 1-Mid (2)
+> [ 76.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [ 77.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [ 77.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [ 77.000000] (2:sleeper1@Tremblay) 1-Done (2)
+> [ 78.000000] (2:sleeper1@Tremblay) 5-Mid (3)
+> [ 78.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [ 79.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [ 79.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [ 79.000000] (2:sleeper1@Tremblay) 5-Done (3)
+> [ 80.000000] (2:sleeper1@Tremblay) 3-Mid (4)
+> [ 80.000000] (2:sleeper1@Tremblay) 5-Iter 2
+> [ 80.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [ 81.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [ 81.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [ 82.000000] (2:sleeper1@Tremblay) 5-Mid (2)
+> [ 82.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [ 83.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [ 83.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [ 83.000000] (2:sleeper1@Tremblay) 5-Done (2)
+> [ 83.000000] (2:sleeper1@Tremblay) 3-Done (4)
+> [ 84.000000] (2:sleeper1@Tremblay) 1-Mid (5)
+> [ 84.000000] (2:sleeper1@Tremblay) 3-Iter 2
+> [ 84.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [ 85.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [ 85.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [ 86.000000] (2:sleeper1@Tremblay) 3-Mid (2)
+> [ 86.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [ 87.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [ 87.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [ 87.000000] (2:sleeper1@Tremblay) 3-Done (2)
+> [ 87.000000] (2:sleeper1@Tremblay) 1-Done (5)
+> [ 88.000000] (2:sleeper1@Tremblay) 5-Mid (6)
+> [ 88.000000] (2:sleeper1@Tremblay) 1-Iter 3
+> [ 88.000000] (2:sleeper1@Tremblay) 3-Iter 2
+> [ 88.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [ 89.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [ 89.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [ 90.000000] (2:sleeper1@Tremblay) 3-Mid (2)
+> [ 90.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [ 91.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [ 91.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [ 91.000000] (2:sleeper1@Tremblay) 3-Done (2)
+> [ 92.000000] (2:sleeper1@Tremblay) 1-Mid (3)
+> [ 92.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [ 93.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [ 93.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [ 93.000000] (2:sleeper1@Tremblay) 1-Done (3)
+> [ 93.000000] (2:sleeper1@Tremblay) 5-Done (6)
+> [ 93.000000] (2:sleeper1@Tremblay) 3-Done (12)
+> [ 94.000000] (2:sleeper1@Tremblay) 1-Mid (13)
+> [ 94.000000] (2:sleeper1@Tremblay) 3-Iter 6
+> [ 94.000000] (2:sleeper1@Tremblay) 5-Iter 5
+> [ 94.000000] (2:sleeper1@Tremblay) 1-Iter 4
+> [ 94.000000] (2:sleeper1@Tremblay) 3-Iter 3
+> [ 94.000000] (2:sleeper1@Tremblay) 5-Iter 2
+> [ 94.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [ 95.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [ 95.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [ 96.000000] (2:sleeper1@Tremblay) 5-Mid (2)
+> [ 96.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [ 97.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [ 97.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [ 97.000000] (2:sleeper1@Tremblay) 5-Done (2)
+> [ 98.000000] (2:sleeper1@Tremblay) 3-Mid (3)
+> [ 98.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [ 99.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [ 99.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [ 99.000000] (2:sleeper1@Tremblay) 3-Done (3)
+> [100.000000] (2:sleeper1@Tremblay) 1-Mid (4)
+> [100.000000] (2:sleeper1@Tremblay) 3-Iter 2
+> [100.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [101.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [101.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [102.000000] (2:sleeper1@Tremblay) 3-Mid (2)
+> [102.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [103.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [103.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [103.000000] (2:sleeper1@Tremblay) 3-Done (2)
+> [103.000000] (2:sleeper1@Tremblay) 1-Done (4)
+> [104.000000] (2:sleeper1@Tremblay) 5-Mid (5)
+> [104.000000] (2:sleeper1@Tremblay) 1-Iter 2
+> [104.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [105.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [105.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [106.000000] (2:sleeper1@Tremblay) 1-Mid (2)
+> [106.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [107.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [107.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [107.000000] (2:sleeper1@Tremblay) 1-Done (2)
+> [107.000000] (2:sleeper1@Tremblay) 5-Done (5)
+> [108.000000] (2:sleeper1@Tremblay) 3-Mid (6)
+> [108.000000] (2:sleeper1@Tremblay) 5-Iter 3
+> [108.000000] (2:sleeper1@Tremblay) 1-Iter 2
+> [108.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [109.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [109.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [110.000000] (2:sleeper1@Tremblay) 1-Mid (2)
+> [110.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [111.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [111.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [111.000000] (2:sleeper1@Tremblay) 1-Done (2)
+> [112.000000] (2:sleeper1@Tremblay) 5-Mid (3)
+> [112.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [113.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [113.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [113.000000] (2:sleeper1@Tremblay) 5-Done (3)
+> [113.000000] (2:sleeper1@Tremblay) 3-Done (6)
+> [113.000000] (2:sleeper1@Tremblay) 1-Done (13)
+> [114.000000] (2:sleeper1@Tremblay) 5-Mid (14)
+> [114.000000] (2:sleeper1@Tremblay) 1-Iter 7
+> [114.000000] (2:sleeper1@Tremblay) 3-Iter 6
+> [114.000000] (2:sleeper1@Tremblay) 5-Iter 5
+> [114.000000] (2:sleeper1@Tremblay) 1-Iter 4
+> [114.000000] (2:sleeper1@Tremblay) 3-Iter 3
+> [114.000000] (2:sleeper1@Tremblay) 5-Iter 2
+> [114.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [115.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [115.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [116.000000] (2:sleeper1@Tremblay) 5-Mid (2)
+> [116.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [117.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [117.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [117.000000] (2:sleeper1@Tremblay) 5-Done (2)
+> [118.000000] (2:sleeper1@Tremblay) 3-Mid (3)
+> [118.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [119.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [119.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [119.000000] (2:sleeper1@Tremblay) 3-Done (3)
+> [120.000000] (2:sleeper1@Tremblay) 1-Mid (4)
+> [120.000000] (2:sleeper1@Tremblay) 3-Iter 2
+> [120.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [121.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [121.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [122.000000] (2:sleeper1@Tremblay) 3-Mid (2)
+> [122.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [123.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [123.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [123.000000] (2:sleeper1@Tremblay) 3-Done (2)
+> [123.000000] (2:sleeper1@Tremblay) 1-Done (4)
+> [124.000000] (2:sleeper1@Tremblay) 5-Mid (5)
+> [124.000000] (2:sleeper1@Tremblay) 1-Iter 2
+> [124.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [125.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [125.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [126.000000] (2:sleeper1@Tremblay) 1-Mid (2)
+> [126.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [127.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [127.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [127.000000] (2:sleeper1@Tremblay) 1-Done (2)
+> [127.000000] (2:sleeper1@Tremblay) 5-Done (5)
+> [128.000000] (2:sleeper1@Tremblay) 3-Mid (6)
+> [128.000000] (2:sleeper1@Tremblay) 5-Iter 3
+> [128.000000] (2:sleeper1@Tremblay) 1-Iter 2
+> [128.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [129.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [129.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [130.000000] (2:sleeper1@Tremblay) 1-Mid (2)
+> [130.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [131.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [131.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [131.000000] (2:sleeper1@Tremblay) 1-Done (2)
+> [132.000000] (2:sleeper1@Tremblay) 5-Mid (3)
+> [132.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [133.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [133.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [133.000000] (2:sleeper1@Tremblay) 5-Done (3)
+> [133.000000] (2:sleeper1@Tremblay) 3-Done (6)
+> [134.000000] (2:sleeper1@Tremblay) 1-Mid (7)
+> [134.000000] (2:sleeper1@Tremblay) 3-Iter 3
+> [134.000000] (2:sleeper1@Tremblay) 5-Iter 2
+> [134.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [135.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [135.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [136.000000] (2:sleeper1@Tremblay) 5-Mid (2)
+> [136.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [137.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [137.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [137.000000] (2:sleeper1@Tremblay) 5-Done (2)
+> [138.000000] (2:sleeper1@Tremblay) 3-Mid (3)
+> [138.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [139.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [139.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [139.000000] (2:sleeper1@Tremblay) 3-Done (3)
+> [139.000000] (2:sleeper1@Tremblay) 1-Done (7)
+> [139.000000] (2:sleeper1@Tremblay) 5-Done (14)
+> [140.000000] (2:sleeper1@Tremblay) 3-Mid (15)
+> [140.000000] (2:sleeper1@Tremblay) 5-Iter 7
+> [140.000000] (2:sleeper1@Tremblay) 1-Iter 6
+> [140.000000] (2:sleeper1@Tremblay) 3-Iter 5
+> [140.000000] (2:sleeper1@Tremblay) 5-Iter 4
+> [140.000000] (2:sleeper1@Tremblay) 1-Iter 3
+> [140.000000] (2:sleeper1@Tremblay) 3-Iter 2
+> [140.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [141.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [141.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [142.000000] (2:sleeper1@Tremblay) 3-Mid (2)
+> [142.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [143.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [143.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [143.000000] (2:sleeper1@Tremblay) 3-Done (2)
+> [144.000000] (2:sleeper1@Tremblay) 1-Mid (3)
+> [144.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [145.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [145.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [145.000000] (2:sleeper1@Tremblay) 1-Done (3)
+> [146.000000] (2:sleeper1@Tremblay) 5-Mid (4)
+> [146.000000] (2:sleeper1@Tremblay) 1-Iter 2
+> [146.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [147.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [147.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [148.000000] (2:sleeper1@Tremblay) 1-Mid (2)
+> [148.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [149.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [149.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [149.000000] (2:sleeper1@Tremblay) 1-Done (2)
+> [149.000000] (2:sleeper1@Tremblay) 5-Done (4)
+> [150.000000] (2:sleeper1@Tremblay) 3-Mid (5)
+> [150.000000] (2:sleeper1@Tremblay) 5-Iter 2
+> [150.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [151.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [151.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [152.000000] (2:sleeper1@Tremblay) 5-Mid (2)
+> [152.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [153.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [153.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [153.000000] (2:sleeper1@Tremblay) 5-Done (2)
+> [153.000000] (2:sleeper1@Tremblay) 3-Done (5)
+> [154.000000] (2:sleeper1@Tremblay) 1-Mid (6)
+> [154.000000] (2:sleeper1@Tremblay) 3-Iter 3
+> [154.000000] (2:sleeper1@Tremblay) 5-Iter 2
+> [154.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [155.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [155.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [156.000000] (2:sleeper1@Tremblay) 5-Mid (2)
+> [156.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [157.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [157.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [157.000000] (2:sleeper1@Tremblay) 5-Done (2)
+> [158.000000] (2:sleeper1@Tremblay) 3-Mid (3)
+> [158.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [159.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [159.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [159.000000] (2:sleeper1@Tremblay) 3-Done (3)
+> [159.000000] (2:sleeper1@Tremblay) 1-Done (6)
+> [160.000000] (2:sleeper1@Tremblay) 5-Mid (7)
+> [160.000000] (2:sleeper1@Tremblay) 1-Iter 3
+> [160.000000] (2:sleeper1@Tremblay) 3-Iter 2
+> [160.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [161.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [161.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [162.000000] (2:sleeper1@Tremblay) 3-Mid (2)
+> [162.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [163.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [163.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [163.000000] (2:sleeper1@Tremblay) 3-Done (2)
+> [164.000000] (2:sleeper1@Tremblay) 1-Mid (3)
+> [164.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [165.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [165.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [165.000000] (2:sleeper1@Tremblay) 1-Done (3)
+> [165.000000] (2:sleeper1@Tremblay) 5-Done (7)
+> [165.000000] (2:sleeper1@Tremblay) 3-Done (15)
+> [166.000000] (2:sleeper1@Tremblay) 1-Mid (16)
+> [166.000000] (2:sleeper1@Tremblay) 3-Iter 8
+> [166.000000] (2:sleeper1@Tremblay) 5-Iter 7
+> [166.000000] (2:sleeper1@Tremblay) 1-Iter 6
+> [166.000000] (2:sleeper1@Tremblay) 3-Iter 5
+> [166.000000] (2:sleeper1@Tremblay) 5-Iter 4
+> [166.000000] (2:sleeper1@Tremblay) 1-Iter 3
+> [166.000000] (2:sleeper1@Tremblay) 3-Iter 2
+> [166.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [167.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [167.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [168.000000] (2:sleeper1@Tremblay) 3-Mid (2)
+> [168.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [169.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [169.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [169.000000] (2:sleeper1@Tremblay) 3-Done (2)
+> [170.000000] (2:sleeper1@Tremblay) 1-Mid (3)
+> [170.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [171.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [171.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [171.000000] (2:sleeper1@Tremblay) 1-Done (3)
+> [172.000000] (2:sleeper1@Tremblay) 5-Mid (4)
+> [172.000000] (2:sleeper1@Tremblay) 1-Iter 2
+> [172.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [173.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [173.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [174.000000] (2:sleeper1@Tremblay) 1-Mid (2)
+> [174.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [175.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [175.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [175.000000] (2:sleeper1@Tremblay) 1-Done (2)
+> [175.000000] (2:sleeper1@Tremblay) 5-Done (4)
+> [176.000000] (2:sleeper1@Tremblay) 3-Mid (5)
+> [176.000000] (2:sleeper1@Tremblay) 5-Iter 2
+> [176.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [177.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [177.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [178.000000] (2:sleeper1@Tremblay) 5-Mid (2)
+> [178.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [179.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [179.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [179.000000] (2:sleeper1@Tremblay) 5-Done (2)
+> [179.000000] (2:sleeper1@Tremblay) 3-Done (5)
+> [180.000000] (2:sleeper1@Tremblay) 1-Mid (6)
+> [180.000000] (2:sleeper1@Tremblay) 3-Iter 3
+> [180.000000] (2:sleeper1@Tremblay) 5-Iter 2
+> [180.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [181.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [181.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [182.000000] (2:sleeper1@Tremblay) 5-Mid (2)
+> [182.000000] (2:sleeper1@Tremblay) 1-Iter 1
+> [183.000000] (2:sleeper1@Tremblay) 1-Mid (1)
+> [183.000000] (2:sleeper1@Tremblay) 1-Done (1)
+> [183.000000] (2:sleeper1@Tremblay) 5-Done (2)
+> [184.000000] (2:sleeper1@Tremblay) 3-Mid (3)
+> [184.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [185.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [185.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [185.000000] (2:sleeper1@Tremblay) 3-Done (3)
+> [185.000000] (2:sleeper1@Tremblay) 1-Done (6)
+> [186.000000] (2:sleeper1@Tremblay) 5-Mid (7)
+> [186.000000] (2:sleeper1@Tremblay) 1-Iter 3
+> [186.000000] (2:sleeper1@Tremblay) 3-Iter 2
+> [186.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [187.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [187.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [188.000000] (2:sleeper1@Tremblay) 3-Mid (2)
+> [188.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [189.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [189.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [189.000000] (2:sleeper1@Tremblay) 3-Done (2)
+> [190.000000] (2:sleeper1@Tremblay) 1-Mid (3)
+> [190.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [191.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [191.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [191.000000] (2:sleeper1@Tremblay) 1-Done (3)
+> [191.000000] (2:sleeper1@Tremblay) 5-Done (7)
+> [192.000000] (2:sleeper1@Tremblay) 3-Mid (8)
+> [192.000000] (2:sleeper1@Tremblay) 5-Iter 4
+> [192.000000] (2:sleeper1@Tremblay) 1-Iter 3
+> [192.000000] (2:sleeper1@Tremblay) 3-Iter 2
+> [192.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [193.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [193.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [194.000000] (2:sleeper1@Tremblay) 3-Mid (2)
+> [194.000000] (2:sleeper1@Tremblay) 5-Iter 1
+> [195.000000] (2:sleeper1@Tremblay) 5-Mid (1)
+> [195.000000] (2:sleeper1@Tremblay) 5-Done (1)
+> [195.000000] (2:sleeper1@Tremblay) 3-Done (2)
+> [196.000000] (2:sleeper1@Tremblay) 1-Mid (3)
+> [196.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [197.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [197.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [197.000000] (2:sleeper1@Tremblay) 1-Done (3)
+> [198.000000] (2:sleeper1@Tremblay) 5-Mid (4)
+> [198.000000] (2:sleeper1@Tremblay) 1-Iter 2
+> [198.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [199.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [199.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [200.000000] (2:sleeper1@Tremblay) 1-Mid (2)
+> [200.000000] (2:sleeper1@Tremblay) 3-Iter 1
+> [201.000000] (2:sleeper1@Tremblay) 3-Mid (1)
+> [201.000000] (2:sleeper1@Tremblay) 3-Done (1)
+> [201.000000] (2:sleeper1@Tremblay) 1-Done (2)
+> [201.000000] (2:sleeper1@Tremblay) 5-Done (4)
+> [201.000000] (2:sleeper1@Tremblay) 3-Done (8)
+> [201.000000] (2:sleeper1@Tremblay) 1-Done (16)
+> [201.000000] (0:maestro@) Finalize!
--- /dev/null
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
+<platform version="4.1">
+ <actor host="Ruby" function="sleeper3"/>
+ <actor host="Tremblay" function="sleeper1"/>
+ <actor host="Java" function="sleeper5"/>
+</platform>
endforeach()
## Add the tests.
-## Some need to be run with all factories, some need not tesh to run
+## Some need to be run with all factories, some don't need tesh to run
foreach(x actor actor-autorestart
activity-lifecycle wait-any-for
- cloud-interrupt-migration concurrent_rw) # TODO: actor-autorestart is disabled for now
+ cloud-interrupt-migration concurrent_rw)
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
ADD_TESH_FACTORIES(tesh-s4u-${x} "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/s4u/${x} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x} --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_BINARY_DIR}/teshsuite/s4u/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x}/${x}.tesh)
endforeach()
-/* 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
/* Random number initialization */
srand( (int) (xbt_os_time()*1000) );
- do {
- i = rand()%host_count;
- j = rand()%host_count;
- } while(i==j);
+ /* Take random i and j, with i != j */
+ xbt_assert(host_count > 1);
+ i = rand() % host_count;
+ j = rand() % (host_count - 1);
+ if (j >= 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. */
#include <xbt/future.hpp>
-#include <simgrid/engine.h>
#include <simgrid/kernel/future.hpp>
+#include <simgrid/s4u/Actor.hpp>
+#include <simgrid/s4u/Engine.hpp>
#include <simgrid/simix.hpp>
#include <simgrid/simix/blocking_simcall.hpp>
#include <xbt/log.h>
int main(int argc, char* argv[])
{
- SIMIX_global_init(&argc, argv);
+ simgrid::s4u::Engine e(&argc, argv);
xbt_assert(argc == 2, "Usage: %s platform.xml\n", argv[0]);
- simgrid_load_platform(argv[1]);
- simcall_process_create("master", example::master, NULL, sg_host_by_name("Tremblay"), NULL);
- SIMIX_run();
+ e.load_platform(argv[1]);
+ simgrid::s4u::Actor::create("master", e.host_by_name("Tremblay"), example::master);
+ e.run();
return 0;
}
/* 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. */
-#include "simgrid/simix.hpp"
+#include "simgrid/s4u/Actor.hpp"
+#include "simgrid/s4u/Engine.hpp"
#include "xbt/log.h"
-#include <simgrid/engine.h>
#include <string>
int main(int argc, char* argv[])
{
- SIMIX_global_init(&argc, argv);
+ simgrid::s4u::Engine e(&argc, argv);
xbt_assert(argc == 2, "Usage: %s platform.xml\n", argv[0]);
- simgrid_load_platform(argv[1]);
- simcall_process_create("master", master, NULL, sg_host_by_name("Tremblay"), NULL);
- SIMIX_run();
+ e.load_platform(argv[1]);
+ simgrid::s4u::Actor::create("master", e.host_by_name("Tremblay"), master);
+ e.run();
return 0;
}
foreach(x coll-allgather coll-allgatherv coll-allreduce coll-alltoall coll-alltoallv coll-barrier coll-bcast
coll-gather coll-reduce coll-reduce-scatter coll-scatter macro-sample pt2pt-dsend pt2pt-pingpong
type-hvector type-indexed type-struct type-vector bug-17132 gh-139 timers privatization
- io-simple io-simple-at io-all io-all-at io-shared io-ordered)
+ io-simple io-simple-at io-all io-all-at io-shared io-ordered topo-cart-sub)
add_executable (${x} EXCLUDE_FROM_ALL ${x}/${x}.c)
target_link_libraries(${x} simgrid)
set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
coll-gather coll-reduce coll-reduce-scatter coll-scatter macro-sample pt2pt-dsend pt2pt-pingpong
type-hvector type-indexed type-struct type-vector bug-17132 gh-139 timers privatization
macro-shared auto-shared macro-partial-shared macro-partial-shared-communication
- io-simple io-simple-at io-all io-all-at io-shared io-ordered)
+ io-simple io-simple-at io-all io-all-at io-shared io-ordered topo-cart-sub)
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.c)
endforeach()
foreach(x coll-allgather coll-allgatherv coll-allreduce coll-alltoall coll-alltoallv coll-barrier coll-bcast
coll-gather coll-reduce coll-reduce-scatter coll-scatter macro-sample pt2pt-dsend pt2pt-pingpong
- type-hvector type-indexed type-struct type-vector bug-17132 timers io-simple io-simple-at io-all io-all-at io-shared io-ordered)
+ type-hvector type-indexed type-struct type-vector bug-17132 timers io-simple io-simple-at io-all io-all-at io-shared io-ordered topo-cart-sub)
ADD_TESH_FACTORIES(tesh-smpi-${x} "thread;ucontext;raw;boost" --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/smpi/${x} --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/${x} ${x}.tesh)
endforeach()
-/* 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
p Test compute
! output sort
! timeout 5
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/auto-shared --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/auto-shared-malloc-thresh:8
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/auto-shared --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/auto-shared-malloc-thresh:8
> [0] After change, the value in the shared buffer is: 16053117601147974045
> [0] The value in the shared buffer is: 4
> [1] After change, the value in the shared buffer is: 16053117601147974045
! output sort
! timeout 5
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/auto-shared --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/shared-malloc:local --cfg=smpi/auto-shared-malloc-thresh:8
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/auto-shared --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/shared-malloc:local --cfg=smpi/auto-shared-malloc-thresh:8
> [0] After change, the value in the shared buffer is: 16053117601147974045
> [0] The value in the shared buffer is: 4
> [1] After change, the value in the shared buffer is: 16053117601147974045
-/* 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
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -np 16 -platform ../../../examples/platforms/small_platform.xml -hostfile ../hostfile ${bindir:=.}/bug-17132 --cfg=smpi/simulate-computation:no --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -np 16 -platform ../../../examples/platforms/small_platform.xml -hostfile ../hostfile ${bindir:=.}/bug-17132 --cfg=smpi/simulate-computation:no --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> You requested to use 16 ranks, but there is only 5 processes in your hostfile...
> Walltime = 0.476791
-/* 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. */
! output sort
p Test allgather
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-allgather --log=smpi_kernel.thres:warning --log=smpi_coll.thres:error --log=smpi_pmpi.thres:error --log=smpi_mpi.thres:error
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-allgather --log=smpi_config.thres:warning --log=smpi_coll.thres:error --log=smpi_pmpi.thres:error --log=smpi_mpi.thres:error
> [rank 0] -> Tremblay
> [rank 1] -> Tremblay
> [rank 2] -> Tremblay
-/* 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(status!=MPI_ERR_BUFFER)
printf("MPI_Allgatherv did not return MPI_ERR_BUFFER for empty recvbuf\n");
status = MPI_Allgatherv(sb, recv_counts[rank], MPI_INT, rb, NULL, recv_disps, MPI_INT, MPI_COMM_WORLD);
- if(status!=MPI_ERR_ARG)
- printf("MPI_Allgatherv did not return MPI_ERR_ARG for NULL recvcounts\n");
+ if(status!=MPI_ERR_COUNT)
+ printf("MPI_Allgatherv did not return MPI_ERR_COUNT for NULL recvcounts\n");
status = MPI_Allgatherv(sb, recv_counts[rank], MPI_INT, rb, recv_counts, NULL, MPI_INT, MPI_COMM_WORLD);
if(status!=MPI_ERR_ARG)
printf("MPI_Allgatherv did not return MPI_ERR_ARG for NULL recvdisps\n");
! output sort
p Test allgatherv
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-allgatherv --log=smpi_kernel.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-allgatherv --log=smpi_config.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error --log=smpi_pmpi.thres:error
> [rank 0] -> Tremblay
> [rank 1] -> Tremblay
> [rank 2] -> Tremblay
p Test allreduce
! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-allreduce --log=smpi_kernel.thres:warning --log=smpi_coll.thres:error --cfg=smpi/allreduce:automatic --cfg=smpi/async-small-thresh:65536 --cfg=smpi/send-is-detached-thresh:128000 --cfg=smpi/simulate-computation:no "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --log=smpi_mpi.thres:error
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-allreduce --log=smpi_config.thres:warning --log=smpi_coll.thres:error --cfg=smpi/allreduce:automatic --cfg=smpi/async-small-thresh:65536 --cfg=smpi/send-is-detached-thresh:128000 --cfg=smpi/simulate-computation:no "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --log=smpi_mpi.thres:error --log=smpi_pmpi.thres:error
> [rank 0] -> Tremblay
> [rank 1] -> Tremblay
> [rank 2] -> Tremblay
! timeout 20
p Test allreduce
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-allreduce 300000 --log=smpi_kernel.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-allreduce 300000 --log=smpi_config.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error --log=smpi_pmpi.thres:error
> [rank 0] -> Tremblay
> [rank 1] -> Jupiter
> [rank 2] -> Fafard
-/* 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
printf("MPI_Allreduce did not return MPI_ERR_TYPE for MPI_DATATYPE_NULL type\n");
status = MPI_Allreduce(sb, rb, size, MPI_UNSIGNED_LONG_LONG, MPI_OP_NULL, MPI_COMM_WORLD);
if(status!=MPI_ERR_OP)
- printf("MPI_Allreduce did not return MPI_ERR_COMM for MPI_OP_NULL op\n");
+ printf("MPI_Allreduce did not return MPI_ERR_OP for MPI_OP_NULL op\n");
status = MPI_Allreduce(sb, rb, size, MPI_UNSIGNED_LONG_LONG, MPI_SUM, MPI_COMM_NULL);
if(status!=MPI_ERR_COMM)
printf("MPI_Allreduce did not return MPI_ERR_COMM for MPI_COMM_NULL comm\n");
! output sort
p Test allreduce
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-allreduce --log=smpi_kernel.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-allreduce --log=smpi_config.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error --log=smpi_pmpi.thres:error
> [rank 0] -> Tremblay
> [rank 1] -> Tremblay
> [rank 2] -> Tremblay
! output sort
p Test classic - backbone
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ${bindir}/../hostfile_cluster -platform ${platfdir:=.}/cluster_backbone.xml -np 12 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-alltoall -q --log=smpi_kernel.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ${bindir}/../hostfile_cluster -platform ${platfdir:=.}/cluster_backbone.xml -np 12 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-alltoall -q --log=smpi_config.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error --log=smpi_pmpi.thres:error
> [rank 0] -> node-0.simgrid.org
> [rank 1] -> node-1.simgrid.org
> [rank 2] -> node-2.simgrid.org
! output sort
p Test separate clusters
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -platform ../../../examples/platforms/cluster_multi.xml -np 12 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-alltoall -q --log=smpi_kernel.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -platform ../../../examples/platforms/cluster_multi.xml -np 12 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-alltoall -q --log=smpi_config.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error --log=smpi_pmpi.thres:error
> [rank 0] -> node-0.1core.org
> [rank 1] -> node-1.1core.org
> [rank 2] -> node-2.1core.org
! output sort
p Test torus
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_cluster -platform ../../../examples/platforms/cluster_torus.xml -np 12 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-alltoall -q --log=smpi_kernel.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_cluster -platform ../../../examples/platforms/cluster_torus.xml -np 12 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-alltoall -q --log=smpi_config.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error --log=smpi_pmpi.thres:error
> [rank 0] -> node-0.simgrid.org
> [rank 1] -> node-1.simgrid.org
> [rank 2] -> node-2.simgrid.org
! output sort
p Test fat tree
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_cluster -platform ../../../examples/platforms/cluster_fat_tree.xml -np 12 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-alltoall -q --log=smpi_kernel.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_cluster -platform ../../../examples/platforms/cluster_fat_tree.xml -np 12 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-alltoall -q --log=smpi_config.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error --log=smpi_pmpi.thres:error
> [rank 0] -> node-0.simgrid.org
> [rank 1] -> node-1.simgrid.org
> [rank 2] -> node-2.simgrid.org
! output sort
p Test fat tree IB
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_cluster -platform ../../../examples/platforms/cluster_fat_tree.xml -np 12 --cfg=network/model:IB --log=xbt_cfg.thres:critical ${bindir:=.}/coll-alltoall -q --log=smpi_kernel.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_cluster -platform ../../../examples/platforms/cluster_fat_tree.xml -np 12 --cfg=network/model:IB --log=xbt_cfg.thres:critical ${bindir:=.}/coll-alltoall -q --log=smpi_config.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error --log=smpi_pmpi.thres:error
> [rank 0] -> node-0.simgrid.org
> [rank 1] -> node-1.simgrid.org
> [rank 2] -> node-2.simgrid.org
! output sort
p Test Dragonfly
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_cluster -platform ../../../examples/platforms/cluster_dragonfly.xml -np 12 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-alltoall -q --log=smpi_kernel.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_cluster -platform ../../../examples/platforms/cluster_dragonfly.xml -np 12 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-alltoall -q --log=smpi_config.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error --log=smpi_pmpi.thres:error
> [rank 0] -> node-0.simgrid.org
> [rank 1] -> node-1.simgrid.org
> [rank 2] -> node-2.simgrid.org
-/* 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
! output sort
p Test all to all
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ${bindir:=.}/../hostfile_coll -platform ${platfdir}/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-alltoall -q --log=smpi_kernel.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ${bindir:=.}/../hostfile_coll -platform ${platfdir}/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-alltoall -q --log=smpi_config.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error --log=smpi_pmpi.thres:error
> [rank 0] -> Tremblay
> [rank 1] -> Tremblay
> [rank 2] -> Tremblay
-/* 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
if(status!=MPI_ERR_BUFFER)
printf("MPI_Alltoallv did not return MPI_ERR_BUFFER for empty sendbuf\n");
status = MPI_Alltoallv(sbuf, NULL, sdispls, MPI_INT, rbuf, recvcounts, rdispls, MPI_INT, MPI_COMM_WORLD);
- if(status!=MPI_ERR_ARG)
- printf("MPI_Alltoallv did not return MPI_ERR_ARG for NULL sendcounts\n");
+ if(status!=MPI_ERR_COUNT)
+ printf("MPI_Alltoallv did not return MPI_ERR_COUNT for NULL sendcounts\n");
status = MPI_Alltoallv(sbuf, sendcounts, NULL, MPI_INT, rbuf, recvcounts, rdispls, MPI_INT, MPI_COMM_WORLD);
if(status!=MPI_ERR_ARG)
printf("MPI_Alltoallv did not return MPI_ERR_ARG for NULL senddispl\n");
status = MPI_Alltoallv(sbuf, sendcounts, sdispls, MPI_DATATYPE_NULL, rbuf, recvcounts, rdispls, MPI_INT, MPI_COMM_WORLD);
if(status!=MPI_ERR_TYPE)
printf("MPI_Alltoallv did not return MPI_ERR_TYPE for MPI_DATATYPE_NULL sendtype\n");
- status = MPI_Alltoallv(sbuf, sendcounts, sdispls, MPI_INT, NULL, recvcounts, rdispls, MPI_INT, MPI_COMM_WORLD);
+ if (rank == 0)//if total recvcounts == 0 the call is not illegal, so be sure to fail for rank 0 to avoid deadlocks
+ status = MPI_Alltoallv(NULL, sendcounts, sdispls, MPI_INT, NULL, recvcounts, rdispls, MPI_INT, MPI_COMM_WORLD);
+ else
+ status = MPI_Alltoallv(sbuf, sendcounts, sdispls, MPI_INT, NULL, recvcounts, rdispls, MPI_INT, MPI_COMM_WORLD);
if(status!=MPI_ERR_BUFFER)
printf("MPI_Alltoallv did not return MPI_ERR_BUFFER for empty recvbuf\n");
status = MPI_Alltoallv(sbuf, sendcounts, sdispls, MPI_INT, rbuf, NULL, rdispls, MPI_INT, MPI_COMM_WORLD);
- if(status!=MPI_ERR_ARG)
- printf("MPI_Alltoallv did not return MPI_ERR_ARG for NULL recvcounts\n");
+ if(status!=MPI_ERR_COUNT)
+ printf("MPI_Alltoallv did not return MPI_ERR_COUNT for NULL recvcounts\n");
status = MPI_Alltoallv(sbuf, sendcounts, sdispls, MPI_INT, rbuf, recvcounts, NULL, MPI_INT, MPI_COMM_WORLD);
if(status!=MPI_ERR_ARG)
printf("MPI_Alltoallv did not return MPI_ERR_ARG for NULL recvdispl\n");
! output sort
p Test all to all
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-alltoallv --log=smpi_kernel.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-alltoallv --log=smpi_config.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error --log=smpi_pmpi.thres:error
> [rank 0] -> Tremblay
> [rank 1] -> Tremblay
> [rank 2] -> Tremblay
-/* 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
! output sort
p Test barrier
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-barrier --log=smpi_kernel.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-barrier --log=smpi_config.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error --log=smpi_pmpi.thres:error
> ... Barrier ....
> [rank 0] -> Tremblay
> [rank 1] -> Tremblay
-/* 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
p Test Broadcast with more processes than hosts
! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-bcast --log=smpi_kernel.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-bcast --log=smpi_config.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error --log=smpi_pmpi.thres:error
> [rank 0] -> Tremblay
> [rank 1] -> Tremblay
> [rank 2] -> Tremblay
-/* 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
! timeout 30
p Test all to all
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-gather --log=smpi_kernel.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-gather --log=smpi_config.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error --log=smpi_pmpi.thres:error
> [rank 0] -> Tremblay
> [rank 1] -> Tremblay
> [rank 2] -> Tremblay
-/* 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
if(retval!=MPI_ERR_BUFFER)
printf("MPI_Reduce_scatter did not return MPI_ERR_BUFFER for empty recvbuf\n");
retval = MPI_Reduce_scatter(sendbuf, recvbuf, NULL, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
- if(retval!=MPI_ERR_ARG)
- printf("MPI_Reduce_scatter did not return MPI_ERR_ARG for NULL recvcounts\n");
+ if(retval!=MPI_ERR_COUNT)
+ printf("MPI_Reduce_scatter did not return MPI_ERR_COUNT for NULL recvcounts\n");
retval = MPI_Reduce_scatter(sendbuf, recvbuf, recvcounts, MPI_DATATYPE_NULL, MPI_SUM, MPI_COMM_WORLD);
if(retval!=MPI_ERR_TYPE)
printf("MPI_Reduce_scatter did not return MPI_ERR_TYPE for MPI_DATATYPE_NULL type\n");
! output sort
p Test reduce_scatter
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-reduce-scatter --log=smpi_kernel.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-reduce-scatter --log=smpi_config.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error --log=smpi_pmpi.thres:error
> No Errors
> [rank 0] -> Tremblay
> [rank 10] -> Fafard
-/* 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
printf("MPI_Reduce did not return MPI_ERR_TYPE for MPI_DATATYPE_NULL type\n");
status = MPI_Reduce(sb, rb, size, MPI_UNSIGNED_LONG_LONG, MPI_OP_NULL, root, MPI_COMM_WORLD);
if(status!=MPI_ERR_OP)
- printf("MPI_Reduce did not return MPI_ERR_COMM for MPI_OP_NULL op\n");
+ printf("MPI_Reduce did not return MPI_ERR_OP for MPI_OP_NULL op\n");
status = MPI_Reduce(sb, rb, size, MPI_UNSIGNED_LONG_LONG, MPI_SUM, -1, MPI_COMM_WORLD);
if(status!=MPI_ERR_ROOT)
printf("MPI_Reduce did not return MPI_ERR_ROOT for root -1\n");
! output sort
p Test allreduce
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-reduce --log=smpi_kernel.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-reduce --log=smpi_config.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error --log=smpi_pmpi.thres:error
> [0] rcvbuf=[1920 1936 1952 1968 1984 2000 2016 2032 2048 2064 2080 2096 2112 2128 2144 2160 ]
> [0] second sndbuf=[0 ]
> [0] sndbuf=[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ]
-/* 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
! output sort
p Test scatter
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-scatter --log=smpi_kernel.thres:warning --log=smpi_coll.thres:error --log=smpi_mpi.thres:error
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-scatter --log=smpi_config.thres:warning --log=smpi_coll.thres:error --log=smpi_pmpi.thres:error --log=smpi_mpi.thres:error
> [0] ok.
> [10] ok.
> [11] ok.
p Test fortran params
! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ${platfdir}/small_platform.xml -np 2 ${bindir:=.}/fort_args 'a' 3 -q --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ${platfdir}/small_platform.xml -np 2 ${bindir:=.}/fort_args 'a' 3 -q --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [rank 0] -> Tremblay
> [rank 1] -> Jupiter
-/* 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
// Thread creation helper
-static int thread_create_wrapper(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
+static void thread_create_wrapper(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
{
int the_global_rank = global_rank;
struct threadwrap* t = (struct threadwrap*)sg_actor_self_data();
t->f(t->param);
sg_actor_self_data_set(NULL);
free(t);
- return 0;
}
static void mpi_thread_create(const char* name, void* (*f)(void*), void* param)
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -np 2 -platform ../../../examples/platforms/small_platform.xml -hostfile ../hostfile ${bindir:=.}/gh-139 --cfg=smpi/simulate-computation:no --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -np 2 -platform ../../../examples/platforms/small_platform.xml -hostfile ../hostfile ${bindir:=.}/gh-139 --cfg=smpi/simulate-computation:no --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [Tremblay:0:(1) 0.000000] [smpi_test/INFO] I'm 0/2
> [Jupiter:1:(2) 0.000000] [smpi_test/INFO] I'm 1/2
> [Tremblay:wait send:(3) 0.000000] [smpi_test/INFO] new thread has parameter rank 0 and global variable rank 0
# Test for MPI_File_read and MPI_File_write
! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_io -platform ../../../examples/platforms/hosts_with_disks.xml -np 4 --log=xbt_cfg.thres:critical --log=smpi_kernel.thres:warning --log=smpi_mpi.thres:error --log=smpi_io.thres:verbose "--log=root.fmt:(%P@%h)%e%m%n" --cfg=smpi/simulate-computation:0 ${bindir:=.}/io-all-at
-> You requested to use 4 ranks, but there is only 2 processes in your hostfile...
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_io -platform ../../../examples/platforms/hosts_with_disks.xml -np 4 --log=xbt_cfg.thres:critical --log=smpi_config.thres:warning --log=smpi_mpi.thres:error --log=s4u_file.thres:error --log=smpi_io.thres:verbose "--log=root.fmt:(%P@%h)%e%m%n" --cfg=smpi/simulate-computation:0 ${bindir:=.}/io-all-at
> [rank 0] -> bob
> [rank 1] -> carl
> [rank 2] -> bob
# Test for MPI_File_read and MPI_File_write
! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_io -platform ../../../examples/platforms/hosts_with_disks.xml -np 4 --log=xbt_cfg.thres:critical --log=smpi_kernel.thres:warning --log=smpi_mpi.thres:error --log=smpi_io.thres:verbose "--log=root.fmt:(%P@%h)%e%m%n" --cfg=smpi/simulate-computation:0 ${bindir:=.}/io-all
-> You requested to use 4 ranks, but there is only 2 processes in your hostfile...
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_io -platform ../../../examples/platforms/hosts_with_disks.xml -np 4 --log=xbt_cfg.thres:critical --log=smpi_config.thres:warning --log=smpi_mpi.thres:error --log=s4u_file.thres:error --log=smpi_io.thres:verbose "--log=root.fmt:(%P@%h)%e%m%n" --cfg=smpi/simulate-computation:0 ${bindir:=.}/io-all
> [rank 0] -> bob
> [rank 1] -> carl
> [rank 2] -> bob
# Test for MPI_File_read and MPI_File_write
! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_io -platform ../../../examples/platforms/hosts_with_disks.xml -np 4 --log=xbt_cfg.thres:critical --log=smpi_kernel.thres:warning --log=smpi_mpi.thres:error --log=smpi_io.thres:verbose "--log=root.fmt:(%P@%h)%e%m%n" --cfg=smpi/simulate-computation:0 ${bindir:=.}/io-ordered
-> You requested to use 4 ranks, but there is only 2 processes in your hostfile...
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_io -platform ../../../examples/platforms/hosts_with_disks.xml -np 4 --log=xbt_cfg.thres:critical --log=smpi_config.thres:warning --log=smpi_mpi.thres:error --log=s4u_file.thres:error --log=smpi_io.thres:verbose "--log=root.fmt:(%P@%h)%e%m%n" --cfg=smpi/simulate-computation:0 ${bindir:=.}/io-ordered
> [rank 0] -> bob
> [rank 1] -> carl
> [rank 2] -> bob
# Test for MPI_File_read and MPI_File_write
! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_io -platform ../../../examples/platforms/hosts_with_disks.xml -np 4 --log=xbt_cfg.thres:critical --log=smpi_kernel.thres:warning --log=smpi_mpi.thres:error --log=smpi_io.thres:verbose "--log=root.fmt:(%P@%h)%e%m%n" --cfg=smpi/simulate-computation:0 ${bindir:=.}/io-shared
-> You requested to use 4 ranks, but there is only 2 processes in your hostfile...
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_io -platform ../../../examples/platforms/hosts_with_disks.xml -np 4 --log=xbt_cfg.thres:critical --log=smpi_config.thres:warning --log=smpi_mpi.thres:error --log=s4u_file.thres:error --log=smpi_io.thres:verbose "--log=root.fmt:(%P@%h)%e%m%n" --cfg=smpi/simulate-computation:0 ${bindir:=.}/io-shared
> [rank 0] -> bob
> [rank 1] -> carl
> [rank 2] -> bob
# Test for MPI_File_read and MPI_File_write
! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_io -platform ../../../examples/platforms/hosts_with_disks.xml -np 4 --log=xbt_cfg.thres:critical --log=smpi_kernel.thres:warning --log=smpi_mpi.thres:error --log=smpi_io.thres:verbose "--log=root.fmt:(%P@%h)%e%m%n" --cfg=smpi/simulate-computation:0 ${bindir:=.}/io-simple-at
-> You requested to use 4 ranks, but there is only 2 processes in your hostfile...
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_io -platform ../../../examples/platforms/hosts_with_disks.xml -np 4 --log=xbt_cfg.thres:critical --log=smpi_config.thres:warning --log=smpi_mpi.thres:error --log=s4u_file.thres:error --log=smpi_io.thres:verbose "--log=root.fmt:(%P@%h)%e%m%n" --cfg=smpi/simulate-computation:0 ${bindir:=.}/io-simple-at
> [rank 0] -> bob
> [rank 1] -> carl
> [rank 2] -> bob
# Test for MPI_File_read and MPI_File_write
! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_io -platform ../../../examples/platforms/hosts_with_disks.xml -np 4 --log=xbt_cfg.thres:critical --log=smpi_kernel.thres:warning --log=smpi_mpi.thres:error --log=smpi_io.thres:verbose "--log=root.fmt:(%P@%h)%e%m%n" --cfg=smpi/simulate-computation:0 ${bindir:=.}/io-simple
-> You requested to use 4 ranks, but there is only 2 processes in your hostfile...
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_io -platform ../../../examples/platforms/hosts_with_disks.xml -np 4 --log=xbt_cfg.thres:critical --log=smpi_config.thres:warning --log=smpi_mpi.thres:error --log=s4u_file.thres:error --log=smpi_io.thres:verbose "--log=root.fmt:(%P@%h)%e%m%n" --cfg=smpi/simulate-computation:0 ${bindir:=.}/io-simple
> [rank 0] -> bob
> [rank 1] -> carl
> [rank 2] -> bob
-/* 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;
}
p Test compute
! output sort
! timeout 5
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/macro-partial-shared-communication --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/macro-partial-shared-communication --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [3] The result of the (normal) communication check for block (0x123456, 0x130000) is: 1
> [3] The result of the (normal) communication check for block (0x130001, 0x345678) is: 1
> [3] The result of the (normal) communication check for block (0x345789, 0x444444) is: 1
-/* 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
p Test compute
! output sort
! timeout 5
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/macro-partial-shared --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/macro-partial-shared --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [0] The result of the shared check for block (0x0, 0x123456) is: 1
> [0] The result of the shared check for block (0x130000, 0x130001) is: 1
> [0] The result of the shared check for block (0x345678, 0x345789) is: 1
-/* 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
p Test compute and bench
! output sort
! timeout 45
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform_with_routers.xml -np 3 --log=root.thres:warning ${bindir:=.}/macro-sample quiet --log=smpi_kernel.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform_with_routers.xml -np 3 --log=root.thres:warning ${bindir:=.}/macro-sample quiet --log=smpi_config.thres:warning
> (0) Run the first computation. It's globally benched, and I want no more than 4 benchmarks (thres<0)
> (0) Run the first computation. It's globally benched, and I want no more than 4 benchmarks (thres<0)
> (0) Run the first computation. It's globally benched, and I want no more than 4 benchmarks (thres<0)
-/* 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
printf("[%d] After change, the value in the shared buffer is: %" PRIu64"\n", rank, *buf);
+ //try to send/receive shared data, to check if we skip the copies correctly.
+ if(rank==0)
+ MPI_Send(buf, 1, MPI_AINT, 1, 100, MPI_COMM_WORLD);
+ else if (rank ==1)
+ MPI_Recv(buf, 1, MPI_AINT, 0, 100, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+
+ //same thing with an MPI_IN_PLACE collective (no)
+ if (rank == 0)
+ MPI_Scatter(buf, 1, MPI_AINT, MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, 0, MPI_COMM_WORLD);
+ else
+ MPI_Scatter(NULL, -1, MPI_DATATYPE_NULL, buf, 1, MPI_AINT, 0, MPI_COMM_WORLD);
SMPI_SHARED_FREE(buf);
MPI_Finalize();
p Test compute
! output sort
! timeout 5
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/macro-shared --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/macro-shared --log=xbt_cfg.thres:warning --log=smpi_kernel.thres:verbose "--log=root.fmt:(%P@%h)%e%m%n"
+> (maestro@) You did not set the power of the host running the simulation. The timings will certainly not be accurate. Use the option "--cfg=smpi/host-speed:<flops>" to set its value. Check https://simgrid.org/doc/latest/Configuring_SimGrid.html#automatic-benchmarking-of-smpi-code for more information.
+> (maestro@) Receiver is shared. Let's ignore it.
+> (maestro@) Receiver is shared. Let's ignore it.
+> (maestro@) Receiver is shared. Let's ignore it.
+> (maestro@) Receiver is shared. Let's ignore it.
> [0] After change, the value in the shared buffer is: 16053117601147974045
> [0] The value in the shared buffer is: 4
> [1] After change, the value in the shared buffer is: 16053117601147974045
! output sort
! timeout 5
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/macro-shared --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/shared-malloc:local
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/macro-shared --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/shared-malloc:local
> [0] After change, the value in the shared buffer is: 16053117601147974045
> [0] The value in the shared buffer is: 4
> [1] After change, the value in the shared buffer is: 16053117601147974045
}
/* Test Iallreduce */
if (sol != out)
- errs++;;
+ errs++;
/* Test new communicator */
errs += MTestTestComm(newcomm);
}
/* Test Iallreduce */
if (sol != out)
- errs++;;
+ errs++;
/* Test new communicator */
errs += MTestTestComm(newcomm);
if (sol != out)
- errs++;;
+ errs++;
/* Test new inter communicator */
errs += MTestTestComm(newcomm);
MPI_Comm_free(&newcomm);
}
/* Test Iallreduce resutls for split-communicator */
if (sol != out)
- errs++;;
+ errs++;
/* Test new inter-communicator */
errs += MTestTestComm(newcomm);
if (sol != out)
- errs++;;
+ errs++;
/* Test new communicator */
errs += MTestTestComm(newcomm);
MPI_Comm_free(&newcomm);
add_executable(${test} EXCLUDE_FROM_ALL ${test}.f)
add_dependencies(tests ${test})
target_link_libraries(${test} simgrid mtest_f77)
+ if((CMAKE_Fortran_COMPILER_ID MATCHES "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "9.99"))
+ set_property(SOURCE ${test}.f PROPERTY COMPILE_FLAGS -std=legacy)
+ endif()
endforeach()
endif()
foreach(test gaddressf
allctypesf hindex1f hindexed_blockf packef typecntsf
typem2f typename3f typenamef typesnamef
- typesubf)
+ typesubf)
add_executable(${test} EXCLUDE_FROM_ALL ${test}.f)
add_dependencies(tests ${test})
- target_link_libraries(${test} simgrid mtest_f77)
+ target_link_libraries(${test} simgrid mtest_f77)
+ if((CMAKE_Fortran_COMPILER_ID MATCHES "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "9.99"))
+ set_property(SOURCE ${test}.f PROPERTY COMPILE_FLAGS -std=legacy)
+ endif()
endforeach()
endif()
include_directories(BEFORE "${CMAKE_HOME_DIRECTORY}/include/smpi")
add_executable(allpairf EXCLUDE_FROM_ALL allpairf.f)
+ if((CMAKE_Fortran_COMPILER_ID MATCHES "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "9.99"))
+ set_property(SOURCE allpairf.f PROPERTY COMPILE_FLAGS -std=legacy)
+ endif()
add_executable(greqf EXCLUDE_FROM_ALL greqf.f dummyf.f)
# add_executable(mprobef EXCLUDE_FROM_ALL mprobef.f)
add_executable(statusesf EXCLUDE_FROM_ALL statusesf.f)
add_executable(${test} EXCLUDE_FROM_ALL ${test}.f90)
add_dependencies(tests ${test})
target_link_libraries(${test} simgrid mtest_f90)
+ if((CMAKE_Fortran_COMPILER_ID MATCHES "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "9.99"))
+ set_property(SOURCE ${test}.f90 PROPERTY COMPILE_FLAGS -std=legacy)
+ endif()
endforeach()
endif()
typesubf90)
add_executable(${test} EXCLUDE_FROM_ALL ${test}.f90)
add_dependencies(tests ${test})
- target_link_libraries(${test} simgrid mtest_f90)
+ target_link_libraries(${test} simgrid mtest_f90)
+ if((CMAKE_Fortran_COMPILER_ID MATCHES "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "9.99"))
+ set_property(SOURCE ${test}.f90 PROPERTY COMPILE_FLAGS -std=legacy)
+ endif()
endforeach()
endif()
--- /dev/null
+if(enable_smpi AND enable_smpi_MPICH3_testsuite)
+ if(WIN32)
+ set(CMAKE_C_FLAGS "-include ${CMAKE_HOME_DIRECTORY}/include/smpi/smpi_main.h")
+ else()
+ set(CMAKE_C_COMPILER "${CMAKE_BINARY_DIR}/smpi_script/bin/smpicc")
+ set(CMAKE_Fortran_COMPILER "${CMAKE_BINARY_DIR}/smpi_script/bin/smpiff")
+ endif()
+
+ include_directories(BEFORE "${CMAKE_HOME_DIRECTORY}/include/smpi")
+ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../include/")
+
+ foreach(file async_any async bigtype external32-derived-dtype getextent hindexed_io rdwrord rdwrzero resized2 resized setinfo setviewcur simple_collective userioerr)
+ #i_aggregation1 i_aggregation2 i_bigtype i_coll_test i_darray_read i_hindexed i_hindexed_io i_noncontig i_noncontig_coll2 i_noncontig_coll i_rdwrord i_setviewcur i_types_with_zeros
+ add_executable(${file} EXCLUDE_FROM_ALL ${file}.c)
+ add_dependencies(tests ${file})
+ target_link_libraries(${file} simgrid mtest_c)
+ endforeach()
+endif()
+
+if (enable_smpi_MPICH3_testsuite AND HAVE_RAW_CONTEXTS)
+ ADD_TEST(test-smpi-mpich3-io-raw ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/io ${PERL_EXECUTABLE} ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests "-wrapper=${TESH_WRAPPER}" -platformfile=../../../../examples/platforms/hosts_with_disks.xml -hostfile=../../hostfile_io -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/io -tests=testlist -execarg=--cfg=contexts/factory:raw)
+ SET_TESTS_PROPERTIES(test-smpi-mpich3-io-raw PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!")
+endif()
+
+ foreach(file async_any async bigtype external32-derived-dtype getextent hindexed_io rdwrord rdwrzero resized2 resized setinfo setviewcur simple_collective userioerr i_aggregation1 i_aggregation2 i_bigtype i_coll_test i_darray_read i_hindexed i_hindexed_io i_noncontig i_noncontig_coll2 i_noncontig_coll i_rdwrord i_setviewcur i_types_with_zeros )
+ set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${file}.c)
+endforeach()
+
+set(examples_src ${examples_src} PARENT_SCOPE)
+set(txt_files ${txt_files} ${CMAKE_CURRENT_SOURCE_DIR}/testlist PARENT_SCOPE)
+
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2001 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+#include "mpi.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include "mpitest.h"
+
+/*
+static char MTEST_Descrip[] = "Test contig asynchronous I/O";
+*/
+
+#define DEFAULT_SIZE (65536)
+
+/* Uses asynchronous I/O. Each process writes to separate files and
+ reads them back. The file name is taken as a command-line argument,
+ and the process rank is appended to it.*/
+
+static void handle_error(int errcode, const char *str)
+{
+ char msg[MPI_MAX_ERROR_STRING];
+ int resultlen;
+ MPI_Error_string(errcode, msg, &resultlen);
+ fprintf(stderr, "%s: %s\n", str, msg);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+}
+
+int main(int argc, char **argv)
+{
+ int *buf, i, rank, nints, len, err;
+ char *filename = 0, *tmp;
+ int errs = 0;
+ int SIZE = DEFAULT_SIZE;
+ MPI_File fh;
+ MPI_Status status;
+#ifdef MPIO_USES_MPI_REQUEST
+ MPI_Request request;
+#else
+ MPIO_Request request;
+#endif
+
+ MTest_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+
+/* process 0 takes the file name as a command-line argument and
+ broadcasts it to other processes */
+ if (!rank) {
+ i = 1;
+ argv++;
+ /* Skip unrecognized arguments */
+ while (i < argc) {
+ if (strcmp(*argv, "-fname") == 0) {
+ argv++;
+ i++;
+ len = (int) strlen(*argv);
+ filename = (char *) malloc(len + 10);
+ MTEST_VG_MEM_INIT(filename, (len + 10) * sizeof(char));
+ strcpy(filename, *argv);
+ }
+ else if (strcmp(*argv, "-size") == 0) {
+ argv++;
+ i++;
+ SIZE = strtol(*argv, 0, 10);
+ if (errno) {
+ fprintf(stderr, "-size requires a numeric argument\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ else if (SIZE <= 0) {
+ fprintf(stderr, "-size requires a positive value\n");
+ }
+ }
+ else {
+ i++;
+ argv++;
+ }
+ }
+
+ if (!filename) {
+ /* Use a default filename of testfile */
+ len = 8;
+ filename = (char *) malloc(len + 10);
+ MTEST_VG_MEM_INIT(filename, (len + 10) * sizeof(char));
+ strcpy(filename, "/scratch/testfile");
+ }
+ MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ MPI_Bcast(filename, len + 10, MPI_CHAR, 0, MPI_COMM_WORLD);
+ MPI_Bcast(&SIZE, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ }
+ else {
+ MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ filename = (char *) malloc(len + 10);
+ MPI_Bcast(filename, len + 10, MPI_CHAR, 0, MPI_COMM_WORLD);
+ MPI_Bcast(&SIZE, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ }
+
+
+ /* printf("Starting (size=%d, file=%s)...\n", SIZE, filename); fflush(stdout); */
+
+ buf = (int *) malloc(SIZE);
+ nints = SIZE / sizeof(int);
+ for (i = 0; i < nints; i++)
+ buf[i] = rank * 100000 + i;
+
+ /* each process opens a separate file called filename.'myrank' */
+ tmp = (char *) malloc(len + 10);
+ strcpy(tmp, filename);
+ sprintf(filename, "%s.%d", tmp, rank);
+ free(tmp);
+
+ err = MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR,
+ MPI_INFO_NULL, &fh);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_open");
+
+ err = MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, (char *) "native", MPI_INFO_NULL);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_set_view");
+ err = MPI_File_iwrite(fh, buf, nints, MPI_INT, &request);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_iwrtie");
+#ifdef MPIO_USES_MPI_REQUEST
+ MPI_Wait(&request, &status);
+#else
+ MPIO_Wait(&request, &status);
+#endif
+ MPI_File_close(&fh);
+
+ /* reopen the file and read the data back */
+
+ for (i = 0; i < nints; i++)
+ buf[i] = 0;
+ err = MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR,
+ MPI_INFO_NULL, &fh);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_open (read)");
+ err = MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, (char *) "native", MPI_INFO_NULL);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_set_view (read)");
+ err = MPI_File_iread(fh, buf, nints, MPI_INT, &request);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_iread");
+#ifdef MPIO_USES_MPI_REQUEST
+ MPI_Wait(&request, &status);
+#else
+ MPIO_Wait(&request, &status);
+#endif
+ MPI_File_close(&fh);
+
+ /* check if the data read is correct */
+/* for (i = 0; i < nints; i++) {*/
+/* if (buf[i] != (rank * 100000 + i)) {*/
+/* errs++;*/
+/* if (errs < 25) {*/
+/* fprintf(stderr, "Process %d: error, read %d, should be %d\n", rank, buf[i],*/
+/* rank * 100000 + i);*/
+/* }*/
+/* else if (errs == 25) {*/
+/* fprintf(stderr, "Reached maximum number of errors to report\n");*/
+/* }*/
+/* }*/
+/* }*/
+
+ free(buf);
+ free(filename);
+
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2001 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+#include "mpi.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "mpitest.h"
+
+/*
+static char MTEST_Descrip[] = "Test asynchronous I/O w/ multiple completion";
+*/
+
+#define SIZE (65536)
+#define NUMOPS 10
+
+/* Uses asynchronous I/O. Each process writes to separate files and
+ reads them back. The file name is taken as a command-line argument,
+ and the process rank is appended to it.*/
+
+int main(int argc, char **argv)
+{
+ int *buf, i, rank, nints, len;
+ char *filename, *tmp;
+ int errs = 0;
+ MPI_File fh;
+ MPI_Status statuses[NUMOPS];
+ MPI_Request requests[NUMOPS];
+
+ MTest_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+/* process 0 takes the file name as a command-line argument and
+ broadcasts it to other processes */
+ if (!rank) {
+ i = 1;
+ while ((i < argc) && strcmp("-fname", *argv)) {
+ i++;
+ argv++;
+ }
+ if (i >= argc) {
+ /* Use a default filename of testfile */
+ len = 8;
+ filename = (char *) malloc(len + 10);
+ memset(filename, 0, (len + 10) * sizeof(char));
+ strcpy(filename, "testfile");
+ /*
+ * fprintf(stderr, "\n*# Usage: async_any -fname filename\n\n");
+ * MPI_Abort(MPI_COMM_WORLD, 1);
+ */
+ }
+ else {
+ argv++;
+ len = (int) strlen(*argv);
+ filename = (char *) malloc(len + 10);
+ MTEST_VG_MEM_INIT(filename, (len + 10) * sizeof(char));
+ strcpy(filename, *argv);
+ }
+ MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ MPI_Bcast(filename, len + 10, MPI_CHAR, 0, MPI_COMM_WORLD);
+ }
+ else {
+ MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ filename = (char *) malloc(len + 10);
+ MTEST_VG_MEM_INIT(filename, (len + 10) * sizeof(char));
+ MPI_Bcast(filename, len + 10, MPI_CHAR, 0, MPI_COMM_WORLD);
+ }
+
+
+ buf = (int *) malloc(SIZE);
+ nints = SIZE / sizeof(int);
+ for (i = 0; i < nints; i++)
+ buf[i] = rank * 100000 + i;
+
+ /* each process opens a separate file called filename.'myrank' */
+ tmp = (char *) malloc(len + 10);
+ strcpy(tmp, filename);
+ sprintf(filename, "%s.%d", tmp, rank);
+
+ MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+ MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, (char *) "native", MPI_INFO_NULL);
+ for (i = 0; i < NUMOPS; i++) {
+ MPI_File_iwrite(fh, buf, nints, MPI_INT, &(requests[i]));
+ }
+ MPI_Waitall(NUMOPS, requests, statuses);
+ MPI_File_close(&fh);
+
+ /* reopen the file and read the data back */
+
+ for (i = 0; i < nints; i++)
+ buf[i] = 0;
+ MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+ MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, (char *) "native", MPI_INFO_NULL);
+ for (i = 0; i < NUMOPS; i++) {
+ MPI_File_iread(fh, buf, nints, MPI_INT, &(requests[i]));
+ }
+ MPI_Waitall(NUMOPS, requests, statuses);
+ MPI_File_close(&fh);
+
+ /* check if the data read is correct */
+ for (i = 0; i < nints; i++) {
+ if (buf[i] != (rank * 100000 + i)) {
+ errs++;
+ fprintf(stderr, "Process %d: error, read %d, should be %d\n", rank, buf[i],
+ rank * 100000 + i);
+ }
+ }
+
+ free(buf);
+ free(filename);
+ free(tmp);
+
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2014 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include <mpi.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <assert.h>
+
+//#define NUM_X 536870911
+#define NUM_X 53687091
+#define NUM_Y 1
+
+//#define BIGDT 2147483643
+#define BIGDT 214748364
+
+int main(int argc, char **argv)
+{
+
+ MPI_File fh;
+ int i, j;
+ size_t k;
+ MPI_Datatype inner_type, rem_type, mem_type;
+ MPI_Datatype int_type, file_type;
+ int *buf_write, *buf_read;
+ int rc;
+ MPI_Aint disp[2];
+ int block_len[2];
+ MPI_Datatype type[2];
+
+ MPI_Init(&argc, &argv);
+
+ if (sizeof(MPI_Aint) <= sizeof(int)) {
+ /* can't test on this platform... */
+ goto exit;
+ }
+
+ k = 0;
+ /* create a large buffer 2 */
+ buf_write = malloc(NUM_X * NUM_Y * sizeof(int));
+ if (buf_write == NULL) {
+ fprintf(stderr, "not enough memory\n");
+ exit(1);
+ }
+ buf_read = malloc(NUM_X * NUM_Y * sizeof(int));
+ if (buf_read == NULL) {
+ fprintf(stderr, "not enough memory\n");
+ exit(1);
+ }
+ memset(buf_read, 0, NUM_X * NUM_Y * sizeof(int));
+
+ for (i = 0; i < NUM_X; i++) {
+ for (j = 0; j < NUM_Y; j++) {
+ buf_write[k] = k;
+ k++;
+ }
+ }
+
+ /* Big Datatype (2^31 - 1 bytes) */
+ MPI_Type_contiguous(BIGDT, MPI_BYTE, &inner_type);
+ /* Small Datatype (1 byte) */
+ MPI_Type_contiguous(1, MPI_BYTE, &rem_type);
+
+ type[0] = inner_type;
+ type[1] = rem_type;
+ block_len[0] = 1;
+ block_len[1] = 1;
+ disp[0] = 0;
+ disp[1] = BIGDT;
+
+ /* combine both types */
+ MPI_Type_struct(2, block_len, disp, type, &mem_type);
+
+ MPI_Type_commit(&mem_type);
+ MPI_Type_free(&rem_type);
+ MPI_Type_free(&inner_type);
+
+ MPI_Type_contiguous(4, MPI_BYTE, &int_type);
+ {
+ /* This creates a big type that is actually contituous, touching an
+ * optimization that was at one point buggy */
+ MPI_Type_vector(1, NUM_X, 1, int_type, &file_type);
+ }
+
+ MPI_Type_commit(&file_type);
+ MPI_Type_free(&int_type);
+
+ if (MPI_File_open(MPI_COMM_WORLD, "testfile", MPI_MODE_RDWR | MPI_MODE_CREATE,
+ MPI_INFO_NULL, &fh) != 0) {
+ fprintf(stderr, "Can't open file: %s\n", "testfile");
+ exit(1);
+ }
+
+ if (MPI_SUCCESS != MPI_File_set_view(fh, 2144, MPI_BYTE, file_type, "native", MPI_INFO_NULL)) {
+ fprintf(stderr, "ERROR SET VIEW\n");
+ exit(1);
+ }
+
+ /* write everything */
+ rc = MPI_File_write_at_all(fh, 0, buf_write, 1, mem_type, MPI_STATUS_IGNORE);
+ if (rc != MPI_SUCCESS) {
+ fprintf(stderr, "%d ERROR WRITE AT ALL\n", rc);
+ exit(1);
+ }
+
+ if (MPI_SUCCESS != MPI_File_set_view(fh, 2144, MPI_BYTE, file_type, "native", MPI_INFO_NULL)) {
+ fprintf(stderr, "ERROR SET VIEW\n");
+ exit(1);
+ }
+
+ /* read everything */
+ rc = MPI_File_read_at_all(fh, 0, buf_read, 1, mem_type, MPI_STATUS_IGNORE);
+ if (rc != MPI_SUCCESS) {
+ fprintf(stderr, "%d ERROR READ AT ALL\n", rc);
+ exit(1);
+ }
+
+/* for (k = 0; k < NUM_X * NUM_Y; k++) {
+ if (buf_read[k] != buf_write[k]) {
+ fprintf(stderr, "Verfiy Failed index %zu: expected %d found %d\n",
+ k, buf_write[k], buf_read[k]);
+ assert(0);
+ }
+ }
+*/
+ free(buf_write);
+ free(buf_read);
+ MPI_File_close(&fh);
+
+ MPI_Type_free(&mem_type);
+ MPI_Type_free(&file_type);
+
+ exit:
+ MPI_Finalize();
+ printf(" No Errors\n");
+
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2015 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ *
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include "mpi.h"
+
+static void read_file(const char *name, void *buf, MPI_Datatype dt)
+{
+ int rank, rc;
+ MPI_File fh;
+ char datarep[] = "external32";
+ int amode = MPI_MODE_RDONLY;
+ MPI_Status status;
+ MPI_Offset offset;
+
+ /* get our rank */
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+ /* open file */
+ rc = MPI_File_open(MPI_COMM_WORLD, (char *) name,
+ amode, MPI_INFO_NULL, &fh);
+ if (rc != MPI_SUCCESS) {
+ printf("Rank %d: Failed to open file %s\n", rank, name);
+ fflush(stdout);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ return;
+ }
+
+ /* set file view to be sequence of datatypes past header */
+ MPI_File_set_view(fh, 0, dt, dt, datarep, MPI_INFO_NULL);
+
+ /* issue a collective read: In 3.2 and older the external32 code
+ * path had a bug that would cause an overlapping memcopy and crash
+ */
+ offset = rank;
+ MPI_File_read_at_all(fh, offset, buf, 1, dt, &status);
+
+ /* close file */
+ MPI_File_close(&fh);
+
+ return;
+}
+
+static void write_file(const char *name, void *buf, MPI_Datatype dt)
+{
+ int rank, amode;
+ char datarep[] = "external32";
+ MPI_Status status;
+ MPI_File fh;
+ MPI_Offset offset;
+
+ /* get our rank in job */
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+ /* open file */
+ amode = MPI_MODE_WRONLY | MPI_MODE_CREATE;
+ MPI_File_open(MPI_COMM_WORLD, (char *) name, amode, MPI_INFO_NULL, &fh);
+
+ /* truncate file to 0 bytes */
+ MPI_File_set_size(fh, 0);
+
+ /* set file view to be sequence of datatypes past header */
+ MPI_File_set_view(fh, 0, dt, dt, datarep, MPI_INFO_NULL);
+
+ /* collective write of file info */
+ offset = rank;
+ MPI_File_write_at_all(fh, offset, buf, 1, dt, &status);
+
+ /* close file */
+ MPI_File_close(&fh);
+
+ return;
+}
+
+/* write and read a file in which each process writes one int
+ * in rank order */
+int main(int argc, char *argv[])
+{
+
+ char buf[2] = "a";
+ MPI_Datatype dt;
+ int blocks[2] = { 1, 1 };
+ int disps[2] = { 0, 1 };
+
+ MPI_Init(&argc, &argv);
+ MPI_Type_indexed(2, blocks, disps, MPI_CHAR, &dt);
+ MPI_Type_commit(&dt);
+
+ write_file("testfile", buf, dt);
+
+ read_file("testfile", buf, dt);
+
+ MPI_Type_free(&dt);
+
+ /* if we get this far, then we've passed. No verification in this test at
+ * this time. */
+ fprintf(stdout, " No Errors\n");
+
+ MPI_Finalize();
+
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *
+ * (C) 2003 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+#include "mpi.h"
+#include <stdio.h>
+#include "mpitest.h"
+
+/*
+static char MTEST_Descrip[] = "Test file_get_extent";
+*/
+
+int main(int argc, char *argv[])
+{
+ int errs = 0;
+ MPI_File fh;
+ MPI_Comm comm;
+ MPI_Aint extent, nextent;
+
+ MTest_Init(&argc, &argv);
+
+ comm = MPI_COMM_WORLD;
+ MPI_File_open(comm, (char *) "test.ord",
+ MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh);
+
+ MPI_File_get_type_extent(fh, MPI_INT, &extent);
+ MPI_Type_extent(MPI_INT, &nextent);
+
+ if (nextent != extent) {
+ errs++;
+ fprintf(stderr, "Native extent not the same as the file extent\n");
+ }
+ MPI_File_close(&fh);
+
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2014 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include <mpi.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#define DATA_SIZE 324*4
+#define PAD 256
+#define HEADER 144
+#define BLK_COUNT 3
+
+static void handle_error(int errcode, const char *str)
+{
+ char msg[MPI_MAX_ERROR_STRING];
+ int resultlen;
+ MPI_Error_string(errcode, msg, &resultlen);
+ fprintf(stderr, "%s: %s\n", str, msg);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+}
+
+#define CHECK(fn) { int errcode; errcode = (fn); if (errcode != MPI_SUCCESS) handle_error(errcode, #fn); }
+
+int main(int argc, char **argv)
+{
+
+ MPI_File fh;
+ MPI_Datatype file_type, mem_type;
+ int *data = NULL;
+ int *verify = NULL;
+ int data_size = DATA_SIZE;
+ int i, nr_errors = 0;
+ //int j, k;
+ MPI_Aint disp[BLK_COUNT];
+ const char *filename = "unnamed.dat";
+
+ MPI_Init(&argc, &argv);
+ disp[0] = (MPI_Aint) (PAD);
+ disp[1] = (MPI_Aint) (data_size * 1 + PAD);
+ disp[2] = (MPI_Aint) (data_size * 2 + PAD);
+
+ data = malloc(data_size);
+ verify = malloc(data_size * BLK_COUNT + HEADER + PAD);
+ for (i = 0; i < data_size / sizeof(int); i++)
+ data[i] = i;
+
+ MPI_Type_create_hindexed_block(BLK_COUNT, data_size, disp, MPI_BYTE, &file_type);
+ MPI_Type_commit(&file_type);
+
+ MPI_Type_create_hvector(BLK_COUNT, data_size, 0, MPI_BYTE, &mem_type);
+ MPI_Type_commit(&mem_type);
+
+ if (1 < argc)
+ filename = argv[1];
+
+ CHECK(MPI_File_open(MPI_COMM_WORLD, filename,
+ MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE,
+ MPI_INFO_NULL, &fh) != 0);
+
+ CHECK(MPI_File_set_view(fh, HEADER, MPI_BYTE, file_type, "native", MPI_INFO_NULL));
+
+ /* write everything */
+ CHECK(MPI_File_write_at_all(fh, 0, data, 1, mem_type, MPI_STATUS_IGNORE));
+ /* verify */
+ CHECK(MPI_File_set_view(fh, 0, MPI_BYTE, MPI_BYTE, "native", MPI_INFO_NULL));
+ CHECK(MPI_File_read_at_all(fh, 0,
+ verify, (HEADER + PAD + BLK_COUNT * DATA_SIZE) / sizeof(int),
+ MPI_INT, MPI_STATUS_IGNORE));
+
+ /* header and block padding should have no data */
+/* for (i = 0; i < (HEADER + PAD) / sizeof(int); i++) {
+ if (verify[i] != 0) {
+ nr_errors++;
+ fprintf(stderr, "expected 0, read %d\n", verify[i]);
+ }
+ }
+*/
+ /* blocks are replicated */
+/* for (j = 0; j < BLK_COUNT; j++) {
+ for (k = 0; k < (DATA_SIZE / sizeof(int)); k++) {
+ if (verify[(HEADER + PAD) / sizeof(int) + k + j * (DATA_SIZE / sizeof(int))] != data[k]) {
+ nr_errors++;
+ fprintf(stderr, "expcted %d, read %d\n", data[k],
+ verify[(HEADER + PAD) / sizeof(int) + k + j * (DATA_SIZE / sizeof(int))]);
+ }
+ i++;
+ }
+ }
+*/
+ MPI_File_close(&fh);
+
+ MPI_Type_free(&mem_type);
+ MPI_Type_free(&file_type);
+
+ if (nr_errors == 0)
+ printf(" No Errors\n");
+
+ MPI_Finalize();
+
+ free(data);
+ free(verify);
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2014 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+/* Test case from John Bent (ROMIO req #835)
+ * Aggregation code was not handling certain access patterns when collective
+ * buffering forced */
+
+/* Uses nonblocking collective I/O.*/
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <mpi.h>
+#include <stdio.h>
+#include <string.h>
+
+#define NUM_OBJS 4
+#define OBJ_SIZE 1048576
+
+extern char *optarg;
+extern int optind, opterr, optopt;
+
+
+char *prog = NULL;
+int debug = 0;
+
+static void Usage(int line)
+{
+ int rank;
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ if (rank == 0) {
+ fprintf(stderr,
+ "Usage (line %d): %s [-d] [-h] -f filename\n"
+ "\t-d for debugging\n"
+ "\t-h to turn on the hints to force collective aggregation\n", line, prog);
+ }
+ exit(0);
+}
+
+static void fatal_error(int mpi_ret, MPI_Status * mpi_stat, const char *msg)
+{
+ fprintf(stderr, "Fatal error %s: %d\n", msg, mpi_ret);
+ MPI_Abort(MPI_COMM_WORLD, -1);
+}
+
+static void print_hints(int rank, MPI_File * mfh)
+{
+ MPI_Info info;
+ int nkeys;
+ int i, dummy_int;
+ char key[1024];
+ char value[1024];
+
+ MPI_Barrier(MPI_COMM_WORLD);
+ if (rank == 0) {
+ MPI_File_get_info(*mfh, &info);
+ MPI_Info_get_nkeys(info, &nkeys);
+
+ printf("HINTS:\n");
+ for (i = 0; i < nkeys; i++) {
+ MPI_Info_get_nthkey(info, i, key);
+ printf("%35s -> ", key);
+ MPI_Info_get(info, key, 1024, value, &dummy_int);
+ printf("%s\n", value);
+ }
+ MPI_Info_free(&info);
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+}
+
+static void fill_buffer(char *buffer, int bufsize, int rank, MPI_Offset offset)
+{
+ memset((void *) buffer, 0, bufsize);
+ snprintf(buffer, bufsize, "Hello from %d at %lld\n", rank, offset);
+}
+
+static MPI_Offset get_offset(int rank, int num_objs, int obj_size, int which_obj)
+{
+ MPI_Offset offset;
+ offset = (MPI_Offset) rank *num_objs * obj_size + which_obj * obj_size;
+ return offset;
+}
+
+static void write_file(char *target, int rank, MPI_Info * info)
+{
+ MPI_File wfh;
+ MPI_Request *request;
+ MPI_Status *mpi_stat;
+ int mpi_ret;
+ int i;
+ char **buffer;
+
+ request = (MPI_Request *) malloc(NUM_OBJS * sizeof(MPI_Request));
+ mpi_stat = (MPI_Status *) malloc(NUM_OBJS * sizeof(MPI_Status));
+ buffer = (char **) malloc(NUM_OBJS * sizeof(char *));
+
+ if (debug)
+ printf("%d writing file %s\n", rank, target);
+
+ if ((mpi_ret = MPI_File_open(MPI_COMM_WORLD, target,
+ MPI_MODE_WRONLY | MPI_MODE_CREATE, *info, &wfh))
+ != MPI_SUCCESS) {
+ fatal_error(mpi_ret, NULL, "open for write");
+ }
+
+ /* nonblocking collective write */
+ for (i = 0; i < NUM_OBJS; i++) {
+ MPI_Offset offset = get_offset(rank, NUM_OBJS, OBJ_SIZE, i);
+ buffer[i] = (char *) malloc(OBJ_SIZE);
+ fill_buffer(buffer[i], OBJ_SIZE, rank, offset);
+ if (debug)
+ printf("%s", buffer[i]);
+ if ((mpi_ret = MPI_File_iwrite_at_all(wfh, offset, buffer[i], OBJ_SIZE,
+ MPI_CHAR, &request[i]))
+ != MPI_SUCCESS) {
+ fatal_error(mpi_ret, NULL, "write");
+ }
+ }
+
+ if (debug)
+ print_hints(rank, &wfh);
+
+ MPI_Waitall(NUM_OBJS, request, mpi_stat);
+
+ if ((mpi_ret = MPI_File_close(&wfh)) != MPI_SUCCESS) {
+ fatal_error(mpi_ret, NULL, "close for write");
+ }
+ if (debug)
+ printf("%d wrote file %s\n", rank, target);
+
+ for (i = 0; i < NUM_OBJS; i++)
+ free(buffer[i]);
+ free(buffer);
+ free(mpi_stat);
+ free(request);
+}
+
+static int reduce_corruptions(int corrupt_blocks)
+{
+ int mpi_ret;
+ int sum;
+ if ((mpi_ret = MPI_Reduce(&corrupt_blocks, &sum, 1, MPI_INT, MPI_SUM, 0,
+ MPI_COMM_WORLD)) != MPI_SUCCESS) {
+ fatal_error(mpi_ret, NULL, "MPI_Reduce");
+ }
+ return sum;
+}
+
+static void read_file(char *target, int rank, MPI_Info * info, int *corrupt_blocks)
+{
+ MPI_File rfh;
+ MPI_Offset *offset;
+ MPI_Request *request;
+ MPI_Status *mpi_stat;
+ int mpi_ret;
+ int i;
+ char **buffer;
+ char **verify_buf = NULL;
+
+ offset = (MPI_Offset *) malloc(NUM_OBJS * sizeof(MPI_Offset));
+ request = (MPI_Request *) malloc(NUM_OBJS * sizeof(MPI_Request));
+ mpi_stat = (MPI_Status *) malloc(NUM_OBJS * sizeof(MPI_Status));
+ buffer = (char **) malloc(NUM_OBJS * sizeof(char *));
+ verify_buf = (char **) malloc(NUM_OBJS * sizeof(char *));
+
+ if (debug)
+ printf("%d reading file %s\n", rank, target);
+
+ if ((mpi_ret = MPI_File_open(MPI_COMM_WORLD, target, MPI_MODE_RDONLY,
+ *info, &rfh)) != MPI_SUCCESS) {
+ fatal_error(mpi_ret, NULL, "open for read");
+ }
+
+ /* nonblocking collective read */
+ for (i = 0; i < NUM_OBJS; i++) {
+ offset[i] = get_offset(rank, NUM_OBJS, OBJ_SIZE, i);
+ buffer[i] = (char *) malloc(OBJ_SIZE);
+ verify_buf[i] = (char *) malloc(OBJ_SIZE);
+ fill_buffer(verify_buf[i], OBJ_SIZE, rank, offset[i]);
+ if (debug)
+ printf("Expecting %s", verify_buf[i]);
+ if ((mpi_ret = MPI_File_iread_at_all(rfh, offset[i], buffer[i],
+ OBJ_SIZE, MPI_CHAR, &request[i]))
+ != MPI_SUCCESS) {
+ fatal_error(mpi_ret, NULL, "read");
+ }
+ }
+
+ MPI_Waitall(NUM_OBJS, request, mpi_stat);
+
+ /* verification */
+ for (i = 0; i < NUM_OBJS; i++) {
+ if (memcmp(verify_buf[i], buffer[i], OBJ_SIZE) != 0) {
+ (*corrupt_blocks)++;
+ printf("Corruption at %lld\n", offset[i]);
+ if (debug) {
+ printf("\tExpecting %s\n" "\tRecieved %s\n", verify_buf[i], buffer[i]);
+ }
+ }
+ }
+
+ if ((mpi_ret = MPI_File_close(&rfh)) != MPI_SUCCESS) {
+ fatal_error(mpi_ret, NULL, "close for read");
+ }
+
+ for (i = 0; i < NUM_OBJS; i++) {
+ free(verify_buf[i]);
+ free(buffer[i]);
+ }
+ free(verify_buf);
+ free(buffer);
+ free(mpi_stat);
+ free(request);
+ free(offset);
+}
+
+static void set_hints(MPI_Info * info)
+{
+ MPI_Info_set(*info, "romio_cb_write", "enable");
+ MPI_Info_set(*info, "romio_no_indep_rw", "1");
+ MPI_Info_set(*info, "cb_nodes", "1");
+ MPI_Info_set(*info, "cb_buffer_size", "4194304");
+}
+
+/*
+void
+set_hints(MPI_Info *info, char *hints) {
+ char *delimiter = " ";
+ char *hints_cp = strdup(hints);
+ char *key = strtok(hints_cp, delimiter);
+ char *val;
+ while (key) {
+ val = strtok(NULL, delimiter);
+ if (debug) printf("HINT: %s = %s\n", key, val);
+ if (! val) {
+ Usage(__LINE__);
+ }
+ MPI_Info_set(*info, key, val);
+ key = strtok(NULL, delimiter);
+ }
+ free(hints_cp);
+}
+*/
+
+int main(int argc, char *argv[])
+{
+ int nproc = 1, rank = 0;
+ char *target = NULL;
+ int c;
+ MPI_Info info;
+ int mpi_ret;
+ int corrupt_blocks = 0;
+
+ MPI_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nproc);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+ if ((mpi_ret = MPI_Info_create(&info)) != MPI_SUCCESS) {
+ if (rank == 0)
+ fatal_error(mpi_ret, NULL, "MPI_info_create.\n");
+ }
+
+ prog = strdup(argv[0]);
+
+ if (argc > 1) {
+ while ((c = getopt(argc, argv, "df:h")) != EOF) {
+ switch (c) {
+ case 'd':
+ debug = 1;
+ break;
+ case 'f':
+ target = strdup(optarg);
+ break;
+ case 'h':
+ set_hints(&info);
+ break;
+ default:
+ Usage(__LINE__);
+ }
+ }
+ if (!target) {
+ Usage(__LINE__);
+ }
+ }
+ else {
+ target = (char*)"testfile";
+ set_hints(&info);
+ }
+
+ write_file(target, rank, &info);
+ read_file(target, rank, &info, &corrupt_blocks);
+
+ corrupt_blocks = reduce_corruptions(corrupt_blocks);
+ if (rank == 0) {
+ if (corrupt_blocks == 0) {
+ fprintf(stdout, " No Errors\n");
+ }
+ else {
+ fprintf(stdout, "%d/%d blocks corrupt\n", corrupt_blocks, nproc * NUM_OBJS);
+ }
+ }
+ MPI_Info_free(&info);
+
+ MPI_Finalize();
+ free(prog);
+ exit(0);
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2014 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+/* Look for regressions in aggregator code. A more simple access pattern than
+ * aggregation1 */
+
+/* Uses nonblocking collective I/O.*/
+
+#include <mpi.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <string.h>
+
+#define BUFSIZE 512
+
+static void handle_error(int errcode, const char *str)
+{
+ char msg[MPI_MAX_ERROR_STRING];
+ int resultlen;
+ MPI_Error_string(errcode, msg, &resultlen);
+ fprintf(stderr, "%s: %s\n", str, msg);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+}
+
+int main(int argc, char **argv)
+{
+ MPI_Info info = MPI_INFO_NULL;
+ MPI_File fh;
+ MPI_Offset off = 0;
+ MPI_Status status;
+ int errcode;
+ int i, rank, errs = 0, toterrs, buffer[BUFSIZE], buf2[BUFSIZE];
+ MPI_Request request;
+ const char *filename = NULL;
+
+ filename = (argc > 1) ? argv[1] : "testfile";
+
+ MPI_Init(&argc, &argv);
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+ MPI_Info_create(&info);
+ MPI_Info_set(info, "romio_cb_write", "enable");
+ MPI_Info_set(info, "cb_nodes", "1");
+
+ for (i = 0; i < BUFSIZE; i++) {
+ buffer[i] = 10000 + rank;
+ }
+ off = rank * sizeof(buffer);
+
+ errcode = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_WRONLY | MPI_MODE_CREATE, info, &fh);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_open");
+ errcode = MPI_File_iwrite_at_all(fh, off, buffer, BUFSIZE, MPI_INT, &request);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_iwrite_at_all");
+ MPI_Wait(&request, &status);
+ errcode = MPI_File_close(&fh);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_close");
+
+ errcode = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, info, &fh);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_open");
+ errcode = MPI_File_iread_at_all(fh, off, buf2, BUFSIZE, MPI_INT, &request);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_iread_at_all");
+ MPI_Wait(&request, &status);
+ errcode = MPI_File_close(&fh);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_close");
+
+ for (i = 0; i < BUFSIZE; i++) {
+ if (buf2[i] != 10000 + rank)
+ errs++;
+ }
+ MPI_Allreduce(&errs, &toterrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
+ if (rank == 0) {
+ if (toterrs > 0) {
+ fprintf(stderr, "Found %d errors\n", toterrs);
+ }
+ else {
+ fprintf(stdout, " No Errors\n");
+ }
+ }
+ MPI_Info_free(&info);
+ MPI_Finalize();
+
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2014 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+#include <mpi.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <assert.h>
+
+//#define NUM_X 536870911
+#define NUM_X 536870912
+#define NUM_Y 1
+
+//#define BIGDT 2147483643
+#define BIGDT 2147483647
+
+/*
+static char MTEST_Descrip[] = "Nonblocking file read/write for bigtype";
+*/
+
+int main(int argc, char **argv)
+{
+ MPI_File fh;
+ int i, j;
+ size_t k;
+ MPI_Datatype inner_type, rem_type, mem_type;
+ MPI_Datatype int_type, file_type;
+ int *buf_write, *buf_read;
+ int rc;
+ MPI_Aint disp[2];
+ int block_len[2];
+ MPI_Datatype type[2];
+ MPI_Status status;
+ MPI_Request request;
+
+ MPI_Init(&argc, &argv);
+
+ if (sizeof(MPI_Aint) <= sizeof(int)) {
+ /* can't test on this platform... */
+ goto exit;
+ }
+
+ k = 0;
+ /* create a large buffer 2 */
+ buf_write = malloc(NUM_X * NUM_Y * sizeof(int));
+ buf_read = malloc(NUM_X * NUM_Y * sizeof(int));
+ if (buf_write == NULL || buf_read == NULL) {
+ fprintf(stderr, "Not enough memory\n");
+ exit(1);
+ }
+ memset(buf_read, 0, NUM_X * NUM_Y * sizeof(int));
+
+ for (i = 0; i < NUM_X; i++) {
+ for (j = 0; j < NUM_Y; j++) {
+ buf_write[k] = k;
+ k++;
+ }
+ }
+
+ /* Big Datatype (2^31 - 1 bytes) */
+ MPI_Type_contiguous(BIGDT, MPI_BYTE, &inner_type);
+ /* Small Datatype (1 byte) */
+ MPI_Type_contiguous(1, MPI_BYTE, &rem_type);
+
+ type[0] = inner_type;
+ type[1] = rem_type;
+ block_len[0] = 1;
+ block_len[1] = 1;
+ disp[0] = 0;
+ disp[1] = BIGDT;
+
+ /* combine both types */
+ MPI_Type_struct(2, block_len, disp, type, &mem_type);
+
+ MPI_Type_commit(&mem_type);
+ MPI_Type_free(&rem_type);
+ MPI_Type_free(&inner_type);
+
+ MPI_Type_contiguous(4, MPI_BYTE, &int_type);
+ {
+ /* This creates a big type that is actually contituous, touching an
+ * optimization that was at one point buggy */
+ MPI_Type_vector(1, NUM_X, 1, int_type, &file_type);
+ }
+
+ MPI_Type_commit(&file_type);
+ MPI_Type_free(&int_type);
+
+ rc = MPI_File_open(MPI_COMM_WORLD, "testfile",
+ MPI_MODE_RDWR | MPI_MODE_CREATE, MPI_INFO_NULL, &fh);
+ if (rc != MPI_SUCCESS) {
+ fprintf(stderr, "Can't open file: %s\n", "testfile");
+ exit(1);
+ }
+
+ rc = MPI_File_set_view(fh, 2144, MPI_BYTE, file_type, "native", MPI_INFO_NULL);
+ if (rc != MPI_SUCCESS) {
+ fprintf(stderr, "ERROR SET VIEW\n");
+ exit(1);
+ }
+
+ /* write everything */
+ rc = MPI_File_iwrite_at_all(fh, 0, buf_write, 1, mem_type, &request);
+ if (rc != MPI_SUCCESS) {
+ fprintf(stderr, "%d ERROR IWRITE AT ALL\n", rc);
+ exit(1);
+ }
+ MPI_Wait(&request, &status);
+
+ rc = MPI_File_set_view(fh, 2144, MPI_BYTE, file_type, "native", MPI_INFO_NULL);
+ if (rc != MPI_SUCCESS) {
+ fprintf(stderr, "ERROR SET VIEW\n");
+ exit(1);
+ }
+
+ /* read everything */
+ rc = MPI_File_iread_at_all(fh, 0, buf_read, 1, mem_type, &request);
+ if (rc != MPI_SUCCESS) {
+ fprintf(stderr, "%d ERROR IREAD AT ALL\n", rc);
+ exit(1);
+ }
+ MPI_Wait(&request, &status);
+
+ for (k = 0; k < NUM_X * NUM_Y; k++) {
+ if (buf_read[k] != buf_write[k]) {
+ fprintf(stderr, "Verfiy Failed index %zu: expected %d found %d\n",
+ k, buf_write[k], buf_read[k]);
+ assert(0);
+ }
+ }
+
+ free(buf_write);
+ free(buf_read);
+ MPI_File_close(&fh);
+
+ MPI_Type_free(&mem_type);
+ MPI_Type_free(&file_type);
+
+ exit:
+ MPI_Finalize();
+ printf(" No Errors\n");
+
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2014 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "mpi.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+/* A 32^3 array. For other array sizes, change array_of_gsizes below. */
+
+/* Uses nonblocking collective I/O. Writes a 3D block-distributed array to
+ a file corresponding to the global array in row-major (C) order, reads it
+ back, and checks that the data read is correct. */
+
+/* Note that the file access pattern is noncontiguous. */
+
+void handle_error(int errcode, const char *str);
+
+void handle_error(int errcode, const char *str)
+{
+ char msg[MPI_MAX_ERROR_STRING];
+ int resultlen;
+ MPI_Error_string(errcode, msg, &resultlen);
+ fprintf(stderr, "%s: %s\n", str, msg);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+}
+
+int main(int argc, char **argv)
+{
+ MPI_Datatype newtype;
+ int i, ndims, array_of_gsizes[3], array_of_distribs[3];
+ int order, nprocs, j, len;
+ int array_of_dargs[3], array_of_psizes[3];
+ int *readbuf, *writebuf, mynod, *tmpbuf, array_size;
+ MPI_Count bufcount;
+ char *filename;
+ int errs = 0, toterrs;
+ MPI_File fh;
+ MPI_Status status;
+ MPI_Request request;
+ MPI_Info info = MPI_INFO_NULL;
+ int errcode;
+
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &mynod);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+
+ /* process 0 broadcasts the file name to other processes */
+ if (!mynod) {
+ filename = (char*)"testfile";
+ len = strlen(filename);
+ MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ MPI_Bcast(filename, len + 1, MPI_CHAR, 0, MPI_COMM_WORLD);
+ }
+ else {
+ MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ filename = (char *) malloc(len + 1);
+ MPI_Bcast(filename, len + 1, MPI_CHAR, 0, MPI_COMM_WORLD);
+ }
+
+
+ /* create the distributed array filetype */
+ ndims = 3;
+ order = MPI_ORDER_C;
+
+ array_of_gsizes[0] = 32;
+ array_of_gsizes[1] = 32;
+ array_of_gsizes[2] = 32;
+
+ array_of_distribs[0] = MPI_DISTRIBUTE_BLOCK;
+ array_of_distribs[1] = MPI_DISTRIBUTE_BLOCK;
+ array_of_distribs[2] = MPI_DISTRIBUTE_BLOCK;
+
+ array_of_dargs[0] = MPI_DISTRIBUTE_DFLT_DARG;
+ array_of_dargs[1] = MPI_DISTRIBUTE_DFLT_DARG;
+ array_of_dargs[2] = MPI_DISTRIBUTE_DFLT_DARG;
+
+ for (i = 0; i < ndims; i++)
+ array_of_psizes[i] = 0;
+ MPI_Dims_create(nprocs, ndims, array_of_psizes);
+
+ MPI_Type_create_darray(nprocs, mynod, ndims, array_of_gsizes,
+ array_of_distribs, array_of_dargs,
+ array_of_psizes, order, MPI_INT, &newtype);
+ MPI_Type_commit(&newtype);
+
+ /* initialize writebuf */
+
+ MPI_Type_size_x(newtype, &bufcount);
+ bufcount = bufcount / sizeof(int);
+ writebuf = (int *) malloc(bufcount * sizeof(int));
+ for (i = 0; i < bufcount; i++)
+ writebuf[i] = 1;
+
+ array_size = array_of_gsizes[0] * array_of_gsizes[1] * array_of_gsizes[2];
+ tmpbuf = (int *) calloc(array_size, sizeof(int));
+ MPI_Irecv(tmpbuf, 1, newtype, mynod, 10, MPI_COMM_WORLD, &request);
+ MPI_Send(writebuf, bufcount, MPI_INT, mynod, 10, MPI_COMM_WORLD);
+ MPI_Wait(&request, &status);
+
+ j = 0;
+ for (i = 0; i < array_size; i++)
+ if (tmpbuf[i]) {
+ writebuf[j] = i;
+ j++;
+ }
+ free(tmpbuf);
+
+ if (j != bufcount) {
+ fprintf(stderr, "Error in initializing writebuf on process %d\n", mynod);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ /* end of initialization */
+
+ /* write the array to the file */
+ errcode = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, info, &fh);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_open");
+
+ errcode = MPI_File_set_view(fh, 0, MPI_INT, newtype, "native", info);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_set_view");
+
+ errcode = MPI_File_iwrite_all(fh, writebuf, bufcount, MPI_INT, &request);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_iwrite_all");
+ MPI_Wait(&request, &status);
+
+ errcode = MPI_File_close(&fh);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_close");
+
+ if (!mynod) {
+ /* wkl suggests potential for false " No Errors" if both read
+ * and write use the same file view */
+ /* solution: rank 0 reads entire file and checks write values */
+ errcode = MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_RDONLY, info, &fh);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_open");
+
+ readbuf = (int *) malloc(array_size * sizeof(int));
+ errcode = MPI_File_read(fh, readbuf, array_size, MPI_INT, &status);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_read");
+
+ errcode = MPI_File_close(&fh);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_close");
+
+ for (i = 0; i < array_size; i++)
+ if (readbuf[i] != i) {
+ errs++;
+ fprintf(stderr, "Error: write integer %d but read %d\n", i, readbuf[i]);
+ break;
+ }
+ free(readbuf);
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ /* now read it back */
+ readbuf = (int *) malloc(bufcount * sizeof(int));
+ errcode = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, info, &fh);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_open");
+
+ errcode = MPI_File_set_view(fh, 0, MPI_INT, newtype, "native", info);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_set_view");
+ errcode = MPI_File_iread_all(fh, readbuf, bufcount, MPI_INT, &request);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_iread_all");
+ MPI_Wait(&request, &status);
+ errcode = MPI_File_close(&fh);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_close");
+
+ /* check the data read */
+ for (i = 0; i < bufcount; i++) {
+ if (readbuf[i] != writebuf[i]) {
+ errs++;
+ fprintf(stderr, "Process %d, readbuf %d, writebuf %d, i %d\n",
+ mynod, readbuf[i], writebuf[i], i);
+ }
+ }
+
+ MPI_Allreduce(&errs, &toterrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
+ if (mynod == 0) {
+ if (toterrs > 0) {
+ fprintf(stderr, "Found %d errors\n", toterrs);
+ }
+ else {
+ fprintf(stdout, " No Errors\n");
+ }
+ }
+
+ MPI_Type_free(&newtype);
+ free(readbuf);
+ free(writebuf);
+ if (mynod)
+ free(filename);
+
+ MPI_Finalize();
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2014 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <mpi.h>
+
+#define NSIDE 5
+#define NBLOCK 3
+#define NPROC 2
+
+#define CHECK(fn) {int errcode; errcode = (fn); if (errcode != MPI_SUCCESS) handle_error(errcode, #fn);}
+
+static void handle_error(int errcode, const char *str)
+{
+ char msg[MPI_MAX_ERROR_STRING];
+ int resultlen;
+ MPI_Error_string(errcode, msg, &resultlen);
+ fprintf(stderr, "%s: %s\n", str, msg);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+}
+
+
+int main(int argc, char *argv[])
+{
+ int i, j, nerrors = 0, total_errors = 0;
+
+ int rank, size;
+ int bpos;
+
+ MPI_Datatype darray;
+ MPI_Request request;
+ MPI_Status status;
+ MPI_File mpi_fh;
+
+ /* Define array distribution
+ * A 2x2 block size works with ROMIO, a 3x3 block size breaks it. */
+ int distrib[2] = { MPI_DISTRIBUTE_CYCLIC, MPI_DISTRIBUTE_CYCLIC };
+ int bsize[2] = { NBLOCK, NBLOCK };
+ int gsize[2] = { NSIDE, NSIDE };
+ int psize[2] = { NPROC, NPROC };
+
+ double data[NSIDE * NSIDE];
+ double *ldata, *pdata;
+
+ int tsize, nelem;
+ const char *filename;
+
+ MPI_File dfile;
+
+ filename = (argc > 1) ? argv[1] : "testfile";
+
+ MPI_Init(&argc, &argv);
+
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+ /* Set up type */
+ CHECK(MPI_Type_create_darray(size, rank, 2, gsize, distrib,
+ bsize, psize, MPI_ORDER_FORTRAN, MPI_DOUBLE, &darray));
+ CHECK(MPI_Type_commit(&darray));
+ CHECK(MPI_Type_size(darray, &tsize));
+ nelem = tsize / sizeof(double);
+
+ for (i = 0; i < (NSIDE * NSIDE); i++)
+ data[i] = i;
+
+ if (rank == 0) {
+ CHECK(MPI_File_open(MPI_COMM_SELF, filename,
+ MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &dfile));
+ CHECK(MPI_File_write(dfile, data, NSIDE * NSIDE, MPI_DOUBLE, &status));
+ CHECK(MPI_File_close(&dfile));
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ /* Allocate buffer */
+ ldata = (double *) malloc(tsize);
+ pdata = (double *) malloc(tsize);
+
+ /* Use Pack to pull out array */
+ bpos = 0;
+ CHECK(MPI_Pack(data, 1, darray, pdata, tsize, &bpos, MPI_COMM_WORLD));
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ /* Read in array from file. */
+ CHECK(MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &mpi_fh));
+ CHECK(MPI_File_set_view(mpi_fh, 0, MPI_DOUBLE, darray, "native", MPI_INFO_NULL));
+ CHECK(MPI_File_iread_all(mpi_fh, ldata, nelem, MPI_DOUBLE, &request));
+ CHECK(MPI_Wait(&request, &status));
+ CHECK(MPI_File_close(&mpi_fh));
+
+ for (i = 0; i < size; i++) {
+#ifdef VERBOSE
+ MPI_Barrier(MPI_COMM_WORLD);
+ if (rank == i) {
+ printf("=== Rank %i === (%i elements) \nPacked: ", rank, nelem);
+ for (j = 0; j < nelem; j++) {
+ printf("%4.1f ", pdata[j]);
+ fflush(stdout);
+ }
+ printf("\nRead: ");
+ for (j = 0; j < nelem; j++) {
+ printf("%4.1f ", ldata[j]);
+ fflush(stdout);
+ }
+ printf("\n\n");
+ fflush(stdout);
+ }
+#endif
+ if (rank == i) {
+ for (j = 0; j < nelem; j++) {
+ if (pdata[j] != ldata[j]) {
+ fprintf(stderr, "rank %d at index %d: packbuf %4.1f filebuf %4.1f\n",
+ rank, j, pdata[j], ldata[j]);
+ nerrors++;
+ }
+ }
+ }
+ }
+ MPI_Allreduce(&nerrors, &total_errors, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
+ if (rank == 0 && total_errors == 0)
+ printf(" No Errors\n");
+
+ free(ldata);
+ free(pdata);
+ MPI_Type_free(&darray);
+ MPI_Finalize();
+
+ exit(total_errors);
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2014 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+/* Wei-keng Liao (wkliao@ece.northwestern.edu) September 8, 2008 */
+
+/* Uses nonblocking collective I/O.*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <mpi.h>
+
+#define YLEN 5
+#define XLEN 10
+#define SUB_XLEN 3
+
+/* rjl: I was just too lazy to compute this at run-time */
+char compare_buf[XLEN * 4][YLEN * 4] = {
+ {'0', '1', '2', 0, 0, '3', '4', '5', 0, 0, 'D', 'E', 'F', 0, 0, 'G', 'H', 'I'},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {'6', '7', '8', 0, 0, '9', ':', ';', 0, 0, 'J', 'K', 'L', 0, 0, 'M', 'N', 'O'},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {'X', 'Y', 'Z', 0, 0, '[', '\\', ']', 0, 0, 'l', 'm', 'n', 0, 0, 'o', 'p', 'q'},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {'^', '_', '`', 0, 0, 'a', 'b', 'c', 0, 0, 'r', 's', 't', 0, 0, 'u', 'v', 'w'},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {'0', '1', '2', 0, 0, '3', '4', '5', 0, 0, 'D', 'E', 'F', 0, 0, 'G', 'H', 'I'},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {'6', '7', '8', 0, 0, '9', ':', ';', 0, 0, 'J', 'K', 'L', 0, 0, 'M', 'N', 'O'},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {'X', 'Y', 'Z', 0, 0, '[', '\\', ']', 0, 0, 'l', 'm', 'n', 0, 0, 'o', 'p', 'q'},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {'^', '_', '`', 0, 0, 'a', 'b', 'c', 0, 0, 'r', 's', 't', 0, 0, 'u', 'v', 'w'},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+};
+
+
+/* set this if you want a dump of the global array
+#define VERBOSE 1
+*/
+
+/*----< main() >------------------------------------------------------------*/
+int main(int argc, char **argv)
+{
+ int i, j, err, rank, np, num_io;
+ char *buf, *filename;
+ int rank_dim[2], array_of_sizes[2];
+ int array_of_subsizes[2];
+ int count, *blocklengths, global_array_size;
+ MPI_Count ftype_size;
+ MPI_Aint *displacements;
+ MPI_File fh;
+ MPI_Datatype ftype;
+ MPI_Request *request;
+ MPI_Status *statuses;
+ MPI_Status status;
+ MPI_Offset offset = 0;
+ int nr_errors = 0;
+#ifdef VERBOSE
+ int k;
+#endif
+
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &np);
+
+ if (np != 4) {
+ if (!rank)
+ printf("Please run with 4 processes. Exiting ...\n\n");
+ MPI_Finalize();
+ return 1;
+ }
+
+ filename = (argc > 1) ? argv[1] : (char*)"testfile";
+
+ num_io = 2;
+
+ request = (MPI_Request *) malloc(num_io * sizeof(MPI_Request));
+ statuses = (MPI_Status *) malloc(num_io * sizeof(MPI_Status));
+
+ /*-----------------------------------------------------------------------*/
+ /* process rank in each dimension */
+ rank_dim[0] = rank / 2;
+ rank_dim[1] = rank % 2;
+
+ /* global 2D array size */
+ array_of_sizes[0] = YLEN * 2;
+ array_of_sizes[1] = XLEN * 2;
+
+ global_array_size = array_of_sizes[0] * array_of_sizes[1];
+
+ array_of_subsizes[0] = YLEN / 2;
+ array_of_subsizes[1] = XLEN * SUB_XLEN / 5;
+
+ offset = rank_dim[0] * YLEN * array_of_sizes[1] + rank_dim[1] * XLEN;
+
+ /* define data type for file view */
+ count = array_of_subsizes[0] * 2; /* 2 is the no. blocks along X */
+ blocklengths = (int *) malloc(count * sizeof(int));
+ displacements = (MPI_Aint *) malloc(count * sizeof(MPI_Aint));
+ for (i = 0; i < count; i++)
+ blocklengths[i] = array_of_subsizes[1] / 2;
+ for (i = 0; i < array_of_subsizes[0]; i++)
+ for (j = 0; j < 2; j++)
+ displacements[i * 2 + j] = offset + i * 2 * array_of_sizes[1]
+ + j * XLEN / 2;
+ MPI_Type_create_hindexed(count, blocklengths, displacements, MPI_CHAR, &ftype);
+ MPI_Type_commit(&ftype);
+ MPI_Type_size_x(ftype, &ftype_size);
+
+/* subarray's layout in the global array
+
+ P0's 's layout P1's layout
+ [ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9] | [ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9]
+[ 0] 0 1 2 3 4 5 | D E F G H I
+[ 1] |
+[ 2] 6 7 8 9 : ; | J K L M N O
+[ 3] |
+[ 4] |
+[ 5] |
+[ 6] |
+[ 7] |
+[ 8] |
+[ 9] |
+
+ P2's 's layout P3's layout
+ [ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9] | [ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9]
+[ 0] |
+[ 1] |
+[ 2] |
+[ 3] |
+[ 4] |
+[ 5] X Y Z [ \ ] | l m n o p q
+[ 6] |
+[ 7] ^ _ ` a b c | r s t u v w
+[ 8] |
+[ 9] |
+*/
+
+ /* initialize the write buffer */
+ buf = (char *) malloc(array_of_subsizes[0] * array_of_subsizes[1]);
+ for (i = 0; i < array_of_subsizes[0] * array_of_subsizes[1]; i++)
+ buf[i] = '0' + rank * 20 + i % 79;
+
+ /* zero file contents --------------------------------------------------- */
+ if (rank == 0) {
+ char *wr_buf = (char *) calloc(num_io * global_array_size, 1);
+ MPI_File_open(MPI_COMM_SELF, filename,
+ MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &fh);
+ MPI_File_write(fh, wr_buf, num_io * global_array_size, MPI_CHAR, &status);
+ MPI_File_close(&fh);
+ free(wr_buf);
+ }
+ /* open the file -------------------------------------------------------- */
+ err = MPI_File_open(MPI_COMM_WORLD, filename,
+ MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &fh);
+ if (err != MPI_SUCCESS) {
+ printf("Error: MPI_File_open() filename %s\n", filename);
+ MPI_Abort(MPI_COMM_WORLD, -1);
+ exit(1);
+ }
+
+ /* MPI nonblocking collective write */
+ for (i = 0; i < num_io; i++) {
+ offset = i * global_array_size;
+ /* set the file view */
+ MPI_File_set_view(fh, offset, MPI_BYTE, ftype, "native", MPI_INFO_NULL);
+ MPI_File_iwrite_all(fh, buf, ftype_size, MPI_CHAR, &request[i]);
+ }
+ MPI_Waitall(num_io, request, statuses);
+ MPI_File_close(&fh);
+
+ /* read and print file contents ----------------------------------------- */
+ if (rank == 0) {
+ char *ptr;
+ char *rd_buf = (char *) calloc(num_io * global_array_size, 1);
+ MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
+ MPI_File_read(fh, rd_buf, num_io * global_array_size, MPI_CHAR, &status);
+ MPI_File_close(&fh);
+
+#ifdef VERBOSE
+ printf("-------------------------------------------------------\n");
+ printf(" [");
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j < XLEN; j++)
+ printf(" %d", j);
+ printf(" ");
+ }
+ printf("]\n\n");
+
+
+ ptr = rd_buf;
+ for (k = 0; k < num_io; k++) {
+ for (i = 0; i < 2 * YLEN; i++) {
+ printf("[%2d]", k * 2 * YLEN + i);
+ for (j = 0; j < 2 * XLEN; j++) {
+ if (j > 0 && j % XLEN == 0)
+ printf(" ");
+ if (*ptr != 0)
+ printf(" %c", *ptr);
+ else
+ printf(" ");
+ ptr++;
+ }
+ printf("\n");
+ }
+ printf("\n");
+ }
+#endif
+ ptr = rd_buf;
+ for (i = 0; i < 2 * YLEN * num_io; i++) {
+ for (j = 0; j < 2 * XLEN; j++) {
+ if (*ptr != compare_buf[i][j]) {
+ fprintf(stderr, "expected %d got %d at [%d][%d]\n",
+ *ptr, compare_buf[i][j], i, j);
+ nr_errors++;
+ }
+ ptr++;
+ }
+ }
+ free(rd_buf);
+
+ if (nr_errors == 0)
+ fprintf(stdout, " No Errors\n");
+ else
+ fprintf(stderr, "Found %d errors\n", nr_errors);
+ }
+
+ free(blocklengths);
+ free(displacements);
+ free(buf);
+ free(request);
+ free(statuses);
+ MPI_Type_free(&ftype);
+ MPI_Finalize();
+ return 0;
+}
+
+/* command-line outputs are: (the global array is written twice)
+
+% mpiexec -n 4 wkl_subarray
+-------------------------------------------------------
+ [ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 ]
+
+[ 0] 0 1 2 3 4 5 D E F G H I
+[ 1]
+[ 2] 6 7 8 9 : ; J K L M N O
+[ 3]
+[ 4]
+[ 5] X Y Z [ \ ] l m n o p q
+[ 6]
+[ 7] ^ _ ` a b c r s t u v w
+[ 8]
+[ 9]
+
+[10] 0 1 2 3 4 5 D E F G H I
+[11]
+[12] 6 7 8 9 : ; J K L M N O
+[13]
+[14]
+[15] X Y Z [ \ ] l m n o p q
+[16]
+[17] ^ _ ` a b c r s t u v w
+[18]
+[19]
+
+*/
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2014 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+#include <mpi.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#define DATA_SIZE 324*4
+#define PAD 256
+#define HEADER 144
+#define BLK_COUNT 3
+
+static void handle_error(int errcode, const char *str)
+{
+ char msg[MPI_MAX_ERROR_STRING];
+ int resultlen;
+ MPI_Error_string(errcode, msg, &resultlen);
+ fprintf(stderr, "%s: %s\n", str, msg);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+}
+
+#define CHECK(fn) { int errcode; errcode = (fn); if (errcode != MPI_SUCCESS) handle_error(errcode, #fn); }
+
+int main(int argc, char **argv)
+{
+ MPI_File fh;
+ MPI_Datatype file_type, mem_type;
+ int *data = NULL;
+ int *verify = NULL;
+ int data_size = DATA_SIZE;
+ int i, j, k, nr_errors = 0;
+ MPI_Aint disp[BLK_COUNT];
+
+ char *filename = (char*)"unnamed.dat";
+ MPI_Status status;
+ MPI_Request request;
+
+ MPI_Init(&argc, &argv);
+ disp[0] = (MPI_Aint) (PAD);
+ disp[1] = (MPI_Aint) (data_size * 1 + PAD);
+ disp[2] = (MPI_Aint) (data_size * 2 + PAD);
+
+ data = malloc(data_size);
+ verify = malloc(data_size * BLK_COUNT + HEADER + PAD);
+ for (i = 0; i < data_size / sizeof(int); i++)
+ data[i] = i;
+
+ MPI_Type_create_hindexed_block(BLK_COUNT, data_size, disp, MPI_BYTE, &file_type);
+ MPI_Type_commit(&file_type);
+
+ MPI_Type_create_hvector(BLK_COUNT, data_size, 0, MPI_BYTE, &mem_type);
+ MPI_Type_commit(&mem_type);
+
+ if (1 < argc)
+ filename = argv[1];
+
+ CHECK(MPI_File_open(MPI_COMM_WORLD, filename,
+ MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE,
+ MPI_INFO_NULL, &fh) != 0);
+
+ CHECK(MPI_File_set_view(fh, HEADER, MPI_BYTE, file_type, "native", MPI_INFO_NULL));
+
+ /* write everything */
+ CHECK(MPI_File_iwrite_at_all(fh, 0, data, 1, mem_type, &request));
+ MPI_Wait(&request, &status);
+
+ /* verify */
+ CHECK(MPI_File_set_view(fh, 0, MPI_BYTE, MPI_BYTE, "native", MPI_INFO_NULL));
+ CHECK(MPI_File_iread_at_all(fh, 0,
+ verify, (HEADER + PAD + BLK_COUNT * DATA_SIZE) / sizeof(int),
+ MPI_INT, &request));
+ MPI_Wait(&request, &status);
+
+ /* header and block padding should have no data */
+ for (i = 0; i < (HEADER + PAD) / sizeof(int); i++) {
+ if (verify[i] != 0) {
+ nr_errors++;
+ fprintf(stderr, "expected 0, read %d\n", verify[i]);
+ }
+ }
+ /* blocks are replicated */
+ for (j = 0; j < BLK_COUNT; j++) {
+ for (k = 0; k < (DATA_SIZE / sizeof(int)); k++) {
+ if (verify[(HEADER + PAD) / sizeof(int) + k + j * (DATA_SIZE / sizeof(int))]
+ != data[k]) {
+ nr_errors++;
+ fprintf(stderr, "expcted %d, read %d\n", data[k],
+ verify[(HEADER + PAD) / sizeof(int) + k + j * (DATA_SIZE / sizeof(int))]);
+ }
+ i++;
+ }
+ }
+
+ MPI_File_close(&fh);
+
+ MPI_Type_free(&mem_type);
+ MPI_Type_free(&file_type);
+
+ if (nr_errors == 0)
+ printf(" No Errors\n");
+
+ MPI_Finalize();
+
+ free(data);
+ free(verify);
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2001 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+#include "mpi.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "mpitest.h"
+
+/* tests noncontiguous reads/writes using nonblocking I/O */
+
+/*
+static char MTEST_Descrip[] = "Test nonblocking I/O";
+*/
+
+#define SIZE 5000
+
+#define VERBOSE 0
+
+int main(int argc, char **argv)
+{
+ int *buf, i, mynod, nprocs, len, b[3];
+ int errs = 0;
+ MPI_Aint d[3];
+ MPI_File fh;
+ MPI_Status status;
+ char *filename;
+ MPI_Datatype typevec, newtype, t[3];
+ MPI_Request req;
+
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &mynod);
+
+ if (nprocs != 2) {
+ fprintf(stderr, "Run this program on two processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+
+/* process 0 takes the file name as a command-line argument and
+ broadcasts it to other processes */
+ if (!mynod) {
+ i = 1;
+ while ((i < argc) && strcmp("-fname", *argv)) {
+ i++;
+ argv++;
+ }
+ if (i >= argc) {
+ len = 8;
+ filename = (char *) malloc(len + 10);
+ strcpy(filename, "testfile");
+ /*
+ * fprintf(stderr, "\n*# Usage: i_noncontig -fname filename\n\n");
+ * MPI_Abort(MPI_COMM_WORLD, 1);
+ */
+ }
+ else {
+ argv++;
+ len = (int) strlen(*argv);
+ filename = (char *) malloc(len + 1);
+ strcpy(filename, *argv);
+ }
+ MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ MPI_Bcast(filename, len + 1, MPI_CHAR, 0, MPI_COMM_WORLD);
+ }
+ else {
+ MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ filename = (char *) malloc(len + 1);
+ MPI_Bcast(filename, len + 1, MPI_CHAR, 0, MPI_COMM_WORLD);
+ }
+
+ buf = (int *) malloc(SIZE * sizeof(int));
+
+ MPI_Type_vector(SIZE / 2, 1, 2, MPI_INT, &typevec);
+
+ b[0] = b[1] = b[2] = 1;
+ d[0] = 0;
+ d[1] = mynod * sizeof(int);
+ d[2] = SIZE * sizeof(int);
+ t[0] = MPI_LB;
+ t[1] = typevec;
+ t[2] = MPI_UB;
+
+ MPI_Type_struct(3, b, d, t, &newtype);
+ MPI_Type_commit(&newtype);
+ MPI_Type_free(&typevec);
+
+ if (!mynod) {
+#if VERBOSE
+ fprintf(stderr,
+ "\ntesting noncontiguous in memory, noncontiguous in file using nonblocking I/O\n");
+#endif
+ MPI_File_delete(filename, MPI_INFO_NULL);
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+
+ MPI_File_set_view(fh, 0, MPI_INT, newtype, (char *) "native", MPI_INFO_NULL);
+
+ for (i = 0; i < SIZE; i++)
+ buf[i] = i + mynod * SIZE;
+ MPI_File_iwrite(fh, buf, 1, newtype, &req);
+ MPI_Wait(&req, &status);
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ for (i = 0; i < SIZE; i++)
+ buf[i] = -1;
+
+ MPI_File_iread_at(fh, 0, buf, 1, newtype, &req);
+ MPI_Wait(&req, &status);
+
+ for (i = 0; i < SIZE; i++) {
+ if (!mynod) {
+ if ((i % 2) && (buf[i] != -1)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be -1\n", mynod, i, buf[i]);
+ }
+ if (!(i % 2) && (buf[i] != i)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n", mynod, i, buf[i], i);
+ }
+ }
+ else {
+ if ((i % 2) && (buf[i] != i + mynod * SIZE)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n",
+ mynod, i, buf[i], i + mynod * SIZE);
+ }
+ if (!(i % 2) && (buf[i] != -1)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be -1\n", mynod, i, buf[i]);
+ }
+ }
+ }
+
+ MPI_File_close(&fh);
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ if (!mynod) {
+#if VERBOSE
+ fprintf(stderr,
+ "\ntesting noncontiguous in memory, contiguous in file using nonblocking I/O\n");
+#endif
+ MPI_File_delete(filename, MPI_INFO_NULL);
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+
+ for (i = 0; i < SIZE; i++)
+ buf[i] = i + mynod * SIZE;
+ MPI_File_iwrite_at(fh, mynod * (SIZE / 2) * sizeof(int), buf, 1, newtype, &req);
+ MPI_Wait(&req, &status);
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ for (i = 0; i < SIZE; i++)
+ buf[i] = -1;
+
+ MPI_File_iread_at(fh, mynod * (SIZE / 2) * sizeof(int), buf, 1, newtype, &req);
+ MPI_Wait(&req, &status);
+
+ for (i = 0; i < SIZE; i++) {
+ if (!mynod) {
+ if ((i % 2) && (buf[i] != -1)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be -1\n", mynod, i, buf[i]);
+ }
+ if (!(i % 2) && (buf[i] != i)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n", mynod, i, buf[i], i);
+ }
+ }
+ else {
+ if ((i % 2) && (buf[i] != i + mynod * SIZE)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n",
+ mynod, i, buf[i], i + mynod * SIZE);
+ }
+ if (!(i % 2) && (buf[i] != -1)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be -1\n", mynod, i, buf[i]);
+ }
+ }
+ }
+
+ MPI_File_close(&fh);
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ if (!mynod) {
+#if VERBOSE
+ fprintf(stderr,
+ "\ntesting contiguous in memory, noncontiguous in file using nonblocking I/O\n");
+#endif
+ MPI_File_delete(filename, MPI_INFO_NULL);
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+
+ MPI_File_set_view(fh, 0, MPI_INT, newtype, (char *) "native", MPI_INFO_NULL);
+
+ for (i = 0; i < SIZE; i++)
+ buf[i] = i + mynod * SIZE;
+ MPI_File_iwrite(fh, buf, SIZE, MPI_INT, &req);
+ MPI_Wait(&req, &status);
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ for (i = 0; i < SIZE; i++)
+ buf[i] = -1;
+
+ MPI_File_iread_at(fh, 0, buf, SIZE, MPI_INT, &req);
+ MPI_Wait(&req, &status);
+
+ for (i = 0; i < SIZE; i++) {
+ if (!mynod) {
+ if (buf[i] != i) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n", mynod, i, buf[i], i);
+ }
+ }
+ else {
+ if (buf[i] != i + mynod * SIZE) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n",
+ mynod, i, buf[i], i + mynod * SIZE);
+ }
+ }
+ }
+
+ MPI_File_close(&fh);
+
+ MPI_Type_free(&newtype);
+ free(buf);
+ free(filename);
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2014 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "mpi.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+/* tests noncontiguous reads/writes using nonblocking collective I/O */
+
+#define SIZE 5000
+
+#define VERBOSE 0
+int main(int argc, char **argv)
+{
+ int *buf, i, mynod, nprocs, len, b[3];
+ int errs = 0, toterrs;
+ MPI_Aint d[3];
+ MPI_File fh;
+ MPI_Request request;
+ MPI_Status status;
+ char *filename;
+ MPI_Datatype typevec, newtype, t[3];
+
+ MPI_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &mynod);
+
+ if (nprocs != 2) {
+ fprintf(stderr, "Run this program on two processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+
+ /* process 0 broadcasts the file name to other processes */
+ if (!mynod) {
+ filename = (char*)"testfile";
+ len = strlen(filename);
+ MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ MPI_Bcast(filename, len + 1, MPI_CHAR, 0, MPI_COMM_WORLD);
+ }
+ else {
+ MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ filename = (char *) malloc(len + 1);
+ MPI_Bcast(filename, len + 1, MPI_CHAR, 0, MPI_COMM_WORLD);
+ }
+
+ buf = (int *) malloc(SIZE * sizeof(int));
+
+ MPI_Type_vector(SIZE / 2, 1, 2, MPI_INT, &typevec);
+
+ b[0] = b[1] = b[2] = 1;
+ d[0] = 0;
+ d[1] = mynod * sizeof(int);
+ d[2] = SIZE * sizeof(int);
+ t[0] = MPI_LB;
+ t[1] = typevec;
+ t[2] = MPI_UB;
+
+ MPI_Type_struct(3, b, d, t, &newtype);
+ MPI_Type_commit(&newtype);
+ MPI_Type_free(&typevec);
+
+ if (!mynod) {
+#if VERBOSE
+ fprintf(stderr, "\ntesting noncontiguous in memory, noncontiguous in "
+ "file using collective I/O\n");
+#endif
+ MPI_File_delete(filename, MPI_INFO_NULL);
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+
+ MPI_File_set_view(fh, 0, MPI_INT, newtype, "native", MPI_INFO_NULL);
+
+ for (i = 0; i < SIZE; i++)
+ buf[i] = i + mynod * SIZE;
+ MPI_File_iwrite_all(fh, buf, 1, newtype, &request);
+
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Wait(&request, &status);
+
+ for (i = 0; i < SIZE; i++)
+ buf[i] = -1;
+
+ MPI_File_iread_at_all(fh, 0, buf, 1, newtype, &request);
+ MPI_Wait(&request, &status);
+
+ for (i = 0; i < SIZE; i++) {
+ if (!mynod) {
+ if ((i % 2) && (buf[i] != -1)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be -1\n", mynod, i, buf[i]);
+ }
+ if (!(i % 2) && (buf[i] != i)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n", mynod, i, buf[i], i);
+ }
+ }
+ else {
+ if ((i % 2) && (buf[i] != i + mynod * SIZE)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n",
+ mynod, i, buf[i], i + mynod * SIZE);
+ }
+ if (!(i % 2) && (buf[i] != -1)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be -1\n", mynod, i, buf[i]);
+ }
+ }
+ }
+
+ MPI_File_close(&fh);
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ if (!mynod) {
+#if VERBOSE
+ fprintf(stderr, "\ntesting noncontiguous in memory, contiguous in file "
+ "using collective I/O\n");
+#endif
+ MPI_File_delete(filename, MPI_INFO_NULL);
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+
+ for (i = 0; i < SIZE; i++)
+ buf[i] = i + mynod * SIZE;
+ MPI_File_iwrite_at_all(fh, mynod * (SIZE / 2) * sizeof(int), buf, 1, newtype, &request);
+
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Wait(&request, &status);
+
+ for (i = 0; i < SIZE; i++)
+ buf[i] = -1;
+
+ MPI_File_iread_at_all(fh, mynod * (SIZE / 2) * sizeof(int), buf, 1, newtype, &request);
+ MPI_Wait(&request, &status);
+
+ for (i = 0; i < SIZE; i++) {
+ if (!mynod) {
+ if ((i % 2) && (buf[i] != -1)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be -1\n", mynod, i, buf[i]);
+ }
+ if (!(i % 2) && (buf[i] != i)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n", mynod, i, buf[i], i);
+ }
+ }
+ else {
+ if ((i % 2) && (buf[i] != i + mynod * SIZE)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n",
+ mynod, i, buf[i], i + mynod * SIZE);
+ }
+ if (!(i % 2) && (buf[i] != -1)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be -1\n", mynod, i, buf[i]);
+ }
+ }
+ }
+
+ MPI_File_close(&fh);
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ if (!mynod) {
+#if VERBOSE
+ fprintf(stderr, "\ntesting contiguous in memory, noncontiguous in file "
+ "using collective I/O\n");
+#endif
+ MPI_File_delete(filename, MPI_INFO_NULL);
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+
+ MPI_File_set_view(fh, 0, MPI_INT, newtype, "native", MPI_INFO_NULL);
+
+ for (i = 0; i < SIZE; i++)
+ buf[i] = i + mynod * SIZE;
+ MPI_File_iwrite_all(fh, buf, SIZE, MPI_INT, &request);
+
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Wait(&request, &status);
+
+ for (i = 0; i < SIZE; i++)
+ buf[i] = -1;
+
+ MPI_File_iread_at_all(fh, 0, buf, SIZE, MPI_INT, &request);
+ MPI_Wait(&request, &status);
+
+ for (i = 0; i < SIZE; i++) {
+ if (!mynod) {
+ if (buf[i] != i) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n", mynod, i, buf[i], i);
+ }
+ }
+ else {
+ if (buf[i] != i + mynod * SIZE) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n",
+ mynod, i, buf[i], i + mynod * SIZE);
+ }
+ }
+ }
+
+ MPI_File_close(&fh);
+
+ MPI_Allreduce(&errs, &toterrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
+ if (mynod == 0) {
+ if (toterrs > 0) {
+ fprintf(stderr, "Found %d errors\n", toterrs);
+ }
+ else {
+ fprintf(stdout, " No Errors\n");
+ }
+ }
+
+ MPI_Type_free(&newtype);
+ free(buf);
+ if (mynod)
+ free(filename);
+ MPI_Finalize();
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2014 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "mpi.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+/* tests noncontiguous reads/writes using nonblocking collective I/O */
+
+/* this test is almost exactly like i_noncontig_coll.c with the following changes:
+ *
+ * . generalized file writing/reading to handle arbitrary number of processors
+ * . provides the "cb_config_list" hint with several permutations of the
+ * avaliable processors.
+ * [ makes use of code copied from ROMIO's ADIO code to collect the names of
+ * the processors ]
+ */
+
+/* we are going to muck with this later to make it evenly divisible by however many compute nodes we have */
+#define STARTING_SIZE 5000
+
+int test_file(char *filename, int mynod, int nprocs, char *cb_hosts, const char *msg, int verbose);
+
+#define ADIOI_Free free
+#define ADIOI_Malloc malloc
+#define FPRINTF fprintf
+/* I have no idea what the "D" stands for; it's how things are done in adio.h
+ */
+struct ADIO_cb_name_arrayD {
+ int refct;
+ int namect;
+ char **names;
+};
+typedef struct ADIO_cb_name_arrayD *ADIO_cb_name_array;
+
+void handle_error(int errcode, const char *str);
+int cb_gather_name_array(MPI_Comm comm, ADIO_cb_name_array * arrayp);
+void default_str(int mynod, int len, ADIO_cb_name_array array, char *dest);
+void reverse_str(int mynod, int len, ADIO_cb_name_array array, char *dest);
+void reverse_alternating_str(int mynod, int len, ADIO_cb_name_array array, char *dest);
+void simple_shuffle_str(int mynod, int len, ADIO_cb_name_array array, char *dest);
+
+
+void handle_error(int errcode, const char *str)
+{
+ char msg[MPI_MAX_ERROR_STRING];
+ int resultlen;
+ MPI_Error_string(errcode, msg, &resultlen);
+ fprintf(stderr, "%s: %s\n", str, msg);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+}
+
+
+/* cb_gather_name_array() - gather a list of processor names from all processes
+ * in a communicator and store them on rank 0.
+ *
+ * This is a collective call on the communicator(s) passed in.
+ *
+ * Obtains a rank-ordered list of processor names from the processes in
+ * "dupcomm".
+ *
+ * Returns 0 on success, -1 on failure.
+ *
+ * NOTE: Needs some work to cleanly handle out of memory cases!
+ */
+int cb_gather_name_array(MPI_Comm comm, ADIO_cb_name_array * arrayp)
+{
+ /* this is copied from ROMIO, but since this test is for correctness,
+ * not performance, note that we have removed the parts where ROMIO
+ * uses a keyval to cache the name array. We'll just rebuild it if we
+ * need to */
+
+ char my_procname[MPI_MAX_PROCESSOR_NAME], **procname = 0;
+ int *procname_len = NULL, my_procname_len, *disp = NULL, i;
+ int commsize, commrank;
+ ADIO_cb_name_array array = NULL;
+
+ MPI_Comm_size(comm, &commsize);
+ MPI_Comm_rank(comm, &commrank);
+
+ MPI_Get_processor_name(my_procname, &my_procname_len);
+
+ /* allocate space for everything */
+ array = (ADIO_cb_name_array) malloc(sizeof(*array));
+ if (array == NULL) {
+ return -1;
+ }
+ array->refct = 1;
+
+ if (commrank == 0) {
+ /* process 0 keeps the real list */
+ array->namect = commsize;
+
+ array->names = (char **) ADIOI_Malloc(sizeof(char *) * commsize);
+ if (array->names == NULL) {
+ return -1;
+ }
+ procname = array->names; /* simpler to read */
+
+ procname_len = (int *) ADIOI_Malloc(commsize * sizeof(int));
+ if (procname_len == NULL) {
+ return -1;
+ }
+ }
+ else {
+ /* everyone else just keeps an empty list as a placeholder */
+ array->namect = 0;
+ array->names = NULL;
+ }
+ /* gather lengths first */
+ MPI_Gather(&my_procname_len, 1, MPI_INT, procname_len, 1, MPI_INT, 0, comm);
+
+ if (commrank == 0) {
+#ifdef CB_CONFIG_LIST_DEBUG
+ for (i = 0; i < commsize; i++) {
+ FPRINTF(stderr, "len[%d] = %d\n", i, procname_len[i]);
+ }
+#endif
+
+ for (i = 0; i < commsize; i++) {
+ /* add one to the lengths because we need to count the
+ * terminator, and we are going to use this list of lengths
+ * again in the gatherv.
+ */
+ procname_len[i]++;
+ procname[i] = malloc(procname_len[i]);
+ if (procname[i] == NULL) {
+ return -1;
+ }
+ }
+
+ /* create our list of displacements for the gatherv. we're going
+ * to do everything relative to the start of the region allocated
+ * for procname[0]
+ *
+ * I suppose it is theoretically possible that the distance between
+ * malloc'd regions could be more than will fit in an int. We don't
+ * cover that case.
+ */
+ disp = malloc(commsize * sizeof(int));
+ disp[0] = 0;
+ for (i = 1; i < commsize; i++) {
+ disp[i] = (int) (procname[i] - procname[0]);
+ }
+
+ }
+
+ /* now gather strings */
+ if (commrank == 0) {
+ MPI_Gatherv(my_procname, my_procname_len + 1, MPI_CHAR,
+ procname[0], procname_len, disp, MPI_CHAR, 0, comm);
+ }
+ else {
+ /* if we didn't do this, we would need to allocate procname[]
+ * on all processes...which seems a little silly.
+ */
+ MPI_Gatherv(my_procname, my_procname_len + 1, MPI_CHAR,
+ NULL, NULL, NULL, MPI_CHAR, 0, comm);
+ }
+
+ if (commrank == 0) {
+ /* no longer need the displacements or lengths */
+ free(disp);
+ free(procname_len);
+
+#ifdef CB_CONFIG_LIST_DEBUG
+ for (i = 0; i < commsize; i++) {
+ fprintf(stderr, "name[%d] = %s\n", i, procname[i]);
+ }
+#endif
+ }
+
+ *arrayp = array;
+ return 0;
+}
+
+void default_str(int mynod, int len, ADIO_cb_name_array array, char *dest)
+{
+ char *ptr;
+ int i, p;
+ if (!mynod) {
+ ptr = dest;
+ for (i = 0; i < array->namect; i++) {
+ p = snprintf(ptr, len, "%s,", array->names[i]);
+ ptr += p;
+ }
+ /* chop off that last comma */
+ dest[strlen(dest) - 1] = '\0';
+ }
+ MPI_Bcast(dest, len, MPI_CHAR, 0, MPI_COMM_WORLD);
+}
+
+void reverse_str(int mynod, int len, ADIO_cb_name_array array, char *dest)
+{
+ char *ptr;
+ int i, p;
+ if (!mynod) {
+ ptr = dest;
+ for (i = (array->namect - 1); i >= 0; i--) {
+ p = snprintf(ptr, len, "%s,", array->names[i]);
+ ptr += p;
+ }
+ dest[strlen(dest) - 1] = '\0';
+ }
+ MPI_Bcast(dest, len, MPI_CHAR, 0, MPI_COMM_WORLD);
+}
+
+void reverse_alternating_str(int mynod, int len, ADIO_cb_name_array array, char *dest)
+{
+ char *ptr;
+ int i, p;
+ if (!mynod) {
+ ptr = dest;
+ /* evens */
+ for (i = (array->namect - 1); i >= 0; i -= 2) {
+ p = snprintf(ptr, len, "%s,", array->names[i]);
+ ptr += p;
+ }
+ /* odds */
+ for (i = (array->namect - 2); i > 0; i -= 2) {
+ p = snprintf(ptr, len, "%s,", array->names[i]);
+ ptr += p;
+ }
+ dest[strlen(dest) - 1] = '\0';
+ }
+ MPI_Bcast(dest, len, MPI_CHAR, 0, MPI_COMM_WORLD);
+}
+
+void simple_shuffle_str(int mynod, int len, ADIO_cb_name_array array, char *dest)
+{
+ char *ptr;
+ int i, p;
+ if (!mynod) {
+ ptr = dest;
+ for (i = (array->namect / 2); i < array->namect; i++) {
+ p = snprintf(ptr, len, "%s,", array->names[i]);
+ ptr += p;
+ }
+ for (i = 0; i < (array->namect / 2); i++) {
+ p = snprintf(ptr, len, "%s,", array->names[i]);
+ ptr += p;
+ }
+ dest[strlen(dest) - 1] = '\0';
+ }
+ MPI_Bcast(dest, len, MPI_CHAR, 0, MPI_COMM_WORLD);
+}
+
+int main(int argc, char **argv)
+{
+ int i, mynod, nprocs, len, errs = 0, sum_errs = 0, verbose = 0;
+ char *filename;
+ char *cb_config_string;
+ int cb_config_len;
+ ADIO_cb_name_array array;
+
+
+ MPI_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &mynod);
+
+
+ /* process 0 takes the file name as a command-line argument and
+ * broadcasts it to other processes */
+ if (!mynod) {
+ filename = (char*)"testfile";
+ len = strlen(filename);
+ MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ MPI_Bcast(filename, len + 1, MPI_CHAR, 0, MPI_COMM_WORLD);
+ }
+ else {
+ MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ filename = (char *) malloc(len + 1);
+ MPI_Bcast(filename, len + 1, MPI_CHAR, 0, MPI_COMM_WORLD);
+ }
+
+ /* want to hint the cb_config_list, but do so in a non-sequential way */
+ cb_gather_name_array(MPI_COMM_WORLD, &array);
+
+ /* sanity check */
+ if (!mynod) {
+ if (array->namect < 2) {
+ fprintf(stderr, "Run this test on two or more hosts\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ }
+ /* get space for the permuted cb_config_string */
+ if (!mynod) {
+ cb_config_len = 0;
+ for (i = 0; i < array->namect; i++) {
+ /* +1: space for either a , or \0 if last */
+ cb_config_len += strlen(array->names[i]) + 1;
+ }
+ ++cb_config_len;
+ }
+ MPI_Bcast(&cb_config_len, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ if ((cb_config_string = malloc(cb_config_len)) == NULL) {
+ perror("malloc");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+
+ /* first, no hinting */
+ errs += test_file(filename, mynod, nprocs, NULL, "collective w/o hinting", verbose);
+
+ /* hint, but no change in order */
+ default_str(mynod, cb_config_len, array, cb_config_string);
+ errs += test_file(filename, mynod, nprocs, cb_config_string,
+ "collective w/ hinting: default order", verbose);
+
+ /* reverse order */
+ reverse_str(mynod, cb_config_len, array, cb_config_string);
+ errs += test_file(filename, mynod, nprocs, cb_config_string,
+ "collective w/ hinting: reverse order", verbose);
+
+ /* reverse, every other */
+ reverse_alternating_str(mynod, cb_config_len, array, cb_config_string);
+ errs += test_file(filename, mynod, nprocs, cb_config_string,
+ "collective w/ hinting: permutation1", verbose);
+
+ /* second half, first half */
+ simple_shuffle_str(mynod, cb_config_len, array, cb_config_string);
+ errs += test_file(filename, mynod, nprocs, cb_config_string,
+ "collective w/ hinting: permutation2", verbose);
+
+ MPI_Allreduce(&errs, &sum_errs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
+
+ if (!mynod) {
+ if (sum_errs)
+ fprintf(stderr, "Found %d error cases\n", sum_errs);
+ else
+ printf(" No Errors\n");
+ }
+ if (mynod)
+ free(filename);
+ free(cb_config_string);
+ MPI_Finalize();
+ return 0;
+}
+
+#define SEEDER(x,y,z) ((x)*1000000 + (y) + (x)*(z))
+
+int test_file(char *filename, int mynod, int nprocs, char *cb_hosts, const char *msg, int verbose)
+{
+ MPI_Datatype typevec, newtype, t[3];
+ int *buf, i, b[3], errcode, errors = 0;
+ MPI_File fh;
+ MPI_Aint d[3];
+ MPI_Request request;
+ MPI_Status status;
+ int SIZE = (STARTING_SIZE / nprocs) * nprocs;
+ MPI_Info info;
+
+ if (mynod == 0 && verbose)
+ fprintf(stderr, "%s\n", msg);
+
+ buf = (int *) malloc(SIZE * sizeof(int));
+ if (buf == NULL) {
+ perror("test_file");
+ MPI_Abort(MPI_COMM_WORLD, -1);
+ }
+
+
+ if (cb_hosts != NULL) {
+ MPI_Info_create(&info);
+ MPI_Info_set(info, "cb_config_list", cb_hosts);
+ }
+ else {
+ info = MPI_INFO_NULL;
+ }
+
+ MPI_Type_vector(SIZE / nprocs, 1, nprocs, MPI_INT, &typevec);
+
+ b[0] = b[1] = b[2] = 1;
+ d[0] = 0;
+ d[1] = mynod * sizeof(int);
+ d[2] = SIZE * sizeof(int);
+ t[0] = MPI_LB;
+ t[1] = typevec;
+ t[2] = MPI_UB;
+
+ MPI_Type_struct(3, b, d, t, &newtype);
+ MPI_Type_commit(&newtype);
+ MPI_Type_free(&typevec);
+
+ if (!mynod) {
+ if (verbose)
+ fprintf(stderr, "\ntesting noncontiguous in memory, noncontiguous "
+ "in file using collective I/O\n");
+ MPI_File_delete(filename, info);
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ errcode = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, info, &fh);
+ if (errcode != MPI_SUCCESS) {
+ handle_error(errcode, "MPI_File_open");
+ }
+
+ MPI_File_set_view(fh, 0, MPI_INT, newtype, "native", info);
+
+ for (i = 0; i < SIZE; i++)
+ buf[i] = SEEDER(mynod, i, SIZE);
+ errcode = MPI_File_iwrite_all(fh, buf, 1, newtype, &request);
+ if (errcode != MPI_SUCCESS) {
+ handle_error(errcode, "nc mem - nc file: MPI_File_iwrite_all");
+ }
+
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Wait(&request, &status);
+
+ for (i = 0; i < SIZE; i++)
+ buf[i] = -1;
+
+ errcode = MPI_File_iread_at_all(fh, 0, buf, 1, newtype, &request);
+ if (errcode != MPI_SUCCESS) {
+ handle_error(errcode, "nc mem - nc file: MPI_File_iread_at_all");
+ }
+ MPI_Wait(&request, &status);
+
+ /* the verification for N compute nodes is tricky. Say we have 3
+ * processors.
+ * process 0 sees: 0 -1 -1 3 -1 -1 ...
+ * process 1 sees: -1 34 -1 -1 37 -1 ...
+ * process 2 sees: -1 -1 68 -1 -1 71 ... */
+
+ /* verify those leading -1s exist if they should */
+ for (i = 0; i < mynod; i++) {
+ if (buf[i] != -1) {
+ if (verbose)
+ fprintf(stderr, "Process %d: buf is %d, should be -1\n", mynod, buf[i]);
+ errors++;
+ }
+ }
+ /* now the modulo games are hairy. processor 0 sees real data in the 0th,
+ * 3rd, 6th... elements of the buffer (assuming nprocs==3). proc 1 sees
+ * the data in 1st, 4th, 7th..., and proc 2 sees it in 2nd, 5th, 8th */
+
+ for (/* 'i' set in above loop */ ; i < SIZE; i++) {
+ if (((i - mynod) % nprocs) && buf[i] != -1) {
+ if (verbose)
+ fprintf(stderr, "Process %d: buf %d is %d, should be -1\n", mynod, i, buf[i]);
+ errors++;
+ }
+ if (!((i - mynod) % nprocs) && buf[i] != SEEDER(mynod, i, SIZE)) {
+ if (verbose)
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n",
+ mynod, i, buf[i], SEEDER(mynod, i, SIZE));
+ errors++;
+ }
+ }
+ MPI_File_close(&fh);
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ if (!mynod) {
+ if (verbose)
+ fprintf(stderr, "\ntesting noncontiguous in memory, contiguous in "
+ "file using collective I/O\n");
+ MPI_File_delete(filename, info);
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, info, &fh);
+
+ for (i = 0; i < SIZE; i++)
+ buf[i] = SEEDER(mynod, i, SIZE);
+ errcode = MPI_File_iwrite_at_all(fh, mynod * (SIZE / nprocs) * sizeof(int),
+ buf, 1, newtype, &request);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "nc mem - c file: MPI_File_iwrite_at_all");
+
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Wait(&request, &status);
+
+ for (i = 0; i < SIZE; i++)
+ buf[i] = -1;
+
+ errcode = MPI_File_iread_at_all(fh, mynod * (SIZE / nprocs) * sizeof(int),
+ buf, 1, newtype, &request);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "nc mem - c file: MPI_File_iread_at_all");
+ MPI_Wait(&request, &status);
+
+ /* just like as above */
+ for (i = 0; i < mynod; i++) {
+ if (buf[i] != -1) {
+ if (verbose)
+ fprintf(stderr, "Process %d: buf is %d, should be -1\n", mynod, buf[i]);
+ errors++;
+ }
+ }
+ for (/* i set in above loop */ ; i < SIZE; i++) {
+ if (((i - mynod) % nprocs) && buf[i] != -1) {
+ if (verbose)
+ fprintf(stderr, "Process %d: buf %d is %d, should be -1\n", mynod, i, buf[i]);
+ errors++;
+ }
+ if (!((i - mynod) % nprocs) && buf[i] != SEEDER(mynod, i, SIZE)) {
+ if (verbose)
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n",
+ mynod, i, buf[i], SEEDER(mynod, i, SIZE));
+ errors++;
+ }
+ }
+
+ MPI_File_close(&fh);
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ if (!mynod) {
+ if (verbose)
+ fprintf(stderr, "\ntesting contiguous in memory, noncontiguous in "
+ "file using collective I/O\n");
+ MPI_File_delete(filename, info);
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, info, &fh);
+
+ MPI_File_set_view(fh, 0, MPI_INT, newtype, "native", info);
+
+ for (i = 0; i < SIZE; i++)
+ buf[i] = SEEDER(mynod, i, SIZE);
+ errcode = MPI_File_iwrite_all(fh, buf, SIZE, MPI_INT, &request);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "c mem - nc file: MPI_File_iwrite_all");
+
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Wait(&request, &status);
+
+ for (i = 0; i < SIZE; i++)
+ buf[i] = -1;
+
+ errcode = MPI_File_iread_at_all(fh, 0, buf, SIZE, MPI_INT, &request);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "c mem - nc file: MPI_File_iread_at_all");
+ MPI_Wait(&request, &status);
+
+ /* same crazy checking */
+ for (i = 0; i < SIZE; i++) {
+ if (buf[i] != SEEDER(mynod, i, SIZE)) {
+ if (verbose)
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n",
+ mynod, i, buf[i], SEEDER(mynod, i, SIZE));
+ errors++;
+ }
+ }
+
+ MPI_File_close(&fh);
+
+ MPI_Type_free(&newtype);
+ free(buf);
+ if (info != MPI_INFO_NULL)
+ MPI_Info_free(&info);
+ return errors;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2014 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+#include "mpi.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpitest.h"
+
+/*
+static char MTEST_Descrip[] = "Test reading and writing ordered output";
+*/
+
+int main(int argc, char *argv[])
+{
+ int errs = 0;
+ int size, rank, i, *buf, rc;
+ MPI_File fh;
+ MPI_Comm comm;
+ MPI_Status status;
+ MPI_Request request;
+
+ MTest_Init(&argc, &argv);
+
+ comm = MPI_COMM_WORLD;
+ MPI_File_open(comm, (char *) "test.ord",
+ MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh);
+
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
+ buf = (int *) malloc(size * sizeof(int));
+ buf[0] = rank;
+ rc = MPI_File_write_ordered(fh, buf, 1, MPI_INT, &status);
+ if (rc != MPI_SUCCESS) {
+ MTestPrintErrorMsg("File_write_ordered", rc);
+ errs++;
+ }
+ /* make sure all writes finish before we seek/read */
+ MPI_Barrier(comm);
+
+ /* Set the individual pointer to 0, since we want to use a iread_all */
+ MPI_File_seek(fh, 0, MPI_SEEK_SET);
+ rc = MPI_File_iread_all(fh, buf, size, MPI_INT, &request);
+ if (rc != MPI_SUCCESS) {
+ MTestPrintErrorMsg("File_iread_all", rc);
+ errs++;
+ }
+ MPI_Wait(&request, &status);
+
+ for (i = 0; i < size; i++) {
+ if (buf[i] != i) {
+ errs++;
+ fprintf(stderr, "%d: buf[%d] = %d\n", rank, i, buf[i]);
+ }
+ }
+
+ MPI_File_seek_shared(fh, 0, MPI_SEEK_SET);
+ for (i = 0; i < size; i++)
+ buf[i] = -1;
+ MPI_File_read_ordered(fh, buf, 1, MPI_INT, &status);
+ if (buf[0] != rank) {
+ errs++;
+ fprintf(stderr, "%d: buf[0] = %d\n", rank, buf[0]);
+ }
+
+ free(buf);
+ MPI_File_close(&fh);
+
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2014 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+#include "mpi.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpitest.h"
+
+/*
+static char MTEST_Descrip[] = "Test set_view with DISPLACEMENT_CURRENT";
+*/
+
+int main(int argc, char *argv[])
+{
+ int errs = 0, err;
+ int size, rank, *buf;
+ MPI_Offset offset;
+ MPI_File fh;
+ MPI_Comm comm;
+ MPI_Status status;
+ MPI_Request request;
+
+ MTest_Init(&argc, &argv);
+
+ /* This test reads a header then sets the view to every "size" int,
+ * using set view and current displacement. The file is first written
+ * using a combination of collective and ordered writes */
+
+ comm = MPI_COMM_WORLD;
+ err = MPI_File_open(comm, (char *) "test.ord",
+ MPI_MODE_WRONLY | MPI_MODE_CREATE, MPI_INFO_NULL, &fh);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Open(1)", err);
+ }
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
+ buf = (int *) malloc(size * sizeof(int));
+ buf[0] = size;
+ err = MPI_File_iwrite_all(fh, buf, 1, MPI_INT, &request);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Iwrite_all", err);
+ }
+ err = MPI_Wait(&request, &status);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Wait", err);
+ }
+
+ err = MPI_File_get_position(fh, &offset);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Get_position", err);
+ }
+ err = MPI_File_seek_shared(fh, offset, MPI_SEEK_SET);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Seek_shared", err);
+ }
+ buf[0] = rank;
+ err = MPI_File_write_ordered(fh, buf, 1, MPI_INT, &status);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Write_ordered", err);
+ }
+ err = MPI_File_close(&fh);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Close(1)", err);
+ }
+
+ /* Reopen the file as sequential */
+ err = MPI_File_open(comm, (char *) "test.ord",
+ MPI_MODE_RDONLY | MPI_MODE_SEQUENTIAL |
+ MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Open(Read)", err);
+ }
+
+ if (rank == 0) {
+ err = MPI_File_read_shared(fh, buf, 1, MPI_INT, &status);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Read_all", err);
+ }
+ if (buf[0] != size) {
+ errs++;
+ fprintf(stderr, "Unexpected value for the header = %d, should be %d\n", buf[0], size);
+ fflush(stderr);
+ }
+ }
+ MPI_Barrier(comm);
+ /* All processes must provide the same file view for MODE_SEQUENTIAL */
+ /* See MPI 2.1, 13.3 - DISPLACEMENT_CURRENT is *required* for
+ * MODE_SEQUENTIAL files */
+ err = MPI_File_set_view(fh, MPI_DISPLACEMENT_CURRENT, MPI_INT,
+ MPI_INT, (char *) "native", MPI_INFO_NULL);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Set_view (DISPLACEMENT_CURRENT)", err);
+ }
+ buf[0] = -1;
+ err = MPI_File_read_ordered(fh, buf, 1, MPI_INT, &status);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Read_all", err);
+ }
+ if (buf[0] != rank) {
+ errs++;
+ fprintf(stderr, "%d: buf[0] = %d\n", rank, buf[0]);
+ fflush(stderr);
+ }
+
+ free(buf);
+ err = MPI_File_close(&fh);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Close(2)", err);
+ }
+
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2014 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/uio.h>
+
+#include <mpi.h>
+
+#define MAXLEN 9
+
+static void handle_error(int errcode, const char *str)
+{
+ char msg[MPI_MAX_ERROR_STRING];
+ int resultlen;
+ MPI_Error_string(errcode, msg, &resultlen);
+ fprintf(stderr, "%s: %s\n", str, msg);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+}
+
+enum {
+ INDEXED,
+ HINDEXED,
+ STRUCT
+} testcases;
+
+static int test_indexed_with_zeros(const char *filename, int testcase)
+{
+ int i, rank, np, buflen, num, err, nr_errors = 0;
+ int nelms[MAXLEN], buf[MAXLEN], indices[MAXLEN], blocklen[MAXLEN];
+ MPI_File fh;
+ MPI_Request request;
+ MPI_Status status;
+ MPI_Datatype filetype;
+ MPI_Datatype types[MAXLEN];
+ MPI_Aint addrs[MAXLEN];
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &np);
+
+ /* set up the number of integers to write in each iteration */
+ for (i = 0; i < MAXLEN; i++)
+ nelms[i] = 0;
+ if (rank == 0)
+ nelms[4] = nelms[5] = nelms[7] = 1;
+ if (rank == 1)
+ nelms[0] = nelms[1] = nelms[2] = nelms[3] = nelms[6] = nelms[8] = 1;
+
+ /* pre-fill the file with integers -999 */
+ if (rank == 0) {
+ for (i = 0; i < MAXLEN; i++)
+ buf[i] = -999;
+ err = MPI_File_open(MPI_COMM_SELF, filename,
+ MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &fh);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_open");
+ err = MPI_File_write(fh, buf, MAXLEN, MPI_INT, &status);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_write");
+ err = MPI_File_close(&fh);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_close");
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ /* define a filetype with spurious leading zeros */
+ buflen = num = 0;
+ for (i = 0; i < MAXLEN; i++) {
+ buflen += nelms[i];
+ indices[num] = i;
+ addrs[num] = i * sizeof(int);
+ blocklen[num] = nelms[i];
+ types[num] = MPI_INT;
+ num++;
+ }
+ switch (testcase) {
+ case INDEXED:
+ MPI_Type_indexed(num, blocklen, indices, MPI_INT, &filetype);
+ break;
+ case HINDEXED:
+ MPI_Type_hindexed(num, blocklen, addrs, MPI_INT, &filetype);
+ break;
+ case STRUCT:
+ MPI_Type_create_struct(num, blocklen, addrs, types, &filetype);
+ break;
+ default:
+ fprintf(stderr, "unknown testcase!\n");
+ return (-100);
+ }
+
+ MPI_Type_commit(&filetype);
+
+ /* initialize write buffer and write to file */
+ for (i = 0; i < MAXLEN; i++)
+ buf[i] = 1;
+ err = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_WRONLY, MPI_INFO_NULL, &fh);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_open");
+ err = MPI_File_set_view(fh, 0, MPI_INT, filetype, "native", MPI_INFO_NULL);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_set_view");
+ err = MPI_File_iwrite_all(fh, buf, buflen, MPI_INT, &request);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_iwrite_all");
+ err = MPI_Wait(&request, &status);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_Wait");
+ MPI_Type_free(&filetype);
+ err = MPI_File_close(&fh);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_close");
+
+ /* read back and check */
+ if (rank == 0) {
+ err = MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_open");
+ err = MPI_File_read(fh, buf, MAXLEN, MPI_INT, &status);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_read");
+ err = MPI_File_close(&fh);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_close");
+ for (i = 0; i < MAXLEN; i++) {
+ if (buf[i] < 0) {
+ nr_errors++;
+ printf("Error: unexpected value for case %d at buf[%d] == %d\n",
+ testcase, i, buf[i]);
+ }
+ }
+ }
+ return nr_errors;
+}
+
+int main(int argc, char **argv)
+{
+ int nr_errors, rank, np;
+ const char *filename;
+
+ filename = (argc > 1) ? argv[1] : "testfile";
+
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &np);
+
+ if (np != 2) {
+ if (rank == 0)
+ fprintf(stderr, "Must run on 2 MPI processes\n");
+ MPI_Finalize();
+ return 1;
+ }
+ nr_errors = test_indexed_with_zeros(filename, INDEXED);
+ nr_errors += test_indexed_with_zeros(filename, HINDEXED);
+ nr_errors += test_indexed_with_zeros(filename, STRUCT);
+
+ if (rank == 0 && nr_errors == 0)
+ printf(" No Errors\n");
+
+ MPI_Finalize();
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *
+ * (C) 2003 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+#include "mpi.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpitest.h"
+
+/*
+static char MTEST_Descrip[] = "Test reading and writing ordered output";
+*/
+
+int main(int argc, char *argv[])
+{
+ int errs = 0;
+ int size, rank, i, *buf, rc;
+ MPI_File fh;
+ MPI_Comm comm;
+ MPI_Status status;
+
+ MTest_Init(&argc, &argv);
+
+ comm = MPI_COMM_WORLD;
+ MPI_File_open(comm, (char *) "test.ord",
+ MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh);
+
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
+ buf = (int *) malloc(size * sizeof(int));
+ buf[0] = rank;
+ rc = MPI_File_write_ordered(fh, buf, 1, MPI_INT, &status);
+ if (rc) {
+ MTestPrintErrorMsg("File_write_ordered", rc);
+ errs++;
+ }
+ /* make sure all writes finish before we seek/read */
+ MPI_Barrier(comm);
+
+ /* Set the individual pointer to 0, since we want to use a read_all */
+ MPI_File_seek(fh, 0, MPI_SEEK_SET);
+ MPI_File_read_all(fh, buf, size, MPI_INT, &status);
+
+/* for (i = 0; i < size; i++) {*/
+/* if (buf[i] != i) {*/
+/* errs++;*/
+/* fprintf(stderr, "%d: buf[%d] = %d\n", rank, i, buf[i]);*/
+/* }*/
+/* }*/
+
+ MPI_File_seek_shared(fh, 0, MPI_SEEK_SET);
+ for (i = 0; i < size; i++)
+ buf[i] = -1;
+ MPI_File_read_ordered(fh, buf, 1, MPI_INT, &status);
+ /*if (buf[0] != rank) {
+ errs++;
+ fprintf(stderr, "%d: buf[0] = %d\n", rank, buf[0]);
+ }*/
+
+ free(buf);
+ MPI_File_close(&fh);
+
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *
+ * (C) 2003 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+#include "mpi.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpitest.h"
+#include "mpitestconf.h"
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_MEMORY_H
+#include <memory.h>
+#endif
+
+/*
+static char MTEST_Descrip[] = "Test reading and writing zero bytes (set status correctly)";
+*/
+
+int main(int argc, char *argv[])
+{
+ int errs = 0;
+ int size, rank, i, *buf, count, rc;
+ MPI_File fh;
+ MPI_Comm comm;
+ MPI_Status status;
+
+ MTest_Init(&argc, &argv);
+
+ comm = MPI_COMM_WORLD;
+ rc = MPI_File_open(comm, (char *) "/scratch/test.ord",
+ MPI_MODE_RDWR | MPI_MODE_CREATE |
+ MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh);
+ if (rc) {
+ MTestPrintErrorMsg("File_open", rc);
+ errs++;
+ /* If the open fails, there isn't anything else that we can do */
+ goto fn_fail;
+ }
+
+
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
+ buf = (int *) malloc(size * sizeof(int));
+ buf[0] = rank;
+ /* Write to file */
+ rc = MPI_File_write_ordered(fh, buf, 1, MPI_INT, &status);
+ if (rc) {
+ MTestPrintErrorMsg("File_write_ordered", rc);
+ errs++;
+ }
+ else {
+ MPI_Get_count(&status, MPI_INT, &count);
+ if (count != 1) {
+ errs++;
+ fprintf(stderr, "Wrong count (%d) on write-ordered\n", count);
+ }
+ }
+
+ /* Set the individual pointer to 0, since we want to use a read_all */
+ MPI_File_seek(fh, 0, MPI_SEEK_SET);
+
+ /* Read nothing (check status) */
+ memset(&status, 0xff, sizeof(MPI_Status));
+ MPI_File_read(fh, buf, 0, MPI_INT, &status);
+ MPI_Get_count(&status, MPI_INT, &count);
+ if (count != 0) {
+ errs++;
+ fprintf(stderr, "Count not zero (%d) on read\n", count);
+ }
+
+ /* Write nothing (check status) */
+ memset(&status, 0xff, sizeof(MPI_Status));
+ MPI_File_write(fh, buf, 0, MPI_INT, &status);
+ if (count != 0) {
+ errs++;
+ fprintf(stderr, "Count not zero (%d) on write\n", count);
+ }
+
+ /* Read shared nothing (check status) */
+ MPI_File_seek_shared(fh, 0, MPI_SEEK_SET);
+ /* Read nothing (check status) */
+ memset(&status, 0xff, sizeof(MPI_Status));
+ MPI_File_read_shared(fh, buf, 0, MPI_INT, &status);
+ MPI_Get_count(&status, MPI_INT, &count);
+ if (count != 0) {
+ errs++;
+ fprintf(stderr, "Count not zero (%d) on read shared\n", count);
+ }
+
+ /* Write nothing (check status) */
+ memset(&status, 0xff, sizeof(MPI_Status));
+ MPI_File_write_shared(fh, buf, 0, MPI_INT, &status);
+ if (count != 0) {
+ errs++;
+ fprintf(stderr, "Count not zero (%d) on write\n", count);
+ }
+
+ MPI_Barrier(comm);
+
+ MPI_File_seek_shared(fh, 0, MPI_SEEK_SET);
+ for (i = 0; i < size; i++)
+ buf[i] = -1;
+ MPI_File_read_ordered(fh, buf, 1, MPI_INT, &status);
+/* if (buf[0] != rank) {*/
+/* errs++;*/
+/* fprintf(stderr, "%d: buf = %d\n", rank, buf[0]);*/
+/* }*/
+
+ free(buf);
+
+ MPI_File_close(&fh);
+
+ fn_fail:
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+#include "mpi.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "mpitest.h"
+
+/*
+static char MTEST_Descrip[] = "Test file views with MPI_Type_create_resized";
+*/
+
+int main(int argc, char **argv)
+{
+ int i, nprocs, len, mpi_errno, buf[2], newbuf[4];
+ int errs = 0;
+ MPI_Offset size;
+ MPI_Aint lb, extent;
+ MPI_File fh;
+ char *filename;
+ MPI_Datatype newtype;
+
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+
+ if (nprocs != 1) {
+ fprintf(stderr, "Run this program on 1 process\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+
+ i = 1;
+ while ((i < argc) && strcmp("-fname", *argv)) {
+ i++;
+ argv++;
+ }
+ if (i >= argc) {
+ len = 8;
+ filename = (char *) malloc(len + 10);
+ strcpy(filename, "testfile");
+ /*
+ * fprintf(stderr, "\n*# Usage: resized -fname filename\n\n");
+ * MPI_Abort(MPI_COMM_WORLD, 1);
+ */
+ }
+ else {
+ argv++;
+ len = (int) strlen(*argv);
+ filename = (char *) malloc(len + 1);
+ strcpy(filename, *argv);
+ }
+
+ MPI_File_delete(filename, MPI_INFO_NULL);
+
+ /* create a resized type comprising an integer with an lb at sizeof(int) and extent = 3*sizeof(int) */
+ lb = sizeof(int);
+ extent = 3 * sizeof(int);
+ MPI_Type_create_resized(MPI_INT, lb, extent, &newtype);
+
+ MPI_Type_commit(&newtype);
+
+ /* initialize the file */
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+ for (i = 0; i < 4; i++)
+ newbuf[i] = 55;
+ MPI_File_write(fh, newbuf, 4, MPI_INT, MPI_STATUS_IGNORE);
+ MPI_File_close(&fh);
+
+ /* write 2 ints into file view with resized type */
+
+ buf[0] = 10;
+ buf[1] = 20;
+
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+
+ mpi_errno = MPI_File_set_view(fh, 0, MPI_INT, newtype, (char *) "native", MPI_INFO_NULL);
+ if (mpi_errno != MPI_SUCCESS)
+ errs++;
+
+ MPI_File_write(fh, buf, 2, MPI_INT, MPI_STATUS_IGNORE);
+
+ MPI_File_close(&fh);
+
+
+ /* read back file view with resized type and verify */
+
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
+
+ mpi_errno = MPI_File_set_view(fh, 0, MPI_INT, newtype, (char *) "native", MPI_INFO_NULL);
+ if (mpi_errno != MPI_SUCCESS)
+ errs++;
+
+ for (i = 0; i < 4; i++)
+ newbuf[i] = 100;
+ MPI_File_read(fh, newbuf, 2, MPI_INT, MPI_STATUS_IGNORE);
+/* if ((newbuf[0] != 10) || (newbuf[1] != 20) || (newbuf[2] != 100) || (newbuf[3] != 100)) {
+ errs++;
+ fprintf(stderr,
+ "newbuf[0] is %d, should be 10,\n newbuf[1] is %d, should be 20\n newbuf[2] is %d, should be 100,\n newbuf[3] is %d, should be 100,\n",
+ newbuf[0], newbuf[1], newbuf[2], newbuf[3]);
+ }*/
+
+ MPI_File_close(&fh);
+
+ /* read file back and verify */
+
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
+
+ MPI_File_get_size(fh, &size);
+ if (size != 4 * sizeof(int)) {
+ errs++;
+ fprintf(stderr, "file size is %lld, should be %d\n", size, (int) (4 * sizeof(int)));
+ }
+
+ for (i = 0; i < 4; i++)
+ newbuf[i] = 100;
+ MPI_File_read(fh, newbuf, 4, MPI_INT, MPI_STATUS_IGNORE);
+/* if ((newbuf[0] != 10) || (newbuf[3] != 20) || (newbuf[1] != 55) || (newbuf[2] != 55)) {
+ errs++;
+ fprintf(stderr,
+ "newbuf[0] is %d, should be 10,\n newbuf[1] is %d, should be 55,\n newbuf[2] is %d, should be 55,\n newbuf[3] is %d, should be 20\n",
+ newbuf[0], newbuf[1], newbuf[2], newbuf[3]);
+ }
+*/
+ MPI_File_close(&fh);
+
+ MPI_Type_free(&newtype);
+ free(filename);
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2008 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+#include "mpi.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "mpitest.h"
+
+/*
+static char MTEST_Descrip[] = "Test file views with MPI_Type_create_resized";
+*/
+
+int main(int argc, char **argv)
+{
+ int i, nprocs, len, mpi_errno, buf[2], newbuf[4];
+ int errs = 0;
+ MPI_Offset size;
+ MPI_Aint lb, extent;
+ MPI_File fh;
+ char *filename;
+ MPI_Datatype newtype, newtype1;
+
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+
+ if (nprocs != 1) {
+ fprintf(stderr, "Run this program on 1 process\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+
+ i = 1;
+ while ((i < argc) && strcmp("-fname", *argv)) {
+ i++;
+ argv++;
+ }
+ if (i >= argc) {
+ len = 8;
+ filename = (char *) malloc(len + 10);
+ strcpy(filename, "/scratch/testfile");
+ /*
+ * fprintf(stderr, "\n*# Usage: resized -fname filename\n\n");
+ * MPI_Abort(MPI_COMM_WORLD, 1);
+ */
+ }
+ else {
+ argv++;
+ len = (int) strlen(*argv);
+ filename = (char *) malloc(len + 1);
+ strcpy(filename, *argv);
+ }
+
+ MPI_File_delete(filename, MPI_INFO_NULL);
+
+ /* create a resized type comprising an integer with an lb at sizeof(int) and extent = 3*sizeof(int) */
+ lb = sizeof(int);
+ extent = 3 * sizeof(int);
+ MPI_Type_create_resized(MPI_INT, lb, extent, &newtype1);
+
+ MPI_Type_commit(&newtype1);
+ MPI_Type_create_resized(newtype1, lb, extent, &newtype);
+ MPI_Type_commit(&newtype);
+
+ /* initialize the file */
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+ for (i = 0; i < 4; i++)
+ newbuf[i] = 55;
+ MPI_File_write(fh, newbuf, 4, MPI_INT, MPI_STATUS_IGNORE);
+ MPI_File_close(&fh);
+
+ /* write 2 ints into file view with resized type */
+
+ buf[0] = 10;
+ buf[1] = 20;
+
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+
+ mpi_errno = MPI_File_set_view(fh, 0, MPI_INT, newtype, (char *) "native", MPI_INFO_NULL);
+ if (mpi_errno != MPI_SUCCESS)
+ errs++;
+
+ MPI_File_write(fh, buf, 2, MPI_INT, MPI_STATUS_IGNORE);
+
+ MPI_File_close(&fh);
+
+
+ /* read back file view with resized type and verify */
+
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
+
+ mpi_errno = MPI_File_set_view(fh, 0, MPI_INT, newtype, (char *) "native", MPI_INFO_NULL);
+ if (mpi_errno != MPI_SUCCESS)
+ errs++;
+
+ for (i = 0; i < 4; i++)
+ newbuf[i] = 100;
+ MPI_File_read(fh, newbuf, 2, MPI_INT, MPI_STATUS_IGNORE);
+/* if ((newbuf[0] != 10) || (newbuf[1] != 20) || (newbuf[2] != 100) || (newbuf[3] != 100)) {*/
+/* errs++;*/
+/* fprintf(stderr,*/
+/* "newbuf[0] is %d, should be 10,\n newbuf[1] is %d, should be 20\n newbuf[2] is %d, should be 100,\n newbuf[3] is %d, should be 100,\n",*/
+/* newbuf[0], newbuf[1], newbuf[2], newbuf[3]);*/
+/* }*/
+
+ MPI_File_close(&fh);
+
+ /* read file back and verify */
+
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
+
+ MPI_File_get_size(fh, &size);
+ if (size != 4 * sizeof(int)) {
+ errs++;
+ fprintf(stderr, "file size is %lld, should be %d\n", size, (int) (4 * sizeof(int)));
+ }
+
+ for (i = 0; i < 4; i++)
+ newbuf[i] = 100;
+ MPI_File_read(fh, newbuf, 4, MPI_INT, MPI_STATUS_IGNORE);
+/* if ((newbuf[0] != 10) || (newbuf[3] != 20) || (newbuf[1] != 55) || (newbuf[2] != 55)) {*/
+/* errs++;*/
+/* fprintf(stderr,*/
+/* "newbuf[0] is %d, should be 10,\n newbuf[1] is %d, should be 55,\n newbuf[2] is %d, should be 55,\n newbuf[3] is %d, should be 20\n",*/
+/* newbuf[0], newbuf[1], newbuf[2], newbuf[3]);*/
+/* }*/
+
+ MPI_File_close(&fh);
+
+ MPI_Type_free(&newtype1);
+ MPI_Type_free(&newtype);
+ free(filename);
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *
+ * (C) 2003 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+#include "mpi.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpitest.h"
+#include "mpitestconf.h"
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+/*
+static char MTEST_Descrip[] = "Test file_set_view";
+*/
+
+/*
+ * access style is explicitly described as modifiable. values include
+ * read_once, read_mostly, write_once, write_mostlye, random
+ *
+ *
+ */
+int main(int argc, char *argv[])
+{
+ int errs = 0, err;
+ int buf[10];
+ int rank;
+ MPI_Comm comm;
+ MPI_Status status;
+ MPI_File fh;
+ MPI_Info infoin, infoout;
+ char value[1024];
+ int flag, count;
+
+ MTest_Init(&argc, &argv);
+ comm = MPI_COMM_WORLD;
+
+ MPI_Comm_rank(comm, &rank);
+ MPI_Info_create(&infoin);
+ MPI_Info_set(infoin, (char *) "access_style", (char *) "write_once,random");
+ MPI_File_open(comm, (char *) "/scratch/testfile", MPI_MODE_RDWR | MPI_MODE_CREATE, infoin, &fh);
+ buf[0] = rank;
+ err = MPI_File_write_ordered(fh, buf, 1, MPI_INT, &status);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+
+ MPI_Info_set(infoin, (char *) "access_style", (char *) "read_once");
+ err = MPI_File_seek_shared(fh, 0, MPI_SEEK_SET);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+
+ err = MPI_File_set_info(fh, infoin);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ MPI_Info_free(&infoin);
+ buf[0] = -1;
+
+ err = MPI_File_read_ordered(fh, buf, 1, MPI_INT, &status);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ MPI_Get_count(&status, MPI_INT, &count);
+ if (count != 1) {
+ errs++;
+ printf("Expected to read one int, read %d\n", count);
+ }
+/* if (buf[0] != rank) {*/
+/* errs++;*/
+/* printf("Did not read expected value (%d)\n", buf[0]);*/
+/* }*/
+
+ err = MPI_File_get_info(fh, &infoout);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ MPI_Info_get(infoout, (char *) "access_style", 1024, value, &flag);
+ /* Note that an implementation is allowed to ignore the set_info,
+ * so we'll accept either the original or the updated version */
+ if (!flag) {
+ ;
+ /*
+ * errs++;
+ * printf("Access style hint not saved\n");
+ */
+ }
+ else {
+ if (strcmp(value, "read_once") != 0 && strcmp(value, "write_once,random") != 0) {
+ errs++;
+ printf("value for access_style unexpected; is %s\n", value);
+ }
+ }
+ MPI_Info_free(&infoout);
+ err = MPI_File_close(&fh);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ MPI_Barrier(comm);
+ MPI_Comm_rank(comm, &rank);
+ if (rank == 0) {
+ err = MPI_File_delete((char *) "/scratch/testfile", MPI_INFO_NULL);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ }
+
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *
+ * (C) 2003 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+#include "mpi.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpitest.h"
+
+/*
+static char MTEST_Descrip[] = "Test set_view with DISPLACEMENT_CURRENT";
+*/
+
+int main(int argc, char *argv[])
+{
+ int errs = 0, err;
+ int size, rank, *buf;
+ MPI_Offset offset;
+ MPI_File fh;
+ MPI_Comm comm;
+ MPI_Status status;
+
+ MTest_Init(&argc, &argv);
+
+ /* This test reads a header then sets the view to every "size" int,
+ * using set view and current displacement. The file is first written
+ * using a combination of collective and ordered writes */
+
+ comm = MPI_COMM_WORLD;
+ err = MPI_File_open(comm, (char *) "/scratch/test.ord",
+ MPI_MODE_WRONLY | MPI_MODE_CREATE, MPI_INFO_NULL, &fh);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Open(1)", err);
+ }
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
+ buf = (int *) malloc(size * sizeof(int));
+ buf[0] = size;
+ err = MPI_File_write_all(fh, buf, 1, MPI_INT, &status);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Write_all", err);
+ }
+ err = MPI_File_get_position(fh, &offset);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Get_position", err);
+ }
+ err = MPI_File_seek_shared(fh, offset, MPI_SEEK_SET);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Seek_shared", err);
+ }
+ buf[0] = rank;
+ err = MPI_File_write_ordered(fh, buf, 1, MPI_INT, &status);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Write_ordered", err);
+ }
+ err = MPI_File_close(&fh);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Close(1)", err);
+ }
+
+ /* Reopen the file as sequential */
+ err = MPI_File_open(comm, (char *) "/scratch/test.ord",
+ MPI_MODE_RDONLY | MPI_MODE_SEQUENTIAL |
+ MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Open(Read)", err);
+ }
+
+ if (rank == 0) {
+ err = MPI_File_read_shared(fh, buf, 1, MPI_INT, &status);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Read_all", err);
+ }
+/* if (buf[0] != size) {*/
+/* errs++;*/
+/* fprintf(stderr, "Unexpected value for the header = %d, should be %d\n", buf[0], size);*/
+/* fflush(stderr);*/
+/* }*/
+ }
+ MPI_Barrier(comm);
+ /* All processes must provide the same file view for MODE_SEQUENTIAL */
+ /* See MPI 2.1, 13.3 - DISPLACEMENT_CURRENT is *required* for
+ * MODE_SEQUENTIAL files */
+ err = MPI_File_set_view(fh, MPI_DISPLACEMENT_CURRENT, MPI_INT,
+ MPI_INT, (char *) "native", MPI_INFO_NULL);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Set_view (DISPLACEMENT_CURRENT)", err);
+ }
+ buf[0] = -1;
+ err = MPI_File_read_ordered(fh, buf, 1, MPI_INT, &status);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Read_all", err);
+ }
+ /*if (buf[0] != rank) {
+ errs++;
+ fprintf(stderr, "%d: buf[0] = %d\n", rank, buf[0]);
+ fflush(stderr);
+ }*/
+
+ free(buf);
+ err = MPI_File_close(&fh);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Close(2)", err);
+ }
+
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2015 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+
+/* this deceptively simple test uncovered a bug in the way certain file systems
+ * dealt with tuning parmeters. See
+ * https://github.com/open-mpi/ompi/issues/158 and
+ * http://trac.mpich.org/projects/mpich/ticket/2261
+ *
+ * originally uncovered in Darshan:
+ * http://lists.mcs.anl.gov/pipermail/darshan-users/2015-February/000256.html
+ *
+ * to really exercise the bug in simple_collective,
+ * we'd have to run on a Lustre or Panasas file system.
+ *
+ * I am surprised src/mpi/romio/test/create_excl.c did not uncover the bug
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/time.h>
+#include <mpi.h>
+#include <errno.h>
+#include <getopt.h>
+
+#include "simgrid/plugins/file_system.h"
+
+static char *opt_file = NULL;
+static int rank = -1;
+
+static int parse_args(int argc, char **argv);
+static void usage(const char *prog);
+int test_write(char *file, int nprocs, int rank, MPI_Info info);
+int test_write(char *file, int nprocs, int rank, MPI_Info info)
+{
+ double stime, etime, wtime, w_elapsed, w_slowest, elapsed, slowest;
+ MPI_File fh;
+ int ret;
+ char buffer[700] = { 0 };
+ MPI_Status status;
+ int verbose = 0;
+
+ MPI_Barrier(MPI_COMM_WORLD);
+ stime = MPI_Wtime();
+
+ ret = MPI_File_open(MPI_COMM_WORLD, file,
+ MPI_MODE_CREATE | MPI_MODE_WRONLY | MPI_MODE_EXCL, info, &fh);
+
+ if (ret != 0) {
+ fprintf(stderr, "Error: failed to open %s\n", file);
+ return 1;
+ }
+
+ etime = MPI_Wtime();
+
+ ret = MPI_File_write_at_all(fh, rank * 700, buffer, 700, MPI_BYTE, &status);
+ if (ret != 0) {
+ fprintf(stderr, "Error: failed to write %s\n", file);
+ return 1;
+ }
+
+ wtime = MPI_Wtime();
+
+ MPI_File_close(&fh);
+
+ elapsed = etime - stime;
+ w_elapsed = wtime - etime;
+ MPI_Reduce(&elapsed, &slowest, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
+ MPI_Reduce(&w_elapsed, &w_slowest, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
+
+ if (rank == 0) {
+ //unlink(file);
+ //to emulate unlink, use sg_file_unlink
+ sg_file_t fd = sg_file_open(file, NULL);
+ sg_file_unlink(fd);
+ slowest *= 1000.0;
+ w_slowest *= 1000.0;
+ if (verbose == 1) {
+ printf("file: %s, nprocs: %d, open_time: %f ms, write_time: %f ms\n",
+ file, nprocs, slowest, w_slowest);
+ }
+ }
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int nprocs;
+ char file[256];
+ MPI_Info info;
+ int nr_errors = 0;
+
+
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+
+ /* parse the command line arguments */
+ parse_args(argc, argv);
+
+ sprintf(file, "%s", opt_file);
+ MPI_Info_create(&info);
+ nr_errors += test_write(file, nprocs, rank, info);
+ /* acutal value does not matter. test only writes a small amount of data */
+ MPI_Info_set(info, "striping_factor", "50");
+ nr_errors += test_write(file, nprocs, rank, info);
+ MPI_Info_free(&info);
+
+ MPI_Finalize();
+ if (!rank && nr_errors == 0) {
+ printf(" No Errors\n");
+ }
+ return (-nr_errors);
+}
+
+static int parse_args(int argc, char **argv)
+{
+ int c;
+
+ while ((c = getopt(argc, argv, "e")) != EOF) {
+ switch (c) {
+ case 'h':
+ if (rank == 0)
+ usage(argv[0]);
+ exit(0);
+ case '?': /* unknown */
+ if (rank == 0)
+ usage(argv[0]);
+ exit(1);
+ default:
+ break;
+ }
+ }
+
+ if (argc - optind != 1) {
+ if (rank == 0)
+ usage(argv[0]);
+ exit(1);
+ }
+
+ opt_file = strdup(argv[optind]);
+ assert(opt_file!=NULL);
+
+ return (0);
+}
+
+static void usage(const char *prog)
+{
+ printf("Usage: %s [<OPTIONS>...] <FILE NAME>\n", prog);
+ printf("\n<OPTIONS> is one or more of\n");
+ printf(" -h print this help\n");
+}
+
+/*
+ * vim: ts=8 sts=4 sw=4 noexpandtab
+ */
--- /dev/null
+rdwrord 4
+rdwrzero 4
+#needs MPI_File_get_type_extent
+#getextent 2
+setinfo 4
+setviewcur 4
+#i_noncontig 2
+#async 4
+#async_any 4
+userioerr 1
+resized 1
+resized2 1
+bigtype 1
+hindexed_io 1
+simple_collective 1 arg="/scratch/simple_collective.testfile"
+#external32-derived-dtype 1
+#i_bigtype 1 mpiversion=3.1
+#i_hindexed_io 1 mpiversion=3.1
+#i_rdwrord 4 mpiversion=3.1
+#i_setviewcur 4 mpiversion=3.1
+#i_aggregation1 4 mpiversion=3.1
+#i_aggregation2 4 mpiversion=3.1
+#i_coll_test 4 mpiversion=3.1
+#i_darray_read 4 mpiversion=3.1
+#i_hindexed 4 mpiversion=3.1
+#i_noncontig_coll 2 mpiversion=3.1
+#i_noncontig_coll2 4 mpiversion=3.1
+#i_types_with_zeros 2 mpiversion=3.1
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *
+ * (C) 2006 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+#include "mpi.h"
+#include <stdio.h>
+#include "mpitest.h"
+#include "mpitestconf.h"
+
+int verbose = 0;
+
+int handlerCalled = 0;
+
+/* Prototype to suppress compiler warnings */
+void user_handler(MPI_File * fh, int *errcode, ...);
+
+void user_handler(MPI_File * fh, int *errcode, ...)
+{
+ if (*errcode != MPI_SUCCESS) {
+ handlerCalled++;
+ if (verbose) {
+ printf("In user_handler with code %d\n", *errcode);
+ }
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ int rank, errs = 0, rc;
+ MPI_Errhandler ioerr_handler;
+ MPI_Status status;
+ MPI_File fh;
+ char inbuf[80];
+
+ MTest_Init(&argc, &argv);
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+ /* Create a file to which to attach the handler */
+ rc = MPI_File_open(MPI_COMM_WORLD, (char *) "/scratch/test.txt",
+ MPI_MODE_CREATE | MPI_MODE_WRONLY | MPI_MODE_DELETE_ON_CLOSE,
+ MPI_INFO_NULL, &fh);
+ if (rc) {
+ errs++;
+ printf("Unable to open test.txt for writing\n");
+ }
+
+ rc = MPI_File_create_errhandler(user_handler, &ioerr_handler);
+ if (rc) {
+ errs++;
+ printf("MPI_File_create_Errhandler returned an error code: %d\n", rc);
+ }
+
+ rc = MPI_File_set_errhandler(fh, ioerr_handler);
+ if (rc) {
+ errs++;
+ printf("MPI_File_set_errhandler returned an error code: %d\n", rc);
+ }
+
+ /* avoid leaking the errhandler, safe because they have refcount semantics */
+ rc = MPI_Errhandler_free(&ioerr_handler);
+ if (rc) {
+ errs++;
+ printf("MPI_Errhandler_free returned an error code: %d\n", rc);
+ }
+
+ /* This should generate an error because the file mode is WRONLY */
+ rc = MPI_File_read_at(fh, 0, inbuf, 80, MPI_BYTE, &status);
+ if (handlerCalled != 1) {
+ errs++;
+ printf("User-defined error handler was not called\n");
+ }
+
+ rc = MPI_File_close(&fh);
+ if (rc) {
+ errs++;
+ printf("MPI_File_close returned an error code: %d\n", rc);
+ }
+
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
+}
if (retval < 0)
retval = -retval;
+ free(margin);
return retval;
}
printf(" No Errors\n");
}
+ free(sbuf);
+ free(rbuf);
MPI_Finalize();
return 0;
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();
$MPIMajorVersion = "3";
$MPIMinorVersion = "1";
$mpiexec = "smpirun"; # Name of mpiexec program (including path, if necessary)
+$platformfile = "../../../../examples/platforms/small_platform_with_routers.xml";
+$hostfile = "../../hostfile_mpich";
$testIsStrict = "true";
$MPIhasMPIX = "no";
$np_arg = "-np"; # Name of argument to specify the number of processes
elsif (/--?np=(.*)/) { $np_default = $1; }
elsif (/--?maxnp=(.*)/) { $np_max = $1; }
elsif (/--?tests=(.*)/) { $listfiles = $1; }
+ elsif (/--?platformfile=(.*)/) { $platformfile = $1; }
+ elsif (/--?hostfile=(.*)/) { $hostfile = $1; }
elsif (/--?srcdir=(.*)/) { $srcdir = $1;
- $mpiexec="$mpiexec -platform ${srcdir}/../../../../examples/platforms/small_platform_with_routers.xml -hostfile ${srcdir}/../../hostfile_mpich --log=root.thr:critical --cfg=smpi/host-speed:1e9 --cfg=smpi/async-small-thresh:65536"; }
+ $mpiexec="$mpiexec -platform ${srcdir}/$platformfile -hostfile ${srcdir}/$hostfile --log=root.thr:critical --cfg=smpi/host-speed:1e9 --cfg=smpi/async-small-thresh:65536"; }
elsif (/--?verbose/) { $verbose = 1; }
elsif (/--?showprogress/) { $showProgress = 1; }
elsif (/--?debug/) { $debug = 1; }
# 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);
p Test privatization
! timeout 5
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 32 ${bindir:=.}/privatization -s -long --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/privatization:${privatization:=1} --log=simix_context.thres:error --log=xbt_memory_map.thres:critical
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 32 ${bindir:=.}/privatization -s -long --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/privatization:${privatization:=1} --log=simix_context.thres:error --log=xbt_memory_map.thres:critical
> You requested to use 32 ranks, but there is only 5 processes in your hostfile...
-/* 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;
p Test dsend
! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ${bindir:=.}/../hostfile -platform ${platfdir}/small_platform.xml -np 2 ${bindir:=.}/pt2pt-dsend -s --long --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/simulate-computation:no
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ${bindir:=.}/../hostfile -platform ${platfdir}/small_platform.xml -np 2 ${bindir:=.}/pt2pt-dsend -s --long --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/simulate-computation:no
> [Jupiter:1:(2) 0.000000] [dsend/INFO] rank 1: data exchanged
> [Tremblay:0:(1) 0.005890] [dsend/INFO] rank 0: data exchanged
> [rank 0] -> Tremblay
p process 1 will finish at 0.5+2*4 (send) + 1+0.1*4 (isend) = 9.9s
p process 2 will finish at 0.5+2*4 (time before first send) + 2*(1+0.5*4) (recv+irecv) + 0.005890 (network time, same as before) = 14.505890s
! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ${bindir:=.}/../hostfile -platform ${platfdir}/small_platform.xml -np 2 ${bindir:=.}/pt2pt-dsend -s --long --log=smpi_kernel.thres:warning --cfg=smpi/or:0:1:0.5 --cfg=smpi/os:0:0.5:2 --cfg=smpi/ois:0:1:0.1 --cfg=smpi/simulate-computation:no --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ${bindir:=.}/../hostfile -platform ${platfdir}/small_platform.xml -np 2 ${bindir:=.}/pt2pt-dsend -s --long --log=smpi_config.thres:warning --cfg=smpi/or:0:1:0.5 --cfg=smpi/os:0:0.5:2 --cfg=smpi/ois:0:1:0.1 --cfg=smpi/simulate-computation:no --log=xbt_cfg.thres:warning
> [Jupiter:1:(2) 9.900000] [dsend/INFO] rank 1: data exchanged
> [Tremblay:0:(1) 14.505890] [dsend/INFO] rank 0: data exchanged
> [rank 0] -> Tremblay
p Test output of time independent tracing
p generate a trace with pingpong, and replay itself, then check that output trace of the second run is the same as in the first (once sorted)
! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace-ti --cfg=tracing/filename:out_in_ti.txt --cfg=smpi/simulate-computation:no -map -hostfile ${srcdir:=.}/../hostfile -platform ${srcdir:=.}/../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/pt2pt-pingpong -s --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace-ti --cfg=tracing/filename:out_in_ti.txt --cfg=smpi/simulate-computation:no -map -hostfile ${srcdir:=.}/../hostfile -platform ${srcdir:=.}/../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/pt2pt-pingpong -s --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
>
>
>
> [rank 2] -> Fafard
> [rank 3] -> Ginette
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -no-privatize -replay ./out_in_ti.txt --log=replay.:critical -trace-ti --cfg=tracing/filename:out_ti.txt --cfg=smpi/simulate-computation:no -map -hostfile ${srcdir:=.}/../hostfile -platform ${srcdir:=.}/../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/../../../examples/smpi/replay/smpi_replay --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -no-privatize -replay ./out_in_ti.txt --log=replay.:critical -trace-ti --cfg=tracing/filename:out_ti.txt --cfg=smpi/simulate-computation:no -map -hostfile ${srcdir:=.}/../hostfile -platform ${srcdir:=.}/../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/../../../examples/smpi/replay/smpi_replay --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [rank 0] -> Tremblay
> [rank 1] -> Jupiter
> [rank 2] -> Fafard
p Same test, but only using one output file for all processes
p generate a trace with pingpong, and replay itself, then check that output trace of the second run is the same as in the first (once sorted)
! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace-ti --cfg=tracing/filename:out_in_ti.txt --cfg=tracing/smpi/format/ti-one-file:yes --cfg=smpi/simulate-computation:no -map -hostfile ${srcdir:=.}/../hostfile -platform ${srcdir:=.}/../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/pt2pt-pingpong -s --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace-ti --cfg=tracing/filename:out_in_ti.txt --cfg=tracing/smpi/format/ti-one-file:yes --cfg=smpi/simulate-computation:no -map -hostfile ${srcdir:=.}/../hostfile -platform ${srcdir:=.}/../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/pt2pt-pingpong -s --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
>
>
>
> [rank 2] -> Fafard
> [rank 3] -> Ginette
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -no-privatize -replay ./out_in_ti.txt --log=replay.:critical -trace-ti --cfg=tracing/filename:out_ti.txt --cfg=tracing/smpi/format/ti-one-file:yes --cfg=smpi/simulate-computation:no -map -hostfile ${srcdir:=.}/../hostfile -platform ${srcdir:=.}/../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/../../../examples/smpi/replay/smpi_replay --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -no-privatize -replay ./out_in_ti.txt --log=replay.:critical -trace-ti --cfg=tracing/filename:out_ti.txt --cfg=tracing/smpi/format/ti-one-file:yes --cfg=smpi/simulate-computation:no -map -hostfile ${srcdir:=.}/../hostfile -platform ${srcdir:=.}/../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/../../../examples/smpi/replay/smpi_replay --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [rank 0] -> Tremblay
> [rank 1] -> Jupiter
> [rank 2] -> Fafard
! expect return 1
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile_empty -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/pt2pt-pingpong -s --log=smpi_kernel.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile_empty -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/pt2pt-pingpong -s --log=smpi_config.thres:warning
> [smpirun] ** error: the hostfile '../hostfile_empty' is empty. Aborting.
! expect return 1
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile hostfile-does-not-exist.txt -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/pt2pt-pingpong -s --log=smpi_kernel.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile hostfile-does-not-exist.txt -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/pt2pt-pingpong -s --log=smpi_config.thres:warning
> [smpirun] ** error: the file 'hostfile-does-not-exist.txt' does not exist. Aborting.
/* 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 rank;
int msg = 99;
MPI_Status status;
-
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");
p Test pingpong
! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/pt2pt-pingpong -s --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/pt2pt-pingpong -s --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> *** Ping-pong test (MPI_Send/MPI_Recv) ***
>
>
p Test timers
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 1 ${bindir:=.}/timers -q --log=smpi_kernel.thres:warning --cfg=smpi/simulate-computation:no --cfg=smpi/host-speed:100000 --log=xbt_cfg.thres:warning --cfg=smpi/wtime:0
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 1 ${bindir:=.}/timers -q --log=smpi_config.thres:warning --cfg=smpi/simulate-computation:no --cfg=smpi/host-speed:100000 --log=xbt_cfg.thres:warning --cfg=smpi/wtime:0
> [rank 0] -> Tremblay
--- /dev/null
+/* 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. Jonathan Borne. */
+
+#include <mpi.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define DIM 2
+#define Q 2
+/* Where DIM is the dimension of the Grid (2D) */
+/* and Q is the number of processes per dimension */
+#define N 3
+/* Local matrices size N*N */
+
+int main(int argc, char** argv)
+{
+ /* Nb of nodes in the grid:
+ initialized by MPI_Comm_size according to commandline -np value */
+ int nbNodes;
+
+ /* Communicators */
+ MPI_Comm gridComm;
+ MPI_Comm lineComm;
+ /* Current process ranks */
+ int rank;
+ int gridSize;
+ int myGridRank;
+ int myLineRank;
+ int myColRank;
+ /* coords: used to get myLineRank and myColRank
+ initialized by MPI_Cart_coords
+ */
+ int coords[DIM];
+ /* dims: Integer array of size ndims specifying the number
+ of processes in each dimension.
+ if init value is 0 it is reset by MPI_Dims_create.
+ */
+ int dims[DIM];
+ for (int i = 0; i < DIM; i++) {
+ dims[i] = Q;
+ }
+ /* periods:
+ Logical array of size ndims specifying whether the grid is
+ periodic (true) or not (false) in each dimension. */
+ int periods[DIM];
+ for (int i = 0; i < DIM; i++) {
+ periods[i] = 1;
+ }
+ /* reorder: do not allows rank reordering when creating the grid comm */
+ int reorder = 0;
+ /* remainDims[]: used to set which dimension is kept in subcommunicators */
+ int remainDim[DIM];
+
+ /* Local Matrix */
+ int* A = malloc(N * N * sizeof(int));
+
+ /* Init */
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &nbNodes);
+
+ printf("rank %d: Alive \n", rank);
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ /* Set dims[] values to descibe a grid of nbNodes and DIM dimensions*/
+ MPI_Cart_create(MPI_COMM_WORLD, DIM, dims, periods, reorder, &gridComm);
+
+ if (gridComm == MPI_COMM_NULL)
+ printf("error grid NULLCOMM \n");
+
+ MPI_Comm_rank(gridComm, &myGridRank);
+ MPI_Comm_size(gridComm, &gridSize);
+ MPI_Cart_coords(gridComm, myGridRank, DIM, coords);
+ myLineRank = coords[0];
+ myColRank = coords[1];
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ /* Create a line communicator for current process */
+ remainDim[0] = 0;
+ remainDim[1] = 1;
+ MPI_Cart_sub(gridComm, remainDim, &lineComm);
+
+ /* Check if lineComm was initialized */
+ if (lineComm == MPI_COMM_NULL)
+ printf("(%d,%d): ERR (lineComm == NULLCOMM)\n", myLineRank, myColRank);
+
+ /* A Initialization */
+ for (int i = 0; i < N; i++) {
+ for (int j = 0; j < N; j++) {
+ *(A + (i * N) + j) = i == j ? rank : 0;
+ }
+ }
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ /* Broadcast */
+ int root = 0;
+ MPI_Bcast(A, N * N, MPI_INT, root, lineComm);
+
+ /* Print A */
+ printf("process:(%d,%d) \n", myLineRank, myColRank);
+
+ printf("-------------------\n");
+ for (int i = 0; i < N; i++) {
+ for (int j = 0; j < N; j++) {
+ printf("%d ", *(A + (i * N) + j));
+ }
+ printf("\n");
+ }
+ printf("-------------------\n");
+
+ MPI_Comm_free(&lineComm);
+ MPI_Comm_free(&gridComm);
+ free(A);
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Finalize();
+ return 0;
+}
--- /dev/null
+p Test cart_sub
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/topo-cart-sub -q --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
+> [rank 0] -> Tremblay
+> [rank 1] -> Jupiter
+> [rank 2] -> Fafard
+> [rank 3] -> Ginette
+> rank 0: Alive
+> rank 1: Alive
+> rank 2: Alive
+> rank 3: Alive
+> process:(0,0)
+> -------------------
+> 0 0 0
+> 0 0 0
+> 0 0 0
+> -------------------
+> process:(1,0)
+> -------------------
+> 2 0 0
+> 0 2 0
+> 0 0 2
+> -------------------
+> process:(0,1)
+> -------------------
+> 0 0 0
+> 0 0 0
+> 0 0 0
+> -------------------
+> process:(1,1)
+> -------------------
+> 2 0 0
+> 0 2 0
+> 0 0 2
+> -------------------
+
-/* 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
p Test hvector
! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 2 ${bindir:=.}/type-hvector -q --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 2 ${bindir:=.}/type-hvector -q --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [rank 0] -> Tremblay
> [rank 1] -> Jupiter
> rank= 0, a[0][0]=0.000000
-/* 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
p Test indexed
! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 2 ${bindir:=.}/type-indexed -q --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 2 ${bindir:=.}/type-indexed -q --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [rank 0] -> Tremblay
> [rank 1] -> Jupiter
> buffer[0] = 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
p Test struct
! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 2 ${bindir:=.}/type-struct -q --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 2 ${bindir:=.}/type-struct -q --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [rank 0] -> Tremblay
> [rank 1] -> Jupiter
> Process 0 got -2 (-2?) and 8.000000 (8.0?), tab (should be all 0): 0 0 0 0 0 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
p Test vector
! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ${platfdir}/small_platform.xml -np 2 ${bindir:=.}/type-vector -q --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ${platfdir}/small_platform.xml -np 2 ${bindir:=.}/type-vector -q --log=smpi_config.thres:warning --log=xbt_cfg.thres:warning
> [rank 0] -> Tremblay
> [rank 1] -> Jupiter
> rank= 0, a[0][0]=0.000000
/* 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. */
-#include "simgrid/msg.h"
+#include "simgrid/s4u/Engine.hpp"
#include "src/kernel/lmm/maxmin.hpp"
#include "src/surf/surf_interface.hpp"
#include "xbt/log.h"
int main(int argc, char** argv)
{
- MSG_init(&argc, argv);
+ simgrid::s4u::Engine e(&argc, argv);
XBT_INFO("***** Test 1");
test1();
/* 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. */
+#include "simgrid/s4u/Engine.hpp"
#include "src/kernel/lmm/maxmin.hpp"
-#include "simgrid/msg.h"
#include "xbt/module.h"
#include "xbt/sysdep.h" /* time manipulation for benchmarking */
#include "xbt/xbt_os_time.h"
int main(int argc, char **argv)
{
- MSG_init(&argc, argv);
+ simgrid::s4u::Engine e(&argc, argv);
float rate_no_limit=0.2;
float acc_date=0;
/* 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();
XBT_DEBUG("\t * Done : %p", &action);
action.unref();
}
-
} while (
(surf_network_model->get_started_action_set()->size() || surf_cpu_model_pm->get_started_action_set()->size()) &&
surf_solve(-1.0) >= 0.0);
/* 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
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include "xbt.h"
-#include <simgrid/msg.h>
+#include <simgrid/engine.h>
+#include <xbt.h>
XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Logs of this example");
int main(int argc, char *argv[])
{
- MSG_init(&argc, argv);
+ simgrid_init(&argc, argv);
char *tmp = bprintf("\n%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s",
1, ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n",
2, ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n",
/* 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
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include <simgrid/msg.h>
+#include <simgrid/engine.h>
#include <xbt.h>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(test, top, "Logging specific to this test");
int main(int argc, char **argv)
{
- MSG_init(&argc, argv);
+ simgrid_init(&argc, argv);
dolog("");
dolog(" ");
-/* 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. */
-#include "simgrid/msg.h"
+#include "simgrid/s4u/Engine.hpp"
#include <thread>
XBT_LOG_NEW_DEFAULT_CATEGORY(synchro_crashtest, "Logs of this example");
int main(int argc, char* argv[])
{
- MSG_init(&argc, argv);
+ simgrid::s4u::Engine e(&argc, argv);
std::thread crashers[crasher_amount];
-/* 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 "src/internal_config.h" // HAVE_FUTEX_H
#include "xbt/parmap.hpp"
-#include <simgrid/msg.h>
+#include <simgrid/s4u/Engine.hpp>
#include <xbt.h>
#include <cstdlib>
unsigned modes = MODES_DEFAULT;
xbt_log_control_set("parmap_bench.fmt:[%c/%p]%e%m%n");
- MSG_init(&argc, argv);
+ simgrid::s4u::Engine e(&argc, argv);
if (argc != 3 && argc != 4) {
XBT_INFO("Usage: %s nthreads timeout [modes]", argv[0]);
/* 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. */
#include "src/internal_config.h" // HAVE_FUTEX_H
-#include <simgrid/msg.h>
+#include <simgrid/s4u/Engine.hpp>
#include <xbt.h>
#include <xbt/parmap.hpp>
{
int status = 0;
xbt_log_control_set("parmap_test.fmt:[%c/%p]%e%m%n");
- MSG_init(&argc, argv);
+ simgrid::s4u::Engine e(&argc, argv);
SIMIX_context_set_nthreads(16); // dummy value > 1
XBT_INFO("Basic testing posix");
-/* 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. */
${CMAKE_CURRENT_SOURCE_DIR}/MSG_visualization/trace2fig.pl PARENT_SCOPE)
set(txt_files ${txt_files} ${CMAKE_CURRENT_SOURCE_DIR}/pkg-config/simgrid.pc.in
- ${CMAKE_CURRENT_SOURCE_DIR}/sanitizers.supp
+ ${CMAKE_CURRENT_SOURCE_DIR}/address_sanitizer.supp
+ ${CMAKE_CURRENT_SOURCE_DIR}/thread_sanitizer.supp
${CMAKE_CURRENT_SOURCE_DIR}/simgrid.supp
${CMAKE_CURRENT_SOURCE_DIR}/simgrid2vite.sed PARENT_SCOPE)
#!/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
# Address sanitizer suppressions for stuff that we cannot control
# ignore libunwind cruft
-interceptor_via_lib:libunwind.so
+#interceptor_via_lib:libunwind.so
# __gnu_cxx::__to_xstring
-interceptor_via_fun:__to_xstring
+#interceptor_via_fun:__to_xstring
src/surf/storage_n11.hpp
src/surf/surf_interface.hpp
src/surf/surf_private.hpp
- src/surf/PropertyHolder.hpp
src/surf/host_clm03.hpp
src/surf/HostImpl.hpp
src/surf/ptask_L07.hpp
src/smpi/internals/smpi_replay.cpp
src/smpi/internals/smpi_actor.cpp
src/smpi/internals/smpi_utils.cpp
+ src/smpi/internals/smpi_config.cpp
src/smpi/mpi/smpi_comm.cpp
src/smpi/mpi/smpi_datatype.cpp
src/smpi/mpi/smpi_datatype_derived.cpp
src/smpi/include/smpi_actor.hpp
src/smpi/include/smpi_coll.hpp
src/smpi/include/smpi_comm.hpp
+ src/smpi/include/smpi_config.hpp
src/smpi/include/smpi_datatype_derived.hpp
src/smpi/include/smpi_datatype.hpp
src/smpi/include/smpi_errhandler.hpp
src/xbt/memory_map.cpp
src/xbt/memory_map.hpp
src/xbt/OsSemaphore.hpp
+ src/xbt/PropertyHolder.cpp
src/xbt/parmap.cpp
src/xbt/random.cpp
src/xbt/snprintf.c
src/surf/network_constant.cpp
src/surf/network_interface.cpp
src/surf/network_wifi.cpp
- src/surf/PropertyHolder.cpp
src/surf/sg_platf.cpp
src/surf/StorageImpl.cpp
src/surf/storage_n11.cpp
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
set(SIMGRID_SRC
src/simgrid/Exception.cpp
src/simgrid/sg_config.cpp
+ src/simgrid/sg_version.cpp
src/simgrid/util.hpp
)
set(headers_to_install
include/simgrid/actor.h
include/simgrid/barrier.h
+ include/simgrid/comm.h
include/simgrid/engine.h
include/simgrid/Exception.hpp
include/simgrid/chrono.hpp
include/simgrid/smpi/replay.hpp
include/simgrid/instr.h
include/simgrid/mailbox.h
- include/simgrid/msg.h
include/simgrid/simdag.h
include/simgrid/modelchecker.h
include/simgrid/forward.h
include/xbt/mallocator.h
include/xbt/misc.h
include/xbt/module.h
+ include/xbt/PropertyHolder.hpp
include/xbt/parmap.h
include/xbt/range.hpp
include/xbt/random.hpp
)
set(source_of_generated_headers
include/simgrid/config.h.in
+ include/simgrid/version.h.in
src/internal_config.h.in
- src/simgrid/version.h.in
include/smpi/mpif.h.in)
### depend of some variables setted upper
${XBT_SRC}
${PLUGINS_SRC}
${BINDINGS_SRC}
- ${MSG_SRC}
${SIMDAG_SRC}
)
+if(${enable_msg})
+ set(headers_to_install ${headers_to_install} include/simgrid/msg.h)
+ set(simgrid_sources ${simgrid_sources} ${MSG_SRC})
+else()
+ set(EXTRA_DIST ${EXTRA_DIST} include/simgrid/msg.h
+ ${MSG_SRC})
+endif()
+
if(${SIMGRID_HAVE_JEDULE})
set(simgrid_sources ${simgrid_sources} ${JEDULE_SRC})
else()
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
# The list of cmake build directories is constructed from the following list.
# Add your CMakeLists file here to see your subdir built.
set(CMAKEFILES_TXT
+ examples/c/CMakeLists.txt
examples/s4u/CMakeLists.txt
examples/smpi/CMakeLists.txt
examples/smpi/NAS/CMakeLists.txt
- examples/smpi/smpi_msg_masterslave/CMakeLists.txt
+ examples/smpi/smpi_s4u_masterslave/CMakeLists.txt
examples/smpi/replay_multiple/CMakeLists.txt
examples/smpi/replay_multiple_manual_deploy/CMakeLists.txt
examples/python/CMakeLists.txt
teshsuite/lua/CMakeLists.txt
teshsuite/mc/CMakeLists.txt
teshsuite/msg/CMakeLists.txt
+ teshsuite/python/CMakeLists.txt
teshsuite/s4u/CMakeLists.txt
teshsuite/simdag/CMakeLists.txt
teshsuite/simix/CMakeLists.txt
teshsuite/smpi/mpich3-test/f90/rma/CMakeLists.txt
teshsuite/smpi/mpich3-test/group/CMakeLists.txt
teshsuite/smpi/mpich3-test/info/CMakeLists.txt
+ teshsuite/smpi/mpich3-test/io/CMakeLists.txt
teshsuite/smpi/mpich3-test/init/CMakeLists.txt
teshsuite/smpi/mpich3-test/pt2pt/CMakeLists.txt
teshsuite/smpi/mpich3-test/topo/CMakeLists.txt
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)
mark_as_advanced(GCCLIBATOMIC_LIBRARY)
if(enable_model-checking AND (NOT LINKER_VERSION VERSION_LESS "2.30"))
- set(SIMGRID_DEP "${SIMGRID_DEP} -Wl,-znoseparate-code")
+ set(SIMGRID_DEP "${SIMGRID_DEP} -Wl,-znorelro -Wl,-znoseparate-code")
endif()
target_link_libraries(simgrid ${SIMGRID_DEP})
# 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.
#
# - Calls include_directories() on where libunwind.h lives
# - Calls link_directories() on where the libs live
-# Of course also need the core lib
+# Of course also need the core lib
set(LIBUNWIND_COMPONENTS ${LIBUNWIND_COMPONENTS} "unwind")
message(STATUS "Looking for libunwind:")
-# Let's assume we have it, and invalidate if parts are missing
+# Let's assume we have it, and invalidate if parts are missing
SET(HAVE_LIBUNWIND 1)
#
option(enable_ns3 "Whether ns-3 model is activated." off)
option(enable_java "Whether the Java bindings are activated." off)
+option(enable_msg "Whether the MSG module is activated." off)
option(enable_lib_in_jar "Whether the native libraries are bundled in a Java jar file" on)
option(minimal-bindings "Whether to compile the bindings libraries (Java/Python) with the minimal dependency set" off)
mark_as_advanced(minimal-bindings)
-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)
LIST(REMOVE_AT ARGR 0)
ENDFOREACH()
FOREACH(FACTORY ${FACTORIES})
- if ((${FACTORY} STREQUAL "thread" ) OR # Always available, thanks to C++11 threads
+ if ((${FACTORY} STREQUAL "thread" ) OR # Always available, thanks to C++11 threads
(${FACTORY} STREQUAL "boost" AND HAVE_BOOST_CONTEXTS) OR
(${FACTORY} STREQUAL "raw" AND HAVE_RAW_CONTEXTS) OR
(${FACTORY} STREQUAL "ucontext" AND HAVE_UCONTEXT_CONTEXTS))
LIST(REMOVE_AT ARGR 0)
ENDFOREACH()
FOREACH(FACTORY ${FACTORIES})
- if ((${FACTORY} STREQUAL "thread" ) OR # Always available, thanks to C++11 threads
+ if ((${FACTORY} STREQUAL "thread" ) OR # Always available, thanks to C++11 threads
(${FACTORY} STREQUAL "boost" AND HAVE_BOOST_CONTEXTS) OR
(${FACTORY} STREQUAL "raw" AND HAVE_RAW_CONTEXTS) OR
(${FACTORY} STREQUAL "ucontext" AND HAVE_UCONTEXT_CONTEXTS))
#!/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.
while (defined(my $arg = shift)) {
# print "arg($count)$arg\n";
if ($arg =~ m!/smpirun$!) {
- @argv = ( $arg, "-keep-temps", "-wrapper", "@argv" );
+ @argv = ( $arg, "-keep-temps", "-quiet", "-wrapper", "@argv" );
} elsif ($arg eq "--cd") {
$arg = shift;
print "cd $arg\n";
#!/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) {}
# - Compile and install SimGrid itself. Clean the tree.
# - Remove everything that was installed, and re-install what's needed by the SimGrid libraries before the Gran Final Cleanup
RUN apt-get --allow-releaseinfo-change update && apt -y upgrade && \
- apt install -y g++ gcc git valgrind default-jdk gfortran libboost-dev libboost-all-dev cmake dpkg-dev && \
+ apt install -y g++ gcc git valgrind gfortran libboost-dev libboost-all-dev cmake dpkg-dev && \
mkdir /source/ && cd /source && git clone --depth=1 https://framagit.org/simgrid/simgrid.git simgrid.git && \
cd simgrid.git && \
- cmake -DCMAKE_INSTALL_PREFIX=/usr/ -Denable_documentation=OFF -Denable_java=ON -Denable_smpi=ON -Denable_compile_optimizations=ON . && \
+ cmake -DCMAKE_INSTALL_PREFIX=/usr/ -Denable_documentation=OFF -Denable_smpi=ON -Denable_compile_optimizations=ON . && \
make -j4 install && \
mkdir debian/ && touch debian/control && dpkg-shlibdeps --ignore-missing-info lib/*.so -llib/ -O/tmp/deps && \
git reset --hard master && git clean -dfx && \
all: build-deps unstable tuto-s4u tuto-smpi
stable:
- # docker build -f Dockerfile.stable --build-arg DLURL=/simgrid/simgrid/uploads/ddd14d9e34ee36bc90d9107f12480c28/SimGrid-3.24.tar.gz -t simgrid/stable:latest -t simgrid/stable:v3.24 . |tee stable.log
+ # docker build -f Dockerfile.stable --build-arg DLURL=/simgrid/simgrid/uploads/0365f13697fb26eae8c20fc234c5af0e/SimGrid-3.25.tar.gz -t simgrid/stable:latest -t simgrid/stable:v3.25 . |tee stable.log
export last_tag=$$(wget https://framagit.org/simgrid/simgrid/tags 2>/dev/null -O - | grep /simgrid/simgrid/-/tags/v | head -n1 | sed 's/[^>]*>//' | sed 's/<.*//'); \
export DLURL=$$(wget https://framagit.org/simgrid/simgrid/tags/$${last_tag} 2>/dev/null -O - | grep SimGrid- | perl -pe 's/.*?<a href="(\/simgrid[^ ]*tar.gz)".*/$1/'); \
echo "DLURL=$$DLURL";\
#! /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.
TRACE=$1
echo "input: $TRACE"
-OUTPUT=$( echo $TRACE | cut -d\. -f1 ).fix.trace
+OUTPUT=${TRACE%.*}.fix.trace
-grep ^% < $TRACE > header
-DEFEVENTS=$(grep Define < header | awk '{ print $3 }')
+grep ^% -- "$TRACE" > header
+DEFEVENTS=( $(awk '/Define/ { print $3 }' header) )
-GREP=""
-GREP2=""
-for i in $DEFEVENTS
+GREP=()
+for i in "${DEFEVENTS[@]}"
do
- GREP="/^$i /d; $GREP"
- GREP2="-e '^$i ' $GREP2"
+ GREP+=( -e "^$i " )
done
-GREP="/^%\ /d; /^% /d; /^%E/d; $GREP"
+GREP2=( -e $'^%[ \tE]' "${GREP[@]}" )
-grep $GREP2 < $TRACE > types
-/bin/sed -e "$GREP" $TRACE > events
+grep "${GREP[@]}" -- "$TRACE" > types
+grep -v "${GREP2[@]}" -- "$TRACE" > events
sort -n -k 2 -s < events > events.sorted
-cat header types events.sorted > $OUTPUT
-rm types events events.sorted header
+cat header types events.sorted > "$OUTPUT"
+rm -f types events events.sorted header
echo "output: $OUTPUT"
#!/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:
-add_executable (graphicator graphicator.c)
-add_dependencies (tests graphicator)
-target_link_libraries(graphicator simgrid)
-set_target_properties(graphicator PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
-ADD_TESH(graphicator --setenv srcdir=${CMAKE_HOME_DIRECTORY} --setenv bindir=${CMAKE_BINARY_DIR}/bin --cd ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/graphicator.tesh)
+if(enable_msg)
+ add_executable (graphicator graphicator.c)
+ add_dependencies (tests graphicator)
+ target_link_libraries(graphicator simgrid)
+ set_target_properties(graphicator PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
+ ADD_TESH(graphicator --setenv srcdir=${CMAKE_HOME_DIRECTORY} --setenv bindir=${CMAKE_BINARY_DIR}/bin --cd ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/graphicator.tesh)
-install(TARGETS graphicator DESTINATION bin/)
+ install(TARGETS graphicator DESTINATION bin/)
-## Clean generated files
-get_directory_property(extra_clean_files ADDITIONAL_MAKE_CLEAN_FILES)
-set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${extra_clean_files};${CMAKE_CURRENT_BINARY_DIR}/simgrid.trace;")
+ ## Clean generated files
+ get_directory_property(extra_clean_files ADDITIONAL_MAKE_CLEAN_FILES)
+ set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${extra_clean_files};${CMAKE_CURRENT_BINARY_DIR}/simgrid.trace;")
+endif()
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/graphicator.tesh PARENT_SCOPE)
set(tools_src ${tools_src} ${CMAKE_CURRENT_SOURCE_DIR}/graphicator.c PARENT_SCOPE)
-/* 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
# Install required software
installSonarQubeScanner() {
- local SONAR_SCANNER_VERSION=3.2.0.1227
+ SONAR_SCANNER_VERSION=3.2.0.1227
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION
rm -rf $SONAR_SCANNER_HOME
mkdir -p $SONAR_SCANNER_HOME
#!/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
exit 1
}
-do_cleanup() {
- for d in "$BUILDFOLDER"
+### Check the node installation
+
+pkg_check() {
+ for pkg
do
- if [ -d "$d" ]
+ if command -v $pkg
then
- rm -rf "$d" || die "Could not remote $d"
+ echo "$pkg is installed. Good."
+ else
+ die "please install $pkg before proceeding"
fi
done
}
-### Check the node installation
-
-for pkg in xsltproc gcovr ant cover2cover.py
-do
- if command -v $pkg
- then
- echo "$pkg is installed. Good."
- else
- die "please install $pkg before proceeding"
- fi
-done
+pkg_check xsltproc gcovr ant cover2cover.py
### Cleanup previous runs
! [ -z "$WORKSPACE" ] || die "No WORKSPACE"
[ -d "$WORKSPACE" ] || die "WORKSPACE ($WORKSPACE) does not exist"
-do_cleanup
+do_cleanup() {
+ for d
+ do
+ if [ -d "$d" ]
+ then
+ rm -rf "$d" || die "Could not remove $d"
+ fi
+ mkdir "$d" || die "Could not create $d"
+ done
+}
-for d in "$BUILDFOLDER"
-do
- mkdir "$d" || die "Could not create $d"
-done
+do_cleanup "$BUILDFOLDER"
NUMPROC="$(nproc)" || NUMPROC=1
ctest -D ExperimentalStart || true
-cmake -Denable_documentation=OFF -Denable_lua=ON -Denable_java=ON \
+cmake -Denable_documentation=OFF -Denable_lua=ON \
-Denable_compile_optimizations=OFF -Denable_compile_warnings=ON \
-Denable_jedule=ON -Denable_mallocators=ON \
-Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=ON -Denable_model-checking=ON \
exit 1
}
-do_cleanup() {
- for d in "$WORKSPACE/build" "$WORKSPACE/memcheck"
+### Check the node installation
+
+pkg_check() {
+ for pkg
do
- if [ -d "$d" ]
+ if command -v $pkg
then
- rm -rf "$d" || die "Could not remote $d"
+ echo "$pkg is installed. Good."
+ else
+ die "please install $pkg before proceeding"
fi
done
- find $WORKSPACE -name "memcheck_test_*.memcheck" -exec rm {} \;
}
-### Check the node installation
-
-for pkg in valgrind pcregrep
-do
- if command -v $pkg
- then
- echo "$pkg is installed. Good."
- else
- die "please install $pkg before proceeding"
- fi
-done
+pkg_check valgrind pcregrep
### Cleanup previous runs
! [ -z "$WORKSPACE" ] || die "No WORKSPACE"
[ -d "$WORKSPACE" ] || die "WORKSPACE ($WORKSPACE) does not exist"
-do_cleanup
+do_cleanup() {
+ for d
+ do
+ if [ -d "$d" ]
+ then
+ rm -rf "$d" || die "Could not remove $d"
+ fi
+ mkdir "$d" || die "Could not create $d"
+ done
+ find $WORKSPACE -name "memcheck_test_*.memcheck" -exec rm {} \;
+}
-for d in "$WORKSPACE/build" "$WORKSPACE/memcheck"
-do
- mkdir "$d" || die "Could not create $d"
-done
+do_cleanup "$WORKSPACE/build" "$WORKSPACE/memcheck"
NUMPROC="$(nproc)" || NUMPROC=1
### Proceed with the tests
ctest -D ExperimentalStart || true
-cmake -Denable_documentation=OFF -Denable_lua=OFF \
+cmake -Denable_documentation=OFF -Denable_lua=OFF -Denable_python=OFF \
-Denable_compile_optimizations=OFF -Denable_compile_warnings=ON \
-Denable_jedule=OFF -Denable_mallocators=OFF \
-Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=OFF -Denable_model-checking=OFF \
#find string containing errors and leaked size for valgrind run
wget https://ci.inria.fr/simgrid/job/SimGrid-DynamicAnalysis-Valgrind/label=simgrid-debian8-64-dynamic-analysis/lastCompletedBuild/
-VALGRIND_RES=$(grep href\=\"valgrindResult\" ./index.html | sed -e "s/.*\"valgrindResult\">\(.*lost\)<\/a.*/\1/g")
+VALGRIND_RES=$(grep href=\"valgrindResult\" ./index.html | sed -e "s/.*\"valgrindResult\">\(.*lost\)<\/a.*/\1/g")
rm index.html
#set html description and write it in a file
set -e
-if [ $# -lt 4 ]
- then
- echo "Needs 4 arguments : JAVA MC SMPI DEBUG"
- exit -1
-fi
-
-
+echo "Starting Flags.sh $*"
die() {
echo "$@"
exit 1
}
-do_cleanup() {
- for d in "$WORKSPACE/build"
- do
- if [ -d "$d" ]
- then
- rm -rf "$d" || die "Could not remote $d"
- fi
- done
-}
-
# Get an ON/OFF string from a command:
onoff() {
if "$@" > /dev/null ; then
fi
}
+[ $# -eq 5 ] || die "Needs 5 arguments : JAVA MC SMPI DEBUG MSG"
+
### Cleanup previous runs
! [ -z "$WORKSPACE" ] || die "No WORKSPACE"
[ -d "$WORKSPACE" ] || die "WORKSPACE ($WORKSPACE) does not exist"
-do_cleanup
+do_cleanup() {
+ for d
+ do
+ if [ -d "$d" ]
+ then
+ rm -rf "$d" || die "Could not remove $d"
+ fi
+ mkdir "$d" || die "Could not create $d"
+ done
+}
-for d in "$WORKSPACE/build"
-do
- mkdir "$d" || die "Could not create $d"
-done
+do_cleanup "$WORKSPACE/build"
NUMPROC="$(nproc)" || NUMPROC=1
builddebug="OFF"
fi
+if [ $5 = "MSG" ]
+then
+ buildmsg="ON"
+else
+ buildmsg="OFF"
+fi
+
+if [ $buildmsg = "OFF" ] && [ $buildjava = "ON" ]
+then
+ echo "Don't even try to build Java without MSG"
+ exit 0
+fi
-echo "Step ${STEP}/${NSTEPS} - Building with java=${buildjava}, debug=${builddebug}, SMPI=${buildsmpi}, MC=${buildmc}"
-cmake -Denable_documentation=OFF -Denable_lua=ON -Denable_java=${buildjava} \
+echo "Step ${STEP}/${NSTEPS} - Building with java=${buildjava}, debug=${builddebug}, SMPI=${buildsmpi}, MC=${buildmc}, MSG=${buildmsg}"
+cmake -Denable_documentation=OFF -Denable_lua=ON -Denable_java=${buildjava} -Denable_msg=${buildmsg} \
-Denable_compile_optimizations=OFF -Denable_compile_warnings=ON \
-Denable_jedule=ON -Denable_mallocators=ON -Denable_debug=${builddebug} \
-Denable_smpi=${buildsmpi} -Denable_smpi_MPICH3_testsuite=${buildsmpi} -Denable_model-checking=${buildmc} \
exit 1
}
-do_cleanup() {
- for d in "$WORKSPACE/build"
- do
- if [ -d "$d" ]
- then
- rm -rf "$d" || die "Could not remote $d"
- fi
- done
-}
-
if [ -z "$1" ]
then
echo "No Sanitizer type selected - run Address"
if [ "${SANITIZER}" = "address" ]
then
- export ASAN_OPTIONS="suppressions=$WORKSPACE/tools/sanitizers.supp"
+ export ASAN_OPTIONS="suppressions=$WORKSPACE/tools/address_sanitizer.supp"
SANITIZER_OPTIONS="-Denable_address_sanitizer=ON -Denable_undefined_sanitizer=OFF -Denable_thread_sanitizer=OFF"
elif [ "${SANITIZER}" = "thread" ]
then
- export TSAN_OPTIONS="memory_limit_mb=1500"
+ export TSAN_OPTIONS="memory_limit_mb=1500 suppressions=$WORKSPACE/tools/thread_sanitizer.supp"
SANITIZER_OPTIONS="-Denable_address_sanitizer=OFF -Denable_undefined_sanitizer=OFF -Denable_thread_sanitizer=ON"
elif [ "${SANITIZER}" = "undefined" ]
then
### Check the node installation
-for pkg in xsltproc
-do
- if command -v $pkg
- then
- echo "$pkg is installed. Good."
- else
- die "please install $pkg before proceeding"
- fi
-done
+pkg_check() {
+ for pkg
+ do
+ if command -v $pkg
+ then
+ echo "$pkg is installed. Good."
+ else
+ die "please install $pkg before proceeding"
+ fi
+ done
+}
+
+pkg_check xsltproc
### Cleanup previous runs
! [ -z "$WORKSPACE" ] || die "No WORKSPACE"
[ -d "$WORKSPACE" ] || die "WORKSPACE ($WORKSPACE) does not exist"
-do_cleanup
+do_cleanup() {
+ for d
+ do
+ if [ -d "$d" ]
+ then
+ rm -rf "$d" || die "Could not remove $d"
+ fi
+ mkdir "$d" || die "Could not create $d"
+ done
+}
-for d in "$WORKSPACE/build"
-do
- mkdir "$d" || die "Could not create $d"
-done
+do_cleanup "$WORKSPACE/build"
NUMPROC="$(nproc)" || NUMPROC=1
rm -rf /tmp/simgrid-java*
rm -rf /var/tmp/simgrid-java*
rm -rf /tmp/jvm-*
-find /builds/workspace/SimGrid/ -name "hs_err_pid*.log" | xargs rm -f
+find /builds/workspace/SimGrid/ -name "hs_err_pid*.log" -exec rm -f {} +
ls /tmp
df -h
echo "XXXX Let's go"
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/os-release ]; then
- # freedesktop.org and systemd, put last as usually missing useful info
+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
. /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"
MAY_DISABLE_SOURCE_CHANGE="-DCMAKE_DISABLE_SOURCE_CHANGES=ON"
fi
-if [ "$os" = "NixOS" -a "$(gcc -dumpversion)" = "7.4.0" ]; then
- echo "Temporary disable LTO, believed to be broken on this system."
- MAY_DISABLE_LTO=-Denable_lto=OFF
-else
- MAY_DISABLE_LTO=
-fi
-
cmake -G"$GENERATOR" ${INSTALL:+-DCMAKE_INSTALL_PREFIX=$INSTALL} \
-Denable_debug=ON -Denable_documentation=OFF -Denable_coverage=OFF \
-Denable_model-checking=$(onoff test "$build_mode" = "ModelChecker") \
-Denable_memcheck=$(onoff test "$build_mode" = "DynamicAnalysis") \
-Denable_compile_warnings=$(onoff test "$GENERATOR" != "MSYS Makefiles") -Denable_smpi=ON \
-Denable_ns3=$(onoff test "$have_NS3" = "yes" -a "$build_mode" = "Debug") \
- -Denable_jedule=OFF -Denable_java=ON -Denable_lua=OFF ${MAY_DISABLE_SOURCE_CHANGE} ${MAY_DISABLE_LTO} \
+ -Denable_jedule=OFF -Denable_lua=OFF ${MAY_DISABLE_SOURCE_CHANGE} \
+ -Denable_java=$(onoff test "$build_mode" = "ModelChecker") \
+ -Denable_msg=$(onoff test "$build_mode" = "ModelChecker") \
$SRCFOLDER
# -Denable_lua=$(onoff test "$build_mode" != "DynamicAnalysis") \
set +x
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"
get_python(){
found=$(grep -c "Compile Python bindings .....: ON" ./consoleText)
if [ $found != 0 ]; then
- echo "✔"
+ grep -m 1 "Found PythonInterp" ./consoleText| sed "s/.*-- Found PythonInterp.*found suitable version \"\([a-zA-Z0-9\.]*\)\",.*/\1/g"
else
echo ""
fi
#!/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.
print "#define ". uc($id) ." smpi_trace_set_call_location(__FILE__,__LINE__); call ". ucfirst $id ."\n";
}
else {
- print "#define $id(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); $id(__VA_ARGS__); })\n";
+ print "#define $id(...) (smpi_trace_set_call_location(__FILE__, __LINE__), $id(__VA_ARGS__))\n";
}
}
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()
--- /dev/null
+# Thread sanitizer suppressions for stuff that we cannot control
+
+# Race reported around std::__cxx11::stod / __gnu_cxx::__stoa when the value of
+# errno is saved and restored
+race:ext/string_conversions.h
+
+# False positive seen when simultaneously destroying a CommPtr in s4u-app-masterworkers-parallel
+# For more information, see
+# https://stackoverflow.com/questions/24446561/threadsanitizer-reports-data-race-on-operator-deletevoid-when-using-embedde
+# and more precisely the answer: https://stackoverflow.com/a/49173574
+race:simgrid::kernel::activity::CommImpl::~CommImpl()