From: Takishipp Date: Mon, 29 May 2017 13:28:40 +0000 (+0200) Subject: Merge branches 'master' and 'master' of github.com:simgrid/simgrid X-Git-Tag: v3.16~153^2~2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a92d7b716f51a53dea7f59db8524d4add713b910?hp=71e809a95b7359973c37b0417bc015a7bbdf0a1f Merge branches 'master' and 'master' of github.com:simgrid/simgrid --- diff --git a/.appveyor.yml b/.appveyor.yml index 72d470e4b5..e1ae3f1c06 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -2,7 +2,7 @@ # # Build logs: https://ci.appveyor.com/project/simgrid/simgrid -# Documentation: https://www.appveyor.com/docs/ +# Documentation: https://www.appveyor.com/docs/ # https://www.appveyor.com/docs/installed-software/ os: Visual Studio 2015 diff --git a/.gitignore b/.gitignore index 725236b2f1..c5eea27e85 100644 --- a/.gitignore +++ b/.gitignore @@ -173,7 +173,6 @@ examples/msg/mc/test/snapshot_comparison4 examples/msg/mc/test/snapshot_comparison5 examples/msg/ms.trace examples/msg/network-ns3/network-ns3 -examples/msg/app-pmm/app-pmm examples/msg/task-priority/task-priority examples/msg/procmig.trace examples/msg/platform-properties/platform-properties @@ -242,8 +241,8 @@ examples/smpi/trace_simple/smpi_trace_simple examples/smpi/trace_call_location/smpi_trace_call_location testall teshsuite/datadesc_usage.out -teshsuite/java/SemaphoreGC/SemaphoreGC_compiled -teshsuite/java/SleepHostOff/SleepHostOff_compiled +teshsuite/java/semaphoreGC/semaphoreGC_compiled +teshsuite/java/sleepHostOff/sleepHostOff_compiled teshsuite/mc/dwarf/dwarf teshsuite/mc/dwarf-expression/dwarf-expression teshsuite/mc/random-bug/random-bug diff --git a/.travis.yml b/.travis.yml index 5f89b91668..b53e23e266 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,14 +47,12 @@ addons: # - ls -lR $TRAVIS_BUILD_DIR/LuaInstall script: - - test "$TRAVIS_OS_NAME" == "osx" && brew update - - test "$TRAVIS_OS_NAME" == "osx" && brew install python3 - - test "$TRAVIS_OS_NAME" == "osx" && 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 . - - test "$TRAVIS_OS_NAME" == "linux" && 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=OFF -Denable_compile_warnings=ON . - # run make in the sonar wrapper && run the tests before sonar to get coverage info - - ./tools/internal/travis-sonarqube.sh make VERBOSE=1 - # if sonar was not run (and if the build succeeded), run the tests manually - - if [[ "$TRAVIS_OS_NAME" == "osx" && -e bin/graphicator ]]; then ctest --output-on-failure --timeout 100 ; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install python3; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then 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 .; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 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=OFF -Denable_compile_warnings=ON .; fi + # run make and ctest in the sonar wrapper on master/linux; run it directly in PR or OSX + - if [[ "$TRAVIS_OS_NAME" == "linux" ]] && [[ "${TRAVIS_PULL_REQUEST}" == "false" ]]; then ./tools/internal/travis-sonarqube.sh make VERBOSE=1; else make VERBOSE=1 && ctest --output-on-failure --timeout 100; fi notifications: recipients: - martin.quinson@ens-rennes.fr diff --git a/CMakeLists.txt b/CMakeLists.txt index d99da0de15..8fede4c2b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,9 @@ if(APPLE AND (CMAKE_C_COMPILER_VERSION VERSION_LESS "4.6")) set(HAVE_UCONTEXT_H 0) endif() +### Check threading support +set(CMAKE_THREAD_PREFER_PTHREAD TRUE) +find_package(Threads) ### Setup Options include(${CMAKE_HOME_DIRECTORY}/tools/cmake/Option.cmake) @@ -77,8 +80,21 @@ if ((NOT DEFINED enable_smpi) OR enable_smpi) if(CMAKE_Fortran_COMPILER) # Fortran compiler detected: save it, then replace by smpiff - set(SAVED_Fortran_COMPILER "${CMAKE_Fortran_COMPILER}" CACHE FILEPATH "The real Fortran compiler") + set(SMPI_Fortran_COMPILER "${CMAKE_Fortran_COMPILER}" CACHE FILEPATH "The real Fortran compiler") set(CMAKE_Fortran_COMPILER smpiff) + + # Set flags/libs to be used in smpiff + if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + set(SMPI_Fortran_FLAGS "\"-fpic\" \"-ff2c\" \"-fno-second-underscore\"") + set(SMPI_Fortran_LIBS "\"-lgfortran\"") + elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + set(SMPI_Fortran_FLAGS "\"-fPIC\" \"-nofor-main\"") + set(SMPI_Fortran_LIBS "\"-lifcore\"") + elseif(CMAKE_Fortran_COMPILER_ID MATCHES "PGI") # flang + set(SMPI_Fortran_FLAGS "\"-fPIC\"") + set(SMPI_Fortran_LIBS "") + endif() + set(SMPI_FORTRAN 1) endif(CMAKE_Fortran_COMPILER) @@ -274,7 +290,6 @@ endif() # Checks for header libraries functions. CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_POSIX_GETTIME) -CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_PTHREAD) if(NOT APPLE) # OS X El Capitan deprecates this function CHECK_LIBRARY_EXISTS(pthread sem_init "" HAVE_SEM_INIT_LIB) endif() @@ -388,7 +403,7 @@ if(HAVE_LIBUNWIND) endif() else() if(enable_model-checking) - message(FATAL_ERROR "Please either install the libunwind7-dev package (or equivalent) or turn off the model-checking option of SimGrid.") + message(FATAL_ERROR "Please install libunwind-dev libdw-dev libevent-dev if you want to compile the SimGrid model checker.") endif() endif() @@ -460,7 +475,7 @@ endif() ### Initialize of CONTEXT THREADS set(HAVE_THREAD_CONTEXTS 0) -if(HAVE_PTHREAD) +if(CMAKE_USE_PTHREADS_INIT) ### Test that we have a way to create semaphores if(HAVE_SEM_OPEN_LIB) @@ -941,7 +956,7 @@ else() endif() endif() if(CMAKE_Fortran_COMPILER) - message(" Compiler: Fortran ...........: ${SAVED_Fortran_COMPILER} (id: ${CMAKE_Fortran_COMPILER_ID})") + message(" Compiler: Fortran ...........: ${SMPI_Fortran_COMPILER} (id: ${CMAKE_Fortran_COMPILER_ID})") message(" version .............: ${CMAKE_Fortran_COMPILER_VERSION}") endif() message(" Linker: .....................: ${CMAKE_LINKER}") diff --git a/ChangeLog b/ChangeLog index 6ca3d3e3a8..449c17d607 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,13 +5,18 @@ SimGrid (3.16) UNRELEASED - Mac, BSD: dlopen+thread broken, switch automatically to raw contexts. XML platforms: Switch to platform v4.1 format. - * This is a backward compatible change: v4 are valid v4.1 files + * This is (mainly) a backward compatible change: v4 are valid v4.1 files - can be used as a synonym for the now deprecated - an be used as a synonym for the now deprecated - an be used as a synonym for the now deprecated - can be used as a synonym for the now deprecated - state_file and avail_file periodicity is now easier to express (check the documentation) the old behavior should still work. + * Storage: not backward compatible, but it seems that nobody ever used it + - Remove attribute 'content_type' of : was never used + - Make attribute 'model' of optional: for future usage + - Remove Bconnection model property: was never (in)validated. Replaced by + the maximum of the read and write bandwidth as a resource constraint. SimDag - New and Backwards Compatibility break: @@ -27,12 +32,14 @@ SimGrid (3.16) UNRELEASED SMPI - New algorithm to privatize globals: dlopen, with dynamic loading tricks - New option: smpi/keep-temps to not cleanup temp files + - Support for sparse privatized malloc with SMPI_PARTIAL_SHARED_MALLOC() XBT - Replay: New function xbt_replay_action_get(): Retrieve the function previously associated to an event type. - DROPPED FUNCTION: xbt_str_varsubst() - DROPPED MODULE: strbuff. We don't need it anymore. + - DROPPED MODULE: matrix. We don't need it anymore. -- Release target: June 21 2017 -- Da SimGrid team diff --git a/README b/README deleted file mode 100644 index 1b62155894..0000000000 --- a/README +++ /dev/null @@ -1,26 +0,0 @@ - -Welcome to the SimGrid project! - -SimGrid is a scientific instrument to study the behavior of -large-scale distributed systems such as Grids, Clouds, HPC or P2P -systems. It can be used to evaluate heuristics, prototype applications -or even assess legacy MPI applications. - -More documentation is included in this archive (doc/html/index.html) -or online at http://simgrid.gforge.inria.fr/ - -In any case, you may want to subscribe to the user mailing list -(http://lists.gforge.inria.fr/mailman/listinfo/simgrid-user). There, -you can find answers to your questions, or simply discuss with people -doing the same kind of research than you do, in an active and friendly -community. - -Thanks for using our software. Please do great things with it and tell -the world about it. Tell us, too, because we love to have positive -feedback. - -Cheers, -Da SimGrid Team. - - -https://travis-ci.org/simgrid/simgrid.svg?branch=master \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000000..dc87a47a2b --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +[![Travis Status](https://travis-ci.org/simgrid/simgrid.svg?branch=master)](https://travis-ci.org/simgrid/simgrid) +[![AppVeyor Status](https://ci.appveyor.com/api/projects/status/gvcssh340fwtoc35?svg=true)](https://ci.appveyor.com/project/mquinson/simgrid) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/bf1bdba50440485fbda2ac19f462ccc7)](https://www.codacy.com/app/mquinson/simgrid?utm_source=github.com&) +[![Doc](https://readthedocs.org/projects/pip/badge/?version=stable)](http://simgrid.gforge.inria.fr/simgrid/latest/doc/) +[![License: LGPL v3][license-badge]](COPYING) + +# Welcome to the SimGrid project! + +SimGrid is a scientific instrument to study the behavior of +large-scale distributed systems such as Grids, Clouds, HPC or P2P +systems. It can be used to evaluate heuristics, prototype applications +or even assess legacy MPI applications. + +More documentation is included in this archive (doc/html/index.html) +or [online](http://simgrid.gforge.inria.fr/) + +In any case, you may want to subscribe to the [user mailing list](http://lists.gforge.inria.fr/mailman/listinfo/simgrid-user). +There, you can find answers to your questions, or simply discuss with +people doing the same kind of research than you do, in an active and +friendly community. + +Thanks for using our software. Please do great things with it and tell +the world about it. Tell us, too, because we love to have positive +feedback. + +Cheers, +Da SimGrid Team. + +[license-badge]: https://img.shields.io/badge/License-LGPL%20v3-blue.svg +[release-badge]: https://img.shields.io/github/release/simgrid/simgrid.svg +[release-link]: https://gforge.inria.fr/frs/?group_id=12 diff --git a/circle.yml b/circle.yml index 3faf1433f8..253cfa2623 100644 --- a/circle.yml +++ b/circle.yml @@ -1,6 +1,6 @@ # This is the configuration file for the https://circleci.com/ continuous integration server # -# Copyright (C) 2017. The SimGrid team. All rights reserved. +# Copyright (C) 2017. The SimGrid team. All rights reserved. # # This program is free software; you can redistribute it and/or modify it # under the terms of the license (GNU LGPL) which comes with this package. diff --git a/doc/doxygen/ns3.doc b/doc/doxygen/ns3.doc index 5022462a43..c91fa5561e 100644 --- a/doc/doxygen/ns3.doc +++ b/doc/doxygen/ns3.doc @@ -43,7 +43,7 @@ cmake . -Denable_ns3=ON -DNS3_HINT=/opt/ns3 # or change the path if needed By the end of the configuration, cmake reports whether ns-3 was found, and this information is also available in include/simgrid_config.h -If your local copy defines the variable \c SIMGRID_HAVE_NS3 to 1, then NS3 +If your local copy defines the variable \c SIMGRID_HAVE_NS3 to 1, then ns-3 was correctly detected. If it's defined to 0, then something went wrong. Explore CMakeFiles/CMakeOutput.log and CMakeFiles/CMakeError.log to diagnose the problem. @@ -54,17 +54,6 @@ Afterward, you can test your installation as follows: $ ctest -R ns3 \endverbatim -\subsection pls_ns3_config_trouble Troubleshooting - -If you have a ns-3 version that is not known to SimGrid yet, edit \c -tools/cmake/Modules/FindNS3.cmake in your SimGrid tree, according to -the comments on top of this file. - -If the compilation fails on Debian/Ubuntu when linking the library -because of some .a file that cannot be used dynamically, then you are -probably using a very old (and buggy) libns3-dev -package. Update it, or install libns3-3 manually. - \section pls_ns3_use Using ns-3 from SimGrid The SimGrid-ns3 binding only contains features that are common to both @@ -72,26 +61,66 @@ systems: ns-3 wireless models are not available, while SimGrid routes cannot be longer than 1. Also, the platform built in ns-3 from the SimGrid description is very basic. -If your platform have longer routes, simply add some routers to break -these routes. SimGrid's routers are similar to hosts, without -computational abilities. +Any route longer than one will be ignored when using ns-3. They are +harmless, but you still need to connect your hosts using one-hop routes. +The best solution is to add routers to split your route. Here is an +example of invalid platform: + +@code{.xml} + + + + + + + + + + + + +@endcode + +Here is the same platform expressed in a way that ns-3 will understand. +There is no direct connexion from alice to bob, but that's OK because +ns-3 will find the path from point to point. + +@code{.xml} + + + + + + + + + + + + + + + + + +@endcode -Once your platform is OK, just change the "network/model" -configuration option to "NS3". The rest remains unchanged. -The following should work from the examples/msg/network-ns3 folder, -where the \c network-ns3 binary example lives. +Once your platform is OK, just change the "network/model" +configuration option to "NS3" as follows. The rest remains unchanged. \verbatim -./network-ns3 ../../platforms/small_platform_one_link_routes.xml 3hosts_2links_d.xml --cfg=network/model:NS3 --log=root.threshold:info +./network-ns3 ../../platforms/small_platform_one_link_routes.xml 3hosts_2links_d.xml --cfg=network/model:NS3 \endverbatim Many other files from the examples/platform directory are usable with -the ns-3 model. Check the file +the ns-3 model, such as @ref examples/platforms/dogbone.xml. Check the file examples/msg/network-ns3/network-ns3.tesh to see which ones are used in our regression tests. You may also be interested in the @ref msg_ex_ns3 "ns-3/SimGrid examples". +@subsection pls_ns3_shortcomings Shortcomings of the ns-3 bindings in SimGrid + A ns-3 platform is automatically created from the provided SimGrid platform. However, there are some known caveats: @@ -115,4 +144,33 @@ readable) as possible. If the current state does not fit your needs, you should modify this plugin, and/or create your own plugin from the existing one. +@section pls_trouble Troubleshooting with ns-3 and SimGrid + +@subsection pls_ns3_config_trouble I fail to compile ns-3 within SimGrid + +If you have a ns-3 version that is not known to SimGrid yet, edit \c +tools/cmake/Modules/FindNS3.cmake in your SimGrid tree, according to +the comments on top of this file. + +If the compilation fails on Debian/Ubuntu when linking the library +because of some .a file that cannot be used dynamically, then you are +probably using a very old (and buggy) libns3-dev +package. Update it, or install libns3-3 manually. + +@subsection pls_trouble_hang The simulation hangs at some point + +If your simulation hangs in a communication, this is probably because +one host is sending data that is not routable in your platform. Make +sure that you only use routes of length 1, and that any host is +connected to the platform. + +Arguably, SimGrid could detect this situation and report it, but +unfortunately, this is still to be done. + +@subsection pls_trouble_warning I get a warning that some routes are ignored + +Please read again the @ref pls_ns3_use section. + + +@example examples/platforms/dogbone.xml */ diff --git a/doc/doxygen/options.doc b/doc/doxygen/options.doc index d75d27e153..3fad32cb85 100644 --- a/doc/doxygen/options.doc +++ b/doc/doxygen/options.doc @@ -1110,11 +1110,42 @@ returns a new adress, but it only points to a shadow bloc: its memory area is mapped on a 1MiB file on disk. If the returned bloc is of size N MiB, then the same file is mapped N times to cover the whole bloc. At the end, no matter how many SMPI_SHARED_MALLOC you do, this will -only consume 1 MiB in memory. +only consume 1 MiB in memory. You can disable this behavior and come back to regular mallocs (for example for debugging purposes) using \c "no" as a value. +If you want to keep private some parts of the buffer, for instance if these +parts are used by the application logic and should not be corrupted, you +can use SMPI_PARTIAL_SHARED_MALLOC(size, offsets, offsets_count). + +As an example, + +\code{.C} + mem = SMPI_PARTIAL_SHARED_MALLOC(500, {27,42 , 100,200}, 2); +\endcode + +will allocate 500 bytes to mem, such that mem[27..41] and mem[100..199] +are shared and other area remain private. + +Then, it can be deallocated by calling SMPI_SHARED_FREE(mem). + +When smpi/shared-malloc:global is used, the memory consumption problem +is solved, but it may induce too much load on the kernel's pages table. +In this case, you should use huge pages so that we create only one +entry per Mb of malloced data instead of one entry per 4k. +To activate this, you must mount a hugetlbfs on your system and allocate +at least one huge page: + +\code{.sh} + mkdir /home/huge + sudo mount none /home/huge -t hugetlbfs -o rw,mode=0777 + sudo sh -c 'echo 1 > /proc/sys/vm/nr_hugepages' # echo more if you need more +\endcode + +Then, you can pass the option --cfg=smpi/shared-malloc-hugepage:/home/huge +to smpirun to actually activate the huge page support in shared mallocs. + \subsection options_model_smpi_wtime smpi/wtime: Inject constant times for calls to MPI_Wtime \b Default value: 0 @@ -1273,6 +1304,7 @@ It can be done by using XBT. Go to \ref XBT_log for more details. - \c smpi/privatization: \ref options_smpi_privatization - \c smpi/send-is-detached-thresh: \ref options_model_smpi_detached - \c smpi/shared-malloc: \ref options_model_smpi_shared_malloc +- \c smpi/shared-malloc-hugepage: \ref options_model_smpi_shared_malloc - \c smpi/simulate-computation: \ref options_smpi_bench - \c smpi/test: \ref options_model_smpi_test - \c smpi/wtime: \ref options_model_smpi_wtime diff --git a/doc/doxygen/platform.doc b/doc/doxygen/platform.doc index 89ee5f6ae3..1ef202b403 100644 --- a/doc/doxygen/platform.doc +++ b/doc/doxygen/platform.doc @@ -682,10 +682,9 @@ these might also help you to get started. Attribute name | Mandatory | Values | Description --------------- | --------- | ------ | ----------- id | yes | string | Identifier of this storage_type; used when referring to it -model | yes | string | For reasons of future backwards compatibility only; specifies the name of the model for the storage that should be used +model | no | string | In the future, this will allow 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. -content_type | no | ("txt_unix"\|"txt_win") | Determines which kind of filesystem you're using; make sure the filenames (stored in that file, see \ref pf_storage_content_file_structure "Storage Content File Structure"!) This tag must contain some predefined model properties, specified via the <model_prop> tag. Here is a list, see below for an example: @@ -694,7 +693,6 @@ 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") -Bconnexion | yes | string | Throughput (of the storage connector) in B/s. \note A storage_type can also contain the <prop> tag. The <prop> tag allows you @@ -704,10 +702,9 @@ Bconnexion | yes | string | Throughput (of the storage connector) in Here is a complete example for the ``storage_type`` tag: \verbatim - + - \endverbatim @@ -720,7 +717,6 @@ id | yes | string | Identifier of this ``storage``; used when typeId | yes | string | Here you need to refer to an already existing \ref pf_storage_entity_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_host) to which this storage is physically 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 "\" -content_type | no | string | When specified, overwrites the content_type attribute of \ref pf_storage_entity_storage_type "\" Here are two examples: @@ -728,8 +724,7 @@ Here are two examples: + content="content/win_storage_content.txt" /> \endverbatim The first example is straightforward: A disk is defined and called "Disk1"; it is @@ -754,18 +749,17 @@ is; this location is specified by the ``name`` attribute. Here is a simple example, taken from the file ``examples/platform/storage.xml``: \verbatim - + - + attach="alice" /> + attach="denise"/> diff --git a/doc/manpage/tesh.pod b/doc/manpage/tesh.pod index 7d9130cd82..0a9ef6ce97 100755 --- a/doc/manpage/tesh.pod +++ b/doc/manpage/tesh.pod @@ -22,7 +22,7 @@ they produce the expected output and return the expected value. --setenv var=value : set a specific environment variable --cfg arg : add parameter --cfg=arg to each command line --log arg : add parameter --log=arg to each command line - --ignore-jenkins : ignore all cruft generated on SimGrid + --ignore-jenkins : ignore all cruft generated on SimGrid continuous integration servers diff --git a/examples/java/app/bittorrent/Peer.java b/examples/java/app/bittorrent/Peer.java index 3a2e19eb85..94d0a68cf8 100644 --- a/examples/java/app/bittorrent/Peer.java +++ b/examples/java/app/bittorrent/Peer.java @@ -216,7 +216,7 @@ public class Peer extends Process { return success; } - void handleMessage(Task task) { + private void handleMessage(Task task) { MessageTask message = (MessageTask)task; Connection remotePeer = peers.get(message.peerId); switch (message.type) { @@ -332,7 +332,7 @@ public class Peer extends Process { beginReceiveTime = Msg.getClock(); } - void waitForPieces() { + private void waitForPieces() { boolean finished = false; while (Msg.getClock() < deadline && !finished) { if (commReceived == null) { @@ -380,7 +380,7 @@ public class Peer extends Process { * If the peer has more than pieces, he downloads the pieces that are the less * replicated */ - void updateCurrentPiece() { + private void updateCurrentPiece() { if (currentPieces.size() >= (Common.FILE_PIECES - pieces)) { return; } diff --git a/examples/java/app/centralizedmutex/Coordinator.java b/examples/java/app/centralizedmutex/Coordinator.java index 193129305b..22b3cfd0d4 100644 --- a/examples/java/app/centralizedmutex/Coordinator.java +++ b/examples/java/app/centralizedmutex/Coordinator.java @@ -1,5 +1,4 @@ -/* Copyright (c) 2012-2014, 2016. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -14,18 +13,16 @@ import org.simgrid.msg.Process; import org.simgrid.msg.MsgException; public class Coordinator extends Process { - LinkedList waitingQueue=new LinkedList<>(); - int csToServe; - public Coordinator(Host host, String name, String[]args) { super(host,name,args); } public void main(String[] args) throws MsgException { - csToServe = Integer.parseInt(args[0]); - Task task; + int csToServe = Integer.parseInt(args[0]); + LinkedList waitingQueue=new LinkedList<>(); + while (csToServe >0) { - task = Task.receive("coordinator"); + Task task = Task.receive("coordinator"); if (task instanceof RequestTask) { RequestTask t = (RequestTask) task; if (waitingQueue.isEmpty()) { diff --git a/examples/java/app/centralizedmutex/GrantTask.java b/examples/java/app/centralizedmutex/GrantTask.java index ff21e2a90a..e80bbc4f7a 100644 --- a/examples/java/app/centralizedmutex/GrantTask.java +++ b/examples/java/app/centralizedmutex/GrantTask.java @@ -1,5 +1,4 @@ -/* Copyright (c) 2012-2014, 2016. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ diff --git a/examples/java/app/centralizedmutex/Main.java b/examples/java/app/centralizedmutex/Main.java index 24da241f69..cb0a4e5550 100644 --- a/examples/java/app/centralizedmutex/Main.java +++ b/examples/java/app/centralizedmutex/Main.java @@ -1,5 +1,4 @@ -/* Copyright (c) 2012-2014, 2016. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ diff --git a/examples/java/app/centralizedmutex/Node.java b/examples/java/app/centralizedmutex/Node.java index 43ed0cf0bd..a1495a00a3 100644 --- a/examples/java/app/centralizedmutex/Node.java +++ b/examples/java/app/centralizedmutex/Node.java @@ -1,5 +1,4 @@ -/* Copyright (c) 2012-2014, 2016. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ diff --git a/examples/java/app/centralizedmutex/ReleaseTask.java b/examples/java/app/centralizedmutex/ReleaseTask.java index ebc2286b8d..37c2c7a20b 100644 --- a/examples/java/app/centralizedmutex/ReleaseTask.java +++ b/examples/java/app/centralizedmutex/ReleaseTask.java @@ -1,5 +1,4 @@ -/* Copyright (c) 2012-2014, 2016. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ diff --git a/examples/java/app/centralizedmutex/RequestTask.java b/examples/java/app/centralizedmutex/RequestTask.java index adfc3a78ae..c8f4c5c4c8 100644 --- a/examples/java/app/centralizedmutex/RequestTask.java +++ b/examples/java/app/centralizedmutex/RequestTask.java @@ -1,5 +1,4 @@ -/* Copyright (c) 2012-2014, 2016. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -8,7 +7,7 @@ package app.centralizedmutex; import org.simgrid.msg.Task; public class RequestTask extends Task { - String from; + protected String from; public RequestTask(String name) { super(); from=name; diff --git a/examples/java/cloud/migration/Daemon.java b/examples/java/cloud/migration/Daemon.java index d03d09aed6..d3c2af2001 100644 --- a/examples/java/cloud/migration/Daemon.java +++ b/examples/java/cloud/migration/Daemon.java @@ -11,7 +11,7 @@ import org.simgrid.msg.Process; public class Daemon extends Process { private Task currentTask; - public Daemon(VM vm, int load) { + public Daemon(VM vm) { super((Host)vm,"Daemon"); currentTask = new Task(this.getHost().getName()+"-daemon-0", this.getHost().getSpeed()*100, 0); } diff --git a/examples/java/cloud/migration/XVM.java b/examples/java/cloud/migration/XVM.java index 756b7535a2..3cc30eaeda 100644 --- a/examples/java/cloud/migration/XVM.java +++ b/examples/java/cloud/migration/XVM.java @@ -24,7 +24,7 @@ public class XVM extends VM { this.currentLoad = 0; this.dpIntensity = dpIntensity ; this.ramsize= ramsize; - this.daemon = new Daemon(this, 100); + this.daemon = new Daemon(this); } public void setLoad(int load){ diff --git a/examples/java/dht/chord/ChordTask.java b/examples/java/dht/chord/ChordTask.java index e17a19b253..04fde06df7 100644 --- a/examples/java/dht/chord/ChordTask.java +++ b/examples/java/dht/chord/ChordTask.java @@ -1,5 +1,4 @@ -/* Copyright (c) 2006-2014. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2006-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ diff --git a/examples/java/dht/chord/Node.java b/examples/java/dht/chord/Node.java index 835c316977..1817ab36cf 100644 --- a/examples/java/dht/chord/Node.java +++ b/examples/java/dht/chord/Node.java @@ -1,5 +1,4 @@ -/* Copyright (c) 2006-2014. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2006-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -22,7 +21,7 @@ public class Node extends Process { protected Comm commReceive; ///Last time I changed a finger or my predecessor protected double lastChangeDate; - int[] fingers; + private int[] fingers; public Node(Host host, String name, String[] args) { super(host,name,args); @@ -109,7 +108,7 @@ public class Node extends Process { } } - void handleTask(Task task) { + private void handleTask(Task task) { if (task instanceof FindSuccessorTask) { FindSuccessorTask fTask = (FindSuccessorTask)task; Msg.debug("Receiving a 'Find Successor' request from " + fTask.getIssuerHostName() + " for id " + @@ -138,30 +137,19 @@ public class Node extends Process { } } - void leave() { + private void leave() { Msg.debug("Well Guys! I Think it's time for me to quit ;)"); - quitNotify(1); //Notify my successor - quitNotify(-1); //Notify my predecessor. + // TODO: Notify my successor and predecessor. } - /** - * @brief Notifies the successor or the predecessor of the current node of the departure - * @param to 1 to notify the successor, -1 to notify the predecessor - */ - static void quitNotify( int to) { - //TODO - } - - /** - * @brief Initializes the current node as the first one of the system. - */ - void create() { + /** @brief Initializes the current node as the first one of the system */ + private void create() { Msg.debug("Create a new Chord ring..."); setPredecessor(-1); } // Makes the current node join the ring, knowing the id of a node already in the ring - boolean join(int knownId) { + private boolean join(int knownId) { Msg.info("Joining the ring with id " + this.id + " knowing node " + knownId); setPredecessor(-1); int successorId = remoteFindSuccessor(knownId, this.id); @@ -173,7 +161,7 @@ public class Node extends Process { return successorId != -1; } - void setPredecessor(int predecessorId) { + private void setPredecessor(int predecessorId) { if (predecessorId != predId) { predId = predecessorId; if (predecessorId != -1) { @@ -188,7 +176,7 @@ public class Node extends Process { * @param askTo the node to ask to * @return the id of its predecessor node, or -1 if the request failed(or if the node does not know its predecessor) */ - int remoteGetPredecessor(int askTo) { + private int remoteGetPredecessor(int askTo) { int predecessorId = -1; boolean stop = false; Msg.debug("Sending a 'Get Predecessor' request to " + askTo); @@ -229,7 +217,7 @@ public class Node extends Process { * @param id the id to find * @return the id of the successor node, or -1 if the request failed */ - int findSuccessor(int id) { + private int findSuccessor(int id) { if (isInInterval(id, this.id + 1, fingers[0])) { return fingers[0]; } @@ -239,7 +227,7 @@ public class Node extends Process { } // Asks another node the successor node of an id. - int remoteFindSuccessor(int askTo, int id) { + private int remoteFindSuccessor(int askTo, int id) { int successor = -1; boolean stop = false; String askToMailbox = Integer.toString(askTo); @@ -281,7 +269,7 @@ public class Node extends Process { } // This function is called periodically. It checks the immediate successor of the current node. - void stabilize() { + private void stabilize() { Msg.debug("Stabilizing node"); int candidateId; int successorId = fingers[0]; @@ -303,7 +291,7 @@ public class Node extends Process { * @brief Notifies the current node that its predecessor may have changed. * @param candidate_id the possible new predecessor */ - void notify(int predecessorCandidateId) { + private void notify(int predecessorCandidateId) { if (predId == -1 || isInInterval(predecessorCandidateId, predId + 1, this.id - 1 )) { setPredecessor(predecessorCandidateId); } @@ -314,7 +302,7 @@ public class Node extends Process { * @param notify_id id of the node to notify * @param candidate_id the possible new predecessor */ - void remoteNotify(int notifyId, int predecessorCandidateId) { + private void remoteNotify(int notifyId, int predecessorCandidateId) { Msg.debug("Sending a 'Notify' request to " + notifyId); Task sentTask = new NotifyTask(getHost().getName(), this.mailbox, predecessorCandidateId); sentTask.dsend(Integer.toString(notifyId)); @@ -322,7 +310,7 @@ public class Node extends Process { // This function is called periodically. // It refreshes the finger table of the current node. - void fixFingers() { + private void fixFingers() { Msg.debug("Fixing fingers"); int i = this.nextFingerToFix; int successorId = this.findSuccessor(this.id + (int)Math.pow(2,i)); //FIXME: SLOW @@ -336,12 +324,12 @@ public class Node extends Process { // This function is called periodically. // It checks whether the predecessor has failed - void checkPredecessor() { + private void checkPredecessor() { //TODO } // Performs a find successor request to a random id. - void randomLookup() { + private void randomLookup() { int id = 1337; //Msg.info("Making a lookup request for id " + id); findSuccessor(id); @@ -352,7 +340,7 @@ public class Node extends Process { * @param id the id to find * @return the closest preceding finger of that id */ - int closestPrecedingNode(int id) { + private int closestPrecedingNode(int id) { for (int i = Common.NB_BITS - 1; i >= 0; i--) { if (isInInterval(fingers[i], this.id + 1, id - 1)) { return fingers[i]; @@ -377,7 +365,7 @@ public class Node extends Process { * @param end upper bound * @return a non-zero value if id in in [start, end] */ - static boolean isInInterval(int id, int start, int end) { + private static boolean isInInterval(int id, int start, int end) { int normId = normalize(id); int normStart = normalize(start); int normEnd = normalize(end); @@ -397,7 +385,7 @@ public class Node extends Process { * @param id an id * @return the corresponding normalized id */ - static int normalize(int id) { + private static int normalize(int id) { return id & (Common.NB_KEYS - 1); } @@ -406,7 +394,7 @@ public class Node extends Process { * @param finger_index index of the finger to set (0 to nb_bits - 1) * @param id the id to set for this finger */ - void setFinger(int fingerIndex, int id) { + private void setFinger(int fingerIndex, int id) { if (id != fingers[fingerIndex]) { fingers[fingerIndex] = id; lastChangeDate = Msg.getClock(); diff --git a/examples/java/dht/kademlia/Answer.java b/examples/java/dht/kademlia/Answer.java index a18bc2af9d..c339c3b21c 100644 --- a/examples/java/dht/kademlia/Answer.java +++ b/examples/java/dht/kademlia/Answer.java @@ -19,15 +19,15 @@ public class Answer { nodes = new ArrayList<>(); } - int getDestinationId() { + protected int getDestinationId() { return destinationId; } - ArrayList getNodes() { + protected ArrayList getNodes() { return nodes; } - int size() { + protected int size() { return nodes.size(); } diff --git a/examples/msg/CMakeLists.txt b/examples/msg/CMakeLists.txt index 15c5b87970..001abeda3e 100644 --- a/examples/msg/CMakeLists.txt +++ b/examples/msg/CMakeLists.txt @@ -1,9 +1,10 @@ # C examples -foreach(x actions-comm actions-storage app-masterworker app-pingpong app-pmm app-token-ring async-yield async-wait async-waitall +foreach(x actions-comm actions-storage app-masterworker app-pingpong app-token-ring async-wait async-waitall async-waitany cloud-capping cloud-masterworker cloud-migration cloud-simple cloud-two-tasks dht-chord dht-pastry energy-consumption energy-onoff energy-pstate energy-ptask energy-vm platform-failures io-file io-remote io-storage task-priority - plugin-hostload process-create process-daemon process-join process-kill process-migration process-suspend + plugin-hostload + process-create process-daemon process-join process-kill process-migration process-suspend process-yield platform-properties process-startkilltime synchro-semaphore trace-categories trace-route-user-variables trace-link-user-variables trace-masterworker trace-platform trace-process-migration trace-host-user-variables) @@ -50,8 +51,8 @@ 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() -foreach (file actions-comm actions-storage app-bittorrent app-chainsend app-masterworker app-pingpong async-yield async-wait - async-waitall async-waitany dht-chord dht-kademlia io-remote platform-properties +foreach (file actions-comm actions-storage app-bittorrent app-chainsend app-masterworker app-pingpong async-wait + async-waitall async-waitany dht-chord dht-kademlia io-remote platform-properties process-yield task-priority) set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/${file}/${file}_d.xml) endforeach() @@ -95,9 +96,9 @@ set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/actio ${CMAKE_CURRENT_SOURCE_DIR}/process-startkilltime/start_kill_d.xml PARENT_SCOPE) foreach(x actions-comm actions-storage app-bittorrent app-chainsend app-masterworker app-pingpong app-token-ring - async-yield async-wait async-waitall async-waitany cloud-capping cloud-masterworker cloud-migration cloud-simple + async-wait async-waitall async-waitany cloud-capping cloud-masterworker cloud-migration cloud-simple cloud-two-tasks dht-chord dht-pastry dht-kademlia platform-failures io-file io-remote io-storage task-priority - process-create process-daemon process-join process-kill process-migration process-startkilltime process-suspend + process-create process-daemon process-join process-kill process-migration process-startkilltime process-suspend process-yield platform-properties synchro-semaphore) ADD_TESH_FACTORIES(msg-${x} "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/${x} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/${x} ${x}.tesh) endforeach() @@ -126,8 +127,6 @@ endif() ADD_TESH_FACTORIES(app-masterworker-multicore "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/app-masterworker/app-masterworker-multicore.tesh) ADD_TESH_FACTORIES(app-masterworker-vivaldi "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/app-masterworker/app-masterworker-vivaldi.tesh) -ADD_TESH(msg-app-pmm --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/app-pmm/app-pmm.tesh) - if(SIMGRID_HAVE_NS3) ADD_TESH_FACTORIES(msg-network-ns3 "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY} --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/network-ns3/network-ns3.tesh) endif() diff --git a/examples/msg/README.doc b/examples/msg/README.doc index 16878978b7..522000bacc 100644 --- a/examples/msg/README.doc +++ b/examples/msg/README.doc @@ -65,12 +65,6 @@ shipped in the archive: until one activity of the set completes, no matter which terminates first. - - Yielding to other processes. - @ref examples/msg/async-yield/async-yield.c\n - The @ref MSG_process_yield function interrupts the execution of the - current process, leaving a chance to run to the other processes - that are ready to run at the exact same timestamp - @section msg_ex_process Acting on Processes - Creating processes. @@ -91,6 +85,12 @@ shipped in the archive: @ref examples/msg/process-migration/process-migration.c \n Processes can move or be moved from a host to another with the @ref MSG_process_migrate function. + - Yielding to other processes. + @ref examples/msg/process-yield/process-yield.c\n + The @ref MSG_process_yield function interrupts the execution of the + current process, leaving a chance to run to the other processes + that are ready to run at the exact same timestamp + - Controling the process life cycle from the XML. @ref examples/msg/process-startkilltime/process-startkilltime.c \n You can specify a start time and a kill time in the deployment @@ -233,14 +233,6 @@ also the tesh files in the example directories for details. @section msg_ex_apps Examples of Full Applications - - Parallel Matrix Multiplication. - @ref examples/msg/app-pmm/app-pmm.c \n - This little application multiplies two matrices in parallel. Each - of the 9 processes computes a sub-block of the result, with the - sub-blocks of the input matrices exchanged between the processes. \n - This is a classical assignment in MPI lectures, here implemented - in MSG. - - Chord P2P protocol. @ref examples/msg/dht-chord/dht-chord.c \n This example implements the well known Chord protocol, @@ -307,7 +299,6 @@ top of the example file). @example examples/msg/actions-comm/actions-comm.c @example examples/msg/actions-storage/actions-storage.c -@example examples/msg/app-pmm/app-pmm.c @example examples/msg/dht-chord/dht-chord.c @example examples/msg/task-priority/task-priority.c diff --git a/examples/msg/app-bittorrent/peer.c b/examples/msg/app-bittorrent/peer.c index ee19ff211f..40a8256a13 100644 --- a/examples/msg/app-bittorrent/peer.c +++ b/examples/msg/app-bittorrent/peer.c @@ -167,7 +167,7 @@ void seed_loop(peer_t peer, double deadline) } } -/** @brief Retrieves the peer list from the tracker +/** @brief Retrieves the peer list from the tracker * @param peer current peer data */ int get_peers_data(peer_t peer) @@ -263,7 +263,7 @@ void peer_free(peer_t peer) xbt_free(peer); } -/** @brief Returns if a peer has finished downloading the file +/** @brief Returns if a peer has finished downloading the file * @param bitfield peer bitfield */ int has_finished(unsigned int bitfield) @@ -672,10 +672,9 @@ void update_interested_after_receive(peer_t peer) char *key; xbt_dict_cursor_t cursor; connection_t connection; - int interested; xbt_dict_foreach(peer->peers, cursor, key, connection) { - interested = 0; if (connection->am_interested != 0) { + int interested = 0; //Check if the peer still has a piece we want. for (int i = 0; i < FILE_PIECES; i++) { if (peer_has_not_piece(peer, i) && connection_has_piece(connection,i)) { diff --git a/examples/msg/app-chainsend/broadcaster.c b/examples/msg/app-chainsend/broadcaster.c index f17ed64827..61a1acaa8a 100644 --- a/examples/msg/app-chainsend/broadcaster.c +++ b/examples/msg/app-chainsend/broadcaster.c @@ -1,5 +1,4 @@ -/* Copyright (c) 2012-2014. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -105,15 +104,12 @@ static void broadcaster_destroy(broadcaster_t bc) /** Emitter function */ int broadcaster(int argc, char *argv[]) { - broadcaster_t bc = NULL; - xbt_dynar_t host_list = NULL; - int status; unsigned int piece_count = PIECE_COUNT; XBT_DEBUG("broadcaster"); /* Add every mailbox given by the hostcount in argv[1] to a dynamic array */ - host_list = build_hostlist_from_hostcount(xbt_str_parse_int(argv[1], "Invalid number of peers: %s")); + xbt_dynar_t host_list = build_hostlist_from_hostcount(xbt_str_parse_int(argv[1], "Invalid number of peers: %s")); /* argv[2] is the number of pieces */ if (argc > 2) { @@ -122,10 +118,10 @@ int broadcaster(int argc, char *argv[]) } else { XBT_DEBUG("No piece_count specified, defaulting to %d", piece_count); } - bc = broadcaster_init(host_list, piece_count); + broadcaster_t bc = broadcaster_init(host_list, piece_count); /* TODO: Error checking */ - status = broadcaster_send_file(bc); + int status = broadcaster_send_file(bc); broadcaster_destroy(bc); diff --git a/examples/msg/app-chainsend/iterator.c b/examples/msg/app-chainsend/iterator.c index e36ab5dab1..a6f7e4448b 100644 --- a/examples/msg/app-chainsend/iterator.c +++ b/examples/msg/app-chainsend/iterator.c @@ -1,5 +1,4 @@ -/* Copyright (c) 2012, 2014. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -27,11 +26,10 @@ xbt_dynar_iterator_t xbt_dynar_iterator_new(xbt_dynar_t list, xbt_dynar_t (*crit /* Returns the next element iterated by iterator it, NULL if there are no more elements */ void *xbt_dynar_iterator_next(xbt_dynar_iterator_t it) { - int *next; if (it->current >= it->length) { return NULL; } else { - next = xbt_dynar_get_ptr(it->indices_list, it->current); + int* next = xbt_dynar_get_ptr(it->indices_list, it->current); it->current++; return xbt_dynar_get_ptr(it->list, *next); } diff --git a/examples/msg/app-pingpong/app-pingpong.c b/examples/msg/app-pingpong/app-pingpong.c index bd5d39b78b..9687ce7e2e 100644 --- a/examples/msg/app-pingpong/app-pingpong.c +++ b/examples/msg/app-pingpong/app-pingpong.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2007-2016. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -69,7 +69,7 @@ int main(int argc, char *argv[]) MSG_init(&argc, argv); xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" - "\tExample: %s ../../platform/small_platform.xml app-pingpong_d.xml\n", argv[0], argv[0]); + "\tExample: %s ../../platforms/small_platform.xml app-pingpong_d.xml\n", argv[0], argv[0]); MSG_create_environment(argv[1]); /* - Load the platform description */ diff --git a/examples/msg/app-pmm/app-pmm.c b/examples/msg/app-pmm/app-pmm.c deleted file mode 100644 index e68636f771..0000000000 --- a/examples/msg/app-pmm/app-pmm.c +++ /dev/null @@ -1,328 +0,0 @@ -/* pmm - double broadcast parallel matrix multiplication */ - -/* Copyright (c) 2006-2016. The SimGrid Team. All rights reserved. */ - -/* This program 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 "xbt/matrix.h" -#include "xbt/xbt_os_time.h" - -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_pmm, "Messages specific for this msg example"); - -/* This example should always be executed using a deployment of GRID_SIZE * GRID_SIZE nodes. */ -#define GRID_SIZE 3 /* Modify to adjust the grid's size */ -#define NODE_MATRIX_SIZE 300 /* Amount of work done by each node*/ - -#define GRID_NUM_NODES GRID_SIZE * GRID_SIZE -#define MATRIX_SIZE NODE_MATRIX_SIZE * GRID_SIZE -#define MAILBOX_NAME_SIZE 10 -#define NEIGHBOURS_COUNT GRID_SIZE - 1 - -/* The job sent to every node */ -typedef struct s_node_job{ - int row; - int col; - int nodes_in_row[NEIGHBOURS_COUNT]; - int nodes_in_col[NEIGHBOURS_COUNT]; - xbt_matrix_t A; - xbt_matrix_t B; -} s_node_job_t; - -typedef s_node_job_t *node_job_t; - -/* Structure for recovering results */ -typedef struct s_result { - int row; - int col; - xbt_matrix_t sC; -} s_result_t; - -typedef s_result_t *result_t; - -int node(int argc, char **argv); -static void create_jobs(xbt_matrix_t A, xbt_matrix_t B, node_job_t *jobs); -static void broadcast_jobs(node_job_t *jobs); -static node_job_t wait_job(int selfid); -static void broadcast_matrix(xbt_matrix_t M, int num_nodes, int *nodes); -static void get_sub_matrix(xbt_matrix_t *sM, int selfid); -static void receive_results(result_t *results); -static void task_cleanup(void *arg); - -int node(int argc, char **argv) -{ - char my_mbox[MAILBOX_NAME_SIZE]; - node_job_t myjob; - node_job_t jobs[GRID_NUM_NODES]; - xbt_matrix_t A = NULL; - xbt_matrix_t B = NULL; - xbt_matrix_t C = NULL; - result_t result; - - xbt_assert(argc != 1, "Wrong number of arguments for this node"); - - /* Initialize the node's data-structures */ - int myid = xbt_str_parse_int(argv[1], "Invalid ID received as first node parameter: %s"); - snprintf(my_mbox, MAILBOX_NAME_SIZE - 1, "%d", myid); - xbt_matrix_t sC = xbt_matrix_double_new_zeros(NODE_MATRIX_SIZE, NODE_MATRIX_SIZE); - - if (myid == 0){ - /* Create the matrices to multiply and one to store the result */ - A = xbt_matrix_double_new_id(MATRIX_SIZE, MATRIX_SIZE); - B = xbt_matrix_double_new_seq(MATRIX_SIZE, MATRIX_SIZE); - C = xbt_matrix_double_new_zeros(MATRIX_SIZE, MATRIX_SIZE); - - /* Create the nodes' jobs */ - create_jobs(A, B, jobs); - - /* Get own job first */ - myjob = jobs[0]; - - /* Broadcast the rest of the jobs to the other nodes */ - broadcast_jobs(jobs + 1); - - } else { - myjob = wait_job(myid); - } - - /* Multiplication main-loop */ - XBT_VERB("Start Multiplication's Main-loop"); - for (int k=0; k < GRID_SIZE; k++){ - xbt_matrix_t sA; - xbt_matrix_t sB; - - if(k == myjob->col){ - XBT_VERB("Broadcast sA(%d,%d) to row %d", myjob->row, k, myjob->row); - broadcast_matrix(myjob->A, NEIGHBOURS_COUNT, myjob->nodes_in_row); - } - - if(k == myjob->row){ - XBT_VERB("Broadcast sB(%d,%d) to col %d", k, myjob->col, myjob->col); - broadcast_matrix(myjob->B, NEIGHBOURS_COUNT, myjob->nodes_in_col); - } - - if(myjob->row == k && myjob->col == k){ - xbt_matrix_double_addmult(myjob->A, myjob->B, sC); - }else if(myjob->row == k){ - get_sub_matrix(&sA, myid); - xbt_matrix_double_addmult(sA, myjob->B, sC); - xbt_matrix_free(sA); - }else if(myjob->col == k){ - get_sub_matrix(&sB, myid); - xbt_matrix_double_addmult(myjob->A, sB, sC); - xbt_matrix_free(sB); - }else{ - get_sub_matrix(&sA, myid); - get_sub_matrix(&sB, myid); - xbt_matrix_double_addmult(sA, sB, sC); - xbt_matrix_free(sA); - xbt_matrix_free(sB); - } - } - - /* Node 0: gather the results and reconstruct the final matrix */ - if(myid == 0){ - int node; - result_t results[GRID_NUM_NODES] = {0}; - - XBT_VERB("Multiplication done."); - - /* Get the result from the nodes in the GRID */ - receive_results(results); - - /* First add our results */ - xbt_matrix_copy_values(C, sC, NODE_MATRIX_SIZE, NODE_MATRIX_SIZE, 0, 0, 0, 0, NULL); - - /* Reconstruct the rest of the result matrix */ - for (node = 1; node < GRID_NUM_NODES; node++){ - xbt_matrix_copy_values(C, results[node]->sC, NODE_MATRIX_SIZE, NODE_MATRIX_SIZE, - NODE_MATRIX_SIZE * results[node]->row, NODE_MATRIX_SIZE * results[node]->col, - 0, 0, NULL); - xbt_matrix_free(results[node]->sC); - xbt_free(results[node]); - } - - //xbt_matrix_dump(C, "C:res", 0, xbt_matrix_dump_display_double); - - xbt_matrix_free(A); - xbt_matrix_free(B); - xbt_matrix_free(C); - - /* The rest: return the result to node 0 */ - }else{ - msg_task_t task; - - XBT_VERB("Multiplication done. Send the sub-result."); - - result = xbt_new0(s_result_t, 1); - result->row = myjob->row; - result->col = myjob->col; - result->sC = xbt_matrix_new_sub(sC, NODE_MATRIX_SIZE, NODE_MATRIX_SIZE, 0, 0, NULL); - task = MSG_task_create("result",100,100,result); - MSG_task_send(task, "0"); - } - - /* Clean up and finish*/ - xbt_matrix_free(sC); - xbt_matrix_free(myjob->A); - xbt_matrix_free(myjob->B); - xbt_free(myjob); - return 0; -} - -/* - * Broadcast the jobs to the nodes of the grid (except to node 0) - */ -static void broadcast_jobs(node_job_t *jobs) -{ - char node_mbox[MAILBOX_NAME_SIZE]; - msg_comm_t comms[GRID_NUM_NODES - 1] = {0}; - - XBT_VERB("Broadcast Jobs"); - for (int node = 1; node < GRID_NUM_NODES; node++){ - msg_task_t task = MSG_task_create("Job", 100, 100, jobs[node-1]); - snprintf(node_mbox, MAILBOX_NAME_SIZE - 1, "%d", node); - comms[node-1] = MSG_task_isend(task, node_mbox); - } - - MSG_comm_waitall(comms, GRID_NUM_NODES-1, -1); - for (int node = 1; node < GRID_NUM_NODES; node++) - MSG_comm_destroy(comms[node - 1]); -} - -static node_job_t wait_job(int selfid) -{ - msg_task_t task = NULL; - char self_mbox[MAILBOX_NAME_SIZE]; - snprintf(self_mbox, MAILBOX_NAME_SIZE - 1, "%d", selfid); - msg_error_t err = MSG_task_receive(&task, self_mbox); - xbt_assert(err == MSG_OK, "Error while receiving from %s (%d)", self_mbox, (int)err); - node_job_t job = (node_job_t)MSG_task_get_data(task); - MSG_task_destroy(task); - XBT_VERB("Got Job (%d,%d)", job->row, job->col); - - return job; -} - -static void broadcast_matrix(xbt_matrix_t M, int num_nodes, int *nodes) -{ - char node_mbox[MAILBOX_NAME_SIZE]; - - for(int node=0; node < num_nodes; node++){ - snprintf(node_mbox, MAILBOX_NAME_SIZE - 1, "%d", nodes[node]); - xbt_matrix_t sM = xbt_matrix_new_sub(M, NODE_MATRIX_SIZE, NODE_MATRIX_SIZE, 0, 0, NULL); - msg_task_t task = MSG_task_create("sub-matrix", 100, 100, sM); - MSG_task_dsend(task, node_mbox, task_cleanup); - XBT_DEBUG("sub-matrix sent to %s", node_mbox); - } -} - -static void get_sub_matrix(xbt_matrix_t *sM, int selfid) -{ - msg_task_t task = NULL; - char node_mbox[MAILBOX_NAME_SIZE]; - - XBT_VERB("Get sub-matrix"); - - snprintf(node_mbox, MAILBOX_NAME_SIZE - 1, "%d", selfid); - msg_error_t err = MSG_task_receive(&task, node_mbox); - xbt_assert(err == MSG_OK, "Error while receiving from %s (%d)", node_mbox, (int)err); - *sM = (xbt_matrix_t)MSG_task_get_data(task); - MSG_task_destroy(task); -} - -static void task_cleanup(void *arg){ - msg_task_t task = (msg_task_t)arg; - xbt_matrix_t m = (xbt_matrix_t)MSG_task_get_data(task); - xbt_matrix_free(m); - MSG_task_destroy(task); -} - -int main(int argc, char *argv[]) -{ - MSG_init(&argc, argv); - const char *platform = "../../platforms/cluster.xml"; - if (argc > 1) - platform = argv[1]; - MSG_create_environment(platform); - - MSG_function_register("node", node); - for(int i = 0 ; i< 9; i++) { - char *hostname = bprintf("node-%d.acme.org", i); - char **argvF = xbt_new(char *, 3); - argvF[0] = xbt_strdup("node"); - argvF[1] = bprintf("%d", i); - argvF[2] = NULL; - MSG_process_create_with_arguments("node", node, NULL, MSG_host_by_name(hostname), 2, argvF); - xbt_free(hostname); - } - - msg_error_t res = MSG_main(); - XBT_INFO("Simulated time: %g", MSG_get_clock()); - - return res != MSG_OK; -} - -static void create_jobs(xbt_matrix_t A, xbt_matrix_t B, node_job_t *jobs) -{ - int row = 0; - int col = 0; - - for (int node = 0; node < GRID_NUM_NODES; node++){ - XBT_VERB("Create job %d", node); - jobs[node] = xbt_new0(s_node_job_t, 1); - jobs[node]->row = row; - jobs[node]->col = col; - - /* Compute who are the nodes in the same row and column than the node receiving this job */ - int k=0; - for (int j = 0; j < GRID_SIZE; j++) { - if (node != (GRID_SIZE * row) + j) { - jobs[node]->nodes_in_row[k] = (GRID_SIZE * row) + j; - k++; - } - } - - k=0; - for (int j = 0; j < GRID_SIZE; j++) { - if (node != (GRID_SIZE * j) + col) { - jobs[node]->nodes_in_col[k] = (GRID_SIZE * j) + col; - k++; - } - } - - /* Assign a sub matrix of A and B to the job */ - jobs[node]->A = - xbt_matrix_new_sub(A, NODE_MATRIX_SIZE, NODE_MATRIX_SIZE, NODE_MATRIX_SIZE * row, NODE_MATRIX_SIZE * col, NULL); - jobs[node]->B = - xbt_matrix_new_sub(B, NODE_MATRIX_SIZE, NODE_MATRIX_SIZE, NODE_MATRIX_SIZE * row, NODE_MATRIX_SIZE * col, NULL); - - col++; - if (col >= GRID_SIZE){ - col = 0; - row++; - } - } -} - -static void receive_results(result_t *results) { - msg_comm_t comms[GRID_NUM_NODES-1] = {0}; - msg_task_t tasks[GRID_NUM_NODES-1] = {0}; - - XBT_VERB("Receive Results."); - - /* Get the result from the nodes in the GRID */ - for (int node = 1; node < GRID_NUM_NODES; node++) - comms[node-1] = MSG_task_irecv(&tasks[node-1], "0"); - - MSG_comm_waitall(comms, GRID_NUM_NODES - 1, -1); - for (int node = 1; node < GRID_NUM_NODES; node++) - MSG_comm_destroy(comms[node - 1]); - - /* Reconstruct the result matrix */ - for (int node = 1; node < GRID_NUM_NODES; node++){ - results[node] = (result_t)MSG_task_get_data(tasks[node-1]); - MSG_task_destroy(tasks[node-1]); - } -} diff --git a/examples/msg/app-pmm/app-pmm.tesh b/examples/msg/app-pmm/app-pmm.tesh deleted file mode 100644 index 0912eb8e6f..0000000000 --- a/examples/msg/app-pmm/app-pmm.tesh +++ /dev/null @@ -1,98 +0,0 @@ -#! ./tesh - -p Testing the Parallel Matrix Multiplication - -! timeout 120 -$ ./app-pmm/app-pmm --log=msg_pmm.thres:verbose --log=no_loc ${srcdir:=.}/../platforms/cluster.xml -> [node-0.acme.org:node:(1) 0.000000] [msg_pmm/VERBOSE] Create job 0 -> [node-0.acme.org:node:(1) 0.000000] [msg_pmm/VERBOSE] Create job 1 -> [node-0.acme.org:node:(1) 0.000000] [msg_pmm/VERBOSE] Create job 2 -> [node-0.acme.org:node:(1) 0.000000] [msg_pmm/VERBOSE] Create job 3 -> [node-0.acme.org:node:(1) 0.000000] [msg_pmm/VERBOSE] Create job 4 -> [node-0.acme.org:node:(1) 0.000000] [msg_pmm/VERBOSE] Create job 5 -> [node-0.acme.org:node:(1) 0.000000] [msg_pmm/VERBOSE] Create job 6 -> [node-0.acme.org:node:(1) 0.000000] [msg_pmm/VERBOSE] Create job 7 -> [node-0.acme.org:node:(1) 0.000000] [msg_pmm/VERBOSE] Create job 8 -> [node-0.acme.org:node:(1) 0.000000] [msg_pmm/VERBOSE] Broadcast Jobs -> [node-2.acme.org:node:(3) 0.007813] [msg_pmm/VERBOSE] Got Job (0,2) -> [node-2.acme.org:node:(3) 0.007813] [msg_pmm/VERBOSE] Start Multiplication's Main-loop -> [node-2.acme.org:node:(3) 0.007813] [msg_pmm/VERBOSE] Broadcast sB(0,2) to col 2 -> [node-1.acme.org:node:(2) 0.007813] [msg_pmm/VERBOSE] Got Job (0,1) -> [node-1.acme.org:node:(2) 0.007813] [msg_pmm/VERBOSE] Start Multiplication's Main-loop -> [node-1.acme.org:node:(2) 0.007813] [msg_pmm/VERBOSE] Broadcast sB(0,1) to col 1 -> [node-8.acme.org:node:(9) 0.007813] [msg_pmm/VERBOSE] Got Job (2,2) -> [node-8.acme.org:node:(9) 0.007813] [msg_pmm/VERBOSE] Start Multiplication's Main-loop -> [node-8.acme.org:node:(9) 0.007813] [msg_pmm/VERBOSE] Get sub-matrix -> [node-7.acme.org:node:(8) 0.007813] [msg_pmm/VERBOSE] Got Job (2,1) -> [node-7.acme.org:node:(8) 0.007813] [msg_pmm/VERBOSE] Start Multiplication's Main-loop -> [node-7.acme.org:node:(8) 0.007813] [msg_pmm/VERBOSE] Get sub-matrix -> [node-6.acme.org:node:(7) 0.007813] [msg_pmm/VERBOSE] Got Job (2,0) -> [node-6.acme.org:node:(7) 0.007813] [msg_pmm/VERBOSE] Start Multiplication's Main-loop -> [node-6.acme.org:node:(7) 0.007813] [msg_pmm/VERBOSE] Broadcast sA(2,0) to row 2 -> [node-5.acme.org:node:(6) 0.007813] [msg_pmm/VERBOSE] Got Job (1,2) -> [node-5.acme.org:node:(6) 0.007813] [msg_pmm/VERBOSE] Start Multiplication's Main-loop -> [node-5.acme.org:node:(6) 0.007813] [msg_pmm/VERBOSE] Get sub-matrix -> [node-4.acme.org:node:(5) 0.007813] [msg_pmm/VERBOSE] Got Job (1,1) -> [node-4.acme.org:node:(5) 0.007813] [msg_pmm/VERBOSE] Start Multiplication's Main-loop -> [node-4.acme.org:node:(5) 0.007813] [msg_pmm/VERBOSE] Get sub-matrix -> [node-3.acme.org:node:(4) 0.007813] [msg_pmm/VERBOSE] Got Job (1,0) -> [node-3.acme.org:node:(4) 0.007813] [msg_pmm/VERBOSE] Start Multiplication's Main-loop -> [node-3.acme.org:node:(4) 0.007813] [msg_pmm/VERBOSE] Broadcast sA(1,0) to row 1 -> [node-2.acme.org:node:(3) 0.007813] [msg_pmm/VERBOSE] Get sub-matrix -> [node-1.acme.org:node:(2) 0.007813] [msg_pmm/VERBOSE] Get sub-matrix -> [node-6.acme.org:node:(7) 0.007813] [msg_pmm/VERBOSE] Get sub-matrix -> [node-3.acme.org:node:(4) 0.007813] [msg_pmm/VERBOSE] Get sub-matrix -> [node-0.acme.org:node:(1) 0.007813] [msg_pmm/VERBOSE] Start Multiplication's Main-loop -> [node-0.acme.org:node:(1) 0.007813] [msg_pmm/VERBOSE] Broadcast sA(0,0) to row 0 -> [node-0.acme.org:node:(1) 0.007813] [msg_pmm/VERBOSE] Broadcast sB(0,0) to col 0 -> [node-0.acme.org:node:(1) 0.007813] [msg_pmm/VERBOSE] Get sub-matrix -> [node-7.acme.org:node:(8) 0.015619] [msg_pmm/VERBOSE] Get sub-matrix -> [node-4.acme.org:node:(5) 0.015619] [msg_pmm/VERBOSE] Get sub-matrix -> [node-8.acme.org:node:(9) 0.015619] [msg_pmm/VERBOSE] Get sub-matrix -> [node-5.acme.org:node:(6) 0.015619] [msg_pmm/VERBOSE] Get sub-matrix -> [node-6.acme.org:node:(7) 0.015619] [msg_pmm/VERBOSE] Get sub-matrix -> [node-2.acme.org:node:(3) 0.015619] [msg_pmm/VERBOSE] Get sub-matrix -> [node-3.acme.org:node:(4) 0.015619] [msg_pmm/VERBOSE] Broadcast sB(1,0) to col 0 -> [node-1.acme.org:node:(2) 0.015619] [msg_pmm/VERBOSE] Broadcast sA(0,1) to row 0 -> [node-3.acme.org:node:(4) 0.015619] [msg_pmm/VERBOSE] Get sub-matrix -> [node-1.acme.org:node:(2) 0.015619] [msg_pmm/VERBOSE] Get sub-matrix -> [node-8.acme.org:node:(9) 0.023426] [msg_pmm/VERBOSE] Get sub-matrix -> [node-2.acme.org:node:(3) 0.023426] [msg_pmm/VERBOSE] Get sub-matrix -> [node-7.acme.org:node:(8) 0.023426] [msg_pmm/VERBOSE] Broadcast sA(2,1) to row 2 -> [node-5.acme.org:node:(6) 0.023426] [msg_pmm/VERBOSE] Broadcast sB(1,2) to col 2 -> [node-6.acme.org:node:(7) 0.023426] [msg_pmm/VERBOSE] Get sub-matrix -> [node-4.acme.org:node:(5) 0.023426] [msg_pmm/VERBOSE] Broadcast sA(1,1) to row 1 -> [node-0.acme.org:node:(1) 0.023426] [msg_pmm/VERBOSE] Get sub-matrix -> [node-7.acme.org:node:(8) 0.023426] [msg_pmm/VERBOSE] Get sub-matrix -> [node-5.acme.org:node:(6) 0.023426] [msg_pmm/VERBOSE] Get sub-matrix -> [node-4.acme.org:node:(5) 0.023426] [msg_pmm/VERBOSE] Broadcast sB(1,1) to col 1 -> [node-4.acme.org:node:(5) 0.023426] [msg_pmm/VERBOSE] Get sub-matrix -> [node-2.acme.org:node:(3) 0.031233] [msg_pmm/VERBOSE] Broadcast sA(0,2) to row 0 -> [node-0.acme.org:node:(1) 0.031233] [msg_pmm/VERBOSE] Get sub-matrix -> [node-6.acme.org:node:(7) 0.031233] [msg_pmm/VERBOSE] Broadcast sB(2,0) to col 0 -> [node-8.acme.org:node:(9) 0.031233] [msg_pmm/VERBOSE] Get sub-matrix -> [node-5.acme.org:node:(6) 0.031233] [msg_pmm/VERBOSE] Broadcast sA(1,2) to row 1 -> [node-3.acme.org:node:(4) 0.031233] [msg_pmm/VERBOSE] Get sub-matrix -> [node-1.acme.org:node:(2) 0.031233] [msg_pmm/VERBOSE] Get sub-matrix -> [node-7.acme.org:node:(8) 0.031233] [msg_pmm/VERBOSE] Broadcast sB(2,1) to col 1 -> [node-2.acme.org:node:(3) 0.031233] [msg_pmm/VERBOSE] Get sub-matrix -> [node-6.acme.org:node:(7) 0.031233] [msg_pmm/VERBOSE] Get sub-matrix -> [node-5.acme.org:node:(6) 0.031233] [msg_pmm/VERBOSE] Get sub-matrix -> [node-7.acme.org:node:(8) 0.031233] [msg_pmm/VERBOSE] Get sub-matrix -> [node-0.acme.org:node:(1) 0.039040] [msg_pmm/VERBOSE] Get sub-matrix -> [node-1.acme.org:node:(2) 0.039040] [msg_pmm/VERBOSE] Get sub-matrix -> [node-8.acme.org:node:(9) 0.039040] [msg_pmm/VERBOSE] Broadcast sA(2,2) to row 2 -> [node-3.acme.org:node:(4) 0.039040] [msg_pmm/VERBOSE] Get sub-matrix -> [node-4.acme.org:node:(5) 0.039040] [msg_pmm/VERBOSE] Get sub-matrix -> [node-8.acme.org:node:(9) 0.039040] [msg_pmm/VERBOSE] Broadcast sB(2,2) to col 2 -> [node-8.acme.org:node:(9) 0.039040] [msg_pmm/VERBOSE] Multiplication done. Send the sub-result. -> [node-1.acme.org:node:(2) 0.046847] [msg_pmm/VERBOSE] Multiplication done. Send the sub-result. -> [node-4.acme.org:node:(5) 0.046847] [msg_pmm/VERBOSE] Multiplication done. Send the sub-result. -> [node-3.acme.org:node:(4) 0.046847] [msg_pmm/VERBOSE] Multiplication done. Send the sub-result. -> [node-0.acme.org:node:(1) 0.046847] [msg_pmm/VERBOSE] Multiplication done. -> [node-0.acme.org:node:(1) 0.046847] [msg_pmm/VERBOSE] Receive Results. -> [node-6.acme.org:node:(7) 0.046847] [msg_pmm/VERBOSE] Multiplication done. Send the sub-result. -> [node-2.acme.org:node:(3) 0.046847] [msg_pmm/VERBOSE] Multiplication done. Send the sub-result. -> [node-5.acme.org:node:(6) 0.046847] [msg_pmm/VERBOSE] Multiplication done. Send the sub-result. -> [node-7.acme.org:node:(8) 0.046847] [msg_pmm/VERBOSE] Multiplication done. Send the sub-result. -> [0.054659] [msg_pmm/INFO] Simulated time: 0.0546594 diff --git a/examples/msg/async-yield/async-yield.tesh b/examples/msg/async-yield/async-yield.tesh deleted file mode 100644 index e5aef16db5..0000000000 --- a/examples/msg/async-yield/async-yield.tesh +++ /dev/null @@ -1,5 +0,0 @@ -#! ./tesh - -$ $SG_TEST_EXENV ${bindir:=.}/async-yield ${srcdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/../msg/async-yield/async-yield_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" -> [ 0.000000] (1:yielder@Tremblay) I yielded 10 times. Goodbye now! -> [ 0.000000] (2:yielder@Ruby) I yielded 15 times. Goodbye now! diff --git a/examples/msg/cloud-masterworker/cloud-masterworker.c b/examples/msg/cloud-masterworker/cloud-masterworker.c index 0c13cc2380..41fa98969a 100644 --- a/examples/msg/cloud-masterworker/cloud-masterworker.c +++ b/examples/msg/cloud-masterworker/cloud-masterworker.c @@ -1,5 +1,4 @@ -/* Copyright (c) 2007-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -152,7 +151,7 @@ static int master_fun(int argc, char *argv[]) XBT_INFO("# Shutdown the half of worker processes gracefully. The remaining half will be forcibly killed."); for (i = 0; i < nb_workers; i++) { char mbox[MAXMBOXLEN]; - snprintf(mbox, MAXMBOXLEN, "MBOX:WRK%02d", i); + snprintf(mbox, MAXMBOXLEN, "MBOX:WRK%02u", i); msg_task_t finalize = MSG_task_create("finalize", 0, 0, 0); MSG_task_send(finalize, mbox); } diff --git a/examples/msg/dht-chord/dht-chord.c b/examples/msg/dht-chord/dht-chord.c index 717b19d276..66faa97c3a 100644 --- a/examples/msg/dht-chord/dht-chord.c +++ b/examples/msg/dht-chord/dht-chord.c @@ -327,7 +327,6 @@ void quit_notify(node_t node) get_mailbox(node->pred_id, mailbox); task_data_t req_data_s = xbt_new0(s_task_data_t,1); req_data_s->type = TASK_SUCCESSOR_LEAVING; - req_data_s->request_id = node->fingers[0].id; req_data_s->request_id = node->pred_id; get_mailbox(node->id, req_data_s->answer_to); req_data_s->issuer_host_name = MSG_host_get_name(MSG_host_self()); diff --git a/examples/msg/dht-kademlia/answer.c b/examples/msg/dht-kademlia/answer.c index 1cd48a0cf9..6fb5f75de2 100644 --- a/examples/msg/dht-kademlia/answer.c +++ b/examples/msg/dht-kademlia/answer.c @@ -109,15 +109,14 @@ void answer_trim(answer_t answer) */ void answer_add_bucket(bucket_t bucket, answer_t answer) { - unsigned int cpt; - unsigned int id; - unsigned int distance; - node_contact_t contact; xbt_assert((bucket != NULL), "Provided a NULL bucket"); xbt_assert((bucket->nodes != NULL), "Provided a bucket which nodes are NULL"); + + unsigned int cpt; + unsigned int id; xbt_dynar_foreach(bucket->nodes, cpt, id) { - distance = id ^ answer->destination_id; - contact = node_contact_new(id, distance); + unsigned int distance = id ^ answer->destination_id; + node_contact_t contact = node_contact_new(id, distance); xbt_dynar_push(answer->nodes, &contact); answer->size++; } diff --git a/examples/msg/dht-kademlia/dht-kademlia.c b/examples/msg/dht-kademlia/dht-kademlia.c index 463fd01338..c0c69997e3 100644 --- a/examples/msg/dht-kademlia/dht-kademlia.c +++ b/examples/msg/dht-kademlia/dht-kademlia.c @@ -183,13 +183,9 @@ unsigned int find_node(node_t node, unsigned int id_to_find, unsigned int count_ unsigned int answers; unsigned int destination_found = 0; unsigned int nodes_added = 0; - double time_beginreceive; - double timeout; double global_timeout = MSG_get_clock() + find_node_global_timeout; unsigned int steps = 0; - xbt_assert((id_to_find >= 0), "Id supplied incorrect"); - /* First we build a list of who we already know */ answer_t node_list = node_find_closest(node, id_to_find); xbt_assert((node_list != NULL), "node_list incorrect"); @@ -203,9 +199,9 @@ unsigned int find_node(node_t node, unsigned int id_to_find, unsigned int count_ answers = 0; queries = send_find_node_to_best(node, node_list); nodes_added = 0; - timeout = MSG_get_clock() + find_node_timeout; + double timeout = MSG_get_clock() + find_node_timeout; steps++; - time_beginreceive = MSG_get_clock(); + double time_beginreceive = MSG_get_clock(); do { if (node->receive_comm == NULL) { node->task_received = NULL; @@ -278,7 +274,7 @@ unsigned int find_node(node_t node, unsigned int id_to_find, unsigned int count_ unsigned int ping(node_t node, unsigned int id_to_ping) { char mailbox[MAILBOX_NAME_SIZE]; - snprintf(mailbox,MAILBOX_NAME_SIZE, "%d", id_to_ping); + snprintf(mailbox, MAILBOX_NAME_SIZE, "%u", id_to_ping); double timeout = MSG_get_clock() + ping_timeout; @@ -360,11 +356,10 @@ unsigned int send_find_node_to_best(node_t node, answer_t node_list) unsigned int i = 0; unsigned int j = 0; unsigned int destination = node_list->destination_id; - node_contact_t node_to_query; 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_to_query = xbt_dynar_get_as(node_list->nodes, i, node_contact_t); + 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++; diff --git a/examples/msg/dht-pastry/dht-pastry.c b/examples/msg/dht-pastry/dht-pastry.c index 12d13daf11..b9cac1eb3a 100644 --- a/examples/msg/dht-pastry/dht-pastry.c +++ b/examples/msg/dht-pastry/dht-pastry.c @@ -230,7 +230,6 @@ static void handle_task(node_t node, msg_task_t task) { int j; int min; int max; - int d; int next; msg_task_t task_sent; task_data_t req_data; @@ -280,7 +279,7 @@ static void handle_task(node_t node, msg_task_t task) { /* Join reply from all the node touched by the join */ case TASK_JOIN_LAST_REPLY: // if last node touched reply, copy its namespace set - // TODO: it works only if the two nodes are side to side (is it really the case ?) + // TODO: it works only if the two nodes are side to side (is it really the case ?) j = (task_data->sender_id < node->id) ? -1 : 0; for (i=0; inamespace_set[i] = task_data->state->namespace_set[i-j]; @@ -303,11 +302,11 @@ static void handle_task(node_t node, msg_task_t task) { min = (node->id==task_data->answer_id) ? 0 : shl(node->id, task_data->answer_id); max = shl(node->id, task_data->sender_id)+1; for (i=min;iid, i); + int d = domain(node->id, i); for (j=0; jrouting_table[i][j] = task_data->state->routing_table[i][j]; - } + } node->ready--; // if the node is ready, do all the pending tasks and send update to known nodes diff --git a/examples/msg/energy-vm/energy-vm.c b/examples/msg/energy-vm/energy-vm.c index 8a2011dc9f..0ec0344cc7 100644 --- a/examples/msg/energy-vm/energy-vm.c +++ b/examples/msg/energy-vm/energy-vm.c @@ -9,7 +9,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(energy_vm, "Messages of this example"); -static int worker_func() { +static int worker_func(int argc, char *argv[]) { msg_task_t task1 = MSG_task_create("t1", 300E6, 0, NULL); MSG_task_execute (task1); MSG_task_destroy(task1); diff --git a/examples/msg/io-file/io-file.tesh b/examples/msg/io-file/io-file.tesh index 95f41b13f7..c6915ff75a 100644 --- a/examples/msg/io-file/io-file.tesh +++ b/examples/msg/io-file/io-file.tesh @@ -14,7 +14,6 @@ $ ${bindir:=.}/io-file ${srcdir:=.}/storage/storage.xml "--log=root.fmt:[%10.6r] > Mount point: '/home' > Storage Id: 'Disk4' > Storage Type: 'single_SSD' -> Content Type: 'txt_unix' > File Descriptor Id: 0 > [ 0.000000] (4:host@denise) Open file '/home/doc/simgrid/examples/platforms/g5k.xml' > [ 0.000000] (4:host@denise) Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k.xml' is stored on: 13221994 / 536870912000 diff --git a/examples/msg/io-remote/io-remote.tesh b/examples/msg/io-remote/io-remote.tesh index 6d047278f9..46b251e2e5 100644 --- a/examples/msg/io-remote/io-remote.tesh +++ b/examples/msg/io-remote/io-remote.tesh @@ -13,7 +13,6 @@ $ ${bindir:=.}/io-remote$EXEEXT ${srcdir:=.}/storage/remote_io.xml ${srcdir:=.}/ > Mount point: 'c:' > Storage Id: 'Disk2' > Storage Type: 'SATA-II_HDD' -> Content Type: 'txt_windows' > File Descriptor Id: 0 > [ 0.000000] (2@ bob) File Descriptor information: > Full path: '/scratch/lib/libsimgrid.so.3.6.2' @@ -21,7 +20,6 @@ $ ${bindir:=.}/io-remote$EXEEXT ${srcdir:=.}/storage/remote_io.xml ${srcdir:=.}/ > Mount point: '/scratch' > Storage Id: 'Disk1' > Storage Type: 'SATA-II_HDD' -> Content Type: 'txt_unix' > File Descriptor Id: 0 > [ 0.000000] (3@ carl) File Descriptor information: > Full path: '/scratch/lib/libsimgrid.so.3.6.2' @@ -29,7 +27,6 @@ $ ${bindir:=.}/io-remote$EXEEXT ${srcdir:=.}/storage/remote_io.xml ${srcdir:=.}/ > Mount point: '/scratch' > Storage Id: 'Disk1' > Storage Type: 'SATA-II_HDD' -> Content Type: 'txt_unix' > File Descriptor Id: 0 > [ 0.000000] (4@ dave) File Descriptor information: > Full path: 'c:\Windows\bootstat.dat' @@ -37,7 +34,6 @@ $ ${bindir:=.}/io-remote$EXEEXT ${srcdir:=.}/storage/remote_io.xml ${srcdir:=.}/ > Mount point: 'c:' > Storage Id: 'Disk2' > Storage Type: 'SATA-II_HDD' -> Content Type: 'txt_windows' > File Descriptor Id: 0 > [ 0.000000] (1@alice) Try to read 101663 from 'c:\Windows\setupact.log' > [ 0.000000] (2@ bob) Try to read 12710497 from '/scratch/lib/libsimgrid.so.3.6.2' @@ -48,9 +44,9 @@ $ ${bindir:=.}/io-remote$EXEEXT ${srcdir:=.}/storage/remote_io.xml ${srcdir:=.}/ > [ 0.001469] (4@ dave) Offset is now at: 0 > [ 0.001469] (4@ dave) Opened file 'c:\Windows\Professional.xml' > [ 0.001469] (4@ dave) Try to write 31 MiB to 'c:\Windows\Professional.xml' -> [ 0.003559] (1@alice) Have read 101663 from 'c:\Windows\setupact.log'. Offset is now at: 101663 -> [ 0.003559] (1@alice) Seek back to the begining of the stream... -> [ 0.003559] (1@alice) Offset is now at: 0 +> [ 0.003741] (1@alice) Have read 101663 from 'c:\Windows\setupact.log'. Offset is now at: 101663 +> [ 0.003741] (1@alice) Seek back to the begining of the stream... +> [ 0.003741] (1@alice) Offset is now at: 0 > [ 0.276315] (3@ carl) Have read 12710497 from '/scratch/lib/libsimgrid.so.3.6.2'. Offset is now at: 12710497 > [ 0.276315] (3@ carl) Seek back to the begining of the stream... > [ 0.276315] (3@ carl) Offset is now at: 0 @@ -59,10 +55,10 @@ $ ${bindir:=.}/io-remote$EXEEXT ${srcdir:=.}/storage/remote_io.xml ${srcdir:=.}/ > [ 0.387036] (2@ bob) Offset is now at: 0 > [ 0.387036] (2@ bob) Opened file '/scratch/doc/simgrid/examples/platforms/g5k.xml' > [ 0.387036] (2@ bob) Try to write 16 MiB to '/scratch/doc/simgrid/examples/platforms/g5k.xml' -> [ 0.528029] (4@ dave) Have written 32646144 bytes to 'c:\Windows\Professional.xml'. -> [ 0.528029] (4@ dave) Move 'c:\Windows\Professional.xml' (of size 32646144) from 'dave' to 'carl' +> [ 0.528211] (4@ dave) Have written 32646144 bytes to 'c:\Windows\Professional.xml'. +> [ 0.528211] (4@ dave) Move 'c:\Windows\Professional.xml' (of size 32646144) from 'dave' to 'carl' > [ 0.819921] (2@ bob) Have written 17436672 bytes to '/scratch/doc/simgrid/examples/platforms/g5k.xml'. > [ 0.819921] (2@ bob) Copy '/scratch/doc/simgrid/examples/platforms/g5k.xml' (of size 17436672) from 'bob' to 'alice' -> [ 1.843786] (0@ ) Init: 60 MiB used on 'Disk1' -> [ 1.843786] (0@ ) Init: 2297 MiB used on 'Disk2' -> [ 1.843786] (0@ ) Simulation time 1.84379 +> [ 1.843969] (0@ ) Init: 60 MiB used on 'Disk1' +> [ 1.843969] (0@ ) Init: 2297 MiB used on 'Disk2' +> [ 1.843969] (0@ ) Simulation time 1.84397 diff --git a/examples/msg/io-storage/io-storage.tesh b/examples/msg/io-storage/io-storage.tesh index 90d6b07d1d..78cc08df47 100644 --- a/examples/msg/io-storage/io-storage.tesh +++ b/examples/msg/io-storage/io-storage.tesh @@ -17,7 +17,6 @@ $ ${bindir:=.}/io-storage$EXEEXT ${srcdir:=.}/storage/storage.xml "--log=root.fm > Mount point: '/home' > Storage Id: 'Disk4' > Storage Type: 'single_SSD' -> Content Type: 'txt_unix' > File Descriptor Id: 0 > [ 0.003333] (1:@denise) Free size: 536857490006 bytes > [ 0.003333] (1:@denise) Used size: 13421994 bytes @@ -29,7 +28,6 @@ $ ${bindir:=.}/io-storage$EXEEXT ${srcdir:=.}/storage/storage.xml "--log=root.fm > Mount point: '/home' > Storage Id: 'Disk4' > Storage Type: 'single_SSD' -> Content Type: 'txt_unix' > File Descriptor Id: 0 > [ 0.006000] (1:@denise) *** Move '/tmp/data.txt' into '/tmp/simgrid.readme' > [ 0.006000] (1:@denise) User data attached to the file: 777 diff --git a/examples/msg/mc/electric_fence.c b/examples/msg/mc/electric_fence.c index f260cd989b..7d32c04d4c 100644 --- a/examples/msg/mc/electric_fence.c +++ b/examples/msg/mc/electric_fence.c @@ -22,10 +22,9 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(electric_fence, "Example to check the soundness of static int server(int argc, char *argv[]) { msg_task_t task1 = NULL, task2 = NULL; - msg_comm_t comm_received1 = NULL, comm_received2 = NULL; - comm_received1 = MSG_task_irecv(&task1, "mymailbox"); - comm_received2 = MSG_task_irecv(&task2, "mymailbox"); + msg_comm_t comm_received1 = MSG_task_irecv(&task1, "mymailbox"); + msg_comm_t comm_received2 = MSG_task_irecv(&task2, "mymailbox"); MSG_comm_wait(comm_received1, -1); MSG_comm_wait(comm_received2, -1); diff --git a/examples/msg/network-ns3/network-ns3.c b/examples/msg/network-ns3/network-ns3.c index c422f5c502..390ca97228 100644 --- a/examples/msg/network-ns3/network-ns3.c +++ b/examples/msg/network-ns3/network-ns3.c @@ -11,7 +11,6 @@ int timer_start; //set as 1 in the master process //keep a pointer to all surf running tasks. #define NTASKS 1500 -int bool_printed = 0; double start_time, end_time, elapsed_time; double gl_data_size[NTASKS]; msg_task_t gl_task_array[NTASKS]; @@ -126,9 +125,6 @@ static int worker(int argc, char *argv[]) int main(int argc, char *argv[]) { - msg_error_t res = MSG_OK; - bool_printed = 0; - MSG_init(&argc, argv); xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" "\tExample: %s platform.xml deployment.xml\n", argv[0], argv[0]); @@ -142,7 +138,7 @@ int main(int argc, char *argv[]) MSG_launch_application(argv[2]); - res = MSG_main(); + msg_error_t res = MSG_main(); return res != MSG_OK; } diff --git a/examples/msg/network-ns3/network-ns3.tesh b/examples/msg/network-ns3/network-ns3.tesh index 71750374e7..56410a0f11 100644 --- a/examples/msg/network-ns3/network-ns3.tesh +++ b/examples/msg/network-ns3/network-ns3.tesh @@ -41,6 +41,9 @@ p Dogbone ! timeout 10 $ ${bindir:=.}/network-ns3/network-ns3 ${srcdir:=.}/examples/platforms/dogbone.xml ${srcdir:=.}/examples/msg/network-ns3/dogbone_d.xml --cfg=network/model:NS3 "--log=root.fmt:[%h:%P(%i)]%e[%c/%p]%e%m%n" > [:maestro(0)] [xbt_cfg/INFO] Configuration change: Set 'network/model' to 'NS3' +> [:maestro(0)] [ns3/WARNING] Ignoring a route between S1 and C1 of length 3: Only routes of length 1 are considered with NS3. +> WARNING: You can ignore this warning if your hosts can still communicate when only considering routes of length 1. +> WARNING: Remove long routes to avoid this harmless message; subsequent long routes will be silently ignored. > [C1:worker(3)] [msg_test/INFO] FLOW[0] : Receive 10000 bytes from S1 to C1 > [C2:worker(4)] [msg_test/INFO] FLOW[1] : Receive 10000 bytes from S2 to C2 diff --git a/examples/msg/async-yield/async-yield.c b/examples/msg/process-yield/process-yield.c similarity index 100% rename from examples/msg/async-yield/async-yield.c rename to examples/msg/process-yield/process-yield.c diff --git a/examples/msg/process-yield/process-yield.tesh b/examples/msg/process-yield/process-yield.tesh new file mode 100644 index 0000000000..e39b2b980e --- /dev/null +++ b/examples/msg/process-yield/process-yield.tesh @@ -0,0 +1,5 @@ +#! ./tesh + +$ $SG_TEST_EXENV ${bindir:=.}/process-yield ${srcdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/../msg/process-yield/process-yield_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +> [ 0.000000] (1:yielder@Tremblay) I yielded 10 times. Goodbye now! +> [ 0.000000] (2:yielder@Ruby) I yielded 15 times. Goodbye now! diff --git a/examples/msg/async-yield/async-yield_d.xml b/examples/msg/process-yield/process-yield_d.xml similarity index 100% rename from examples/msg/async-yield/async-yield_d.xml rename to examples/msg/process-yield/process-yield_d.xml diff --git a/examples/msg/trace-masterworker/trace-masterworker.c b/examples/msg/trace-masterworker/trace-masterworker.c index 651d968a5d..2ebf78d686 100644 --- a/examples/msg/trace-masterworker/trace-masterworker.c +++ b/examples/msg/trace-masterworker/trace-masterworker.c @@ -19,8 +19,7 @@ static int master(int argc, char *argv[]) TRACE_mark("msmark", "start_send_tasks"); for (int i = 0; i < number_of_tasks; i++) { - msg_task_t task = NULL; - task = MSG_task_create("task", task_comp_size, task_comm_size, NULL); + msg_task_t task = MSG_task_create("task", task_comp_size, task_comm_size, NULL); //setting the variable "task_creation" to value i TRACE_host_variable_set(MSG_host_get_name(MSG_host_self()), "task_creation", i); diff --git a/examples/platforms/dogbone.xml b/examples/platforms/dogbone.xml index 65879331f0..0b6086fa06 100644 --- a/examples/platforms/dogbone.xml +++ b/examples/platforms/dogbone.xml @@ -1,5 +1,25 @@ + + + diff --git a/examples/platforms/small_platform_one_link_routes.xml b/examples/platforms/small_platform_one_link_routes.xml index faaad678ee..3902e78422 100644 --- a/examples/platforms/small_platform_one_link_routes.xml +++ b/examples/platforms/small_platform_one_link_routes.xml @@ -1,5 +1,9 @@ + + + diff --git a/examples/platforms/storage/remote_io.xml b/examples/platforms/storage/remote_io.xml index b654b9cd19..16a0dfde4a 100644 --- a/examples/platforms/storage/remote_io.xml +++ b/examples/platforms/storage/remote_io.xml @@ -6,17 +6,15 @@ - + - + content="content/win_storage_content.txt" /> diff --git a/examples/platforms/storage/storage.xml b/examples/platforms/storage/storage.xml index 449438eb81..1402e680f9 100644 --- a/examples/platforms/storage/storage.xml +++ b/examples/platforms/storage/storage.xml @@ -6,26 +6,22 @@ - + - - + - + content="content/win_storage_content.txt"/> + content="content/small_content.txt" /> diff --git a/examples/s4u/dht-chord/node.cpp b/examples/s4u/dht-chord/node.cpp index f9ed22a7e8..d0ee0e92a2 100644 --- a/examples/s4u/dht-chord/node.cpp +++ b/examples/s4u/dht-chord/node.cpp @@ -229,10 +229,10 @@ void Node::checkPredecessor() // receive the answer XBT_DEBUG("Sent 'Predecessor Alive' request to %d, waiting for the answer on my mailbox '%s'", pred_id_, message->answer_to->name()); - simgrid::s4u::Comm& comm = simgrid::s4u::this_actor::irecv(return_mailbox, &data); + simgrid::s4u::CommPtr comm = simgrid::s4u::this_actor::irecv(return_mailbox, &data); try { - comm.wait(timeout); + comm->wait(timeout); XBT_DEBUG("Received the answer to my 'Predecessor Alive': my predecessor %d is alive", pred_id_); delete message; } catch (xbt_ex& e) { @@ -274,10 +274,10 @@ int Node::remoteGetPredecessor(int ask_to) // receive the answer XBT_DEBUG("Sent 'Get Predecessor' request to %d, waiting for the answer on my mailbox '%s'", ask_to, message->answer_to->name()); - simgrid::s4u::Comm& comm = simgrid::s4u::this_actor::irecv(return_mailbox, &data); + simgrid::s4u::CommPtr comm = simgrid::s4u::this_actor::irecv(return_mailbox, &data); try { - comm.wait(timeout); + comm->wait(timeout); ChordMessage* answer = static_cast(data); XBT_DEBUG("Received the answer to my 'Get Predecessor' request: the predecessor of node %d is %d", ask_to, answer->answer_id); @@ -348,10 +348,10 @@ int Node::remoteFindSuccessor(int ask_to, int id) } // receive the answer XBT_DEBUG("Sent a 'Find Successor' request to %d for key %d, waiting for the answer", ask_to, id); - simgrid::s4u::Comm& comm = simgrid::s4u::this_actor::irecv(return_mailbox, &data); + simgrid::s4u::CommPtr comm = simgrid::s4u::this_actor::irecv(return_mailbox, &data); try { - comm.wait(timeout); + comm->wait(timeout); ChordMessage* answer = static_cast(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); @@ -387,15 +387,7 @@ void Node::remoteNotify(int notify_id, int predecessor_candidate_id) // send a "Notify" request to notify_id XBT_DEBUG("Sending a 'Notify' request to %d", notify_id); simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(std::to_string(notify_id)); - try { - // TODO make it a dsend - simgrid::s4u::this_actor::isend(mailbox, message, 10); - } catch (xbt_ex& e) { - if (e.category == timeout_error) { - XBT_DEBUG("Send of 'Notify' failed due to an expired timeout on receiver side"); - delete message; - } - } + simgrid::s4u::this_actor::dsend(mailbox, message, 10); } /* This function is called periodically. It checks the immediate successor of the current node. */ @@ -437,28 +429,14 @@ void Node::handleMessage(ChordMessage* message) message->answer_id = fingers_[0]; XBT_DEBUG("Sending back a 'Find Successor Answer' to %s (mailbox %s): the successor of %d is %d", message->issuer_host_name.c_str(), message->answer_to->name(), message->request_id, message->answer_id); - // TODO Replace by dsend - try { - simgrid::s4u::this_actor::isend(message->answer_to, message, 10); - } catch(xbt_ex& e) { - if (e.category == timeout_error) { - XBT_DEBUG("Send of 'Find Successor Answer' failed due du an expired timeout on receiver side"); - } - } + simgrid::s4u::this_actor::dsend(message->answer_to, message, 10); } else { // otherwise, forward the request to the closest preceding finger in my table int closest = closestPrecedingFinger(message->request_id); XBT_DEBUG("Forwarding the 'Find Successor' request for id %d to my closest preceding finger %d", message->request_id, closest); simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(std::to_string(closest)); - //TODO make it a dsend - try{ - simgrid::s4u::this_actor::isend(mailbox, message, 10); - } catch (xbt_ex& e) { - if (e.category == timeout_error) { - XBT_DEBUG("Forward of 'Find Successor' failed due du an expired timeout on receiver side"); - } - } + simgrid::s4u::this_actor::dsend(mailbox, message, 10); } break; @@ -468,14 +446,7 @@ void Node::handleMessage(ChordMessage* message) message->answer_id = pred_id_; XBT_DEBUG("Sending back a 'Get Predecessor Answer' to %s via mailbox '%s': my predecessor is %d", message->issuer_host_name.c_str(), message->answer_to->name(), message->answer_id); - //TODO make it a dsend - try{ - simgrid::s4u::this_actor::isend(message->answer_to, message, 10); - } catch (xbt_ex& e) { - if (e.category == timeout_error) { - XBT_DEBUG("Send of 'Get Predecessor Answer' failed due du an expired timeout on receiver side"); - } - } + simgrid::s4u::this_actor::dsend(message->answer_to, message, 10); break; case NOTIFY: @@ -513,14 +484,7 @@ void Node::handleMessage(ChordMessage* message) message->type = PREDECESSOR_ALIVE_ANSWER; XBT_DEBUG("Sending back a 'Predecessor Alive Answer' to %s (mailbox %s)", message->issuer_host_name.c_str(), message->answer_to->name()); - //TODO Make it a dsend - try{ - simgrid::s4u::this_actor::isend(message->answer_to, message, 10); - } catch (xbt_ex& e) { - if (e.category == timeout_error) { - XBT_DEBUG("Send of 'Predecessor Alive' failed due du an expired timeout on receiver side"); - } - } + simgrid::s4u::this_actor::dsend(message->answer_to, message, 10); break; default: diff --git a/examples/s4u/dht-chord/s4u_dht-chord.cpp b/examples/s4u/dht-chord/s4u_dht-chord.cpp index 68239898c9..db79af6405 100644 --- a/examples/s4u/dht-chord/s4u_dht-chord.cpp +++ b/examples/s4u/dht-chord/s4u_dht-chord.cpp @@ -46,14 +46,14 @@ int main(int argc, char* argv[]) "\tExample: %s ../msg_platform.xml chord.xml\n", argv[0], argv[0]); char** options = &argv[1]; - while (!strncmp(options[0], "-", 1)) { + while (not strncmp(options[0], "-", 1)) { unsigned int length = strlen("-nb_bits="); - if (!strncmp(options[0], "-nb_bits=", length) && strlen(options[0]) > length) { + if (not strncmp(options[0], "-nb_bits=", length) && strlen(options[0]) > length) { nb_bits = xbt_str_parse_int(options[0] + length, "Invalid nb_bits parameter: %s"); XBT_DEBUG("Set nb_bits to %d", nb_bits); } else { length = strlen("-timeout="); - if (!strncmp(options[0], "-timeout=", length) && strlen(options[0]) > length) { + if (not strncmp(options[0], "-timeout=", length) && strlen(options[0]) > length) { timeout = xbt_str_parse_int(options[0] + length, "Invalid timeout parameter: %s"); XBT_DEBUG("Set timeout to %d", timeout); } else { diff --git a/examples/s4u/dht-chord/s4u_dht-chord.hpp b/examples/s4u/dht-chord/s4u_dht-chord.hpp index 7b64d2c801..60f3d6b964 100644 --- a/examples/s4u/dht-chord/s4u_dht-chord.hpp +++ b/examples/s4u/dht-chord/s4u_dht-chord.hpp @@ -118,9 +118,8 @@ public: join(known_id_); } - if (!joined) + if (not joined) return; - ChordMessage* message = nullptr; void* data = nullptr; double now = simgrid::s4u::Engine::getClock(); double next_stabilize_date = start_time_ + PERIODIC_STABILIZE_DELAY; @@ -129,9 +128,9 @@ public: double next_lookup_date = start_time_ + PERIODIC_LOOKUP_DELAY; while ((now < (start_time_ + deadline_)) && now < MAX_SIMULATION_TIME) { - data = nullptr; - simgrid::s4u::Comm& comm_receive = simgrid::s4u::this_actor::irecv(mailbox_, &data); - while ((now < (start_time_ + deadline_)) && now < MAX_SIMULATION_TIME && !comm_receive.test()) { + data = nullptr; + simgrid::s4u::CommPtr comm_receive = simgrid::s4u::this_actor::irecv(mailbox_, &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(); @@ -153,8 +152,10 @@ public: } if (data != nullptr) { - message = static_cast(data); + ChordMessage* message = static_cast(data); handleMessage(message); + } else { + comm_receive->cancel(); } now = simgrid::s4u::Engine::getClock(); } diff --git a/examples/smpi/energy/f77/energy.tesh b/examples/smpi/energy/f77/energy.tesh index b6a69d88ef..3ea74d9370 100644 --- a/examples/smpi/energy/f77/energy.tesh +++ b/examples/smpi/energy/f77/energy.tesh @@ -1,26 +1,26 @@ p Test smpi bindings for dvfs functions (Fortran 77 example) $ ../../../smpi_script/bin/smpirun -np 2 -hostfile ${srcdir:=.}/hostfile -platform ${srcdir:=.}/../../platforms/energy_platform.xml --cfg=smpi/simulate-computation:no ${bindir:=.}/f77/sef --cfg=plugin:Energy --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning -> [ 0.0000000000000000 ] [rank 0 ] 3 pstates available -> [ 0.0000000000000000 ] [rank 1 ] 3 pstates available -> [ 0.0000000000000000 ] [rank 0 ] Power: 100000000.00000000 -> [ 0.0000000000000000 ] [rank 1 ] Power: 100000000.00000000 -> [ 0.0000000000000000 ] [rank 0 ] Power: 50000000.000000000 -> [ 0.0000000000000000 ] [rank 1 ] Power: 50000000.000000000 -> [ 0.0000000000000000 ] [rank 0 ] Power: 20000000.000000000 -> [ 0.0000000000000000 ] [rank 1 ] Power: 20000000.000000000 -> [ 0.0000000000000000 ] [rank 0 ] Current pstate: 0 ; Current power: 100000000.00000000 -> [ 0.0000000000000000 ] [rank 1 ] Current pstate: 0 ; Current power: 100000000.00000000 -> [ 10.000000000000000 ] [rank 0 ] Energy consumed (Joules): 1200.0000000000000 -> [ 10.000000000000000 ] [rank 1 ] Energy consumed (Joules): 1200.0000000000000 -> [ 10.000000000000000 ] [rank 0 ] Current pstate: 1 ; Current power: 50000000.000000000 -> [ 10.000000000000000 ] [rank 1 ] Current pstate: 1 ; Current power: 50000000.000000000 -> [ 30.000000000000000 ] [rank 0 ] Energy consumed (Joules): 3400.0000000000000 -> [ 30.000000000000000 ] [rank 1 ] Energy consumed (Joules): 3400.0000000000000 -> [ 30.000000000000000 ] [rank 0 ] Current pstate: 2 ; Current power: 20000000.000000000 -> [ 30.000000000000000 ] [rank 1 ] Current pstate: 2 ; Current power: 20000000.000000000 -> [ 80.000000000000000 ] [rank 0 ] Energy consumed (Joules): 8650.0000000000000 -> [ 80.000000000000000 ] [rank 1 ] Energy consumed (Joules): 8650.0000000000000 +> [ 0.00000000] [rank 0] 3 pstates available +> [ 0.00000000] [rank 1] 3 pstates available +> [ 0.00000000] [rank 0] Power: 100000000.0000 +> [ 0.00000000] [rank 1] Power: 100000000.0000 +> [ 0.00000000] [rank 0] Power: 50000000.0000 +> [ 0.00000000] [rank 1] Power: 50000000.0000 +> [ 0.00000000] [rank 0] Power: 20000000.0000 +> [ 0.00000000] [rank 1] Power: 20000000.0000 +> [ 0.00000000] [rank 0] Current pstate: 0; Current power: 100000000.0000 +> [ 0.00000000] [rank 1] Current pstate: 0; Current power: 100000000.0000 +> [ 10.00000000] [rank 0] Energy consumed (Joules): 1200.0000 +> [ 10.00000000] [rank 1] Energy consumed (Joules): 1200.0000 +> [ 10.00000000] [rank 0] Current pstate: 1; Current power: 50000000.0000 +> [ 10.00000000] [rank 1] Current pstate: 1; Current power: 50000000.0000 +> [ 30.00000000] [rank 0] Energy consumed (Joules): 3400.0000 +> [ 30.00000000] [rank 1] Energy consumed (Joules): 3400.0000 +> [ 30.00000000] [rank 0] Current pstate: 2; Current power: 20000000.0000 +> [ 30.00000000] [rank 1] Current pstate: 2; Current power: 20000000.0000 +> [ 80.00000000] [rank 0] Energy consumed (Joules): 8650.0000 +> [ 80.00000000] [rank 1] Energy consumed (Joules): 8650.0000 > [80.000000] [surf_energy/INFO] Total energy consumption: 25300.000000 Joules (used hosts: 17300.000000 Joules; unused/idle hosts: 8000.000000) > [80.000000] [surf_energy/INFO] Energy consumption of host MyHost1: 8650.000000 Joules > [80.000000] [surf_energy/INFO] Energy consumption of host MyHost2: 8650.000000 Joules diff --git a/examples/smpi/energy/f77/sef.f b/examples/smpi/energy/f77/sef.f index 1c00d59bd7..4cbc5a3643 100644 --- a/examples/smpi/energy/f77/sef.f +++ b/examples/smpi/energy/f77/sef.f @@ -28,30 +28,33 @@ t = MPI_Wtime() - print *, '[', t, '] [rank ', rank, ']', + print '(1a,F15.8,1a,i2,1a,i2,1a)', '[', t, '] [rank ', rank, '] ', & pstates, ' pstates available' do i = 0, pstates - 1 p = smpi_get_host_power_peak_at(i) - print *, '[', t, '] [rank ', rank, '] Power: ', p + print '(1a,F15.8,1a,i2,1a,F15.4)', '[', t, '] [rank ', + & rank, '] Power: ', p end do do i = 0, pstates - 1 call smpi_set_host_pstate(i) t = MPI_Wtime() p = smpi_get_host_current_power_peak() - print *, '[', t, '] [rank ', rank, '] Current pstate: ', i, - & '; Current power: ', p + print '(1a,F15.8,1a,i2,1a,i2,1a,F15.4)', '[', t, '] [rank ', + & rank,'] Current pstate: ', i,'; Current power: ', p e = 1e9 call smpi_execute_flops(e) t = MPI_Wtime() e = smpi_get_host_consumed_energy() - print *, '[', t, '] [rank ', rank, ']', - & ' Energy consumed (Joules): ', e + print '(1a,F15.8,1a,i2,1a,1a,F15.4)', '[', t, '] [rank ', + & rank, ']',' Energy consumed (Joules): ', e end do + flush(6) + call MPI_Finalize(ierr) if (ierr .ne. MPI_SUCCESS) then print *, 'MPI_Finalize failed:', ierr diff --git a/examples/smpi/energy/f90/energy.tesh b/examples/smpi/energy/f90/energy.tesh index deff318e24..aa6cd218ba 100644 --- a/examples/smpi/energy/f90/energy.tesh +++ b/examples/smpi/energy/f90/energy.tesh @@ -1,26 +1,26 @@ p Test smpi bindings for dvfs functions (Fortran 90 example) ! output sort 1 $ ../../../smpi_script/bin/smpirun -np 2 -hostfile ${srcdir:=.}/hostfile -platform ${srcdir:=.}/../../platforms/energy_platform.xml --cfg=smpi/simulate-computation:no ${bindir:=.}/f90/sef90 --cfg=plugin:Energy --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning -> [ 0.0000000000000000 ] [rank 0 ] 3 pstates available -> [ 0.0000000000000000 ] [rank 1 ] 3 pstates available -> [ 0.0000000000000000 ] [rank 0 ] Power: 100000000.00000000 -> [ 0.0000000000000000 ] [rank 1 ] Power: 100000000.00000000 -> [ 0.0000000000000000 ] [rank 0 ] Power: 50000000.000000000 -> [ 0.0000000000000000 ] [rank 1 ] Power: 50000000.000000000 -> [ 0.0000000000000000 ] [rank 0 ] Power: 20000000.000000000 -> [ 0.0000000000000000 ] [rank 1 ] Power: 20000000.000000000 -> [ 0.0000000000000000 ] [rank 0 ] Current pstate: 0 ; Current power: 100000000.00000000 -> [ 0.0000000000000000 ] [rank 1 ] Current pstate: 0 ; Current power: 100000000.00000000 -> [ 10.000000000000000 ] [rank 0 ] Energy consumed (Joules): 1200.0000000000000 -> [ 10.000000000000000 ] [rank 1 ] Energy consumed (Joules): 1200.0000000000000 -> [ 10.000000000000000 ] [rank 0 ] Current pstate: 1 ; Current power: 50000000.000000000 -> [ 10.000000000000000 ] [rank 1 ] Current pstate: 1 ; Current power: 50000000.000000000 -> [ 30.000000000000000 ] [rank 0 ] Energy consumed (Joules): 3400.0000000000000 -> [ 30.000000000000000 ] [rank 1 ] Energy consumed (Joules): 3400.0000000000000 -> [ 30.000000000000000 ] [rank 0 ] Current pstate: 2 ; Current power: 20000000.000000000 -> [ 30.000000000000000 ] [rank 1 ] Current pstate: 2 ; Current power: 20000000.000000000 -> [ 80.000000000000000 ] [rank 0 ] Energy consumed (Joules): 8650.0000000000000 -> [ 80.000000000000000 ] [rank 1 ] Energy consumed (Joules): 8650.0000000000000 +> [ 0.00000000] [rank 0] 3 pstates available +> [ 0.00000000] [rank 1] 3 pstates available +> [ 0.00000000] [rank 0] Power: 100000000.0000 +> [ 0.00000000] [rank 1] Power: 100000000.0000 +> [ 0.00000000] [rank 0] Power: 50000000.0000 +> [ 0.00000000] [rank 1] Power: 50000000.0000 +> [ 0.00000000] [rank 0] Power: 20000000.0000 +> [ 0.00000000] [rank 1] Power: 20000000.0000 +> [ 0.00000000] [rank 0] Current pstate: 0; Current power: 100000000.0000 +> [ 0.00000000] [rank 1] Current pstate: 0; Current power: 100000000.0000 +> [ 10.00000000] [rank 0] Energy consumed (Joules): 1200.0000 +> [ 10.00000000] [rank 1] Energy consumed (Joules): 1200.0000 +> [ 10.00000000] [rank 0] Current pstate: 1; Current power: 50000000.0000 +> [ 10.00000000] [rank 1] Current pstate: 1; Current power: 50000000.0000 +> [ 30.00000000] [rank 0] Energy consumed (Joules): 3400.0000 +> [ 30.00000000] [rank 1] Energy consumed (Joules): 3400.0000 +> [ 30.00000000] [rank 0] Current pstate: 2; Current power: 20000000.0000 +> [ 30.00000000] [rank 1] Current pstate: 2; Current power: 20000000.0000 +> [ 80.00000000] [rank 0] Energy consumed (Joules): 8650.0000 +> [ 80.00000000] [rank 1] Energy consumed (Joules): 8650.0000 > [80.000000] [surf_energy/INFO] Total energy consumption: 25300.000000 Joules (used hosts: 17300.000000 Joules; unused/idle hosts: 8000.000000) > [80.000000] [surf_energy/INFO] Energy consumption of host MyHost1: 8650.000000 Joules > [80.000000] [surf_energy/INFO] Energy consumption of host MyHost2: 8650.000000 Joules diff --git a/examples/smpi/energy/f90/sef90.f90 b/examples/smpi/energy/f90/sef90.f90 index 14e3a71af8..e4f04a3c1b 100644 --- a/examples/smpi/energy/f90/sef90.f90 +++ b/examples/smpi/energy/f90/sef90.f90 @@ -28,26 +28,32 @@ program main t = MPI_Wtime() - print *, '[', t, '] [rank ', rank, ']', pstates, 'pstates available' + print '(1a,F15.8,1a,i2,1a,i2,1a)', '[', t, '] [rank ', rank, '] ',& + pstates, ' pstates available' do i = 0, pstates - 1 p = smpi_get_host_power_peak_at(i) - print *, '[', t, '] [rank ', rank, '] Power: ', p + print '(1a,F15.8,1a,i2,1a,F15.4)', '[', t, '] [rank ', rank, & + '] Power: ', p end do do i = 0, pstates - 1 call smpi_set_host_pstate(i) t = MPI_Wtime() p = smpi_get_host_current_power_peak() - print *, '[', t, '] [rank ', rank, '] Current pstate: ', i, '; Current power: ', p + print '(1a,F15.8,1a,i2,1a,i2,1a,F15.4)', '[', t, '] [rank ', & + rank, '] Current pstate: ', i, '; Current power: ', p e = 1e9 call smpi_execute_flops(e) t = MPI_Wtime() e = smpi_get_host_consumed_energy() - print *, '[', t, '] [rank ', rank, '] Energy consumed (Joules): ', e + print '(1a,F15.8,1a,i2,1a,F15.4)', '[', t, '] [rank ', & + rank, '] Energy consumed (Joules): ', e end do + flush(6) + call MPI_Finalize(ierr) if (ierr .ne. MPI_SUCCESS) then print *, 'MPI_Finalize failed:', ierr diff --git a/examples/smpi/mc/bugged1.c b/examples/smpi/mc/bugged1.c index 8815dd38b0..3d2e0e9d64 100644 --- a/examples/smpi/mc/bugged1.c +++ b/examples/smpi/mc/bugged1.c @@ -12,7 +12,7 @@ int main(int argc, char **argv) { - int recv_buff, err, size, rank, i; + int recv_buff, err, size, rank; MPI_Status status; /* Initialize MPI */ @@ -33,7 +33,7 @@ int main(int argc, char **argv) if (rank == 0) { printf("MPI_ISend / MPI_IRecv Test \n"); - for(i=0; i < size - 1; i++){ + for (int i = 0; i < size - 1; i++) { MPI_Recv(&recv_buff, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status); printf("Message received from %d\n", recv_buff); } diff --git a/examples/smpi/mc/bugged1_liveness.c b/examples/smpi/mc/bugged1_liveness.c index 213c888a4e..5ec2c2b24a 100644 --- a/examples/smpi/mc/bugged1_liveness.c +++ b/examples/smpi/mc/bugged1_liveness.c @@ -27,7 +27,6 @@ int main(int argc, char **argv){ int err, size, rank; int recv_buff; MPI_Status status; - int CS_used = 0; xbt_dynar_t requests = xbt_dynar_new(sizeof(int), NULL); /* Initialize MPI */ @@ -48,6 +47,7 @@ int main(int argc, char **argv){ MPI_Comm_rank(MPI_COMM_WORLD, &rank); if(rank == 0){ /* Coordinator */ + int CS_used = 0; while(1){ MPI_Recv(&recv_buff, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status); if(status.MPI_TAG == REQUEST_TAG){ diff --git a/examples/smpi/mc/only_send_deterministic.c b/examples/smpi/mc/only_send_deterministic.c index ffc01310ee..01188f1412 100644 --- a/examples/smpi/mc/only_send_deterministic.c +++ b/examples/smpi/mc/only_send_deterministic.c @@ -12,7 +12,7 @@ int main(int argc, char **argv) { - int recv_buff, err, size, rank, i; + int recv_buff, err, size, rank; MPI_Status status; /* Initialize MPI */ @@ -33,7 +33,7 @@ int main(int argc, char **argv) if (rank == 0) { //printf("MPI_ISend / MPI_IRecv Test \n"); - for(i=0; i < size - 1; i++){ + for (int i = 0; i < size - 1; i++) { MPI_Recv(&recv_buff, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status); //printf("Message received from %d\n", recv_buff); } diff --git a/examples/smpi/replay/replay.c b/examples/smpi/replay/replay.c index ea0d438e3e..078385a595 100644 --- a/examples/smpi/replay/replay.c +++ b/examples/smpi/replay/replay.c @@ -14,11 +14,24 @@ static void action_blah(const char* const* args) args is a strings array containing the blank-separated parameters found in the trace for this event instance. */ } +action_fun previous_send; +static void overriding_send(const char* const* args) +{ + (*previous_send)(args); // Just call the overriden symbol. That's a toy example. +} + int main(int argc, char *argv[]) { + /* Setup things and register default actions */ + smpi_replay_init(&argc, &argv); + /* Connect your callback function to the "blah" event in the trace files */ xbt_replay_action_register("blah", action_blah); + /* The send action is an override, so we have to first save its previous value in a global */ + previous_send = xbt_replay_action_get("send"); + xbt_replay_action_register("send", overriding_send); + /* The regular run of the replayer */ - smpi_replay_run(&argc, &argv); + smpi_replay_main(&argc, &argv); return 0; } diff --git a/examples/smpi/replay_multiple/generate_multiple_deployment.sh b/examples/smpi/replay_multiple/generate_multiple_deployment.sh index e454081f3f..134c852eb8 100755 --- a/examples/smpi/replay_multiple/generate_multiple_deployment.sh +++ b/examples/smpi/replay_multiple/generate_multiple_deployment.sh @@ -20,8 +20,6 @@ then exit fi -EXTOPT="" -WRAPPER="" HOSTFILE="" while true; do @@ -29,7 +27,7 @@ while true; do "-platform") PLATFORM="$2" if [ ! -f "${PLATFORM}" ]; then - echo "[`basename $0`] ** error: the file '${PLATFORM}' does not exist. Aborting." + echo "["$(basename $0)"] ** error: the file \'${PLATFORM}\' does not exist. Aborting." exit 1 fi shift 2 @@ -37,7 +35,7 @@ while true; do "-hostfile") HOSTFILE="$2" if [ ! -f "${HOSTFILE}" ]; then - echo "[`basename $0`] ** error: the file '${HOSTFILE}' does not exist. Aborting." + echo "["$(basename $0)"] ** error: the file \'${HOSTFILE}\' does not exist. Aborting." exit 1 fi shift 2 @@ -45,7 +43,7 @@ while true; do "-machinefile") HOSTFILE="$2" if [ ! -f "${HOSTFILE}" ]; then - echo "[`basename $0`] ** error: the file '${HOSTFILE}' does not exist. Aborting." + echo "["$(basename $0)"] ** error: the file \'${HOSTFILE}\' does not exist. Aborting." exit 1 fi shift 2 @@ -88,7 +86,7 @@ fi UNROLLEDHOSTFILETMP=0 #parse if our lines are terminated by :num_process -multiple_processes=`grep -c ":" $HOSTFILE` +multiple_processes=$(grep -c ":" $HOSTFILE) if [ "${multiple_processes}" -gt 0 ] ; then UNROLLEDHOSTFILETMP=1 UNROLLEDHOSTFILE="$(mktemp tmphostXXXXXX)" @@ -101,9 +99,9 @@ if [ "${multiple_processes}" -gt 0 ] ; then fi # Don't use wc -l to compute it to avoid issues with trailing \n at EOF -hostfile_procs=`grep -c "[a-zA-Z0-9]" $HOSTFILE` +hostfile_procs=$(grep -c "[a-zA-Z0-9]" $HOSTFILE) if [ ${hostfile_procs} = 0 ] ; then - echo "[`basename $0`] ** error: the hostfile '${HOSTFILE}' is empty. Aborting." >&2 + echo "["$(basename $0)"] ** error: the hostfile \'${HOSTFILE}\' is empty. Aborting." >&2 exit 1 fi @@ -119,15 +117,13 @@ APPLICATIONHEAD ##---- cache hostnames of hostfile--------------- if [ -n "${HOSTFILE}" ] && [ -f ${HOSTFILE} ]; then - hostnames=$(cat ${HOSTFILE} | tr '\n\r' ' ') - NUMHOSTS=$(cat ${HOSTFILE} | wc -l) + hostnames=$(tr '\n\r' ' ' < ${HOSTFILE}) + NUMHOSTS=$(wc -l < ${HOSTFILE}) fi DESCRIPTIONFILE=$(echo $PROC_ARGS|cut -d' ' -f1) if [ -n "${DESCRIPTIONFILE}" ] && [ -f "${DESCRIPTIONFILE}" ]; then - NUMINSTANCES=$(cat ${DESCRIPTIONFILE} | wc -l) - replayinstances=$(cat ${DESCRIPTIONFILE}) IFS_OLD=$IFS IFS=$'\n' set -f @@ -148,10 +144,10 @@ if [ -n "${DESCRIPTIONFILE}" ] && [ -f "${DESCRIPTIONFILE}" ]; then fi sleeptime=$(echo "$line"|cut -d' ' -f4) - HAVE_SEQ="`which seq 2>/dev/null`" + HAVE_SEQ=$(which seq 2>/dev/null) if [ -n "${HAVE_SEQ}" ]; then - SEQ1=`${HAVE_SEQ} 0 $((${NUMPROCSMINE}-1))` + SEQ1=$( ${HAVE_SEQ} 0 $((${NUMPROCSMINE}-1)) ) else cnt=0 while (( $cnt < ${NUMPROCSMINE} )) ; do diff --git a/examples/smpi/replay_multiple/replay_multiple.tesh b/examples/smpi/replay_multiple/replay_multiple.tesh index 72f83bb1ce..a8816fd11e 100644 --- a/examples/smpi/replay_multiple/replay_multiple.tesh +++ b/examples/smpi/replay_multiple/replay_multiple.tesh @@ -3,7 +3,7 @@ p Test the replay with multiple instances p first generate the deployment file $ ${srcdir:=.}/generate_multiple_deployment.sh -platform ${srcdir:=.}/../../platforms/small_platform_with_routers.xml -hostfile ${srcdir:=.}/../hostfile ${srcdir:=.}/description_file ${srcdir:=.}/deployment.xml -p This test needs maxmin/concurrency-limit=100 because it stats 64 hosts on 5 machines. +p This test needs maxmin/concurrency-limit=100 because it starts 64 hosts on 5 machines. ! timeout 120 $ ./replay_multiple description_file ${srcdir:=.}/../../platforms/small_platform_with_routers.xml ${srcdir:=.}/deployment.xml --log=smpi.:info --cfg=maxmin/concurrency-limit:100 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/concurrency-limit' to '100' diff --git a/examples/smpi/smpi_msg_masterslave/masterslave_mailbox_smpi.c b/examples/smpi/smpi_msg_masterslave/masterslave_mailbox_smpi.c index 71802712c6..51cc923511 100644 --- a/examples/smpi/smpi_msg_masterslave/masterslave_mailbox_smpi.c +++ b/examples/smpi/smpi_msg_masterslave/masterslave_mailbox_smpi.c @@ -1,5 +1,4 @@ -/* Copyright (c) 2010-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2010-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -15,18 +14,15 @@ static int master(int argc, char *argv[]) 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"); - int i; - XBT_INFO("Got %ld slaves and %ld tasks to process", slaves_count, number_of_tasks); - for (i = 0; i < number_of_tasks; i++) { + for (int i = 0; i < number_of_tasks; i++) { char mailbox[256]; char sprintf_buffer[256]; - msg_task_t task = NULL; snprintf(mailbox,256, "slave-%ld", i % slaves_count); snprintf(sprintf_buffer,256, "Task_%d", i); - task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL); + 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\"", task->name, number_of_tasks, mailbox); @@ -34,7 +30,7 @@ static int master(int argc, char *argv[]) } XBT_INFO("All tasks have been dispatched. Let's tell everybody the computation is over."); - for (i = 0; i < slaves_count; i++) { + for (int i = 0; i < slaves_count; i++) { char mailbox[80]; snprintf(mailbox,80, "slave-%ld", i % slaves_count); diff --git a/include/simgrid/forward.h b/include/simgrid/forward.h index 628f1e5e7d..9515436c61 100644 --- a/include/simgrid/forward.h +++ b/include/simgrid/forward.h @@ -9,19 +9,24 @@ #ifdef __cplusplus +#include "xbt/base.h" #include namespace simgrid { - namespace s4u { - class Actor; - class Host; - class Link; - class Mailbox; - class NetZone; - } - namespace kernel { - namespace activity { - class ActivityImpl; +namespace s4u { +class Actor; +class Comm; +class Host; +class Link; +class Mailbox; +class NetZone; + +XBT_PUBLIC(void) intrusive_ptr_release(Comm* c); +XBT_PUBLIC(void) intrusive_ptr_add_ref(Comm* c); +} +namespace kernel { +namespace activity { +class ActivityImpl; } namespace routing { class NetPoint; @@ -35,7 +40,7 @@ namespace simgrid { class Cpu; class LinkImpl; class HostImpl; - class Storage; + class StorageImpl; } namespace trace_mgr { class trace; diff --git a/include/simgrid/kernel/future.hpp b/include/simgrid/kernel/future.hpp index da5bd080f5..777a9f48b2 100644 --- a/include/simgrid/kernel/future.hpp +++ b/include/simgrid/kernel/future.hpp @@ -61,7 +61,7 @@ public: void set_continuation(simgrid::xbt::Task&& continuation) { - xbt_assert(!continuation_); + xbt_assert(not continuation_); switch (status_) { case FutureStatus::done: // This is not supposed to happen if continuation is set @@ -282,7 +282,7 @@ template class Future { public: Future() = default; - Future(std::shared_ptr> state): state_(std::move(state)) {} + Future(std::shared_ptr> state) : state_(std::move(state)) {} // Move type: Future(Future&) = delete; @@ -369,12 +369,9 @@ public: * the future is ready * @exception std::future_error no state is associated with the future */ - template - auto then(F continuation) - -> typename std::enable_if< - !is_future::value, - Future - >::type + template + auto then(F continuation) -> typename std::enable_if::value, + Future>::type { return this->thenNoUnwrap(std::move(continuation)); } diff --git a/include/simgrid/modelchecker.h b/include/simgrid/modelchecker.h index 0b920bb913..c362f999ef 100644 --- a/include/simgrid/modelchecker.h +++ b/include/simgrid/modelchecker.h @@ -1,7 +1,6 @@ /* simgrid/modelchecker.h - Formal Verification made possible in SimGrid */ -/* Copyright (c) 2008-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2008-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -15,7 +14,6 @@ #ifndef SIMGRID_MODELCHECKER_H #define SIMGRID_MODELCHECKER_H -#include #include /* size_t */ #include /* SIMGRID_HAVE_MC ? */ @@ -49,6 +47,11 @@ XBT_PUBLIC(void) MC_automaton_new_propositional_symbol_pointer(const char *id, i XBT_PUBLIC(void) MC_cut(void); XBT_PUBLIC(void) MC_ignore(void *addr, size_t size); +XBT_PUBLIC(void) MC_ignore_heap(void* address, size_t size); +XBT_PUBLIC(void) MC_remove_ignore_heap(void* address, size_t size); +XBT_PUBLIC(void) MC_ignore_local_variable(const char* var_name, const char* frame); +XBT_PUBLIC(void) MC_ignore_global_variable(const char* var_name); + #else #define MC_is_active() 0 @@ -60,6 +63,11 @@ XBT_PUBLIC(void) MC_ignore(void *addr, size_t size); #define MC_cut() ((void)0) #define MC_ignore(a, b) ((void)0) +#define MC_ignore_heap(a,s) ((void)0) +#define MC_remove_ignore_heap(a,s) ((void)0) +#define MC_ignore_local_variable(n,f) ((void)0) +#define MC_ignore_global_variable(v) ((void)0) + #endif SG_END_DECL() diff --git a/include/simgrid/msg.h b/include/simgrid/msg.h index a96060d6c2..9a6efb706f 100644 --- a/include/simgrid/msg.h +++ b/include/simgrid/msg.h @@ -7,7 +7,6 @@ #ifndef MSG_H #define MSG_H -#include "xbt.h" #include "xbt/lib.h" #include "simgrid/forward.h" #include "simgrid/simix.h" @@ -68,7 +67,6 @@ typedef struct msg_file_priv { char* mount_point; char* storageId; char* storage_type; - char* content_type; int desc_id; void *data; simdata_file_t simdata; diff --git a/include/simgrid/s4u.hpp b/include/simgrid/s4u.hpp index fe0ec582ac..ee32b446d5 100644 --- a/include/simgrid/s4u.hpp +++ b/include/simgrid/s4u.hpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include diff --git a/include/simgrid/s4u/Activity.hpp b/include/simgrid/s4u/Activity.hpp index 1cdd79eab0..b85daaaf4f 100644 --- a/include/simgrid/s4u/Activity.hpp +++ b/include/simgrid/s4u/Activity.hpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2006-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2006-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -7,17 +6,10 @@ #ifndef SIMGRID_S4U_ACTIVITY_HPP #define SIMGRID_S4U_ACTIVITY_HPP -#include - -#include -#include - #include #include -typedef enum { - inited, started, finished -} e_s4u_activity_state_t; +typedef enum { inited = 0, started, canceled, errored, finished } e_s4u_activity_state_t; namespace simgrid { namespace s4u { @@ -28,6 +20,9 @@ namespace s4u { */ XBT_PUBLIC_CLASS Activity { friend Comm; + friend void intrusive_ptr_release(Comm * c); + friend void intrusive_ptr_add_ref(Comm * c); + protected: Activity(); virtual ~Activity(); diff --git a/include/simgrid/s4u/Actor.hpp b/include/simgrid/s4u/Actor.hpp index bef7072932..5517dc62bd 100644 --- a/include/simgrid/s4u/Actor.hpp +++ b/include/simgrid/s4u/Actor.hpp @@ -16,15 +16,11 @@ #include #include -#include - #include -#include #include #include #include -#include #include namespace simgrid { @@ -310,7 +306,7 @@ namespace this_actor { * See \ref Comm for the full communication API (including non blocking communications). */ XBT_PUBLIC(void*) recv(MailboxPtr chan); - XBT_PUBLIC(Comm&) irecv(MailboxPtr chan, void** data); + XBT_PUBLIC(CommPtr) irecv(MailboxPtr chan, void** data); /** Block the actor until it delivers a message of the given simulated size to the given mailbox * @@ -319,7 +315,8 @@ namespace this_actor { XBT_PUBLIC(void) send(MailboxPtr chan, void* payload, double simulatedSize); XBT_PUBLIC(void) send(MailboxPtr chan, void* payload, double simulatedSize, double timeout); - XBT_PUBLIC(Comm&) isend(MailboxPtr chan, void* payload, double simulatedSize); + XBT_PUBLIC(CommPtr) isend(MailboxPtr chan, void* payload, double simulatedSize); + XBT_PUBLIC(void) dsend(MailboxPtr chan, void* payload, double simulatedSize); /** @brief Returns the actor ID of the current actor (same as pid). */ XBT_PUBLIC(aid_t) pid(); @@ -351,7 +348,7 @@ namespace this_actor { XBT_PUBLIC(void) migrate(Host* new_host); }; -/** @} */ +/** @} */ }} // namespace simgrid::s4u diff --git a/include/simgrid/s4u/Comm.hpp b/include/simgrid/s4u/Comm.hpp index e2db122157..d889b61251 100644 --- a/include/simgrid/s4u/Comm.hpp +++ b/include/simgrid/s4u/Comm.hpp @@ -14,7 +14,6 @@ namespace simgrid { namespace s4u { - /** @brief Communication async * * Represents all asynchronous communications, that you can test or wait onto. @@ -23,7 +22,10 @@ XBT_PUBLIC_CLASS Comm : public Activity { Comm() : Activity() {} public: - virtual ~Comm() = default; + friend void intrusive_ptr_release(simgrid::s4u::Comm * c); + friend void intrusive_ptr_add_ref(simgrid::s4u::Comm * c); + + virtual ~Comm(); /*! take a range of s4u::Comm* (last excluded) and return when one of them is finished. The return value is an * iterator on the finished Comms. */ @@ -73,13 +75,16 @@ public: return res; } /** Creates (but don't start) an async send to the mailbox @p dest */ - static Comm& send_init(MailboxPtr dest); + static CommPtr send_init(MailboxPtr dest); /** Creates and start an async send to the mailbox @p dest */ - static Comm& send_async(MailboxPtr dest, void* data, int simulatedByteAmount); + static CommPtr send_async(MailboxPtr dest, void* data, int simulatedByteAmount); /** Creates (but don't start) an async recv onto the mailbox @p from */ - static Comm& recv_init(MailboxPtr from); + static CommPtr recv_init(MailboxPtr from); /** Creates and start an async recv to the mailbox @p from */ - static Comm& recv_async(MailboxPtr from, void** data); + static CommPtr recv_async(MailboxPtr from, void** data); + /** Creates and start a detached send to the mailbox @p dest + * TODO: make it possible to detach an already created comm */ + static void send_detached(MailboxPtr dest, void* data, int simulatedSize); void start() override; void wait() override; @@ -103,6 +108,7 @@ public: size_t getDstDataSize(); bool test(); + void cancel(); private: double rate_ = -1; @@ -120,6 +126,8 @@ private: smx_actor_t sender_ = nullptr; smx_actor_t receiver_ = nullptr; MailboxPtr mailbox_ = nullptr; + + std::atomic_int_fast32_t refcount_{0}; }; } } // namespace simgrid::s4u diff --git a/include/simgrid/s4u/ConditionVariable.hpp b/include/simgrid/s4u/ConditionVariable.hpp index c087a0e5ef..b1e2be3e85 100644 --- a/include/simgrid/s4u/ConditionVariable.hpp +++ b/include/simgrid/s4u/ConditionVariable.hpp @@ -52,7 +52,7 @@ public: void wait(std::unique_lock & lock); template void wait(std::unique_lock & lock, P pred) { - while (!pred()) + while (not pred()) wait(lock); } @@ -62,7 +62,7 @@ public: std::cv_status wait_for(std::unique_lock & lock, double duration); template bool wait_until(std::unique_lock & lock, double timeout_time, P pred) { - while (!pred()) + while (not pred()) if (this->wait_until(lock, timeout_time) == std::cv_status::timeout) return pred(); return true; diff --git a/include/simgrid/s4u/Host.hpp b/include/simgrid/s4u/Host.hpp index 999098f3eb..665f2c85fe 100644 --- a/include/simgrid/s4u/Host.hpp +++ b/include/simgrid/s4u/Host.hpp @@ -83,7 +83,7 @@ public: /** Returns if that host is currently up and running */ bool isOn(); /** Returns if that host is currently down and offline */ - bool isOff() { return !isOn(); } + bool isOff() { return not isOn(); } double speed(); int coreCount(); diff --git a/include/simgrid/s4u/Mutex.hpp b/include/simgrid/s4u/Mutex.hpp index 3603d18359..05199bd889 100644 --- a/include/simgrid/s4u/Mutex.hpp +++ b/include/simgrid/s4u/Mutex.hpp @@ -35,9 +35,9 @@ class ConditionVariable; */ XBT_PUBLIC_CLASS Mutex { friend ConditionVariable; - friend simgrid::simix::Mutex; - simgrid::simix::Mutex* mutex_; - Mutex(simgrid::simix::Mutex* mutex) : mutex_(mutex) {} + friend simgrid::simix::MutexImpl; + simgrid::simix::MutexImpl* mutex_; + Mutex(simgrid::simix::MutexImpl * mutex) : mutex_(mutex) {} /* refcounting of the intrusive_ptr is delegated to the implementation object */ friend void intrusive_ptr_add_ref(Mutex* mutex) diff --git a/include/simgrid/s4u/forward.hpp b/include/simgrid/s4u/forward.hpp index 834163240c..10c8d856bb 100644 --- a/include/simgrid/s4u/forward.hpp +++ b/include/simgrid/s4u/forward.hpp @@ -16,6 +16,7 @@ using ActorPtr = boost::intrusive_ptr; class Activity; class Comm; +using CommPtr = boost::intrusive_ptr; class Engine; class Host; class Mailbox; diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 02fdab7357..78dbe75a3d 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -34,13 +34,13 @@ namespace context { \see m_process_management @{ */ class ActorImpl; - class Mutex; + class MutexImpl; } } typedef simgrid::kernel::context::Context* smx_context_t; typedef simgrid::simix::ActorImpl* smx_actor_t; -typedef simgrid::simix::Mutex* smx_mutex_t; +typedef simgrid::simix::MutexImpl* smx_mutex_t; typedef simgrid::kernel::activity::MailboxImpl* smx_mailbox_t; #else @@ -226,6 +226,8 @@ XBT_PUBLIC(smx_activity_t) SIMIX_comm_get_send_match(smx_mailbox_t mbox, int (*m XBT_PUBLIC(int) SIMIX_comm_has_send_match(smx_mailbox_t mbox, int (*match_fun)(void*, void*), void* data); XBT_PUBLIC(int) SIMIX_comm_has_recv_match(smx_mailbox_t mbox, int (*match_fun)(void*, void*), void* data); XBT_PUBLIC(void) SIMIX_comm_finish(smx_activity_t synchro); +XBT_PUBLIC(smx_activity_t) SIMIX_comm_ref(smx_activity_t comm); +XBT_PUBLIC(void) SIMIX_comm_unref(smx_activity_t comm); /******************************************************************************/ /* SIMIX simcalls */ diff --git a/include/simgrid/simix.hpp b/include/simgrid/simix.hpp index a09f323c23..7e0e9e3cd5 100644 --- a/include/simgrid/simix.hpp +++ b/include/simgrid/simix.hpp @@ -7,14 +7,7 @@ #ifndef SIMGRID_SIMIX_HPP #define SIMGRID_SIMIX_HPP -#include - -#include -#include -#include -#include - -#include +//#include #include #include #include diff --git a/include/simgrid/simix/blocking_simcall.hpp b/include/simgrid/simix/blocking_simcall.hpp index 6341521a42..88e522c69c 100644 --- a/include/simgrid/simix/blocking_simcall.hpp +++ b/include/simgrid/simix/blocking_simcall.hpp @@ -87,7 +87,7 @@ public: bool valid() const { return future_.valid(); } T get() { - if (!valid()) + if (not valid()) throw std::future_error(std::future_errc::no_state); smx_actor_t self = SIMIX_process_self(); simgrid::xbt::Result result; @@ -109,7 +109,7 @@ public: } bool is_ready() const { - if (!valid()) + if (not valid()) throw std::future_error(std::future_errc::no_state); return future_.is_ready(); } diff --git a/include/smpi/smpi.h b/include/smpi/smpi.h index 2b54c71c4e..11c67ee7de 100644 --- a/include/smpi/smpi.h +++ b/include/smpi/smpi.h @@ -918,7 +918,9 @@ XBT_PUBLIC(int) smpi_process_index(); XBT_PUBLIC(void) smpi_process_init(int *argc, char ***argv); /* Trace replay specific stuff */ -XBT_PUBLIC(void) smpi_replay_run(int *argc, char***argv); +XBT_PUBLIC(void) smpi_replay_init(int* argc, char*** argv); // Only initialization +XBT_PUBLIC(void) smpi_replay_main(int* argc, char*** argv); // Launch the replay once init is done +XBT_PUBLIC(void) smpi_replay_run(int* argc, char*** argv); // Both init and start XBT_PUBLIC(void) SMPI_app_instance_register(const char *name, xbt_main_func_t code, int num_processes); XBT_PUBLIC(void) SMPI_init(); @@ -987,4 +989,17 @@ if(!name) { \ SG_END_DECL() + +/* C++ declarations for shared_malloc */ +#ifdef __cplusplus +#include + +XBT_PUBLIC(int) smpi_is_shared(void* ptr, std::vector>& private_blocks, size_t* offset); + +std::vector> shift_and_frame_private_blocks(const std::vector> vec, + size_t offset, size_t buff_size); +std::vector> merge_private_blocks(std::vector> src, + std::vector> dst); +#endif + #endif diff --git a/include/smpi/smpi_shared_malloc.hpp b/include/smpi/smpi_shared_malloc.hpp deleted file mode 100644 index a047bf88f5..0000000000 --- a/include/smpi/smpi_shared_malloc.hpp +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef SMPI_SHARED_HPP -#define SMPI_SHARED_HPP -#include -#include -#include - - -/* - * We cannot put this declaration in smpi.h, since we use C++ features. - */ - - -XBT_PUBLIC(int) smpi_is_shared(void* ptr, std::vector> &private_blocks, size_t *offset); - -std::vector> shift_and_frame_private_blocks(const std::vector> vec, size_t offset, size_t buff_size); -std::vector> merge_private_blocks(std::vector> src, std::vector> dst); - -#endif diff --git a/include/surf/surf_routing.h b/include/surf/surf_routing.h index 83fa79e6a6..2d19df1798 100644 --- a/include/surf/surf_routing.h +++ b/include/surf/surf_routing.h @@ -14,7 +14,6 @@ SG_BEGIN_DECL() // FIXME: this header file should die XBT_PUBLIC_DATA(xbt_lib_t) storage_lib; -XBT_PUBLIC_DATA(int) ROUTING_STORAGE_LEVEL; //Routing storage level XBT_PUBLIC_DATA(int) SURF_STORAGE_LEVEL; // Surf storage level SG_END_DECL() diff --git a/include/xbt/automaton.hpp b/include/xbt/automaton.hpp index 1c78e9a211..5c3dad854a 100644 --- a/include/xbt/automaton.hpp +++ b/include/xbt/automaton.hpp @@ -4,8 +4,8 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#ifndef _XBT_AUTOMATON_HPP -#define _XBT_AUTOMATON_HPP +#ifndef XBT_AUTOMATON_HPP +#define XBT_AUTOMATON_HPP #include diff --git a/include/xbt/config.hpp b/include/xbt/config.hpp index 4e0e22221f..f5b3c95222 100644 --- a/include/xbt/config.hpp +++ b/include/xbt/config.hpp @@ -168,8 +168,8 @@ typename std::enable_if class WithContext : public E, public WithContextException { public: - - static_assert(!std::is_base_of::value, - "Trying to appli WithContext twice"); + static_assert(not std::is_base_of::value, "Trying to appli WithContext twice"); WithContext(E exception) : E(std::move(exception)) {} diff --git a/include/xbt/functional.hpp b/include/xbt/functional.hpp index 10c16bf98a..ca034ba73a 100644 --- a/include/xbt/functional.hpp +++ b/include/xbt/functional.hpp @@ -21,8 +21,8 @@ #include #include -#include -#include +#include "xbt/sysdep.h" +#include "xbt/utility.hpp" namespace simgrid { namespace xbt { @@ -232,9 +232,7 @@ private: vtable_ = &vtable; } - template - typename std::enable_if()>::type - init(F code) + template typename std::enable_if()>::type init(F code) { const static TaskVtable vtable { // Call: diff --git a/include/xbt/matrix.h b/include/xbt/matrix.h deleted file mode 100644 index 6d0d3cbc8b..0000000000 --- a/include/xbt/matrix.h +++ /dev/null @@ -1,52 +0,0 @@ -/* xbt_matrix_t management functions */ - -/* Copyright (c) 2006-2007, 2009-2010, 2013-2014. The SimGrid Team. - * All rights reserved. */ - -/* This program is free software; you can redistribute it and/or modify it - * under the terms of the license (GNU LGPL) which comes with this package. */ - -#ifndef XBT_MATRIX_H -#define XBT_MATRIX_H - -#include "xbt/misc.h" -#include "xbt/function_types.h" - -SG_BEGIN_DECL() - -typedef struct { - unsigned int lines; - unsigned int rows; - unsigned long elmsize; - - char *data; - void_f_pvoid_t free_f; -} s_xbt_matrix_t; -typedef s_xbt_matrix_t* xbt_matrix_t; - - /** @brief Retrieve the address of a cell (not its content) - * @hideinitializer */ -#define xbt_matrix_get_ptr(mat,l,c) \ - ((void*)&(mat)->data[(c)*(mat)->lines*(mat)->elmsize + (l)*(mat)->elmsize]) - - /** @brief Quick retrieval of scalar content - * @hideinitializer */ -#define xbt_matrix_get_as(mat,l,c,type) *(type*)xbt_matrix_get_ptr(mat,l,c) - -XBT_PUBLIC(xbt_matrix_t) xbt_matrix_new(int lines, int rows, const unsigned long elmsize, void_f_pvoid_t const free_f); -XBT_PUBLIC(xbt_matrix_t) xbt_matrix_new_sub(xbt_matrix_t from, int lsize, int rsize, int lpos, int rpos, - pvoid_f_pvoid_t const cpy_f); -XBT_PUBLIC(void) xbt_matrix_free(xbt_matrix_t matrix); - -XBT_PUBLIC(void) xbt_matrix_copy_values(xbt_matrix_t dest, xbt_matrix_t src, unsigned int lsize, unsigned int rsize, - unsigned int lpos_dst, unsigned int rpos_dst, unsigned int lpos_src, - unsigned int rpos_src, pvoid_f_pvoid_t const cpy_f); - -XBT_PUBLIC(void) xbt_matrix_dump(xbt_matrix_t matrix, const char *name, int coords, void_f_pvoid_t display_fun); - -XBT_PUBLIC(xbt_matrix_t) xbt_matrix_double_new_zeros(int lines, int rows); -XBT_PUBLIC(xbt_matrix_t) xbt_matrix_double_new_id(int lines, int rows); -XBT_PUBLIC(xbt_matrix_t) xbt_matrix_double_new_seq(int lines, int rows); -XBT_PUBLIC(void) xbt_matrix_double_addmult(xbt_matrix_t A, xbt_matrix_t B, /*OUT*/ xbt_matrix_t C); -SG_END_DECL() -#endif /* XBT_MATRIX_H */ diff --git a/include/xbt/str.h b/include/xbt/str.h index 0f10bef8d0..c89cf9825c 100644 --- a/include/xbt/str.h +++ b/include/xbt/str.h @@ -55,11 +55,10 @@ static inline unsigned int xbt_str_hash_ext(const char *str, int str_len) { #ifdef XBT_DJB2_HASH_FUNCTION /* fast implementation of djb2 algorithm */ - int c; unsigned int hash = 5381; while (str_len--) { - c = *str++; + int c = *str++; hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ } # elif defined(XBT_FNV_HASH_FUNCTION) diff --git a/include/xbt/string.hpp b/include/xbt/string.hpp index b1638673d9..9343ce600d 100644 --- a/include/xbt/string.hpp +++ b/include/xbt/string.hpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2015-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -209,7 +208,7 @@ public: template bool operator!=(X const& that) const { - return !((*this) == that); + return not (*this == that); } // Compare: diff --git a/sonar-project.properties b/sonar-project.properties index 80b897e860..2151a654d1 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -3,7 +3,7 @@ sonar.projectKey=simgrid sonar.projectName=SimGrid -sonar.projectVersion=3.15 +sonar.projectVersion=3.16 sonar.links.homepage=http://simgrid.org sonar.links.issue=https://github.com/simgrid/simgrid/issues @@ -13,7 +13,7 @@ sonar.sources=src,examples,include,teshsuite # Disable some rules on some files -sonar.issue.ignore.multicriteria=j1,jni1,jni2,c1,c2a,c2b,c3,c4a,c4b,f1 +sonar.issue.ignore.multicriteria=j1,jni1,jni2,c1,c2a,c2b,c3,c4a,c4b,c5a,c5b,f1 # The Object.finalize() method should not be overriden # But we need to clean the native memory with JNI @@ -55,6 +55,13 @@ sonar.issue.ignore.multicriteria.c4a.resourceKey=examples/**/*.cpp sonar.issue.ignore.multicriteria.c4b.ruleKey=cpp:GlobalNamespaceMembers sonar.issue.ignore.multicriteria.c4b.resourceKey=examples/**/*.hpp +# Replace alternative operator "not" with "!" +# I like it better so please leave me alone +sonar.issue.ignore.multicriteria.c5a.ruleKey=cpp:S3659 +sonar.issue.ignore.multicriteria.c5a.resourceKey=**/*.cpp +sonar.issue.ignore.multicriteria.c5b.ruleKey=cpp:S3659 +sonar.issue.ignore.multicriteria.c5b.resourceKey=**/*.hpp + # "reinterpret_cast" should not be used # But we need this to interface C and Fortran @@ -73,7 +80,7 @@ sonar.exclusions=src/*_unit.c*,teshsuite/smpi/mpich3-test/**,teshsuite/smpi/isp/ # Exclude our examples from the duplication detection. # Examples are expected to be somehow repetitive -sonar.cpd.exclusions=examples/** +sonar.cpd.exclusions=examples/**,teshsuite/** # The build-wrapper output dir sonar.cfamily.build-wrapper-output=bw-outputs diff --git a/src/bindings/java/jmsg.cpp b/src/bindings/java/jmsg.cpp index a677fdaed3..abb1bacc0e 100644 --- a/src/bindings/java/jmsg.cpp +++ b/src/bindings/java/jmsg.cpp @@ -174,12 +174,12 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Msg_environmentGetRoutingRoot(JNI { msg_netzone_t as = MSG_zone_get_root(); jobject jas = jnetzone_new_instance(env); - if (!jas) { + if (not jas) { jxbt_throw_jni(env, "java As instantiation failed"); return nullptr; } jas = jnetzone_ref(env, jas); - if (!jas) { + if (not jas) { jxbt_throw_jni(env, "new global ref allocation failed"); return nullptr; } diff --git a/src/bindings/java/jmsg_as.cpp b/src/bindings/java/jmsg_as.cpp index 09d996d2e2..af1aa6fd08 100644 --- a/src/bindings/java/jmsg_as.cpp +++ b/src/bindings/java/jmsg_as.cpp @@ -68,24 +68,24 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getSons(JNIEnv * env, job jclass cls = env->FindClass("org/simgrid/msg/As"); - if (!cls) + if (not cls) return nullptr; jtable = env->NewObjectArray(static_cast(self_as->children()->size()), cls, nullptr); - if (!jtable) { + if (not jtable) { jxbt_throw_jni(env, "Hosts table allocation failed"); return nullptr; } for (auto tmp_as : *self_as->children()) { jobject tmp_jas = jnetzone_new_instance(env); - if (!tmp_jas) { + if (not tmp_jas) { jxbt_throw_jni(env, "java As instantiation failed"); return nullptr; } tmp_jas = jnetzone_ref(env, tmp_jas); - if (!tmp_jas) { + if (not tmp_jas) { jxbt_throw_jni(env, "new global ref allocation failed"); return nullptr; } @@ -100,14 +100,14 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getSons(JNIEnv * env, job JNIEXPORT jobject JNICALL Java_org_simgrid_msg_As_getProperty(JNIEnv *env, jobject jas, jobject jname) { simgrid::s4u::NetZone* as = jnetzone_get_native(env, jas); - if (!as) { + if (not as) { jxbt_throw_notbound(env, "as", jas); return nullptr; } const char *name = env->GetStringUTFChars(static_cast(jname), 0); const char* property = MSG_zone_get_property_value(as, name); - if (!property) { + if (not property) { return nullptr; } @@ -126,7 +126,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getHosts(JNIEnv * env, jo simgrid::s4u::NetZone* as = jnetzone_get_native(env, jas); jclass cls = jxbt_get_class(env, "org/simgrid/msg/Host"); - if (!cls) + if (not cls) return nullptr; std::vector table; @@ -134,7 +134,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getHosts(JNIEnv * env, jo jtable = env->NewObjectArray(static_cast(table.size()), cls, nullptr); - if (!jtable) { + if (not jtable) { jxbt_throw_jni(env, "Hosts table allocation failed"); return nullptr; } @@ -142,7 +142,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getHosts(JNIEnv * env, jo int index = 0; for (auto host : table) { jhost = static_cast(host->extension(JAVA_HOST_LEVEL)); - if (!jhost) { + if (not jhost) { jname = env->NewStringUTF(host->cname()); jhost = Java_org_simgrid_msg_Host_getByName(env, cls, jname); diff --git a/src/bindings/java/jmsg_comm.cpp b/src/bindings/java/jmsg_comm.cpp index 320b159fae..8d52bfedf2 100644 --- a/src/bindings/java/jmsg_comm.cpp +++ b/src/bindings/java/jmsg_comm.cpp @@ -78,7 +78,7 @@ JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Comm_test(JNIEnv *env, jobject j return JNI_TRUE; } - if (!comm) { + if (not comm) { jxbt_throw_null(env, bprintf("comm is null")); return JNI_FALSE; } @@ -98,7 +98,7 @@ JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Comm_test(JNIEnv *env, jobject j JNIEXPORT void JNICALL Java_org_simgrid_msg_Comm_waitCompletion(JNIEnv *env, jobject jcomm, jdouble timeout) { msg_comm_t comm = (msg_comm_t) (uintptr_t) env->GetLongField(jcomm, jcomm_field_Comm_bind); - if (!comm) { + if (not comm) { jxbt_throw_null(env, bprintf("comm is null")); return; } @@ -129,7 +129,7 @@ static msg_comm_t* jarray_to_commArray(JNIEnv *env, jobjectArray jcomms, /* OUT break; comms[i] = (msg_comm_t) (uintptr_t) env->GetLongField(jcomm, jcomm_field_Comm_bind); - if (!comms[i]) { + if (not comms[i]) { jxbt_throw_null(env, bprintf("comm at rank %d is null", i)); return nullptr; } @@ -142,7 +142,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Comm_waitAll(JNIEnv *env, jclass cls { int count; msg_comm_t* comms = jarray_to_commArray(env, jcomms, &count); - if (!comms) + if (not comms) return; MSG_comm_waitall(comms, count, static_cast(timeout)); @@ -152,7 +152,7 @@ JNIEXPORT int JNICALL Java_org_simgrid_msg_Comm_waitAny(JNIEnv *env, jclass cls, { int count; msg_comm_t* comms = jarray_to_commArray(env, jcomms, &count); - if (!comms) + if (not comms) return -1; xbt_dynar_t dyn = xbt_dynar_new(sizeof(msg_comm_t),nullptr); for (int i=0; iReleaseStringUTFChars(jname, name); return nullptr; } env->ReleaseStringUTFChars(jname, name); - if (!host->extension(JAVA_HOST_LEVEL)) { /* native host not associated yet with java host */ + if (not host->extension(JAVA_HOST_LEVEL)) { /* native host not associated yet with java host */ /* Instantiate a new java host */ jobject jhost = jhost_new_instance(env); - if (!jhost) { + if (not jhost) { jxbt_throw_jni(env, "java host instantiation failed"); return nullptr; } @@ -81,7 +81,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jcla /* get a global reference to the newly created host */ jhost = jhost_ref(env, jhost); - if (!jhost) { + if (not jhost) { jxbt_throw_jni(env, "new global ref allocation failed"); return nullptr; } @@ -103,13 +103,13 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_currentHost(JNIEnv * env, jc msg_host_t host = MSG_host_self(); - if (!host->extension(JAVA_HOST_LEVEL)) { + if (not host->extension(JAVA_HOST_LEVEL)) { /* the native host not yet associated with the java host instance */ /* instanciate a new java host instance */ jhost = jhost_new_instance(env); - if (!jhost) { + if (not jhost) { jxbt_throw_jni(env, "java host instantiation failed"); return nullptr; } @@ -117,7 +117,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_currentHost(JNIEnv * env, jc /* get a global reference to the newly created host */ jhost = jhost_ref(env, jhost); - if (!jhost) { + if (not jhost) { jxbt_throw_jni(env, "global ref allocation failed"); return nullptr; } @@ -154,7 +154,7 @@ JNIEXPORT jint JNICALL Java_org_simgrid_msg_Host_getCount(JNIEnv * env, jclass c JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getSpeed(JNIEnv * env, jobject jhost) { msg_host_t host = jhost_get_native(env, jhost); - if (!host) { + if (not host) { jxbt_throw_notbound(env, "host", jhost); return -1; } @@ -165,7 +165,7 @@ JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getSpeed(JNIEnv * env, jobje JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCoreNumber(JNIEnv * env, jobject jhost) { msg_host_t host = jhost_get_native(env, jhost); - if (!host) { + if (not host) { jxbt_throw_notbound(env, "host", jhost); return -1; } @@ -176,14 +176,14 @@ JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCoreNumber(JNIEnv * env, JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getProperty(JNIEnv *env, jobject jhost, jobject jname) { msg_host_t host = jhost_get_native(env, jhost); - if (!host) { + if (not host) { jxbt_throw_notbound(env, "host", jhost); return nullptr; } const char *name = env->GetStringUTFChars((jstring) jname, 0); const char *property = MSG_host_get_property_value(host, name); - if (!property) { + if (not property) { return nullptr; } @@ -198,7 +198,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_setProperty(JNIEnv *env, jobject jhost, jobject jname, jobject jvalue) { msg_host_t host = jhost_get_native(env, jhost); - if (!host) { + if (not host) { jxbt_throw_notbound(env, "host", jhost); return; } @@ -216,7 +216,7 @@ JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Host_isOn(JNIEnv * env, jobject { msg_host_t host = jhost_get_native(env, jhost); - if (!host) { + if (not host) { jxbt_throw_notbound(env, "host", jhost); return 0; } @@ -230,7 +230,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getMountedStorage(JNIEn jobject jstorage; jstring jname; - if (!host) { + if (not host) { jxbt_throw_notbound(env, "host", jhost); return 0; } @@ -243,9 +243,9 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getMountedStorage(JNIEn jtable = env->NewObjectArray((jsize) count, cls, nullptr); - if (!jtable) { - jxbt_throw_jni(env, "Storages table allocation failed"); - return nullptr; + if (not jtable) { + jxbt_throw_jni(env, "Storages table allocation failed"); + return nullptr; } xbt_dict_cursor_t cursor=nullptr; @@ -266,7 +266,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getAttachedStorage(JNIE { msg_host_t host = jhost_get_native(env, jhost); - if (!host) { + if (not host) { jxbt_throw_notbound(env, "host", jhost); return 0; } @@ -290,7 +290,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getStorageContent(JNIEn { msg_host_t host = jhost_get_native(env, jhost); - if (!host) { + if (not host) { jxbt_throw_notbound(env, "host", jhost); return 0; } @@ -304,12 +304,12 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_all(JNIEnv * env, jclas int count = xbt_dynar_length(table); jclass cls = jxbt_get_class(env, "org/simgrid/msg/Host"); - if (!cls) + if (not cls) return nullptr; jobjectArray jtable = env->NewObjectArray((jsize)count, cls, nullptr); - if (!jtable) { + if (not jtable) { jxbt_throw_jni(env, "Hosts table allocation failed"); return nullptr; } @@ -318,7 +318,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_all(JNIEnv * env, jclas msg_host_t host = xbt_dynar_get_as(table, index, msg_host_t); jobject jhost = static_cast(host->extension(JAVA_HOST_LEVEL)); - if (!jhost) { + if (not jhost) { jstring jname = env->NewStringUTF(host->cname()); jhost = Java_org_simgrid_msg_Host_getByName(env, cls_arg, jname); } @@ -340,7 +340,7 @@ JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getConsumedEnergy (JNIEnv *e { msg_host_t host = jhost_get_native(env, jhost); - if (!host) { + if (not host) { jxbt_throw_notbound(env, "host", jhost); return 0; } diff --git a/src/bindings/java/jmsg_process.cpp b/src/bindings/java/jmsg_process.cpp index 400ab15000..8fcbe02f34 100644 --- a/src/bindings/java/jmsg_process.cpp +++ b/src/bindings/java/jmsg_process.cpp @@ -100,14 +100,14 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID(JNIEnv * env, jcl { msg_process_t process = MSG_process_from_PID(pid); - if (!process) { + if (not process) { jxbt_throw_process_not_found(env, bprintf("PID = %d",static_cast(pid))); return nullptr; } jobject jprocess = jprocess_from_native(process); - if (!jprocess) { + if (not jprocess) { jxbt_throw_jni(env, "get process failed"); return nullptr; } @@ -118,14 +118,14 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID(JNIEnv * env, jcl JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, jobject jprocess, jobject jname) { msg_process_t process = jprocess_to_native(jprocess, env); - if (!process) { + if (not process) { jxbt_throw_notbound(env, "process", jprocess); return nullptr; } const char *name = env->GetStringUTFChars((jstring)jname, 0); const char *property = MSG_process_get_property_value(process, name); - if (!property) + if (not property) return nullptr; jobject jproperty = env->NewStringUTF(property); @@ -138,7 +138,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getCurrentProcess(JNIEnv * env, jclass cls) { jobject jprocess = jprocess_from_native(MSG_process_self()); - if (!jprocess) + if (not jprocess) jxbt_throw_jni(env, xbt_strdup("SIMIX_process_get_jprocess() failed")); return jprocess; @@ -148,7 +148,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_suspend(JNIEnv * env, jobjec { msg_process_t process = jprocess_to_native(jprocess, env); - if (!process) { + if (not process) { jxbt_throw_notbound(env, "process", jprocess); return; } @@ -163,7 +163,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_resume(JNIEnv * env, jobject { msg_process_t process = jprocess_to_native(jprocess, env); - if (!process) { + if (not process) { jxbt_throw_notbound(env, "process", jprocess); return; } @@ -177,7 +177,7 @@ 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 (!process) { + if (not process) { jxbt_throw_notbound(env, "process", jprocess); return; } @@ -189,7 +189,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart (JNIEnv *env, jobjec msg_process_t process = jprocess_to_native(jprocess, env); xbt_ex_t e; - if (!process) { + if (not process) { jxbt_throw_notbound(env, "process", jprocess); return; } @@ -206,7 +206,7 @@ JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended(JNIEnv * env { msg_process_t process = jprocess_to_native(jprocess, env); - if (!process) { + if (not process) { jxbt_throw_notbound(env, "process", jprocess); return 0; } @@ -250,7 +250,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_kill(JNIEnv * env, jobject j { /* get the native instances from the java ones */ msg_process_t process = jprocess_to_native(jprocess, env); - if (!process) { + if (not process) { jxbt_throw_notbound(env, "process", jprocess); return; } @@ -267,14 +267,14 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate(JNIEnv * env, jobjec { msg_process_t process = jprocess_to_native(jprocess, env); - if (!process) { + if (not process) { jxbt_throw_notbound(env, "process", jprocess); return; } msg_host_t host = jhost_get_native(env, jhost); - if (!host) { + if (not host) { jxbt_throw_notbound(env, "host", jhost); return; } diff --git a/src/bindings/java/jmsg_rngstream.cpp b/src/bindings/java/jmsg_rngstream.cpp index aa1a05013f..0bb54a2a22 100644 --- a/src/bindings/java/jmsg_rngstream.cpp +++ b/src/bindings/java/jmsg_rngstream.cpp @@ -16,7 +16,7 @@ jfieldID jrngstream_bind; RngStream jrngstream_to_native(JNIEnv *env, jobject jrngstream) { RngStream rngstream = (RngStream)(intptr_t)env->GetLongField(jrngstream, jrngstream_bind); - if (!rngstream) { + if (not rngstream) { jxbt_throw_notbound(env, "rngstream", jrngstream); return nullptr; } @@ -67,7 +67,7 @@ Java_org_simgrid_msg_RngStream_setPackageSeed(JNIEnv *env, jobject jrngstream, j JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_resetStart(JNIEnv *env, jobject jrngstream) { RngStream rngstream = jrngstream_to_native(env, jrngstream); - if (!rngstream) + if (not rngstream) return; RngStream_ResetStartStream(rngstream); @@ -75,7 +75,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_resetStart(JNIEnv *env, jo JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_resetStartSubstream(JNIEnv *env, jobject jrngstream) { RngStream rngstream = jrngstream_to_native(env, jrngstream); - if (!rngstream) + if (not rngstream) return; RngStream_ResetStartSubstream(rngstream); @@ -83,7 +83,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_resetStartSubstream(JNIEnv JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_resetNextSubstream(JNIEnv *env, jobject jrngstream) { RngStream rngstream = jrngstream_to_native(env, jrngstream); - if (!rngstream) + if (not rngstream) return; RngStream_ResetNextSubstream(rngstream); @@ -91,7 +91,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_resetNextSubstream(JNIEnv JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_setAntithetic(JNIEnv *env, jobject jrngstream, jboolean ja) { RngStream rngstream = jrngstream_to_native(env, jrngstream); - if (!rngstream) + if (not rngstream) return; if (ja == JNI_TRUE) { @@ -108,7 +108,7 @@ JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_RngStream_setSeed(JNIEnv *env, j env->GetIntArrayRegion(jseed, 0, 6, buffer); RngStream rngstream = jrngstream_to_native(env, jrngstream); - if (!rngstream) + if (not rngstream) return JNI_FALSE; // The C API expects unsigned long which are wider than int on LP64. @@ -124,7 +124,7 @@ JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_RngStream_setSeed(JNIEnv *env, j JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_advanceState(JNIEnv *env, jobject jrngstream, jint e, jint g) { RngStream rngstream = jrngstream_to_native(env, jrngstream); - if (!rngstream) + if (not rngstream) return; RngStream_AdvanceState(rngstream, (long)e, (long)g); @@ -132,7 +132,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_advanceState(JNIEnv *env, JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_RngStream_randU01(JNIEnv *env, jobject jrngstream) { RngStream rngstream = jrngstream_to_native(env, jrngstream); - if (!rngstream) + if (not rngstream) return 0; return (jdouble)RngStream_RandU01(rngstream); @@ -140,7 +140,7 @@ JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_RngStream_randU01(JNIEnv *env, jo JNIEXPORT jint JNICALL Java_org_simgrid_msg_RngStream_randInt(JNIEnv *env, jobject jrngstream, jint i, jint j) { RngStream rngstream = jrngstream_to_native(env, jrngstream); - if (!rngstream) + if (not rngstream) return 0; return (jint)RngStream_RandInt(rngstream, (int)i, (int)j); diff --git a/src/bindings/java/jmsg_storage.cpp b/src/bindings/java/jmsg_storage.cpp index 15bd3fe4ed..e38230cd64 100644 --- a/src/bindings/java/jmsg_storage.cpp +++ b/src/bindings/java/jmsg_storage.cpp @@ -6,7 +6,6 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "simgrid/msg.h" -#include "surf/surf_routing.h" #include "jmsg.h" #include "jmsg_storage.h" @@ -63,7 +62,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getByName(JNIEnv * env, j const char *name = env->GetStringUTFChars(jname, 0); storage = MSG_storage_get_by_name(name); - if (!storage) { /* invalid name */ + if (not storage) { /* invalid name */ jxbt_throw_storage_not_found(env, name); env->ReleaseStringUTFChars(jname, name); return nullptr; @@ -74,7 +73,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getByName(JNIEnv * env, j /* Instantiate a new java storage */ jstorage = jstorage_new_instance(env); - if (!jstorage) { + if (not jstorage) { jxbt_throw_jni(env, "java storage instantiation failed"); return nullptr; } @@ -82,7 +81,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getByName(JNIEnv * env, j /* get a global reference to the newly created storage */ jstorage = jstorage_ref(env, jstorage); - if (!jstorage) { + if (not jstorage) { jxbt_throw_jni(env, "new global ref allocation failed"); return nullptr; } @@ -105,7 +104,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getByName(JNIEnv * env, j JNIEXPORT jlong JNICALL Java_org_simgrid_msg_Storage_getSize(JNIEnv * env,jobject jstorage) { msg_storage_t storage = jstorage_get_native(env, jstorage); - if (!storage) { + if (not storage) { jxbt_throw_notbound(env, "storage", jstorage); return -1; } @@ -116,7 +115,7 @@ JNIEXPORT jlong JNICALL Java_org_simgrid_msg_Storage_getSize(JNIEnv * env,jobjec JNIEXPORT jlong JNICALL Java_org_simgrid_msg_Storage_getFreeSize(JNIEnv * env,jobject jstorage) { msg_storage_t storage = jstorage_get_native(env, jstorage); - if (!storage) { + if (not storage) { jxbt_throw_notbound(env, "storage", jstorage); return -1; } @@ -127,7 +126,7 @@ JNIEXPORT jlong JNICALL Java_org_simgrid_msg_Storage_getFreeSize(JNIEnv * env,jo JNIEXPORT jlong JNICALL Java_org_simgrid_msg_Storage_getUsedSize(JNIEnv * env,jobject jstorage) { msg_storage_t storage = jstorage_get_native(env, jstorage); - if (!storage) { + if (not storage) { jxbt_throw_notbound(env, "storage", jstorage); return -1; } @@ -138,14 +137,14 @@ JNIEXPORT jlong JNICALL Java_org_simgrid_msg_Storage_getUsedSize(JNIEnv * env,jo JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getProperty(JNIEnv *env, jobject jstorage, jobject jname) { msg_storage_t storage = jstorage_get_native(env, jstorage); - if (!storage) { + if (not storage) { jxbt_throw_notbound(env, "storage", jstorage); return nullptr; } const char *name = env->GetStringUTFChars((jstring) jname, 0); const char *property = MSG_storage_get_property_value(storage, name); - if (!property) { + if (not property) { return nullptr; } jobject jproperty = env->NewStringUTF(property); @@ -159,7 +158,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Storage_setProperty(JNIEnv *env, jobject jstorage, jobject jname, jobject jvalue) { msg_storage_t storage = jstorage_get_native(env, jstorage); - if (!storage) { + if (not storage) { jxbt_throw_notbound(env, "storage", jstorage); return; } @@ -177,12 +176,12 @@ Java_org_simgrid_msg_Storage_setProperty(JNIEnv *env, jobject jstorage, jobject JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getHost(JNIEnv * env,jobject jstorage) { msg_storage_t storage = jstorage_get_native(env, jstorage); - if (!storage) { + if (not storage) { jxbt_throw_notbound(env, "storage", jstorage); return nullptr; } const char *host_name = MSG_storage_get_host(storage); - if (!host_name) { + if (not host_name) { return nullptr; } jobject jhost_name = env->NewStringUTF(host_name); @@ -203,13 +202,13 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Storage_all(JNIEnv * env, jc jclass cls = jxbt_get_class(env, "org/simgrid/msg/Storage"); - if (!cls) { + if (not cls) { return nullptr; } jtable = env->NewObjectArray((jsize) count, cls, nullptr); - if (!jtable) { + if (not jtable) { jxbt_throw_jni(env, "Storages table allocation failed"); return nullptr; } diff --git a/src/bindings/java/jmsg_task.cpp b/src/bindings/java/jmsg_task.cpp index d6151845eb..47dfe47f93 100644 --- a/src/bindings/java/jmsg_task.cpp +++ b/src/bindings/java/jmsg_task.cpp @@ -105,7 +105,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_cancel(JNIEnv * env, jobject jt { msg_task_t ptask = jtask_to_native(jtask, env); - if (!ptask) { + if (not ptask) { jxbt_throw_notbound(env, "task", jtask); return; } @@ -119,7 +119,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_execute(JNIEnv * env, jobject j { msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return; } @@ -136,7 +136,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setBound(JNIEnv * env, jobject { msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return; } @@ -146,7 +146,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setBound(JNIEnv * env, jobject JNIEXPORT jstring JNICALL Java_org_simgrid_msg_Task_getName(JNIEnv * env, jobject jtask) { msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return nullptr; } @@ -159,7 +159,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_getSender(JNIEnv * env, jobj msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return nullptr; } @@ -176,7 +176,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_getSource(JNIEnv * env, jobj msg_host_t host; msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return nullptr; } @@ -185,7 +185,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_getSource(JNIEnv * env, jobj if (host == nullptr) { return nullptr; } - if (!host->extension(JAVA_HOST_LEVEL)) { + if (not host->extension(JAVA_HOST_LEVEL)) { jxbt_throw_jni(env, "MSG_task_get_source() failed"); return nullptr; } @@ -197,7 +197,7 @@ JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Task_getFlopsAmount(JNIEnv * env, { msg_task_t ptask = jtask_to_native(jtask, env); - if (!ptask) { + if (not ptask) { jxbt_throw_notbound(env, "task", jtask); return -1; } @@ -207,7 +207,7 @@ JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Task_getFlopsAmount(JNIEnv * env, JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setName(JNIEnv *env, jobject jtask, jobject jname) { msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return; } @@ -223,7 +223,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setPriority(JNIEnv * env, jobje { msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return; } @@ -234,7 +234,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setFlopsAmount (JNIEnv *env, jo { msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return; } @@ -245,7 +245,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setBytesAmount (JNIEnv *env, jo { msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return; } @@ -257,7 +257,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_sendBounded(JNIEnv * env,jobjec jdouble jtimeout,jdouble maxrate) { msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return; } @@ -299,7 +299,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receive(JNIEnv* env, jclass JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_irecv(JNIEnv * env, jclass cls, jstring jmailbox) { jclass comm_class = env->FindClass("org/simgrid/msg/Comm"); - if (!comm_class) + if (not comm_class) return nullptr; //pointer to store the task object pointer. @@ -308,7 +308,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_irecv(JNIEnv * env, jclass c /* There should be a cache here */ jobject jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor); - if (!jcomm) { + if (not jcomm) { jxbt_throw_jni(env, "Can't create a Comm object."); return nullptr; } @@ -354,14 +354,14 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_irecvBounded(JNIEnv * env, j jdouble rate) { jclass comm_class = env->FindClass("org/simgrid/msg/Comm"); - if (!comm_class) + if (not comm_class) return nullptr; // pointer to store the task object pointer. msg_task_t* task = xbt_new0(msg_task_t, 1); jobject jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor); - if (!jcomm) { + if (not jcomm) { jxbt_throw_jni(env, "Can't create a Comm object."); return nullptr; } @@ -383,14 +383,15 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_isend(JNIEnv *env, jobject j jclass comm_class = env->FindClass("org/simgrid/msg/Comm"); - if (!comm_class) return nullptr; + if (not comm_class) + return nullptr; jobject jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor); const char* mailbox = env->GetStringUTFChars(jmailbox, 0); msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { env->ReleaseStringUTFChars(jmailbox, mailbox); env->DeleteLocalRef(jcomm); jxbt_throw_notbound(env, "task", jtask); @@ -418,7 +419,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_isendBounded(JNIEnv *env, jo const char *mailbox; jclass comm_class = env->FindClass("org/simgrid/msg/Comm"); - if (!comm_class) + if (not comm_class) return nullptr; jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor); @@ -426,7 +427,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_isendBounded(JNIEnv *env, jo task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { env->ReleaseStringUTFChars(jmailbox, mailbox); env->DeleteLocalRef(jcomm); jxbt_throw_notbound(env, "task", jtask); @@ -449,7 +450,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_nativeFinalize(JNIEnv * env, jo { msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return; } @@ -474,7 +475,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_dsend(JNIEnv * env, jobject jta msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { env->ReleaseStringUTFChars(jalias, alias); jxbt_throw_notbound(env, "task", jtask); return; @@ -494,7 +495,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_dsendBounded(JNIEnv * env, jobj msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { env->ReleaseStringUTFChars(jalias, alias); jxbt_throw_notbound(env, "task", jtask); return; diff --git a/src/bindings/java/jmsg_vm.cpp b/src/bindings/java/jmsg_vm.cpp index 307b8f3db6..fc5da71197 100644 --- a/src/bindings/java/jmsg_vm.cpp +++ b/src/bindings/java/jmsg_vm.cpp @@ -101,11 +101,11 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_VM_all(JNIEnv* env, jclass c int count = vms.size(); jclass cls = jxbt_get_class(env, "org/simgrid/msg/VM"); - if (!cls) + if (not cls) return nullptr; jobjectArray jtable = env->NewObjectArray((jsize)count, cls, nullptr); - if (!jtable) { + if (not jtable) { jxbt_throw_jni(env, "Hosts table allocation failed"); return nullptr; } @@ -180,7 +180,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_VM_getVMByName(JNIEnv* env, jclas /* get the VM by name (VMs are just special hosts, unfortunately) */ msg_host_t host = MSG_host_by_name(name); - if (!host) { /* invalid name */ + if (not host) { /* invalid name */ jxbt_throw_host_not_found(env, name); env->ReleaseStringUTFChars(jname, name); return nullptr; diff --git a/src/bindings/java/jxbt_utilities.cpp b/src/bindings/java/jxbt_utilities.cpp index c735ff410c..128f0770a5 100644 --- a/src/bindings/java/jxbt_utilities.cpp +++ b/src/bindings/java/jxbt_utilities.cpp @@ -16,7 +16,7 @@ jclass jxbt_get_class(JNIEnv * env, const char *name) { jclass cls = env->FindClass(name); - if (!cls) { + if (not cls) { jxbt_throw_jni(env, std::string("Class ") + name + " not found"); return nullptr; } @@ -28,11 +28,11 @@ jmethodID jxbt_get_jmethod(JNIEnv * env, jclass cls, const char *name, const cha { jmethodID id; - if (!cls) + if (not cls) return 0; id = env->GetMethodID(cls, name, signature); - if (!id) { + if (not id) { jmethodID tostr_id = env->GetMethodID(cls, "getName", "()Ljava/lang/String;"); jstring jclassname = (jstring) env->CallObjectMethod(cls, tostr_id, nullptr); @@ -51,11 +51,11 @@ jmethodID jxbt_get_static_jmethod(JNIEnv * env, jclass cls, const char *name, co { jmethodID id; - if (!cls) + if (not cls) return 0; id = env->GetStaticMethodID(cls, name, signature); - if (!id) { + 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); @@ -75,12 +75,12 @@ jmethodID jxbt_get_static_smethod(JNIEnv * env, const char *classname, const cha jmethodID id; cls = jxbt_get_class(env, classname); - if (!cls) + if (not cls) return 0; id = env->GetStaticMethodID(cls, name, signature); - if (!id) { + if (not id) { jxbt_throw_jni(env, std::string("Cannot find static method") + name + "(" + signature + ") in " + classname); return 0; } @@ -93,12 +93,12 @@ jmethodID jxbt_get_smethod(JNIEnv * env, const char *classname, const char *name jmethodID id; cls = jxbt_get_class(env, classname); - if (!cls) + if (not cls) return 0; id = env->GetMethodID(cls, name, signature); - if (!id) { + if (not id) { jxbt_throw_jni(env, std::string("Cannot find method") + name + "(" + signature + ") in " + classname); return 0; } @@ -109,12 +109,12 @@ jfieldID jxbt_get_jfield(JNIEnv * env, jclass cls, const char *name, const char { jfieldID id; - if (!cls) + if (not cls) return 0; id = env->GetFieldID(cls, name, signature); - if (!id) { + if (not id) { jmethodID getname_id = env->GetMethodID(cls, "getName", "()Ljava/lang/String;"); jstring jclassname = (jstring) env->CallObjectMethod(cls, getname_id, nullptr); const char *classname = env->GetStringUTFChars(jclassname, 0); @@ -134,12 +134,12 @@ jfieldID jxbt_get_sfield(JNIEnv * env, const char *classname, const char *name, jclass cls = jxbt_get_class(env, classname); jfieldID id; - if (!cls) + if (not cls) return 0; id = env->GetFieldID(cls, name, signature); - if (!id) { + if (not id) { jxbt_throw_jni(env, std::string("Cannot find field") + signature + " " + name + " in " + classname); return 0; } diff --git a/src/bindings/java/org/simgrid/NativeLib.java b/src/bindings/java/org/simgrid/NativeLib.java index 11578d490b..6739dba4b3 100644 --- a/src/bindings/java/org/simgrid/NativeLib.java +++ b/src/bindings/java/org/simgrid/NativeLib.java @@ -1,4 +1,4 @@ -/* Copyright (c) 2014-2016. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2014-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -20,7 +20,7 @@ import java.nio.file.Path; */ public final class NativeLib { private static boolean isNativeInited = false; - static Path tempDir = null; // where the embeeded libraries are unpacked before loading them + private static Path tempDir = null; // where the embeeded libraries are unpacked before loading them /** A static-only "class" don't need no constructor */ private NativeLib() { diff --git a/src/bindings/java/org/simgrid/msg/Process.java b/src/bindings/java/org/simgrid/msg/Process.java index 4e9247b0c4..355856d916 100644 --- a/src/bindings/java/org/simgrid/msg/Process.java +++ b/src/bindings/java/org/simgrid/msg/Process.java @@ -51,11 +51,8 @@ public abstract class Process implements Runnable { /** Time at which the process should be created */ protected double startTime = 0; - /** Time at which the process should be killed. - * - * Set at creation, and used internally by SimGrid - */ - private double killTime = -1; + /** Time at which the process should be killed */ + private double killTime = -1; // Used from the C world private String name = null; @@ -116,9 +113,9 @@ public abstract class Process implements Runnable { public Process(Host host, String name, String[]args) { if (host == null) - throw new NullPointerException("Cannot create a process on the null host"); + throw new IllegalArgumentException("Cannot create a process on the null host"); if (name == null) - throw new NullPointerException("Process name cannot be null"); + throw new IllegalArgumentException("Process name cannot be null"); this.host = host; this.name = name; diff --git a/src/bindings/java/org/simgrid/msg/Storage.java b/src/bindings/java/org/simgrid/msg/Storage.java index ea762968b3..4b15bba5e5 100644 --- a/src/bindings/java/org/simgrid/msg/Storage.java +++ b/src/bindings/java/org/simgrid/msg/Storage.java @@ -15,18 +15,11 @@ public class Storage { * a native storage. Even if this attribute is public you must never * access to it. */ - private long bind; + private long bind = 0; /** Storage name */ protected String name; - /** User data. */ - private Object data; - protected Storage() { - this.bind = 0; - this.data = null; - } - @Override public String toString (){ return this.name; diff --git a/src/bindings/java/org/simgrid/msg/Task.java b/src/bindings/java/org/simgrid/msg/Task.java index 0dec155c5b..a82ce2f7c2 100644 --- a/src/bindings/java/org/simgrid/msg/Task.java +++ b/src/bindings/java/org/simgrid/msg/Task.java @@ -74,13 +74,13 @@ public class Task { */ public Task(String name, Host[]hosts, double[]flopsAmount, double[]bytesAmount) { if (flopsAmount == null) - throw new NullPointerException("Parallel task flops amounts is null"); + throw new IllegalArgumentException("Parallel task flops amounts is null"); if (bytesAmount == null) - throw new NullPointerException("Parallel task bytes amounts is null"); + throw new IllegalArgumentException("Parallel task bytes amounts is null"); if (hosts == null) - throw new NullPointerException("Host list is null"); + throw new IllegalArgumentException("Host list is null"); if (name == null) - throw new NullPointerException("Parallel task name is null"); + throw new IllegalArgumentException("Parallel task name is null"); parallelCreate(name, hosts, flopsAmount, bytesAmount); this.name = name; diff --git a/src/bindings/lua/lua_debug.cpp b/src/bindings/lua/lua_debug.cpp index 79b1bc5c06..df54f3f135 100644 --- a/src/bindings/lua/lua_debug.cpp +++ b/src/bindings/lua/lua_debug.cpp @@ -198,7 +198,7 @@ void* sglua_checkudata_debug(lua_State* L, int ud, const char* tname) XBT_DEBUG("Checking the task's metatable: expected %p, found %p", correct_mt, actual_mt); sglua_stack_dump(L, "my_checkudata: "); - if (p == nullptr || !lua_getmetatable(L, ud) || !lua_rawequal(L, -1, -2)) + if (p == nullptr || not lua_getmetatable(L, ud) || not lua_rawequal(L, -1, -2)) XBT_ERROR("Error: Userdata is nullptr, couldn't find metatable or top of stack does not equal element below it."); lua_pop(L, 2); return p; diff --git a/src/bindings/lua/lua_host.cpp b/src/bindings/lua/lua_host.cpp index 71484a4251..4d4eac910a 100644 --- a/src/bindings/lua/lua_host.cpp +++ b/src/bindings/lua/lua_host.cpp @@ -34,7 +34,7 @@ sg_host_t sglua_check_host(lua_State * L, int index) if (pi == nullptr) XBT_ERROR("luaL_checkudata() returned nullptr"); sg_host_t ht = *pi; - if (!ht) + if (not ht) luaL_error(L, "null Host"); return ht; } diff --git a/src/bindings/lua/lua_platf.cpp b/src/bindings/lua/lua_platf.cpp index dea2bab15a..6f9f856f35 100644 --- a/src/bindings/lua/lua_platf.cpp +++ b/src/bindings/lua/lua_platf.cpp @@ -10,7 +10,6 @@ #include "src/kernel/routing/NetPoint.hpp" #include "src/surf/network_interface.hpp" #include "src/surf/xml/platf_private.hpp" -#include "surf/surf_routing.h" #include #include @@ -94,9 +93,9 @@ int console_add_backbone(lua_State *L) { lua_pushstring(L, "sharing_policy"); type = lua_gettable(L, -2); const char* policy = lua_tostring(L, -1); - if (policy && !strcmp(policy,"FULLDUPLEX")) { + if (policy && not strcmp(policy, "FULLDUPLEX")) { link.policy = SURF_LINK_FULLDUPLEX; - } else if (policy && !strcmp(policy,"FATPIPE")) { + } else if (policy && not strcmp(policy, "FATPIPE")) { link.policy = SURF_LINK_FATPIPE; } else { link.policy = SURF_LINK_SHARED; @@ -173,8 +172,8 @@ int console_add_host(lua_State *L) { // get core lua_pushstring(L, "core"); lua_gettable(L, -2); - if(!lua_isnumber(L,-1)) - host.core_amount = 1;// Default value + if (not lua_isnumber(L, -1)) + host.core_amount = 1; // Default value else host.core_amount = lua_tonumber(L, -1); if (host.core_amount == 0) @@ -270,9 +269,9 @@ int console_add_link(lua_State *L) { lua_gettable(L, -2); policy = lua_tostring(L, -1); lua_pop(L, 1); - if (policy && !strcmp(policy,"FULLDUPLEX")) { + if (policy && not strcmp(policy, "FULLDUPLEX")) { link.policy = SURF_LINK_FULLDUPLEX; - } else if (policy && !strcmp(policy,"FATPIPE")) { + } else if (policy && not strcmp(policy, "FATPIPE")) { link.policy = SURF_LINK_FATPIPE; } else { link.policy = SURF_LINK_SHARED; @@ -473,13 +472,20 @@ int console_AS_open(lua_State *L) { lua_pop(L, 1); int mode_int = A_surfxml_AS_routing_None; - if(!strcmp(mode,"Full")) mode_int = A_surfxml_AS_routing_Full; - else if(!strcmp(mode,"Floyd")) mode_int = A_surfxml_AS_routing_Floyd; - else if(!strcmp(mode,"Dijkstra")) mode_int = A_surfxml_AS_routing_Dijkstra; - else if(!strcmp(mode,"DijkstraCache")) mode_int = A_surfxml_AS_routing_DijkstraCache; - else if(!strcmp(mode,"Vivaldi")) mode_int = A_surfxml_AS_routing_Vivaldi; - else if(!strcmp(mode,"Cluster")) mode_int = A_surfxml_AS_routing_Cluster; - else if(!strcmp(mode,"none")) mode_int = A_surfxml_AS_routing_None; + if (not strcmp(mode, "Full")) + mode_int = A_surfxml_AS_routing_Full; + else if (not strcmp(mode, "Floyd")) + mode_int = A_surfxml_AS_routing_Floyd; + else if (not strcmp(mode, "Dijkstra")) + mode_int = A_surfxml_AS_routing_Dijkstra; + else if (not strcmp(mode, "DijkstraCache")) + mode_int = A_surfxml_AS_routing_DijkstraCache; + else if (not strcmp(mode, "Vivaldi")) + mode_int = A_surfxml_AS_routing_Vivaldi; + else if (not strcmp(mode, "Cluster")) + mode_int = A_surfxml_AS_routing_Cluster; + else if (not strcmp(mode, "none")) + mode_int = A_surfxml_AS_routing_None; else xbt_die("Don't have the model name '%s'",mode); s_sg_platf_AS_cbarg_t AS; diff --git a/src/include/surf/maxmin.h b/src/include/surf/maxmin.h index 6ba38d1ca2..9a1ffb310b 100644 --- a/src/include/surf/maxmin.h +++ b/src/include/surf/maxmin.h @@ -12,6 +12,12 @@ #include "surf/datatypes.h" #include +namespace simgrid { +namespace surf { +class Action; +} +} + /** @addtogroup SURF_lmm * @details * A linear maxmin solver to resolve inequations systems. @@ -233,8 +239,9 @@ XBT_PUBLIC(int) lmm_constraint_concurrency_maximum_get(lmm_constraint_t cnst); * @param bound The maximum value of the variable (-1.0 if no maximum value) * @param number_of_constraints The maximum number of constraint to associate to the variable */ -XBT_PUBLIC(lmm_variable_t) lmm_variable_new(lmm_system_t sys, void *id, double weight_value, double bound, - int number_of_constraints); +XBT_PUBLIC(lmm_variable_t) +lmm_variable_new(lmm_system_t sys, simgrid::surf::Action* id, double weight_value, double bound, + int number_of_constraints); /** * @brief Free a variable * @param sys The system associated to the variable diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 09941a4c09..4a3c1094ba 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -16,7 +16,6 @@ #include "surf/surf_routing.h" #include "surf/datatypes.h" #include "xbt/lib.h" -#include "surf/surf_routing.h" #include "simgrid/datatypes.h" #include "simgrid/forward.h" @@ -52,7 +51,7 @@ typedef simgrid::surf::CpuModel surf_CpuModel; typedef simgrid::surf::Cpu surf_Cpu; typedef simgrid::surf::HostModel surf_HostModel; typedef simgrid::surf::NetworkModel surf_NetworkModel; -typedef simgrid::surf::Storage surf_Storage; +typedef simgrid::surf::StorageImpl surf_Storage; typedef simgrid::surf::StorageModel surf_StorageModel; typedef simgrid::surf::Resource surf_Resource; typedef simgrid::surf::HostImpl surf_Host; @@ -65,7 +64,7 @@ typedef struct surf_CpuModel surf_CpuModel; typedef struct surf_Cpu surf_Cpu; typedef struct surf_HostModel surf_HostModel; typedef struct surf_NetworkModel surf_NetworkModel; -typedef struct surf_Storage surf_Storage; +typedef struct surf_StorageImpl surf_Storage; typedef struct surf_StorageModel surf_StorageModel; typedef struct surf_Resource surf_Resource; typedef struct surf_Host surf_Host; diff --git a/src/instr/instr_config.cpp b/src/instr/instr_config.cpp index 8b923a69b1..e6eb6f5182 100644 --- a/src/instr/instr_config.cpp +++ b/src/instr/instr_config.cpp @@ -105,9 +105,9 @@ int TRACE_start() /* open the trace file(s) */ const char* format = xbt_cfg_get_string(OPT_TRACING_FORMAT); XBT_DEBUG("Tracing format %s\n", format); - if(!strcmp(format, "Paje")){ + if (not strcmp(format, "Paje")) { TRACE_paje_start(); - }else if (!strcmp(format, "TI")){ + } else if (not strcmp(format, "TI")) { instr_fmt_type = instr_fmt_TI; TRACE_TI_start(); }else{ @@ -134,7 +134,7 @@ int TRACE_start() int TRACE_end() { int retval; - if (!trace_active) { + if (not trace_active) { retval = 1; } else { retval = 0; @@ -161,9 +161,9 @@ int TRACE_end() /* close the trace files */ const char* format = xbt_cfg_get_string(OPT_TRACING_FORMAT); XBT_DEBUG("Tracing format %s\n", format); - if(!strcmp(format, "Paje")){ + if (not strcmp(format, "Paje")) { TRACE_paje_end(); - }else if (!strcmp(format, "TI")){ + } else if (not strcmp(format, "TI")) { TRACE_TI_end(); }else{ xbt_die("Unknown trace format :%s ", format); @@ -605,7 +605,7 @@ static int previous_trace_state = -1; void instr_pause_tracing () { previous_trace_state = trace_enabled; - if (!TRACE_is_enabled()){ + if (not TRACE_is_enabled()) { XBT_DEBUG ("Tracing is already paused, therefore do nothing."); }else{ XBT_DEBUG ("Tracing is being paused."); diff --git a/src/instr/instr_interface.cpp b/src/instr/instr_interface.cpp index 7946c2be86..79dc5d33dc 100644 --- a/src/instr/instr_interface.cpp +++ b/src/instr/instr_interface.cpp @@ -30,7 +30,7 @@ extern xbt_dict_t trivaEdgeTypes; static xbt_dynar_t instr_dict_to_dynar (xbt_dict_t filter) { - if (!TRACE_is_enabled() || !TRACE_needs_platform()) + if (not TRACE_is_enabled() || not TRACE_needs_platform()) return nullptr; xbt_dynar_t ret = xbt_dynar_new (sizeof(char*), &xbt_free_ref); @@ -81,10 +81,10 @@ void TRACE_category(const char *category) void TRACE_category_with_color (const char *category, const char *color) { /* safe switches. tracing has to be activated and if platform is not traced, we can't deal with categories */ - if (!TRACE_is_enabled() || !TRACE_needs_platform()) + if (not TRACE_is_enabled() || not TRACE_needs_platform()) return; - if (!(TRACE_categorized() && category != nullptr)) + if (not(TRACE_categorized() && category != nullptr)) return; //check if category is already created @@ -95,7 +95,7 @@ void TRACE_category_with_color (const char *category, const char *color) //define final_color char final_color[INSTR_DEFAULT_STR_SIZE]; - if (!color){ + if (not color) { //generate a random color double red = drand48(); double green = drand48(); @@ -125,7 +125,7 @@ void TRACE_category_with_color (const char *category, const char *color) */ xbt_dynar_t TRACE_get_categories () { - if (!TRACE_is_enabled() || !TRACE_categorized()) + if (not TRACE_is_enabled() || not TRACE_categorized()) return nullptr; return instr_dict_to_dynar (created_categories); @@ -144,10 +144,10 @@ xbt_dynar_t TRACE_get_categories () void TRACE_declare_mark(const char *mark_type) { /* safe switchs. tracing has to be activated and if platform is not traced, we can't deal with marks */ - if (!TRACE_is_enabled() || !TRACE_needs_platform()) + if (not TRACE_is_enabled() || not TRACE_needs_platform()) return; - if (!mark_type) + if (not mark_type) THROWF (tracing_error, 1, "mark_type is nullptr"); //check if mark_type is already declared @@ -178,21 +178,21 @@ void TRACE_declare_mark(const char *mark_type) void TRACE_declare_mark_value_with_color (const char *mark_type, const char *mark_value, const char *mark_color) { /* safe switches. tracing has to be activated and if platform is not traced, we can't deal with marks */ - if (!TRACE_is_enabled() || !TRACE_needs_platform()) + if (not TRACE_is_enabled() || not TRACE_needs_platform()) return; - if (!mark_type) + if (not mark_type) THROWF (tracing_error, 1, "mark_type is nullptr"); - if (!mark_value) + if (not mark_value) THROWF (tracing_error, 1, "mark_value is nullptr"); type_t type = PJ_type_get (mark_type, PJ_type_get_root()); - if (!type){ + if (not type) { THROWF (tracing_error, 1, "mark_type with name (%s) is not declared", mark_type); } char white[INSTR_DEFAULT_STR_SIZE] = "1.0 1.0 1.0"; - if (!mark_color) + if (not mark_color) mark_color = white; XBT_DEBUG("MARK,declare_value %s %s %s", mark_type, mark_value, mark_color); @@ -233,17 +233,17 @@ void TRACE_declare_mark_value (const char *mark_type, const char *mark_value) void TRACE_mark(const char *mark_type, const char *mark_value) { /* safe switches. tracing has to be activated and if platform is not traced, we can't deal with marks */ - if (!TRACE_is_enabled() || !TRACE_needs_platform()) + if (not TRACE_is_enabled() || not TRACE_needs_platform()) return; - if (!mark_type) + if (not mark_type) THROWF (tracing_error, 1, "mark_type is nullptr"); - if (!mark_value) + if (not mark_value) THROWF (tracing_error, 1, "mark_value is nullptr"); //check if mark_type is already declared type_t type = PJ_type_get (mark_type, PJ_type_get_root()); - if (!type){ + if (not type) { THROWF (tracing_error, 1, "mark_type with name (%s) is not declared", mark_type); } @@ -261,7 +261,7 @@ void TRACE_mark(const char *mark_type, const char *mark_value) */ xbt_dynar_t TRACE_get_marks () { - if (!TRACE_is_enabled()) + if (not TRACE_is_enabled()) return nullptr; return instr_dict_to_dynar (declared_marks); @@ -271,13 +271,13 @@ static void instr_user_variable(double time, const char *resource, const char *v double value, InstrUserVariable what, const char *color, xbt_dict_t filter) { /* safe switches. tracing has to be activated and if platform is not traced, we don't allow user variables */ - if (!TRACE_is_enabled() || !TRACE_needs_platform()) + if (not TRACE_is_enabled() || not TRACE_needs_platform()) return; //check if variable is already declared char *created = (char*)xbt_dict_get_or_null(filter, variable); if (what == INSTR_US_DECLARE){ - if (!created) { // not declared yet + if (not created) { // not declared yet xbt_dict_set (filter, variable, xbt_strdup("1"), nullptr); instr_new_user_variable_type (father_type, variable, color); } @@ -309,11 +309,11 @@ static void instr_user_srcdst_variable(double time, const char *src, const char const char *father_type, double value, InstrUserVariable what) { sg_netpoint_t src_elm = sg_netpoint_by_name_or_null(src); - if(!src_elm) + if (not src_elm) xbt_die("Element '%s' not found!",src); sg_netpoint_t dst_elm = sg_netpoint_by_name_or_null(dst); - if(!dst_elm) + if (not dst_elm) xbt_die("Element '%s' not found!",dst); std::vector route; @@ -336,7 +336,7 @@ static void instr_user_srcdst_variable(double time, const char *src, const char int TRACE_platform_graph_export_graphviz (const char *filename) { /* returns 1 if successful, 0 otherwise */ - if (!TRACE_is_enabled()) + if (not TRACE_is_enabled()) return 0; xbt_graph_t g = instr_routing_platform_graph(); if (g == nullptr) diff --git a/src/instr/instr_paje_containers.cpp b/src/instr/instr_paje_containers.cpp index 9b50d75e26..f024629ae9 100644 --- a/src/instr/instr_paje_containers.cpp +++ b/src/instr/instr_paje_containers.cpp @@ -203,7 +203,7 @@ void PJ_container_free (container_t container) TRACE_paje_dump_buffer(1); //trace my destruction - if (!TRACE_disable_destroy() && container != PJ_container_get_root()){ + if (not TRACE_disable_destroy() && container != PJ_container_get_root()) { //do not trace the container destruction if user requests //or if the container is root new DestroyContainerEvent(container); @@ -245,7 +245,7 @@ void PJ_container_free_all () rootContainer = nullptr; //checks - if (!xbt_dict_is_empty(allContainers)){ + if (not xbt_dict_is_empty(allContainers)) { THROWF(tracing_error, 0, "some containers still present even after destroying all of them"); } } diff --git a/src/instr/instr_paje_trace.cpp b/src/instr/instr_paje_trace.cpp index ee0c3b6fc7..ae772d9106 100644 --- a/src/instr/instr_paje_trace.cpp +++ b/src/instr/instr_paje_trace.cpp @@ -44,18 +44,20 @@ void buffer_debug(std::vector *buf); void dump_comment (const char *comment) { - if (!strlen(comment)) return; + if (not strlen(comment)) + return; fprintf (tracing_file, "# %s\n", comment); } void dump_comment_file (const char *filename) { - if (!strlen(filename)) return; + if (not strlen(filename)) + return; FILE *file = fopen (filename, "r"); - if (!file){ + if (not file) { THROWF (system_error, 1, "Comment file %s could not be opened for reading.", filename); } - while (!feof(file)){ + while (not feof(file)) { char c; c = fgetc(file); if (feof(file)) break; @@ -74,7 +76,8 @@ double TRACE_last_timestamp_to_dump = 0; //dumps the trace file until the timestamp TRACE_last_timestamp_to_dump void TRACE_paje_dump_buffer (int force) { - if (!TRACE_is_enabled()) return; + if (not TRACE_is_enabled()) + return; XBT_DEBUG("%s: dump until %f. starts", __FUNCTION__, TRACE_last_timestamp_to_dump); if (force){ for (auto event : buffer){ @@ -147,7 +150,6 @@ static void insert_into_buffer (PajeEvent* tbi) if (e1->timestamp <= tbi->timestamp) break; } - buffer.insert(i.base(), tbi); if (i == buffer.rend()) XBT_DEBUG("%s: inserted at beginning", __FUNCTION__); else if (i == buffer.rbegin()) @@ -155,6 +157,7 @@ static void insert_into_buffer (PajeEvent* tbi) else XBT_DEBUG("%s: inserted at pos= %zd from its end", __FUNCTION__, std::distance(buffer.rbegin(),i)); + buffer.insert(i.base(), tbi); buffer_debug(&buffer); } @@ -244,7 +247,6 @@ void DefineContainerEvent::print() { } - DefineVariableTypeEvent::DefineVariableTypeEvent(type_t type) { this->event_type = PAJE_DefineVariableType; @@ -259,21 +261,19 @@ DefineVariableTypeEvent::DefineVariableTypeEvent(type_t type) } void DefineVariableTypeEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - stream << " " << type->id - << " " << type->father->id - << " " << type->name; - if (type->color) - stream << " \"" << type->color << "\""; - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } + if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << (int)this->event_type; + stream << " " << type->id << " " << type->father->id << " " << type->name; + if (type->color) + stream << " \"" << type->color << "\""; + print_row(); + } else if (instr_fmt_type == instr_fmt_TI) { + /* Nothing to do */ + } else { + THROW_IMPOSSIBLE; + } } DefineStateTypeEvent::DefineStateTypeEvent(type_t type) @@ -304,35 +304,31 @@ DefineEventTypeEvent::DefineEventTypeEvent(type_t type) void DefineStateTypeEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - stream << " " << type->id - << " " << type->father->id - << " " << type->name; - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } + if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << (int)this->event_type; + stream << " " << type->id << " " << type->father->id << " " << type->name; + print_row(); + } else if (instr_fmt_type == instr_fmt_TI) { + /* Nothing to do */ + } else { + THROW_IMPOSSIBLE; + } } void DefineEventTypeEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - stream << " " << type->id - << " " << type->father->id - << " " << type->name; - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } + if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << (int)this->event_type; + stream << " " << type->id << " " << type->father->id << " " << type->name; + print_row(); + } else if (instr_fmt_type == instr_fmt_TI) { + /* Nothing to do */ + } else { + THROW_IMPOSSIBLE; + } } DefineLinkTypeEvent::DefineLinkTypeEvent(type_t type, type_t source, type_t dest) @@ -351,21 +347,17 @@ DefineLinkTypeEvent::DefineLinkTypeEvent(type_t type, type_t source, type_t dest } void DefineLinkTypeEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - stream << " " << type->id - << " " << type->father->id - << " " << source->id - << " " << dest->id - << " " << type->name; - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } + if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << (int)this->event_type; + stream << " " << type->id << " " << type->father->id << " " << source->id << " " << dest->id << " " << type->name; + print_row(); + } else if (instr_fmt_type == instr_fmt_TI) { + /* Nothing to do */ + } else { + THROW_IMPOSSIBLE; + } } DefineEntityValueEvent::DefineEntityValueEvent (val_t value) @@ -383,21 +375,19 @@ DefineEntityValueEvent::DefineEntityValueEvent (val_t value) void DefineEntityValueEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - stream << " " << value->id - << " " << value->father->id - << " " << value->name; - if(value->color) - stream << " \"" << value->color << "\""; - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } + if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << (int)this->event_type; + stream << " " << value->id << " " << value->father->id << " " << value->name; + if (value->color) + stream << " \"" << value->color << "\""; + print_row(); + } else if (instr_fmt_type == instr_fmt_TI) { + /* Nothing to do */ + } else { + THROW_IMPOSSIBLE; + } } CreateContainerEvent::CreateContainerEvent (container_t container) @@ -413,47 +403,45 @@ CreateContainerEvent::CreateContainerEvent (container_t container) } void CreateContainerEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - print_timestamp(this); - stream << " " << container->id - << " " << container->type->id - << " " << container->father->id - << " \"" << container->name << "\""; + if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << (int)this->event_type; + print_timestamp(this); + stream << " " << container->id << " " << container->type->id << " " << container->father->id << " \"" + << container->name << "\""; + + print_row(); + } else if (instr_fmt_type == instr_fmt_TI) { + // if we are in the mode with only one file + static FILE* ti_unique_file = nullptr; + + if (tracing_files == nullptr) { + tracing_files = xbt_dict_new_homogeneous(nullptr); + // generate unique run id with time + prefix = xbt_os_time(); + } - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - //if we are in the mode with only one file - static FILE *ti_unique_file = nullptr; - - if (tracing_files == nullptr) { - tracing_files = xbt_dict_new_homogeneous(nullptr); - //generate unique run id with time - prefix = xbt_os_time(); - } - - if (!xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || ti_unique_file == nullptr) { - char *folder_name = bprintf("%s_files", TRACE_get_filename()); - char *filename = bprintf("%s/%f_%s.txt", folder_name, prefix, container->name); + if (not xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || ti_unique_file == nullptr) { + char* folder_name = bprintf("%s_files", TRACE_get_filename()); + char* filename = bprintf("%s/%f_%s.txt", folder_name, prefix, container->name); #ifdef WIN32 - _mkdir(folder_name); + _mkdir(folder_name); #else - mkdir(folder_name, S_IRWXU | S_IRWXG | S_IRWXO); + mkdir(folder_name, S_IRWXU | S_IRWXG | S_IRWXO); #endif - ti_unique_file = fopen(filename, "w"); - xbt_assert(ti_unique_file, "Tracefile %s could not be opened for writing: %s", filename, strerror(errno)); - fprintf(tracing_file, "%s\n", filename); + ti_unique_file = fopen(filename, "w"); + xbt_assert(ti_unique_file, "Tracefile %s could not be opened for writing: %s", filename, strerror(errno)); + fprintf(tracing_file, "%s\n", filename); - xbt_free(folder_name); - xbt_free(filename); - } + xbt_free(folder_name); + xbt_free(filename); + } - xbt_dict_set(tracing_files, container->name, (void *) ti_unique_file, nullptr); - } else { - THROW_IMPOSSIBLE; - } + xbt_dict_set(tracing_files, container->name, (void*)ti_unique_file, nullptr); + } else { + THROW_IMPOSSIBLE; + } } DestroyContainerEvent::DestroyContainerEvent (container_t container) @@ -469,24 +457,23 @@ DestroyContainerEvent::DestroyContainerEvent (container_t container) } void DestroyContainerEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - print_timestamp(this); - stream << " " << container->type->id - << " " << container->id; - - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - if (!xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file")|| xbt_dict_length(tracing_files) == 1) { - FILE* f = (FILE*)xbt_dict_get_or_null(tracing_files, container->name); - fclose(f); - } - xbt_dict_remove(tracing_files, container->name); - } else { - THROW_IMPOSSIBLE; - } + if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << (int)this->event_type; + print_timestamp(this); + stream << " " << container->type->id << " " << container->id; + + print_row(); + } else if (instr_fmt_type == instr_fmt_TI) { + if (not xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || xbt_dict_length(tracing_files) == 1) { + FILE* f = (FILE*)xbt_dict_get_or_null(tracing_files, container->name); + fclose(f); + } + xbt_dict_remove(tracing_files, container->name); + } else { + THROW_IMPOSSIBLE; + } } SetVariableEvent::SetVariableEvent (double timestamp, container_t container, type_t type, double value) @@ -503,20 +490,18 @@ SetVariableEvent::SetVariableEvent (double timestamp, container_t container, typ } void SetVariableEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - print_timestamp(this); - stream << " " << type->id - << " " << container->id - << " " << value; - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } + if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << (int)this->event_type; + print_timestamp(this); + stream << " " << type->id << " " << container->id << " " << value; + print_row(); + } else if (instr_fmt_type == instr_fmt_TI) { + /* Nothing to do */ + } else { + THROW_IMPOSSIBLE; + } } AddVariableEvent::AddVariableEvent (double timestamp, container_t container, type_t type, double value) @@ -533,20 +518,18 @@ AddVariableEvent::AddVariableEvent (double timestamp, container_t container, typ } void AddVariableEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - print_timestamp(this); - stream << " " << type->id - << " " << container->id - << " " << value; - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } + if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << (int)this->event_type; + print_timestamp(this); + stream << " " << type->id << " " << container->id << " " << value; + print_row(); + } else if (instr_fmt_type == instr_fmt_TI) { + /* Nothing to do */ + } else { + THROW_IMPOSSIBLE; + } } SubVariableEvent::SubVariableEvent (double timestamp, container_t container, type_t type, double value) @@ -563,20 +546,18 @@ SubVariableEvent::SubVariableEvent (double timestamp, container_t container, typ } void SubVariableEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - print_timestamp(this); - stream << " " << type->id - << " " << container->id - << " " << value; - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } + if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << (int)this->event_type; + print_timestamp(this); + stream << " " << type->id << " " << container->id << " " << value; + print_row(); + } else if (instr_fmt_type == instr_fmt_TI) { + /* Nothing to do */ + } else { + THROW_IMPOSSIBLE; + } } SetStateEvent::SetStateEvent (double timestamp, container_t container, type_t type, val_t value) @@ -601,26 +582,24 @@ SetStateEvent::SetStateEvent (double timestamp, container_t container, type_t ty } void SetStateEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - print_timestamp(this); - stream << " " << type->id - << " " << container->id; - stream << " " <id; + if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << (int)this->event_type; + print_timestamp(this); + stream << " " << type->id << " " << container->id; + stream << " " << value->id; #if HAVE_SMPI - if (xbt_cfg_get_boolean("smpi/trace-call-location")) { - stream << " \"" << filename - << "\" " << linenumber; - } + if (xbt_cfg_get_boolean("smpi/trace-call-location")) { + stream << " \"" << filename << "\" " << linenumber; + } #endif - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } + print_row(); + } else if (instr_fmt_type == instr_fmt_TI) { + /* Nothing to do */ + } else { + THROW_IMPOSSIBLE; + } } PushStateEvent::PushStateEvent (double timestamp, container_t container, type_t type, val_t value, void* extra) @@ -649,168 +628,165 @@ PushStateEvent::PushStateEvent (double timestamp, container_t container, type_t : PushStateEvent(timestamp, container, type, value, nullptr) {} void PushStateEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - print_timestamp(this); - stream << " " << type->id - << " " << container->id; - stream << " " <id; - - if (TRACE_display_sizes()) { - stream << " "; - if (extra_ != nullptr) { - stream << static_cast(extra_)->send_size; - } - else { - stream << 0; - } - } + if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << (int)this->event_type; + print_timestamp(this); + stream << " " << type->id << " " << container->id; + stream << " " << value->id; + + if (TRACE_display_sizes()) { + stream << " "; + if (extra_ != nullptr) { + stream << static_cast(extra_)->send_size; + } else { + stream << 0; + } + } #if HAVE_SMPI - if (xbt_cfg_get_boolean("smpi/trace-call-location")) { - stream << " \"" << filename - << "\" " << linenumber; - } + if (xbt_cfg_get_boolean("smpi/trace-call-location")) { + stream << " \"" << filename << "\" " << linenumber; + } #endif - print_row(); + print_row(); + + if (extra_ != nullptr) { + if (static_cast(extra_)->sendcounts != nullptr) + xbt_free(static_cast(extra_)->sendcounts); + if (static_cast(extra_)->recvcounts != nullptr) + xbt_free(static_cast(extra_)->recvcounts); + xbt_free(extra_); + } + } else if (instr_fmt_type == instr_fmt_TI) { + if (extra_ == nullptr) + return; + instr_extra_data extra = (instr_extra_data)extra_; + + char* process_id = nullptr; + // FIXME: dirty extract "rank-" from the name, as we want the bare process id here + if (strstr(container->name, "rank-") == nullptr) + process_id = xbt_strdup(container->name); + else + process_id = xbt_strdup(container->name + 5); + + FILE* trace_file = (FILE*)xbt_dict_get(tracing_files, container->name); + + switch (extra->type) { + case TRACING_INIT: + fprintf(trace_file, "%s init\n", process_id); + break; + case TRACING_FINALIZE: + fprintf(trace_file, "%s finalize\n", process_id); + break; + case TRACING_SEND: + fprintf(trace_file, "%s send %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1); + break; + case TRACING_ISEND: + fprintf(trace_file, "%s Isend %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1); + break; + case TRACING_RECV: + fprintf(trace_file, "%s recv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1); + break; + case TRACING_IRECV: + fprintf(trace_file, "%s Irecv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1); + break; + case TRACING_TEST: + fprintf(trace_file, "%s test\n", process_id); + break; + case TRACING_WAIT: + fprintf(trace_file, "%s wait\n", process_id); + break; + case TRACING_WAITALL: + fprintf(trace_file, "%s waitAll\n", process_id); + break; + case TRACING_BARRIER: + fprintf(trace_file, "%s barrier\n", process_id); + break; + case TRACING_BCAST: // rank bcast size (root) (datatype) + fprintf(trace_file, "%s bcast %d ", process_id, extra->send_size); + if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, ""))) + fprintf(trace_file, "%d %s", extra->root, extra->datatype1); + fprintf(trace_file, "\n"); + break; + case TRACING_REDUCE: // rank reduce comm_size comp_size (root) (datatype) + fprintf(trace_file, "%s reduce %d %f ", process_id, extra->send_size, extra->comp_size); + if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, ""))) + fprintf(trace_file, "%d %s", extra->root, extra->datatype1); + fprintf(trace_file, "\n"); + break; + case TRACING_ALLREDUCE: // rank allreduce comm_size comp_size (datatype) + fprintf(trace_file, "%s allReduce %d %f %s\n", process_id, extra->send_size, extra->comp_size, + extra->datatype1); + break; + case TRACING_ALLTOALL: // rank alltoall send_size recv_size (sendtype) (recvtype) + fprintf(trace_file, "%s allToAll %d %d %s %s\n", process_id, extra->send_size, extra->recv_size, + extra->datatype1, extra->datatype2); + break; + case TRACING_ALLTOALLV: // rank alltoallv send_size [sendcounts] recv_size [recvcounts] (sendtype) (recvtype) + fprintf(trace_file, "%s allToAllV %d ", process_id, extra->send_size); + for (int i = 0; i < extra->num_processes; i++) + fprintf(trace_file, "%d ", extra->sendcounts[i]); + fprintf(trace_file, "%d ", extra->recv_size); + for (int i = 0; i < extra->num_processes; i++) + fprintf(trace_file, "%d ", extra->recvcounts[i]); + fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2); + break; + case TRACING_GATHER: // rank gather send_size recv_size root (sendtype) (recvtype) + fprintf(trace_file, "%s gather %d %d %d %s %s\n", process_id, extra->send_size, extra->recv_size, extra->root, + extra->datatype1, extra->datatype2); + break; + case TRACING_ALLGATHERV: // rank allgatherv send_size [recvcounts] (sendtype) (recvtype) + fprintf(trace_file, "%s allGatherV %d ", process_id, extra->send_size); + for (int i = 0; i < extra->num_processes; i++) + fprintf(trace_file, "%d ", extra->recvcounts[i]); + fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2); + break; + case TRACING_REDUCE_SCATTER: // rank reducescatter [recvcounts] comp_size (sendtype) + fprintf(trace_file, "%s reduceScatter ", process_id); + for (int i = 0; i < extra->num_processes; i++) + fprintf(trace_file, "%d ", extra->recvcounts[i]); + fprintf(trace_file, "%f %s\n", extra->comp_size, extra->datatype1); + break; + case TRACING_COMPUTING: + fprintf(trace_file, "%s compute %f\n", process_id, extra->comp_size); + break; + case TRACING_SLEEPING: + fprintf(trace_file, "%s sleep %f\n", process_id, extra->sleep_duration); + break; + case TRACING_GATHERV: // rank gatherv send_size [recvcounts] root (sendtype) (recvtype) + fprintf(trace_file, "%s gatherV %d ", process_id, extra->send_size); + for (int i = 0; i < extra->num_processes; i++) + fprintf(trace_file, "%d ", extra->recvcounts[i]); + fprintf(trace_file, "%d %s %s\n", extra->root, extra->datatype1, extra->datatype2); + break; + case TRACING_WAITANY: + case TRACING_SENDRECV: + case TRACING_SCATTER: + case TRACING_SCATTERV: + case TRACING_ALLGATHER: + case TRACING_SCAN: + case TRACING_EXSCAN: + case TRACING_COMM_SIZE: + case TRACING_COMM_SPLIT: + case TRACING_COMM_DUP: + case TRACING_SSEND: + case TRACING_ISSEND: + default: + XBT_WARN("Call from %s impossible to translate into replay command : Not implemented (yet)", value->name); + break; + } - if (extra_ != nullptr) { - if (static_cast(extra_)->sendcounts != nullptr) - xbt_free(static_cast(extra_)->sendcounts); - if (static_cast(extra_)->recvcounts != nullptr) - xbt_free(static_cast(extra_)->recvcounts); - xbt_free(extra_); - } - } else if (instr_fmt_type == instr_fmt_TI) { - if (extra_ == nullptr) - return; - instr_extra_data extra = (instr_extra_data)extra_; - - char *process_id = nullptr; - //FIXME: dirty extract "rank-" from the name, as we want the bare process id here - if (strstr(container->name, "rank-") == nullptr) - process_id = xbt_strdup(container->name); - else - process_id = xbt_strdup(container->name + 5); - - FILE* trace_file = (FILE* )xbt_dict_get(tracing_files, container->name); - - switch (extra->type) { - case TRACING_INIT: - fprintf(trace_file, "%s init\n", process_id); - break; - case TRACING_FINALIZE: - fprintf(trace_file, "%s finalize\n", process_id); - break; - case TRACING_SEND: - fprintf(trace_file, "%s send %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1); - break; - case TRACING_ISEND: - fprintf(trace_file, "%s Isend %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1); - break; - case TRACING_RECV: - fprintf(trace_file, "%s recv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1); - break; - case TRACING_IRECV: - fprintf(trace_file, "%s Irecv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1); - break; - case TRACING_TEST: - fprintf(trace_file, "%s test\n", process_id); - break; - case TRACING_WAIT: - fprintf(trace_file, "%s wait\n", process_id); - break; - case TRACING_WAITALL: - fprintf(trace_file, "%s waitAll\n", process_id); - break; - case TRACING_BARRIER: - fprintf(trace_file, "%s barrier\n", process_id); - break; - case TRACING_BCAST: // rank bcast size (root) (datatype) - fprintf(trace_file, "%s bcast %d ", process_id, extra->send_size); - if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, ""))) - fprintf(trace_file, "%d %s", extra->root, extra->datatype1); - fprintf(trace_file, "\n"); - break; - case TRACING_REDUCE: // rank reduce comm_size comp_size (root) (datatype) - fprintf(trace_file, "%s reduce %d %f ", process_id, extra->send_size, extra->comp_size); - if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, ""))) - fprintf(trace_file, "%d %s", extra->root, extra->datatype1); - fprintf(trace_file, "\n"); - break; - case TRACING_ALLREDUCE: // rank allreduce comm_size comp_size (datatype) - fprintf(trace_file, "%s allReduce %d %f %s\n", process_id, extra->send_size, extra->comp_size, extra->datatype1); - break; - case TRACING_ALLTOALL: // rank alltoall send_size recv_size (sendtype) (recvtype) - fprintf(trace_file, "%s allToAll %d %d %s %s\n", process_id, extra->send_size, extra->recv_size, extra->datatype1, - extra->datatype2); - break; - case TRACING_ALLTOALLV: // rank alltoallv send_size [sendcounts] recv_size [recvcounts] (sendtype) (recvtype) - fprintf(trace_file, "%s allToAllV %d ", process_id, extra->send_size); - for (int i = 0; i < extra->num_processes; i++) - fprintf(trace_file, "%d ", extra->sendcounts[i]); - fprintf(trace_file, "%d ", extra->recv_size); - for (int i = 0; i < extra->num_processes; i++) - fprintf(trace_file, "%d ", extra->recvcounts[i]); - fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2); - break; - case TRACING_GATHER: // rank gather send_size recv_size root (sendtype) (recvtype) - fprintf(trace_file, "%s gather %d %d %d %s %s\n", process_id, extra->send_size, extra->recv_size, extra->root, - extra->datatype1, extra->datatype2); - break; - case TRACING_ALLGATHERV: // rank allgatherv send_size [recvcounts] (sendtype) (recvtype) - fprintf(trace_file, "%s allGatherV %d ", process_id, extra->send_size); - for (int i = 0; i < extra->num_processes; i++) - fprintf(trace_file, "%d ", extra->recvcounts[i]); - fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2); - break; - case TRACING_REDUCE_SCATTER: // rank reducescatter [recvcounts] comp_size (sendtype) - fprintf(trace_file, "%s reduceScatter ", process_id); - for (int i = 0; i < extra->num_processes; i++) - fprintf(trace_file, "%d ", extra->recvcounts[i]); - fprintf(trace_file, "%f %s\n", extra->comp_size, extra->datatype1); - break; - case TRACING_COMPUTING: - fprintf(trace_file, "%s compute %f\n", process_id, extra->comp_size); - break; - case TRACING_SLEEPING: - fprintf(trace_file, "%s sleep %f\n", process_id, extra->sleep_duration); - break; - case TRACING_GATHERV: // rank gatherv send_size [recvcounts] root (sendtype) (recvtype) - fprintf(trace_file, "%s gatherV %d ", process_id, extra->send_size); - for (int i = 0; i < extra->num_processes; i++) - fprintf(trace_file, "%d ", extra->recvcounts[i]); - fprintf(trace_file, "%d %s %s\n", extra->root, extra->datatype1, extra->datatype2); - break; - case TRACING_WAITANY: - case TRACING_SENDRECV: - case TRACING_SCATTER: - case TRACING_SCATTERV: - case TRACING_ALLGATHER: - case TRACING_SCAN: - case TRACING_EXSCAN: - case TRACING_COMM_SIZE: - case TRACING_COMM_SPLIT: - case TRACING_COMM_DUP: - case TRACING_SSEND: - case TRACING_ISSEND: - default: - XBT_WARN ("Call from %s impossible to translate into replay command : Not implemented (yet)", - value->name); - break; - } - - if (extra->recvcounts != nullptr) - xbt_free(extra->recvcounts); - if (extra->sendcounts != nullptr) - xbt_free(extra->sendcounts); - xbt_free(process_id); - xbt_free(extra); + if (extra->recvcounts != nullptr) + xbt_free(extra->recvcounts); + if (extra->sendcounts != nullptr) + xbt_free(extra->sendcounts); + xbt_free(process_id); + xbt_free(extra); - } else { - THROW_IMPOSSIBLE; - } + } else { + THROW_IMPOSSIBLE; + } } @@ -827,19 +803,18 @@ PopStateEvent::PopStateEvent (double timestamp, container_t container, type_t ty } void PopStateEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - print_timestamp(this); - stream << " " << type->id - << " " << container->id; - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } + if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << (int)this->event_type; + print_timestamp(this); + stream << " " << type->id << " " << container->id; + print_row(); + } else if (instr_fmt_type == instr_fmt_TI) { + /* Nothing to do */ + } else { + THROW_IMPOSSIBLE; + } } ResetStateEvent::ResetStateEvent (double timestamp, container_t container, type_t type) @@ -856,19 +831,18 @@ ResetStateEvent::ResetStateEvent (double timestamp, container_t container, type_ } void ResetStateEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - print_timestamp(this); - stream << " " << type->id - << " " << container->id; - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } + if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << (int)this->event_type; + print_timestamp(this); + stream << " " << type->id << " " << container->id; + print_row(); + } else if (instr_fmt_type == instr_fmt_TI) { + /* Nothing to do */ + } else { + THROW_IMPOSSIBLE; + } } StartLinkEvent::StartLinkEvent (double timestamp, container_t container, @@ -895,26 +869,23 @@ StartLinkEvent::StartLinkEvent (double timestamp, container_t container, type_t } void StartLinkEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - print_timestamp(this); - stream << " " <id - << " " <id - << " " <id - << " " << key; - - if (TRACE_display_sizes()) { - stream << " " << size; - } - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } + if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << (int)this->event_type; + print_timestamp(this); + stream << " " << type->id << " " << container->id << " " << value; + stream << " " << sourceContainer->id << " " << key; + + if (TRACE_display_sizes()) { + stream << " " << size; + } + print_row(); + } else if (instr_fmt_type == instr_fmt_TI) { + /* Nothing to do */ + } else { + THROW_IMPOSSIBLE; + } } EndLinkEvent::EndLinkEvent (double timestamp, container_t container, type_t type, container_t destContainer, @@ -935,22 +906,19 @@ EndLinkEvent::EndLinkEvent (double timestamp, container_t container, type_t type void EndLinkEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - print_timestamp(this); - stream << " " <id - << " " <id - << " " <id - << " " << key; - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } + if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << (int)this->event_type; + print_timestamp(this); + stream << " " << type->id << " " << container->id << " " << value; + stream << " " << destContainer->id << " " << key; + print_row(); + } else if (instr_fmt_type == instr_fmt_TI) { + /* Nothing to do */ + } else { + THROW_IMPOSSIBLE; + } } NewEvent::NewEvent (double timestamp, container_t container, type_t type, val_t value) @@ -967,20 +935,18 @@ NewEvent::NewEvent (double timestamp, container_t container, type_t type, val_t } void NewEvent::print () { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - print_timestamp(this); - stream << " " << type->id - << " " << container->id - << " " << value->id; - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } + if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << (int)this->event_type; + print_timestamp(this); + stream << " " << type->id << " " << container->id << " " << value->id; + print_row(); + } else if (instr_fmt_type == instr_fmt_TI) { + /* Nothing to do */ + } else { + THROW_IMPOSSIBLE; + } } diff --git a/src/instr/instr_paje_types.cpp b/src/instr/instr_paje_types.cpp index c9baee5117..acb89e3c47 100644 --- a/src/instr/instr_paje_types.cpp +++ b/src/instr/instr_paje_types.cpp @@ -156,7 +156,7 @@ type_t PJ_type_variable_new (const char *name, const char *color, type_t father) type_t ret = nullptr; char white[INSTR_DEFAULT_STR_SIZE] = "1 1 1"; - if (!color){ + if (not color) { ret = newType (name, name, white, TYPE_VARIABLE, father); }else{ ret = newType (name, name, color, TYPE_VARIABLE, father); diff --git a/src/instr/instr_private.h b/src/instr/instr_private.h index 81be1f4f61..d4da8faf72 100644 --- a/src/instr/instr_private.h +++ b/src/instr/instr_private.h @@ -255,7 +255,6 @@ class PushStateEvent : public PajeEvent { class PopStateEvent : public PajeEvent { container_t container; type_t type; - xbt_dynar_t extra; public: PopStateEvent (double timestamp, container_t container, type_t type); void print() override; diff --git a/src/instr/instr_resource_utilization.cpp b/src/instr/instr_resource_utilization.cpp index 0cfed5e590..3135882228 100644 --- a/src/instr/instr_resource_utilization.cpp +++ b/src/instr/instr_resource_utilization.cpp @@ -26,7 +26,7 @@ static void __TRACE_surf_check_variable_set_to_zero(double now, const char *vari snprintf (key, n, "%s%s", resource, variable); // check if key exists: if it doesn't, set the variable to zero and mark this in the dict - if (!xbt_dict_get_or_null(platform_variables, key)) { + if (not xbt_dict_get_or_null(platform_variables, key)) { container_t container = PJ_container_get (resource); type_t type = PJ_type_get (variable, container->type); new SetVariableEvent (now, container, type, 0); @@ -46,9 +46,9 @@ static void instr_event (double now, double delta, type_t variable, container_t void TRACE_surf_link_set_utilization(const char *resource, const char *category, double value, double now, double delta) { //only trace link utilization if link is known by tracing mechanism - if (!PJ_container_get_or_null(resource)) + if (not PJ_container_get_or_null(resource)) return; - if (!value) + if (not value) return; //trace uncategorized link utilization @@ -61,7 +61,7 @@ void TRACE_surf_link_set_utilization(const char *resource, const char *category, //trace categorized utilization if (TRACE_categorized()){ - if (!category) + if (not category) return; //variable of this category starts by 'b', because we have a link here char category_type[INSTR_DEFAULT_STR_SIZE]; @@ -78,7 +78,7 @@ void TRACE_surf_host_set_utilization(const char *resource, const char *category, { //only trace host utilization if host is known by tracing mechanism container_t container = PJ_container_get_or_null(resource); - if (!container || !value) + if (not container || not value) return; //trace uncategorized host utilization @@ -90,7 +90,7 @@ void TRACE_surf_host_set_utilization(const char *resource, const char *category, //trace categorized utilization if (TRACE_categorized()){ - if (!category) + if (not category) return; //variable of this category starts by 'p', because we have a host here char category_type[INSTR_DEFAULT_STR_SIZE]; diff --git a/src/instr/jedule/jedule.cpp b/src/instr/jedule/jedule.cpp index 86dbae5e65..4f7841fe43 100644 --- a/src/instr/jedule/jedule.cpp +++ b/src/instr/jedule/jedule.cpp @@ -27,10 +27,10 @@ void Jedule::addMetaInfo(char *key, char *value) { } void Jedule::writeOutput(FILE *file) { - if (!this->event_set.empty()){ + if (not this->event_set.empty()) { fprintf(file, "\n"); - if (!this->meta_info.empty()){ + if (not this->meta_info.empty()) { fprintf(file, " \n"); for (auto elm: this->meta_info) fprintf(file, " \n",elm.first,elm.second); diff --git a/src/instr/jedule/jedule_events.cpp b/src/instr/jedule/jedule_events.cpp index 95a591b042..afe12f3cac 100644 --- a/src/instr/jedule/jedule_events.cpp +++ b/src/instr/jedule/jedule_events.cpp @@ -20,7 +20,7 @@ Event::Event(std::string name, double start_time, double end_time, std::string t Event::~Event() { - if (!this->resource_subsets->empty()){ + if (not this->resource_subsets->empty()) { for (auto subset: *this->resource_subsets) delete subset; delete this->resource_subsets; @@ -51,7 +51,7 @@ void Event::print(FILE *jed_file) fprintf(jed_file, " \n", this->end_time); fprintf(jed_file, " \n", this->type.c_str()); - xbt_assert(!this->resource_subsets-> empty()); + xbt_assert(not this->resource_subsets->empty()); fprintf(jed_file, " \n"); for (auto subset: *this->resource_subsets) { fprintf(jed_file, "