Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'depencencies' of https://framagit.org/simgrid/simgrid into depencencies
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 24 Jan 2020 17:42:07 +0000 (18:42 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 24 Jan 2020 17:42:07 +0000 (18:42 +0100)
1151 files changed:
.circleci/config.yml
.gitignore
.gitlab-ci.yml
.travis.yml
BuildSimGrid.sh
CMakeLists.txt
COPYING
COPYRIGHT.template
ChangeLog
FindSimGrid.cmake
MANIFEST.in
contrib/benchmarking_code_block/bench.h
contrib/benchmarking_code_block/inject.h
doc/doxygen/platform.doc
docs/Build.sh
docs/find-missing.ignore [new file with mode: 0644]
docs/find-missing.py
docs/ignored_symbols
docs/manpages/smpicc.1
docs/manpages/smpicxx.1
docs/manpages/smpif90.1
docs/manpages/smpiff.1
docs/manpages/smpirun.1
docs/source/Configuring_SimGrid.rst
docs/source/Doxyfile
docs/source/Installing_SimGrid.rst
docs/source/Platform_Examples.rst
docs/source/Platform_Routing.rst [new file with mode: 0644]
docs/source/Plugins.rst
docs/source/XML_Reference.rst
docs/source/_ext/autodoxy.py
docs/source/app_s4u.rst
docs/source/app_smpi.rst
docs/source/conf.py
docs/source/index.rst
docs/source/platform.rst
docs/source/platform_howtos.rst
docs/source/tuto_s4u/master-workers-lab1.cpp
docs/source/tuto_s4u/master-workers-lab2.cpp
docs/source/tuto_s4u/master-workers-lab3.cpp
docs/source/tuto_s4u/master-workers-lab4.cpp
examples/README.rst
examples/deprecated/java/app/bittorrent/Common.java
examples/deprecated/java/app/bittorrent/Connection.java
examples/deprecated/java/app/bittorrent/Main.java
examples/deprecated/java/app/bittorrent/MessageTask.java
examples/deprecated/java/app/bittorrent/Peer.java
examples/deprecated/java/app/bittorrent/Tracker.java
examples/deprecated/java/app/bittorrent/TrackerTask.java
examples/deprecated/java/app/bittorrent/generate.py
examples/deprecated/java/app/centralizedmutex/Coordinator.java
examples/deprecated/java/app/centralizedmutex/GrantTask.java
examples/deprecated/java/app/centralizedmutex/Main.java
examples/deprecated/java/app/centralizedmutex/Node.java
examples/deprecated/java/app/centralizedmutex/ReleaseTask.java
examples/deprecated/java/app/centralizedmutex/RequestTask.java
examples/deprecated/java/app/masterworker/Main.java
examples/deprecated/java/app/masterworker/Master.java
examples/deprecated/java/app/masterworker/Worker.java
examples/deprecated/java/app/pingpong/Main.java
examples/deprecated/java/app/pingpong/PingPongTask.java
examples/deprecated/java/app/pingpong/Receiver.java
examples/deprecated/java/app/pingpong/Sender.java
examples/deprecated/java/app/tokenring/Main.java
examples/deprecated/java/app/tokenring/RelayRunner.java
examples/deprecated/java/async/dsend/Main.java
examples/deprecated/java/async/dsend/Receiver.java
examples/deprecated/java/async/dsend/Sender.java
examples/deprecated/java/async/waitall/Main.java
examples/deprecated/java/async/waitall/Receiver.java
examples/deprecated/java/async/waitall/Sender.java
examples/deprecated/java/async/yield/Main.java
examples/deprecated/java/async/yield/Yielder.java
examples/deprecated/java/cloud/masterworker/Main.java
examples/deprecated/java/cloud/masterworker/Master.java
examples/deprecated/java/cloud/masterworker/Worker.java
examples/deprecated/java/cloud/migration/Daemon.java
examples/deprecated/java/cloud/migration/Main.java
examples/deprecated/java/cloud/migration/Test.java
examples/deprecated/java/cloud/migration/XVM.java
examples/deprecated/java/dht/chord/ChordTask.java
examples/deprecated/java/dht/chord/Common.java
examples/deprecated/java/dht/chord/FindSuccessorAnswerTask.java
examples/deprecated/java/dht/chord/FindSuccessorTask.java
examples/deprecated/java/dht/chord/GetPredecessorAnswerTask.java
examples/deprecated/java/dht/chord/GetPredecessorTask.java
examples/deprecated/java/dht/chord/Main.java
examples/deprecated/java/dht/chord/Node.java
examples/deprecated/java/dht/chord/NotifyTask.java
examples/deprecated/java/dht/kademlia/Answer.java
examples/deprecated/java/dht/kademlia/Bucket.java
examples/deprecated/java/dht/kademlia/Common.java
examples/deprecated/java/dht/kademlia/Contact.java
examples/deprecated/java/dht/kademlia/FindNodeAnswerTask.java
examples/deprecated/java/dht/kademlia/FindNodeTask.java
examples/deprecated/java/dht/kademlia/KademliaTask.java
examples/deprecated/java/dht/kademlia/Main.java
examples/deprecated/java/dht/kademlia/Node.java
examples/deprecated/java/dht/kademlia/RoutingTable.java
examples/deprecated/java/energy/consumption/EnergyConsumer.java
examples/deprecated/java/energy/consumption/Main.java
examples/deprecated/java/energy/pstate/Main.java
examples/deprecated/java/energy/pstate/PstateRunner.java
examples/deprecated/java/energy/vm/EnergyVMRunner.java
examples/deprecated/java/energy/vm/Main.java
examples/deprecated/java/hostload/LoadRunner.java
examples/deprecated/java/hostload/Main.java
examples/deprecated/java/io/file/Main.java
examples/deprecated/java/io/file/Node.java
examples/deprecated/java/io/storage/Client.java
examples/deprecated/java/io/storage/Main.java
examples/deprecated/java/process/kill/Killer.java
examples/deprecated/java/process/kill/Main.java
examples/deprecated/java/process/kill/Victim.java
examples/deprecated/java/process/migration/Emigrant.java
examples/deprecated/java/process/migration/Main.java
examples/deprecated/java/process/migration/Policeman.java
examples/deprecated/java/process/startkilltime/Main.java
examples/deprecated/java/process/startkilltime/Sleeper.java
examples/deprecated/java/process/suspend/DreamMaster.java
examples/deprecated/java/process/suspend/LazyGuy.java
examples/deprecated/java/process/suspend/Main.java
examples/deprecated/java/task/priority/Main.java
examples/deprecated/java/task/priority/Test.java
examples/deprecated/java/trace/pingpong/Main.java
examples/deprecated/java/trace/pingpong/PingPongTask.java
examples/deprecated/java/trace/pingpong/Receiver.java
examples/deprecated/java/trace/pingpong/Sender.java
examples/deprecated/msg/app-masterworker/app-masterworker.c
examples/deprecated/msg/cloud-masterworker/cloud-masterworker.c
examples/deprecated/msg/dht-kademlia/answer.c
examples/deprecated/msg/dht-kademlia/answer.h
examples/deprecated/msg/dht-kademlia/common.h
examples/deprecated/msg/dht-kademlia/dht-kademlia.c
examples/deprecated/msg/dht-kademlia/dht-kademlia.h
examples/deprecated/msg/dht-kademlia/generate.py
examples/deprecated/msg/dht-kademlia/node.c
examples/deprecated/msg/dht-kademlia/node.h
examples/deprecated/msg/dht-kademlia/routing_table.c
examples/deprecated/msg/dht-kademlia/routing_table.h
examples/deprecated/msg/dht-kademlia/task.c
examples/deprecated/msg/dht-kademlia/task.h
examples/deprecated/msg/dht-pastry/dht-pastry.c
examples/deprecated/msg/dht-pastry/generate.py
examples/deprecated/msg/energy-vm/energy-vm.c
examples/deprecated/msg/mc/bugged1.c
examples/deprecated/msg/mc/bugged1_liveness.c
examples/deprecated/msg/mc/bugged2.c
examples/deprecated/msg/mc/bugged2_liveness.c
examples/deprecated/msg/mc/bugged3.c
examples/deprecated/msg/mc/centralized_mutex.c
examples/deprecated/msg/mc/electric_fence.c
examples/deprecated/msg/network-ns3/network-ns3.c
examples/deprecated/msg/platform-failures/platform-failures.c
examples/deprecated/msg/process-create/process-create.c
examples/deprecated/msg/synchro-semaphore/synchro-semaphore.c
examples/deprecated/msg/trace-categories/trace-categories.c
examples/deprecated/msg/trace-host-user-variables/trace-host-user-variables.c
examples/deprecated/msg/trace-host-user-variables/trace-host-user-variables.tesh
examples/deprecated/msg/trace-link-user-variables/trace-link-user-variables.c
examples/deprecated/msg/trace-masterworker/trace-masterworker.c
examples/deprecated/msg/trace-process-migration/trace-process-migration.c
examples/deprecated/msg/trace-route-user-variables/trace-route-user-variables.c
examples/deprecated/simdag/dag-dotload/sd_dag-dotload.c
examples/deprecated/simdag/daxload/sd_daxload.c
examples/deprecated/simdag/fail/sd_fail.c
examples/deprecated/simdag/properties/sd_properties.c
examples/deprecated/simdag/ptg-dotload/sd_ptg-dotload.c
examples/deprecated/simdag/schedule-dotload/sd_schedule-dotload.c
examples/deprecated/simdag/scheduling/sd_scheduling.c
examples/deprecated/simdag/test/sd_test.cpp
examples/deprecated/simdag/throttling/sd_throttling.c
examples/deprecated/simdag/typed_tasks/sd_typed_tasks.c
examples/platforms/cluster_dragonfly.svg
examples/platforms/cluster_prototype.lua
examples/platforms/dogbone.xml
examples/platforms/optorsim/transform_optorsim_platform.pl
examples/platforms/small_platform.lua
examples/platforms/syscoord/generate_peer_platform.pl
examples/python/actor-create/actor-create.py
examples/python/actor-daemon/actor-daemon.py
examples/python/actor-join/actor-join.py
examples/python/actor-join/actor-join.tesh
examples/python/actor-kill/actor-kill.py
examples/python/actor-lifetime/actor-lifetime.py
examples/python/actor-migrate/actor-migrate.py
examples/python/actor-suspend/actor-suspend.py
examples/python/actor-yield/actor-yield.py
examples/python/async-wait/async-wait.py
examples/python/async-waitall/async-waitall.py
examples/python/async-waitany/async-waitany.py
examples/python/exec-async/exec-async.py
examples/python/exec-async/exec-async.tesh
examples/python/exec-basic/exec-basic.py
examples/python/exec-dvfs/exec-dvfs.py
examples/python/exec-dvfs/exec-dvfs.tesh
examples/python/exec-remote/exec-remote.py
examples/s4u/CMakeLists.txt
examples/s4u/actor-create/s4u-actor-create.cpp
examples/s4u/actor-daemon/s4u-actor-daemon.cpp
examples/s4u/actor-exiting/s4u-actor-exiting.cpp
examples/s4u/actor-join/s4u-actor-join.cpp
examples/s4u/actor-kill/s4u-actor-kill.cpp
examples/s4u/actor-lifetime/s4u-actor-lifetime.cpp
examples/s4u/actor-migrate/s4u-actor-migrate.cpp
examples/s4u/actor-suspend/s4u-actor-suspend.cpp
examples/s4u/actor-yield/s4u-actor-yield.cpp
examples/s4u/app-bittorrent/s4u-bittorrent.cpp
examples/s4u/app-bittorrent/s4u-bittorrent.hpp
examples/s4u/app-bittorrent/s4u-peer.cpp
examples/s4u/app-bittorrent/s4u-peer.hpp
examples/s4u/app-bittorrent/s4u-tracker.cpp
examples/s4u/app-bittorrent/s4u-tracker.hpp
examples/s4u/app-chainsend/s4u-app-chainsend.cpp
examples/s4u/app-masterworkers/s4u-app-masterworkers-class.cpp
examples/s4u/app-masterworkers/s4u-app-masterworkers-fun.cpp
examples/s4u/app-pingpong/s4u-app-pingpong.cpp
examples/s4u/app-token-ring/s4u-app-token-ring.cpp
examples/s4u/async-ready/s4u-async-ready.cpp
examples/s4u/async-wait/s4u-async-wait.cpp
examples/s4u/async-waitall/s4u-async-waitall.cpp
examples/s4u/async-waitany/s4u-async-waitany.cpp
examples/s4u/async-waituntil/s4u-async-waituntil.cpp
examples/s4u/cloud-capping/s4u-cloud-capping.cpp
examples/s4u/cloud-migration/s4u-cloud-migration.cpp
examples/s4u/cloud-simple/s4u-cloud-simple.cpp
examples/s4u/dht-chord/s4u-dht-chord-node.cpp
examples/s4u/dht-chord/s4u-dht-chord.cpp
examples/s4u/dht-chord/s4u-dht-chord.hpp
examples/s4u/dht-kademlia/answer.cpp
examples/s4u/dht-kademlia/answer.hpp
examples/s4u/dht-kademlia/generate.py
examples/s4u/dht-kademlia/message.hpp
examples/s4u/dht-kademlia/node.cpp
examples/s4u/dht-kademlia/node.hpp
examples/s4u/dht-kademlia/routing_table.cpp
examples/s4u/dht-kademlia/routing_table.hpp
examples/s4u/dht-kademlia/s4u-dht-kademlia.cpp
examples/s4u/dht-kademlia/s4u-dht-kademlia.hpp
examples/s4u/energy-boot/platform_boot.xml
examples/s4u/energy-boot/s4u-energy-boot.cpp
examples/s4u/energy-exec-ptask/s4u-energy-exec-ptask.cpp
examples/s4u/energy-exec/s4u-energy-exec.cpp
examples/s4u/energy-link/s4u-energy-link.cpp
examples/s4u/energy-vm/s4u-energy-vm.cpp
examples/s4u/engine-filtering/s4u-engine-filtering.cpp
examples/s4u/exec-async/s4u-exec-async.cpp
examples/s4u/exec-basic/s4u-exec-basic.cpp
examples/s4u/exec-dependent/s4u-exec-dependent.cpp
examples/s4u/exec-dependent/s4u-exec-dependent.tesh
examples/s4u/exec-dvfs/s4u-exec-dvfs.cpp
examples/s4u/exec-ptask/s4u-exec-ptask.cpp
examples/s4u/exec-ptask/s4u-exec-ptask.tesh
examples/s4u/exec-remote/s4u-exec-remote.cpp
examples/s4u/exec-waitany/s4u-exec-waitany.cpp
examples/s4u/exec-waitfor/s4u-exec-waitfor.cpp [new file with mode: 0644]
examples/s4u/exec-waitfor/s4u-exec-waitfor.tesh [new file with mode: 0644]
examples/s4u/io-async/s4u-io-async.cpp
examples/s4u/io-async/s4u-io-async.tesh
examples/s4u/io-disk-raw/s4u-io-disk-raw.cpp
examples/s4u/io-file-remote/s4u-io-file-remote.cpp
examples/s4u/io-file-system/s4u-io-file-system.cpp
examples/s4u/maestro-set/s4u-maestro-set.cpp
examples/s4u/mc-failing-assert/s4u-mc-failing-assert.cpp
examples/s4u/platform-failures/s4u-platform-failures.cpp
examples/s4u/platform-profile/s4u-platform-profile.cpp
examples/s4u/platform-properties/s4u-platform-properties.cpp
examples/s4u/plugin-hostload/s4u-plugin-hostload.cpp
examples/s4u/replay-comm/s4u-replay-comm.cpp
examples/s4u/replay-io/s4u-replay-io.cpp
examples/s4u/routing-get-clusters/s4u-routing-get-clusters.cpp
examples/s4u/synchro-barrier/s4u-synchro-barrier.cpp
examples/s4u/synchro-condition-variable/s4u-synchro-condition-variable.cpp [new file with mode: 0644]
examples/s4u/synchro-condition-variable/s4u-synchro-condition-variable.tesh [new file with mode: 0644]
examples/s4u/synchro-mutex/s4u-synchro-mutex.cpp
examples/s4u/synchro-semaphore/s4u-synchro-semaphore.cpp
examples/s4u/trace-platform/s4u-trace-platform.cpp
examples/smpi/NAS/nas_common.c
examples/smpi/NAS/nas_common.h
examples/smpi/ampi_test/ampi_test.cpp
examples/smpi/energy/energy.c
examples/smpi/mc/bugged1.c
examples/smpi/mc/bugged1_liveness.c
examples/smpi/mc/bugged2.c
examples/smpi/mc/mutual_exclusion.c
examples/smpi/mc/only_send_deterministic.c
examples/smpi/mc/sendsend.c
examples/smpi/replay/replay.cpp
examples/smpi/replay_multiple/generate_multiple_deployment.sh
examples/smpi/replay_multiple/replay_multiple.c
examples/smpi/replay_multiple_manual_deploy/replay_multiple_manual.cpp
examples/smpi/smpi_msg_masterslave/masterslave_mailbox_smpi.c
examples/smpi/trace/trace.c
examples/smpi/trace_call_location/trace_call_location.c
examples/smpi/trace_simple/trace_simple.c
include/simgrid/Exception.hpp
include/simgrid/actor.h
include/simgrid/barrier.h
include/simgrid/chrono.hpp
include/simgrid/cond.h
include/simgrid/config.h.in
include/simgrid/engine.h
include/simgrid/forward.h
include/simgrid/host.h
include/simgrid/instr.h
include/simgrid/jedule/jedule.hpp
include/simgrid/jedule/jedule_events.hpp
include/simgrid/jedule/jedule_platform.hpp
include/simgrid/jedule/jedule_sd_binding.h
include/simgrid/kernel/future.hpp
include/simgrid/kernel/resource/Action.hpp
include/simgrid/kernel/resource/Model.hpp
include/simgrid/kernel/resource/Resource.hpp
include/simgrid/kernel/routing/ClusterZone.hpp
include/simgrid/kernel/routing/DijkstraZone.hpp
include/simgrid/kernel/routing/DragonflyZone.hpp
include/simgrid/kernel/routing/EmptyZone.hpp
include/simgrid/kernel/routing/FatTreeZone.hpp
include/simgrid/kernel/routing/FloydZone.hpp
include/simgrid/kernel/routing/FullZone.hpp
include/simgrid/kernel/routing/NetPoint.hpp
include/simgrid/kernel/routing/NetZoneImpl.hpp
include/simgrid/kernel/routing/RoutedZone.hpp
include/simgrid/kernel/routing/TorusZone.hpp
include/simgrid/kernel/routing/VivaldiZone.hpp
include/simgrid/link.h
include/simgrid/mailbox.h
include/simgrid/modelchecker.h
include/simgrid/msg.h
include/simgrid/mutex.h
include/simgrid/plugins/dvfs.h
include/simgrid/plugins/energy.h
include/simgrid/plugins/file_system.h
include/simgrid/plugins/live_migration.h
include/simgrid/plugins/load.h
include/simgrid/plugins/load_balancer.h
include/simgrid/s4u.hpp
include/simgrid/s4u/Activity.hpp
include/simgrid/s4u/Actor.hpp
include/simgrid/s4u/Barrier.hpp
include/simgrid/s4u/Comm.hpp
include/simgrid/s4u/ConditionVariable.hpp
include/simgrid/s4u/Disk.hpp
include/simgrid/s4u/Engine.hpp
include/simgrid/s4u/Exec.hpp
include/simgrid/s4u/Host.hpp
include/simgrid/s4u/Io.hpp
include/simgrid/s4u/Link.hpp
include/simgrid/s4u/Mailbox.hpp
include/simgrid/s4u/Mutex.hpp
include/simgrid/s4u/NetZone.hpp
include/simgrid/s4u/Semaphore.hpp
include/simgrid/s4u/Storage.hpp
include/simgrid/s4u/VirtualMachine.hpp
include/simgrid/semaphore.h
include/simgrid/simdag.h
include/simgrid/simix.h
include/simgrid/simix.hpp
include/simgrid/simix/blocking_simcall.hpp
include/simgrid/smpi/replay.hpp
include/simgrid/storage.h
include/simgrid/version.h.in
include/simgrid/vm.h
include/simgrid/zone.h
include/smpi/forward.hpp
include/smpi/mpi.h
include/smpi/mpif.h.in
include/smpi/sampi.h
include/smpi/smpi.h
include/smpi/smpi_helpers.h
include/smpi/smpi_helpers_internal.h
include/smpi/smpi_main.h
include/xbt.h
include/xbt/Extendable.hpp
include/xbt/PropertyHolder.hpp
include/xbt/asserts.h
include/xbt/automaton.h
include/xbt/automaton.hpp
include/xbt/backtrace.hpp
include/xbt/base.h
include/xbt/config.h
include/xbt/config.hpp
include/xbt/dict.h
include/xbt/dynar.h
include/xbt/ex.h
include/xbt/file.hpp
include/xbt/function_types.h
include/xbt/functional.hpp
include/xbt/future.hpp
include/xbt/graph.h
include/xbt/log.h
include/xbt/log.hpp
include/xbt/mallocator.h
include/xbt/misc.h
include/xbt/module.h
include/xbt/parmap.h
include/xbt/random.hpp
include/xbt/range.hpp
include/xbt/replay.hpp
include/xbt/signal.hpp
include/xbt/str.h
include/xbt/string.hpp
include/xbt/synchro.h
include/xbt/sysdep.h
include/xbt/system_error.hpp
include/xbt/utility.hpp
include/xbt/virtu.h
include/xbt/xbt_os_time.h
sonar-project.properties
src/bindings/java/JavaContext.cpp
src/bindings/java/JavaContext.hpp
src/bindings/java/jmsg.cpp
src/bindings/java/jmsg.hpp
src/bindings/java/jmsg_as.cpp
src/bindings/java/jmsg_as.hpp
src/bindings/java/jmsg_comm.cpp
src/bindings/java/jmsg_comm.h
src/bindings/java/jmsg_file.cpp
src/bindings/java/jmsg_file.h
src/bindings/java/jmsg_host.cpp
src/bindings/java/jmsg_host.h
src/bindings/java/jmsg_process.cpp
src/bindings/java/jmsg_process.h
src/bindings/java/jmsg_storage.cpp
src/bindings/java/jmsg_storage.h
src/bindings/java/jmsg_synchro.cpp
src/bindings/java/jmsg_synchro.h
src/bindings/java/jmsg_task.cpp
src/bindings/java/jmsg_task.h
src/bindings/java/jmsg_vm.cpp
src/bindings/java/jmsg_vm.h
src/bindings/java/jtrace.cpp
src/bindings/java/jtrace.h
src/bindings/java/jxbt_utilities.cpp
src/bindings/java/jxbt_utilities.hpp
src/bindings/java/org/simgrid/NativeLib.java
src/bindings/java/org/simgrid/msg/As.java
src/bindings/java/org/simgrid/msg/Comm.java
src/bindings/java/org/simgrid/msg/File.java
src/bindings/java/org/simgrid/msg/Host.java
src/bindings/java/org/simgrid/msg/HostFailureException.java
src/bindings/java/org/simgrid/msg/HostNotFoundException.java
src/bindings/java/org/simgrid/msg/JniException.java
src/bindings/java/org/simgrid/msg/Msg.java
src/bindings/java/org/simgrid/msg/MsgException.java
src/bindings/java/org/simgrid/msg/Mutex.java
src/bindings/java/org/simgrid/msg/Process.java
src/bindings/java/org/simgrid/msg/ProcessKilledError.java
src/bindings/java/org/simgrid/msg/ProcessNotFoundException.java
src/bindings/java/org/simgrid/msg/Semaphore.java
src/bindings/java/org/simgrid/msg/Storage.java
src/bindings/java/org/simgrid/msg/StorageNotFoundException.java
src/bindings/java/org/simgrid/msg/Task.java
src/bindings/java/org/simgrid/msg/TaskCancelledException.java
src/bindings/java/org/simgrid/msg/TimeoutException.java
src/bindings/java/org/simgrid/msg/TransferFailureException.java
src/bindings/java/org/simgrid/msg/VM.java
src/bindings/java/org/simgrid/trace/Trace.java
src/bindings/lua/lua_host.cpp
src/bindings/lua/lua_platf.cpp
src/bindings/lua/lua_private.hpp
src/bindings/lua/lua_utils.cpp
src/bindings/lua/lua_utils.hpp
src/bindings/lua/simgrid_lua.cpp
src/bindings/lua/simgrid_lua.hpp
src/bindings/python/simgrid_python.cpp
src/include/mc/datatypes.h
src/include/mc/mc.h
src/include/simgrid/sg_config.hpp
src/include/surf/surf.hpp
src/include/xbt/coverage.h
src/include/xbt/mmalloc.h
src/include/xbt/parmap.hpp
src/instr/instr_config.cpp
src/instr/instr_interface.cpp
src/instr/instr_paje_containers.cpp
src/instr/instr_paje_containers.hpp
src/instr/instr_paje_events.cpp
src/instr/instr_paje_events.hpp
src/instr/instr_paje_header.cpp
src/instr/instr_paje_trace.cpp
src/instr/instr_paje_types.cpp
src/instr/instr_paje_types.hpp
src/instr/instr_paje_values.cpp
src/instr/instr_paje_values.hpp
src/instr/instr_platform.cpp
src/instr/instr_private.hpp
src/instr/instr_resource_utilization.cpp
src/instr/instr_smpi.hpp
src/instr/jedule/jedule.cpp
src/instr/jedule/jedule_events.cpp
src/instr/jedule/jedule_platform.cpp
src/instr/jedule/jedule_sd_binding.cpp
src/internal_config.h.in
src/kernel/EngineImpl.cpp
src/kernel/EngineImpl.hpp
src/kernel/activity/ActivityImpl.cpp
src/kernel/activity/ActivityImpl.hpp
src/kernel/activity/CommImpl.cpp
src/kernel/activity/CommImpl.hpp
src/kernel/activity/ConditionVariableImpl.cpp
src/kernel/activity/ConditionVariableImpl.hpp
src/kernel/activity/ExecImpl.cpp
src/kernel/activity/ExecImpl.hpp
src/kernel/activity/IoImpl.cpp
src/kernel/activity/IoImpl.hpp
src/kernel/activity/MailboxImpl.cpp
src/kernel/activity/MailboxImpl.hpp
src/kernel/activity/MutexImpl.cpp
src/kernel/activity/MutexImpl.hpp
src/kernel/activity/SemaphoreImpl.cpp
src/kernel/activity/SemaphoreImpl.hpp
src/kernel/activity/SleepImpl.cpp
src/kernel/activity/SleepImpl.hpp
src/kernel/activity/SynchroRaw.cpp
src/kernel/activity/SynchroRaw.hpp
src/kernel/actor/ActorImpl.cpp
src/kernel/actor/ActorImpl.hpp
src/kernel/context/Context.cpp
src/kernel/context/Context.hpp
src/kernel/context/ContextBoost.cpp
src/kernel/context/ContextBoost.hpp
src/kernel/context/ContextRaw.cpp
src/kernel/context/ContextRaw.hpp
src/kernel/context/ContextSwapped.cpp
src/kernel/context/ContextSwapped.hpp
src/kernel/context/ContextThread.cpp
src/kernel/context/ContextThread.hpp
src/kernel/context/ContextUnix.cpp
src/kernel/context/ContextUnix.hpp
src/kernel/context/context_private.hpp [deleted file]
src/kernel/future.cpp
src/kernel/lmm/fair_bottleneck.cpp
src/kernel/lmm/maxmin.cpp
src/kernel/lmm/maxmin.hpp
src/kernel/lmm/maxmin_test.cpp
src/kernel/resource/Action.cpp
src/kernel/resource/DiskImpl.cpp
src/kernel/resource/DiskImpl.hpp
src/kernel/resource/Model.cpp
src/kernel/resource/Resource.cpp
src/kernel/resource/profile/DatedValue.cpp
src/kernel/resource/profile/DatedValue.hpp
src/kernel/resource/profile/Event.hpp
src/kernel/resource/profile/FutureEvtSet.cpp
src/kernel/resource/profile/FutureEvtSet.hpp
src/kernel/resource/profile/Profile.cpp
src/kernel/resource/profile/Profile.hpp
src/kernel/resource/profile/Profile_test.cpp
src/kernel/routing/ClusterZone.cpp
src/kernel/routing/DijkstraZone.cpp
src/kernel/routing/DragonflyZone.cpp
src/kernel/routing/EmptyZone.cpp
src/kernel/routing/FatTreeZone.cpp
src/kernel/routing/FloydZone.cpp
src/kernel/routing/FullZone.cpp
src/kernel/routing/NetPoint.cpp
src/kernel/routing/NetZoneImpl.cpp
src/kernel/routing/RoutedZone.cpp
src/kernel/routing/TorusZone.cpp
src/kernel/routing/VivaldiZone.cpp
src/mc/AddressSpace.hpp
src/mc/ModelChecker.cpp
src/mc/ModelChecker.hpp
src/mc/Session.cpp
src/mc/Session.hpp
src/mc/Transition.hpp
src/mc/VisitedState.cpp
src/mc/VisitedState.hpp
src/mc/checker/Checker.cpp
src/mc/checker/Checker.hpp
src/mc/checker/CommunicationDeterminismChecker.cpp
src/mc/checker/CommunicationDeterminismChecker.hpp
src/mc/checker/LivenessChecker.cpp
src/mc/checker/LivenessChecker.hpp
src/mc/checker/SafetyChecker.cpp
src/mc/checker/SafetyChecker.hpp
src/mc/checker/SimcallInspector.hpp
src/mc/checker/simgrid_mc.cpp
src/mc/compare.cpp
src/mc/inspect/DwarfExpression.cpp
src/mc/inspect/DwarfExpression.hpp
src/mc/inspect/Frame.cpp
src/mc/inspect/Frame.hpp
src/mc/inspect/LocationList.cpp
src/mc/inspect/LocationList.hpp
src/mc/inspect/ObjectInformation.cpp
src/mc/inspect/ObjectInformation.hpp
src/mc/inspect/Type.hpp
src/mc/inspect/Variable.hpp
src/mc/inspect/mc_dwarf.cpp
src/mc/inspect/mc_dwarf.hpp
src/mc/inspect/mc_dwarf_attrnames.cpp
src/mc/inspect/mc_dwarf_tagnames.cpp
src/mc/inspect/mc_member.cpp
src/mc/inspect/mc_unw.cpp
src/mc/inspect/mc_unw.hpp
src/mc/inspect/mc_unw_vmread.cpp
src/mc/mc_base.cpp
src/mc/mc_base.h
src/mc/mc_client_api.cpp
src/mc/mc_comm_pattern.cpp
src/mc/mc_comm_pattern.hpp
src/mc/mc_config.cpp
src/mc/mc_config.hpp
src/mc/mc_exit.hpp
src/mc/mc_forward.hpp
src/mc/mc_global.cpp
src/mc/mc_hash.cpp
src/mc/mc_hash.hpp
src/mc/mc_ignore.hpp
src/mc/mc_memory.cpp
src/mc/mc_mmu.hpp
src/mc/mc_private.hpp
src/mc/mc_record.cpp
src/mc/mc_record.hpp
src/mc/mc_replay.hpp
src/mc/mc_request.cpp
src/mc/mc_request.hpp
src/mc/mc_safety.hpp
src/mc/mc_smx.cpp
src/mc/mc_smx.hpp
src/mc/mc_state.cpp
src/mc/mc_state.hpp
src/mc/remote/Channel.cpp
src/mc/remote/Channel.hpp
src/mc/remote/Client.cpp
src/mc/remote/Client.hpp
src/mc/remote/RemoteClient.cpp
src/mc/remote/RemoteClient.hpp
src/mc/remote/RemotePtr.hpp
src/mc/remote/mc_protocol.cpp
src/mc/remote/mc_protocol.h
src/mc/sosp/ChunkedData.cpp
src/mc/sosp/ChunkedData.hpp
src/mc/sosp/PageStore.cpp
src/mc/sosp/PageStore.hpp
src/mc/sosp/PageStore_test.cpp
src/mc/sosp/Region.cpp
src/mc/sosp/Region.hpp
src/mc/sosp/Snapshot.cpp
src/mc/sosp/Snapshot.hpp
src/mc/sosp/Snapshot_test.cpp
src/msg/msg_comm.cpp
src/msg/msg_global.cpp
src/msg/msg_legacy.cpp
src/msg/msg_private.hpp
src/msg/msg_process.cpp
src/msg/msg_task.cpp
src/plugins/dirty_page_tracking.cpp
src/plugins/file_system/s4u_FileSystem.cpp
src/plugins/host_dvfs.cpp
src/plugins/host_energy.cpp
src/plugins/host_load.cpp
src/plugins/link_energy.cpp
src/plugins/vm/VirtualMachineImpl.cpp
src/plugins/vm/VirtualMachineImpl.hpp
src/plugins/vm/VmHostExt.cpp
src/plugins/vm/VmHostExt.hpp
src/plugins/vm/VmLiveMigration.cpp
src/plugins/vm/VmLiveMigration.hpp
src/plugins/vm/s4u_VirtualMachine.cpp
src/s4u/s4u_Activity.cpp
src/s4u/s4u_Actor.cpp
src/s4u/s4u_Barrier.cpp
src/s4u/s4u_Comm.cpp
src/s4u/s4u_ConditionVariable.cpp
src/s4u/s4u_Disk.cpp
src/s4u/s4u_Engine.cpp
src/s4u/s4u_Exec.cpp
src/s4u/s4u_Host.cpp
src/s4u/s4u_Io.cpp
src/s4u/s4u_Link.cpp
src/s4u/s4u_Mailbox.cpp
src/s4u/s4u_Mutex.cpp
src/s4u/s4u_Netzone.cpp
src/s4u/s4u_Semaphore.cpp
src/s4u/s4u_Storage.cpp
src/simdag/sd_daxloader.cpp
src/simdag/sd_dotloader.cpp
src/simdag/sd_global.cpp
src/simdag/sd_task.cpp
src/simdag/simdag_private.hpp
src/simgrid/Exception.cpp
src/simgrid/sg_config.cpp
src/simgrid/sg_version.cpp
src/simgrid/util.hpp
src/simix/libsmx.cpp
src/simix/popping.cpp
src/simix/popping_accessors.hpp
src/simix/popping_bodies.cpp
src/simix/popping_enum.h
src/simix/popping_generated.cpp
src/simix/popping_private.hpp
src/simix/simcalls.in
src/simix/simcalls.py
src/simix/smx_context.cpp
src/simix/smx_deployment.cpp
src/simix/smx_global.cpp
src/simix/smx_private.hpp
src/smpi/bindings/smpi_f77.cpp
src/smpi/bindings/smpi_f77_coll.cpp
src/smpi/bindings/smpi_f77_comm.cpp
src/smpi/bindings/smpi_f77_request.cpp
src/smpi/bindings/smpi_f77_type.cpp
src/smpi/bindings/smpi_mpi.cpp
src/smpi/bindings/smpi_pmpi.cpp
src/smpi/bindings/smpi_pmpi_coll.cpp
src/smpi/bindings/smpi_pmpi_comm.cpp
src/smpi/bindings/smpi_pmpi_file.cpp
src/smpi/bindings/smpi_pmpi_group.cpp
src/smpi/bindings/smpi_pmpi_info.cpp
src/smpi/bindings/smpi_pmpi_op.cpp
src/smpi/bindings/smpi_pmpi_request.cpp
src/smpi/bindings/smpi_pmpi_topo.cpp
src/smpi/bindings/smpi_pmpi_type.cpp
src/smpi/bindings/smpi_pmpi_win.cpp
src/smpi/colls/allgather/allgather-2dmesh.cpp
src/smpi/colls/allgather/allgather-3dmesh.cpp
src/smpi/colls/allgather/allgather-GB.cpp
src/smpi/colls/allgather/allgather-NTSLR-NB.cpp
src/smpi/colls/allgather/allgather-NTSLR.cpp
src/smpi/colls/allgather/allgather-SMP-NTS.cpp
src/smpi/colls/allgather/allgather-bruck.cpp
src/smpi/colls/allgather/allgather-loosely-lr.cpp
src/smpi/colls/allgather/allgather-mvapich-smp.cpp
src/smpi/colls/allgather/allgather-ompi-neighborexchange.cpp
src/smpi/colls/allgather/allgather-pair.cpp
src/smpi/colls/allgather/allgather-rdb.cpp
src/smpi/colls/allgather/allgather-rhv.cpp
src/smpi/colls/allgather/allgather-ring.cpp
src/smpi/colls/allgather/allgather-smp-simple.cpp
src/smpi/colls/allgather/allgather-spreading-simple.cpp
src/smpi/colls/allgatherv/allgatherv-GB.cpp
src/smpi/colls/allgatherv/allgatherv-mpich-rdb.cpp
src/smpi/colls/allgatherv/allgatherv-mpich-ring.cpp
src/smpi/colls/allgatherv/allgatherv-ompi-bruck.cpp
src/smpi/colls/allgatherv/allgatherv-ompi-neighborexchange.cpp
src/smpi/colls/allgatherv/allgatherv-pair.cpp
src/smpi/colls/allgatherv/allgatherv-ring.cpp
src/smpi/colls/allreduce/allreduce-lr.cpp
src/smpi/colls/allreduce/allreduce-mvapich-rs.cpp
src/smpi/colls/allreduce/allreduce-mvapich-two-level.cpp
src/smpi/colls/allreduce/allreduce-ompi-ring-segmented.cpp
src/smpi/colls/allreduce/allreduce-rab-rdb.cpp
src/smpi/colls/allreduce/allreduce-rab1.cpp
src/smpi/colls/allreduce/allreduce-rab2.cpp
src/smpi/colls/allreduce/allreduce-rdb.cpp
src/smpi/colls/allreduce/allreduce-redbcast.cpp
src/smpi/colls/allreduce/allreduce-smp-binomial-pipeline.cpp
src/smpi/colls/allreduce/allreduce-smp-binomial.cpp
src/smpi/colls/allreduce/allreduce-smp-rdb.cpp
src/smpi/colls/allreduce/allreduce-smp-rsag-lr.cpp
src/smpi/colls/allreduce/allreduce-smp-rsag-rab.cpp
src/smpi/colls/allreduce/allreduce-smp-rsag.cpp
src/smpi/colls/alltoall/alltoall-2dmesh.cpp
src/smpi/colls/alltoall/alltoall-3dmesh.cpp
src/smpi/colls/alltoall/alltoall-basic-linear.cpp
src/smpi/colls/alltoall/alltoall-bruck.cpp
src/smpi/colls/alltoall/alltoall-mvapich-scatter-dest.cpp
src/smpi/colls/alltoall/alltoall-pair-light-barrier.cpp
src/smpi/colls/alltoall/alltoall-pair-mpi-barrier.cpp
src/smpi/colls/alltoall/alltoall-pair-one-barrier.cpp
src/smpi/colls/alltoall/alltoall-pair.cpp
src/smpi/colls/alltoall/alltoall-rdb.cpp
src/smpi/colls/alltoall/alltoall-ring-light-barrier.cpp
src/smpi/colls/alltoall/alltoall-ring-mpi-barrier.cpp
src/smpi/colls/alltoall/alltoall-ring-one-barrier.cpp
src/smpi/colls/alltoall/alltoall-ring.cpp
src/smpi/colls/alltoallv/alltoallv-bruck.cpp
src/smpi/colls/alltoallv/alltoallv-ompi-basic-linear.cpp
src/smpi/colls/alltoallv/alltoallv-pair-light-barrier.cpp
src/smpi/colls/alltoallv/alltoallv-pair-mpi-barrier.cpp
src/smpi/colls/alltoallv/alltoallv-pair-one-barrier.cpp
src/smpi/colls/alltoallv/alltoallv-pair.cpp
src/smpi/colls/alltoallv/alltoallv-ring-light-barrier.cpp
src/smpi/colls/alltoallv/alltoallv-ring-mpi-barrier.cpp
src/smpi/colls/alltoallv/alltoallv-ring-one-barrier.cpp
src/smpi/colls/alltoallv/alltoallv-ring.cpp
src/smpi/colls/barrier/barrier-mpich-smp.cpp
src/smpi/colls/barrier/barrier-mvapich2-pair.cpp
src/smpi/colls/barrier/barrier-ompi.cpp
src/smpi/colls/bcast/bcast-NTSB.cpp
src/smpi/colls/bcast/bcast-NTSL-Isend.cpp
src/smpi/colls/bcast/bcast-NTSL.cpp
src/smpi/colls/bcast/bcast-SMP-binary.cpp
src/smpi/colls/bcast/bcast-SMP-binomial.cpp
src/smpi/colls/bcast/bcast-SMP-linear.cpp
src/smpi/colls/bcast/bcast-arrival-pattern-aware-wait.cpp
src/smpi/colls/bcast/bcast-arrival-pattern-aware.cpp
src/smpi/colls/bcast/bcast-arrival-scatter.cpp
src/smpi/colls/bcast/bcast-binomial-tree.cpp
src/smpi/colls/bcast/bcast-flattree-pipeline.cpp
src/smpi/colls/bcast/bcast-flattree.cpp
src/smpi/colls/bcast/bcast-mvapich-smp.cpp
src/smpi/colls/bcast/bcast-ompi-pipeline.cpp
src/smpi/colls/bcast/bcast-ompi-split-bintree.cpp
src/smpi/colls/bcast/bcast-scatter-LR-allgather.cpp
src/smpi/colls/bcast/bcast-scatter-rdb-allgather.cpp
src/smpi/colls/coll_tuned_topo.cpp
src/smpi/colls/coll_tuned_topo.hpp
src/smpi/colls/colls_global.cpp
src/smpi/colls/colls_private.hpp
src/smpi/colls/gather/gather-mvapich.cpp
src/smpi/colls/gather/gather-ompi.cpp
src/smpi/colls/reduce/reduce-NTSL.cpp
src/smpi/colls/reduce/reduce-arrival-pattern-aware.cpp
src/smpi/colls/reduce/reduce-binomial.cpp
src/smpi/colls/reduce/reduce-flat-tree.cpp
src/smpi/colls/reduce/reduce-mvapich-knomial.cpp
src/smpi/colls/reduce/reduce-mvapich-two-level.cpp
src/smpi/colls/reduce/reduce-ompi.cpp
src/smpi/colls/reduce/reduce-rab.cpp
src/smpi/colls/reduce/reduce-scatter-gather.cpp
src/smpi/colls/reduce_scatter/reduce_scatter-mpich.cpp
src/smpi/colls/reduce_scatter/reduce_scatter-ompi.cpp
src/smpi/colls/scatter/scatter-mvapich-two-level.cpp
src/smpi/colls/scatter/scatter-ompi.cpp
src/smpi/colls/smpi_automatic_selector.cpp
src/smpi/colls/smpi_coll.cpp
src/smpi/colls/smpi_default_selector.cpp
src/smpi/colls/smpi_intel_mpi_selector.cpp
src/smpi/colls/smpi_mpich_selector.cpp
src/smpi/colls/smpi_mvapich2_selector.cpp
src/smpi/colls/smpi_mvapich2_selector_stampede.hpp
src/smpi/colls/smpi_nbc_impl.cpp
src/smpi/colls/smpi_openmpi_selector.cpp
src/smpi/include/private.hpp
src/smpi/include/smpi_actor.hpp
src/smpi/include/smpi_coll.hpp
src/smpi/include/smpi_comm.hpp
src/smpi/include/smpi_config.hpp
src/smpi/include/smpi_datatype.hpp
src/smpi/include/smpi_datatype_derived.hpp
src/smpi/include/smpi_errhandler.hpp
src/smpi/include/smpi_f2c.hpp
src/smpi/include/smpi_file.hpp
src/smpi/include/smpi_group.hpp
src/smpi/include/smpi_host.hpp
src/smpi/include/smpi_info.hpp
src/smpi/include/smpi_keyvals.hpp
src/smpi/include/smpi_op.hpp
src/smpi/include/smpi_request.hpp
src/smpi/include/smpi_status.hpp
src/smpi/include/smpi_topo.hpp
src/smpi/include/smpi_utils.hpp
src/smpi/include/smpi_win.hpp
src/smpi/internals/instr_smpi.cpp
src/smpi/internals/smpi_actor.cpp
src/smpi/internals/smpi_bench.cpp
src/smpi/internals/smpi_config.cpp
src/smpi/internals/smpi_deployment.cpp
src/smpi/internals/smpi_global.cpp
src/smpi/internals/smpi_host.cpp
src/smpi/internals/smpi_memory.cpp
src/smpi/internals/smpi_replay.cpp
src/smpi/internals/smpi_shared.cpp
src/smpi/internals/smpi_utils.cpp
src/smpi/mpi/smpi_comm.cpp
src/smpi/mpi/smpi_datatype.cpp
src/smpi/mpi/smpi_datatype_derived.cpp
src/smpi/mpi/smpi_errhandler.cpp
src/smpi/mpi/smpi_f2c.cpp
src/smpi/mpi/smpi_file.cpp
src/smpi/mpi/smpi_group.cpp
src/smpi/mpi/smpi_info.cpp
src/smpi/mpi/smpi_keyvals.cpp
src/smpi/mpi/smpi_op.cpp
src/smpi/mpi/smpi_request.cpp
src/smpi/mpi/smpi_status.cpp
src/smpi/mpi/smpi_topo.cpp
src/smpi/mpi/smpi_win.cpp
src/smpi/plugins/ampi/ampi.cpp
src/smpi/plugins/ampi/ampi.hpp
src/smpi/plugins/ampi/instr_ampi.cpp
src/smpi/plugins/ampi/instr_ampi.hpp
src/smpi/plugins/load_balancer/LoadBalancer.cpp
src/smpi/plugins/load_balancer/load_balancer.hpp
src/smpi/plugins/sampi_loadbalancer.cpp
src/smpi/smpi_main.c
src/smpi/smpicc.in
src/smpi/smpicxx.in
src/smpi/smpif90.in
src/smpi/smpiff.in
src/smpi/smpirun.in
src/smpi/smpitools.sh
src/surf/HostImpl.cpp
src/surf/HostImpl.hpp
src/surf/StorageImpl.cpp
src/surf/StorageImpl.hpp
src/surf/cpu_cas01.cpp
src/surf/cpu_cas01.hpp
src/surf/cpu_interface.cpp
src/surf/cpu_interface.hpp
src/surf/cpu_ti.cpp
src/surf/cpu_ti.hpp
src/surf/disk_s19.cpp
src/surf/disk_s19.hpp
src/surf/host_clm03.cpp
src/surf/host_clm03.hpp
src/surf/network_cm02.cpp
src/surf/network_cm02.hpp
src/surf/network_constant.cpp
src/surf/network_constant.hpp
src/surf/network_ib.cpp
src/surf/network_ib.hpp
src/surf/network_interface.cpp
src/surf/network_interface.hpp
src/surf/network_ns3.cpp
src/surf/network_ns3.hpp
src/surf/network_smpi.cpp
src/surf/network_smpi.hpp
src/surf/network_wifi.cpp
src/surf/network_wifi.hpp
src/surf/ns3/ns3_simulator.cpp
src/surf/ns3/ns3_simulator.hpp
src/surf/ptask_L07.cpp
src/surf/ptask_L07.hpp
src/surf/sg_platf.cpp
src/surf/storage_n11.cpp
src/surf/storage_n11.hpp
src/surf/surf_c_bindings.cpp
src/surf/surf_interface.cpp
src/surf/surf_interface.hpp
src/surf/surf_private.hpp
src/surf/xml/platf.hpp
src/surf/xml/platf_private.hpp
src/surf/xml/surfxml_parseplatf.cpp
src/surf/xml/surfxml_sax_cb.cpp
src/xbt/OsSemaphore.hpp
src/xbt/PropertyHolder.cpp
src/xbt/automaton/automaton.c
src/xbt/automaton/automaton_lexer.yy.c
src/xbt/automaton/automatonparse_promela.c
src/xbt/automaton/parserPromela.lex
src/xbt/automaton/parserPromela.tab.cacc
src/xbt/automaton/parserPromela.yacc
src/xbt/backtrace.cpp
src/xbt/config.cpp
src/xbt/config_test.cpp
src/xbt/dict.cpp
src/xbt/dict_cursor.c
src/xbt/dict_elm.c
src/xbt/dict_private.h
src/xbt/dict_test.cpp
src/xbt/dynar.cpp
src/xbt/dynar_test.cpp
src/xbt/exception.cpp
src/xbt/graph.c
src/xbt/log.cpp
src/xbt/log_private.hpp
src/xbt/mallocator.c
src/xbt/mallocator_private.h
src/xbt/memory_map.cpp
src/xbt/memory_map.hpp
src/xbt/mmalloc/mfree.c
src/xbt/mmalloc/mm.c
src/xbt/mmalloc/mm_legacy.c
src/xbt/mmalloc/mm_module.c
src/xbt/mmalloc/mmalloc.c
src/xbt/mmalloc/mmorecore.c
src/xbt/mmalloc/mmprivate.h
src/xbt/mmalloc/mrealloc.c
src/xbt/mmalloc/swag.c
src/xbt/mmalloc/swag.h
src/xbt/parmap.cpp
src/xbt/random.cpp
src/xbt/random_test.cpp
src/xbt/snprintf.c
src/xbt/string.cpp
src/xbt/unit-tests_main.cpp
src/xbt/xbt_log_appender_file.cpp
src/xbt/xbt_log_layout_format.cpp
src/xbt/xbt_log_layout_simple.cpp
src/xbt/xbt_main.cpp
src/xbt/xbt_os_file.cpp
src/xbt/xbt_os_synchro.cpp
src/xbt/xbt_os_time.c
src/xbt/xbt_replay.cpp
src/xbt/xbt_str.cpp
src/xbt/xbt_str_test.cpp
src/xbt/xbt_virtu.cpp
src/xbt_modinter.h
teshsuite/java/semaphoregc/SemaphoreGC.java
teshsuite/java/sleephostoff/SleepHostOff.java
teshsuite/mc/dwarf-expression/dwarf-expression.cpp
teshsuite/mc/dwarf/dwarf.cpp
teshsuite/mc/mutex-handling/mutex-handling.c
teshsuite/mc/random-bug/random-bug.cpp
teshsuite/msg/app-bittorrent/bittorrent-messages.c
teshsuite/msg/app-bittorrent/bittorrent-messages.h
teshsuite/msg/app-bittorrent/bittorrent-peer.c
teshsuite/msg/app-bittorrent/bittorrent-peer.h
teshsuite/msg/app-bittorrent/bittorrent.c
teshsuite/msg/app-bittorrent/bittorrent.h
teshsuite/msg/app-bittorrent/connection.c
teshsuite/msg/app-bittorrent/connection.h
teshsuite/msg/app-bittorrent/generate.py
teshsuite/msg/app-bittorrent/tracker.c
teshsuite/msg/app-bittorrent/tracker.h
teshsuite/msg/app-chainsend/broadcaster.c
teshsuite/msg/app-chainsend/broadcaster.h
teshsuite/msg/app-chainsend/chainsend.c
teshsuite/msg/app-chainsend/common.c
teshsuite/msg/app-chainsend/common.h
teshsuite/msg/app-chainsend/iterator.c
teshsuite/msg/app-chainsend/iterator.h
teshsuite/msg/app-chainsend/messages.c
teshsuite/msg/app-chainsend/messages.h
teshsuite/msg/app-chainsend/peer.c
teshsuite/msg/app-chainsend/peer.h
teshsuite/msg/app-pingpong/app-pingpong.c
teshsuite/msg/app-token-ring/app-token-ring.c
teshsuite/msg/async-wait/async-wait.c
teshsuite/msg/async-waitall/async-waitall.c
teshsuite/msg/async-waitany/async-waitany.c
teshsuite/msg/cloud-capping/cloud-capping.c
teshsuite/msg/cloud-migration/cloud-migration.c
teshsuite/msg/cloud-simple/cloud-simple.c
teshsuite/msg/cloud-two-tasks/cloud-two-tasks.c
teshsuite/msg/energy-consumption/energy-consumption.c
teshsuite/msg/energy-pstate/energy-pstate.c
teshsuite/msg/energy-ptask/energy-ptask.c
teshsuite/msg/get_sender/get_sender.c
teshsuite/msg/host_on_off/host_on_off.c
teshsuite/msg/host_on_off_processes/host_on_off_processes.cpp
teshsuite/msg/host_on_off_recv/host_on_off_recv.c
teshsuite/msg/io-file-remote/io-file-remote.c
teshsuite/msg/io-file/io-file.c
teshsuite/msg/io-raw-storage/io-raw-storage.c
teshsuite/msg/platform-properties/platform-properties.c
teshsuite/msg/plugin-hostload/plugin-hostload.c
teshsuite/msg/process-daemon/process-daemon.c
teshsuite/msg/process-join/process-join.c
teshsuite/msg/process-kill/process-kill.c
teshsuite/msg/process-lifetime/process-lifetime.c
teshsuite/msg/process-migration/process-migration.c
teshsuite/msg/process-suspend/process-suspend.c
teshsuite/msg/process-yield/process-yield.c
teshsuite/msg/task-priority/task-priority.c
teshsuite/msg/task_destroy_cancel/task_destroy_cancel.cpp
teshsuite/msg/task_listen_from/task_listen_from.cpp
teshsuite/msg/task_progress/task_progress.cpp
teshsuite/msg/trace_integration/trace_integration.c
teshsuite/s4u/activity-lifecycle/activity-lifecycle.cpp
teshsuite/s4u/actor-autorestart/actor-autorestart.cpp
teshsuite/s4u/actor/actor.cpp
teshsuite/s4u/cloud-interrupt-migration/cloud-interrupt-migration.cpp
teshsuite/s4u/cloud-sharing/cloud-sharing.cpp
teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp
teshsuite/s4u/concurrent_rw/concurrent_rw.cpp
teshsuite/s4u/listen_async/listen_async.cpp
teshsuite/s4u/ns3-simultaneous-send-rcv/ns3-simultaneous-send-rcv.cpp
teshsuite/s4u/pid/pid.cpp
teshsuite/s4u/storage_client_server/storage_client_server.cpp
teshsuite/simdag/availability/availability.c
teshsuite/simdag/basic-link-test/basic-link-test.c
teshsuite/simdag/basic-parsing-test/basic-parsing-test.c
teshsuite/simdag/basic0/basic0.c
teshsuite/simdag/basic1/basic1.c
teshsuite/simdag/basic3/basic3.c
teshsuite/simdag/basic4/basic4.c
teshsuite/simdag/basic5/basic5.c
teshsuite/simdag/basic6/basic6.c
teshsuite/simdag/comm-mxn-all2all/comm-mxn-all2all.c
teshsuite/simdag/comm-mxn-independent/comm-mxn-independent.c
teshsuite/simdag/comm-mxn-scatter/comm-mxn-scatter.c
teshsuite/simdag/comm-p2p-latency-1/comm-p2p-latency-1.c
teshsuite/simdag/comm-p2p-latency-2/comm-p2p-latency-2.c
teshsuite/simdag/comm-p2p-latency-3/comm-p2p-latency-3.c
teshsuite/simdag/comm-p2p-latency-bound/comm-p2p-latency-bound.c
teshsuite/simdag/comp-only-par/comp-only-par.c
teshsuite/simdag/comp-only-seq/comp-only-seq.c
teshsuite/simdag/evaluate-get-route-time/evaluate-get-route-time.c
teshsuite/simdag/evaluate-parse-time/evaluate-parse-time.c
teshsuite/simdag/flatifier/flatifier.cpp
teshsuite/simdag/incomplete/incomplete.c
teshsuite/simdag/is-router/is-router.cpp
teshsuite/simix/check-defaults/check-defaults.cpp
teshsuite/simix/generic-simcalls/generic-simcalls.cpp
teshsuite/simix/stack-overflow/stack-overflow.cpp
teshsuite/smpi/auto-shared/auto-shared.c
teshsuite/smpi/bug-17132/bug-17132.c
teshsuite/smpi/coll-allgather/coll-allgather.c
teshsuite/smpi/coll-allgatherv/coll-allgatherv.c
teshsuite/smpi/coll-allreduce/coll-allreduce.c
teshsuite/smpi/coll-alltoall/coll-alltoall.c
teshsuite/smpi/coll-alltoallv/coll-alltoallv.c
teshsuite/smpi/coll-barrier/coll-barrier.c
teshsuite/smpi/coll-bcast/coll-bcast.c
teshsuite/smpi/coll-gather/coll-gather.c
teshsuite/smpi/coll-reduce-scatter/coll-reduce-scatter.c
teshsuite/smpi/coll-reduce/coll-reduce.c
teshsuite/smpi/coll-scatter/coll-scatter.c
teshsuite/smpi/gh-139/gh-139.c
teshsuite/smpi/macro-partial-shared-communication/macro-partial-shared-communication.c
teshsuite/smpi/macro-partial-shared/macro-partial-shared.c
teshsuite/smpi/macro-sample/macro-sample.c
teshsuite/smpi/macro-shared/macro-shared.c
teshsuite/smpi/mpich3-test/pt2pt/dtype_send.c
teshsuite/smpi/mpich3-test/runtests
teshsuite/smpi/privatization/privatization.c
teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.c
teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.c
teshsuite/smpi/topo-cart-sub/topo-cart-sub.c
teshsuite/smpi/type-hvector/type-hvector.c
teshsuite/smpi/type-indexed/type-indexed.c
teshsuite/smpi/type-struct/type-struct.c
teshsuite/smpi/type-vector/type-vector.c
teshsuite/surf/lmm_usage/lmm_usage.cpp
teshsuite/surf/maxmin_bench/maxmin_bench.cpp
teshsuite/surf/surf_usage/surf_usage.cpp
teshsuite/surf/surf_usage2/surf_usage2.cpp
teshsuite/surf/wifi_usage/wifi_usage.cpp
teshsuite/xbt/cmdline/cmdline.c
teshsuite/xbt/log_large/log_large.c
teshsuite/xbt/log_usage/log_usage.c
teshsuite/xbt/mmalloc/mmalloc_test.cpp
teshsuite/xbt/parallel_log_crashtest/parallel_log_crashtest.cpp
teshsuite/xbt/parmap_bench/parmap_bench.cpp
teshsuite/xbt/parmap_test/parmap_test.cpp
teshsuite/xbt/signals/signals.cpp
tools/MSG_visualization/colorize.pl
tools/MSG_visualization/trace2fig.pl
tools/cmake/DefinePackages.cmake
tools/cmake/Flags.cmake
tools/cmake/Java.cmake
tools/cmake/Modules/FindLibunwind.cmake
tools/cmake/Tests.cmake
tools/cmake/scripts/my_valgrind.pl
tools/cmake/scripts/update_tesh.pl
tools/cmake/test_prog/prog_asan.cpp
tools/cmake/test_prog/prog_makecontext.c
tools/cmake/test_prog/prog_stackgrowth.c
tools/cmake/test_prog/prog_stacksetup.c
tools/cmake/test_prog/prog_tsan.cpp [new file with mode: 0644]
tools/doxygen/fig2dev_postprocessor.pl
tools/doxygen/xbt_log_extract_hierarchy.pl
tools/fix-paje-trace.sh
tools/git-hooks/clang-format.pre-commit
tools/graphicator/graphicator.c
tools/internal/check_dist_archive
tools/internal/indent
tools/internal/spell_comments.pl
tools/internal/update_copyright_header
tools/jenkins/build.sh
tools/normalize-pointers.py
tools/sg_xml_unit_converter.py
tools/simgrid.supp
tools/simgrid_update_xml.pl
tools/tesh/tesh.py

index b9d6b19..285e374 100644 (file)
@@ -1,6 +1,6 @@
 # This is the configuration file for the https://circleci.com/ continuous integration server
 #
-# Copyright (c) 2017-2019. The SimGrid team. All rights reserved.
+# Copyright (c) 2017-2020. The SimGrid team. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
index 5940061..49d8abb 100644 (file)
@@ -181,6 +181,7 @@ examples/s4u/exec-monitor/s4u-exec-monitor
 examples/s4u/exec-ptask/s4u-exec-ptask
 examples/s4u/exec-remote/s4u-exec-remote
 examples/s4u/exec-waitany/s4u-exec-waitany
+examples/s4u/exec-waitfor/s4u-exec-waitfor
 examples/s4u/io-async/s4u-io-async
 examples/s4u/io-file-remote/s4u-io-file-remote
 examples/s4u/io-file-system/s4u-io-file-system
index 7c355ce..254b313 100644 (file)
@@ -11,7 +11,7 @@ pages:
   - make -j4
   - pip3 install --requirement docs/requirements.txt
   - cd docs
-  - LC_ALL=C.UTF-8 SPHINXOPTS=-vv ./Build.sh
+  - LC_ALL=C.UTF-8 ./Build.sh
   - mv build/html ../public
   # - The CSS contains a reference to a font or something, not something we gonna fix on our side
   # - The javasphinx output does not exist in the git, so the "edit on FramaGit" link is broken.
index d1d6767..480a3b0 100644 (file)
@@ -43,7 +43,7 @@ jobs:
       - sudo apt-get update -qq
       - sudo apt-get install cmake valgrind gfortran libboost-dev libboost-all-dev libdw-dev libevent-dev libunwind8-dev pybind11-dev
       - (cmake -Denable_model-checking=ON  -Denable_documentation=OFF -Denable_coverage=ON -Denable_java=ON -Denable_lua=OFF -Denable_compile_optimizations=ON -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=ON -Denable_compile_warnings=ON . || (echo XXX CMakeOutput.log; cat /home/travis/build/simgrid/simgrid/CMakeFiles/CMakeOutput.log; echo XXX CMakeError.log;cat /home/travis/build/simgrid/simgrid/CMakeFiles/CMakeError.log; exit 1))
-      - make -j2 VERBOSE=1 all tests && ctest -j2 --output-on-failure
+      - make -j2 VERBOSE=1 all && make -j2 tests && ctest -j2 --output-on-failure
     - os: windows
       script:
       - mv "C:/Program Files/Git/usr/bin/sh.exe" "sh-ignored.exe"
@@ -67,7 +67,7 @@ jobs:
       script:
       - export LIBRARY_PATH=/usr/local/lib/gcc/9
       - cmake -Denable_model-checking=OFF -Denable_documentation=OFF -Denable_coverage=ON -Denable_java=ON -Denable_lua=OFF -Denable_compile_optimizations=ON -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=OFF -Denable_compile_warnings=ON .
-      - make -j2 VERBOSE=1 all tests && ctest -j2 --output-on-failure
+      - make -j2 VERBOSE=1 all && make -j2 tests && ctest -j2 --output-on-failure
 notifications:
   recipients:
     - martin.quinson@ens-rennes.fr
index 4bb2f7a..1ac4534 100755 (executable)
@@ -3,7 +3,7 @@
 # This little script rebuilds and runs the SimGrid archive in parallel, extracting a log
 # This is almost an internal script, but others may find this useful
 #
-# Copyright (c) 2017-2019 The SimGrid Team. Licence: LGPL of WDFPL, as you want.
+# Copyright (c) 2017-2020 The SimGrid Team. Licence: LGPL of WDFPL, as you want.
 
 if [ ! -e Makefile ] ; then
   if [ -e build/default/Makefile ] ; then
@@ -16,6 +16,7 @@ if [ ! -e Makefile ] ; then
 fi
 
 target=tests
+ncores=$(grep -c processor /proc/cpuinfo)
 
 install_path=$(sed -n 's/^CMAKE_INSTALL_PREFIX:PATH=//p' CMakeCache.txt)
 if [ -e ${install_path} ] && [ -d ${install_path} ] && [ -x ${install_path} ] && [ -w ${install_path} ] ; then
@@ -25,6 +26,7 @@ fi
 (
   echo "install_path: ${install_path}"
   echo "Target: ${target}"
-  (nice make -j4 ${target} tests || make ${target} tests) && nice ctest -j4 --output-on-failure ; date
+  echo "Cores: ${ncores}"
+  (nice make -j${ncores} ${target} tests || make ${target} tests) && nice ctest -j${ncores} --output-on-failure ; date
 ) 2>&1 | tee BuildSimGrid.sh.log
 
index 6146201..5b0f0da 100644 (file)
@@ -29,8 +29,8 @@ project(SimGrid C CXX)
 ## Save compiler flags preset with environment variables CFLAGS or CXXFLAGS;
 ## they will used within smpicc, smpicxx.
 ## Do it early so that we get their genuine values. The same will be done later for Fortran.
-set(SMPI_C_FLAGS "${CMAKE_C_FLAGS}")
-set(SMPI_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+string(REGEX REPLACE " *-f[a-z]+-prefix-map=[^ ]*" "" SMPI_C_FLAGS "${CMAKE_C_FLAGS}")
+string(REGEX REPLACE " *-f[a-z]+-prefix-map=[^ ]*" "" SMPI_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
 
 #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
 #     Check for the compiler        #
@@ -101,7 +101,7 @@ if ((NOT DEFINED enable_smpi) OR enable_smpi)
       set(SMPI_Fortran_LIBS "")
       set(SMPI_FLANG 1)
     endif()
-    set(SMPI_Fortran_FLAGS "${SMPI_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS}")
+    string(REGEX REPLACE " *-f[a-z]+-prefix-map=[^ ]*" "" SMPI_Fortran_FLAGS "${SMPI_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS}")
 
     ## Request debugging flags for Fortran too
     set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g")
diff --git a/COPYING b/COPYING
index 5eeebe3..6d487dd 100644 (file)
--- a/COPYING
+++ b/COPYING
@@ -3,7 +3,7 @@ Upstream-Name: SimGrid
 Source: https://simgrid.org/
 
 Files: *
-Copyright: 2003-2019. The SimGrid team. All rights reserved.
+Copyright: 2003-2020. The SimGrid team. All rights reserved.
 License: LGPL-2.1
 
 Files: src/xbt/snprintf.c
@@ -14,7 +14,7 @@ Comment: Heavily adapted by the SimGrid team but remains under the original lice
 Files: src/xbt/mmalloc/* src/include/xbt/mmalloc.h
 Copyright: 
   Copyright (C) 1991, 1992 Free Software Foundation, Inc.
-  Copyright (C) 2003-2019. The SimGrid team.
+  Copyright (C) 2003-2020. The SimGrid team.
 License: LGPL-2.1
 Comment: these files used to be part of gdb, but were removed there
 
@@ -72,7 +72,7 @@ Files:
 Copyright:
  FleXML is Copyright (C) 1999-2005 Kristoffer Rose.  All rights reserved.
  FleXML is Copyright (C) 2003-2013 Martin Quinson.  All rights reserved.
- Copyright (C) 2003-2019. The SimGrid team.
+ Copyright (C) 2003-2020. The SimGrid team.
 License: GPL-2+ and LGPL-2.1
 Comment: Generated with the FleXML XML processor generator (which is GPL-2+) using SimGrid configuration files (that are LGPL-2.1)
 
@@ -176,7 +176,7 @@ License: other-reduce-rab
 Files: src/xbt/automaton/parserPromela.tab.cacc
 Copyright:
  Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
- Copyright (C) 2003-2019. The SimGrid team.
+ Copyright (C) 2003-2020. The SimGrid team.
 License: GPL-3+ and LGPL-2.1
 Comment: Generated with the Bison processor generator (which is GPL-3+) using SimGrid configuration files (that are LGPL-2.1) 
 
index dedf005..f9e03f6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.               */
+/* Copyright (c) 2020. The SimGrid Team. All rights reserved.               */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 242ee77..feceb39 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,10 +2,17 @@
 
 SimGrid (3.24.1) NOT RELEASED YET (v3.25 expected December 22. 2029, 04:19 UTC)
 
+General:
+- Upgrade documented Java dependency to Java 8 (earlier versions don't work).
+- Drop support for Viva/Triva (old visualization tools), hence removed
+  TRACE_get_node_types() and TRACE_get_edge_types() functions.
+
 S4U:
 - Actor: Merge signals on_migration_start/end into on_host_change
 - Actor: Rename migrate() into set_host()
 - Disk: Allow users to get the read and write nominal bandwidth values
+- Exec: Implement wait_for(timeout)
+- Io: Implement wait_for(timeout)
 
 XML:
 - Parse errors now raise a simgrid::ParseError that you may want to catch.
@@ -19,13 +26,48 @@ Kernel:
 
 XBT:
 - Remove unused parameter 'free_ctn' for xbt_dict_set() and xbt_dict_set_ext().
+- Drop unused functions for dicts and dynars: xbt_dict_cursor_get_elm,
+  xbt_dict_get, xbt_dict_get_elm, xbt_dict_get_ext, xbt_dict_get_key,
+  xbt_dict_remove, xbt_dict_reset, xbt_dynar_compare, xbt_dynar_dump,
+  xbt_dynar_foreach_ptr, xbt_dynar_free_data, xbt_dynar_free_voidp,
+  xbt_dynar_init, xbt_dynar_insert_at_as, xbt_dynar_merge,
+  xbt_dynar_remove_n_at, xbt_dynar_replace, xbt_dynar_search, xbt_dynar_set.
 - New module: random, providing classical random numbers generators.
 
+SMPI:
+- New option : "smpi/auto-shared-malloc-thresh" which sets a value for
+  allocations' size above which they are considered "shared" by default (as if
+  they were performed through SMPI_SHARED_MALLOC macros).
+  Default = 0 = disabled feature.
+  Note : malloc, calloc and free are now overriden by smpicc/cxx by default.
+  This can cause some troubles if codes are already overriding these. If this
+  is the case, defining SMPI_NO_OVERRIDE_MALLOC in the compilation flags can
+  help, but will make this feature unusable.
+- Input check is now performed much more consistently and outputs precise
+  warnings for each error found
+- New supported calls : MPI_File_set_view, MPI_File_get_view
+- MPI I/O now only supports disks, as storage is discontinued.
+- MPI I/O allows opening files without specifying absolute path
+- Note : SMPI configuration options are now initialized by smpi_init_options()
+  call, which should be called if SMPI is not being used through smpirun.
+
 Fixed bugs (FG#.. -> framagit bugs; FG!.. -> framagit merge requests):
+ - FG#39: Missing s4u::Comm::wait_any_for example
+ - FG#42: Add support for ThreadSanitizer (TSan)
+ - FG!19: Removing RngStream
+ - FG!20: A module for RNG calls
+ - FG!21: Choice between ad-hoc and standard distributions implementations
+ - FG!23: Master
+ - FG!25: Fix link in Mutex doc
+ - FG!26: Fix links in SMPI interface doc
  - GH#31: [MC] please provide an option to make MPI_Send asynchronous
  - GH#305: Unscheduled tasks are still excuted
+ - GH#313: smpirun: manual outdated w.r.t. --help
+ - GH#321: [S4U] Get task remaining work ratio
  - GH#323: Crash when an actor turn off his physical host
- - FG!19: Removing RngStream
+ - GH#335: Missing links on dragonfly example svg
+ - https://lists.gforge.inria.fr/pipermail/simgrid-user/2019-November/004653.html:
+   MPI_Cart_sub was not working properly. Kudos to Jonathan Borne for the report.
 
 ----------------------------------------------------------------------------
 
index 25df867..6051874 100644 (file)
@@ -1,6 +1,6 @@
 # CMake find module to search for the SimGrid library. 
 
-# Copyright (c) 2016-2019. The SimGrid Team.
+# Copyright (c) 2016-2020. The SimGrid Team.
 #
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
index 6fe863b..aadfaed 100644 (file)
@@ -378,6 +378,8 @@ include examples/s4u/exec-remote/s4u-exec-remote.cpp
 include examples/s4u/exec-remote/s4u-exec-remote.tesh
 include examples/s4u/exec-waitany/s4u-exec-waitany.cpp
 include examples/s4u/exec-waitany/s4u-exec-waitany.tesh
+include examples/s4u/exec-waitfor/s4u-exec-waitfor.cpp
+include examples/s4u/exec-waitfor/s4u-exec-waitfor.tesh
 include examples/s4u/io-async/s4u-io-async.cpp
 include examples/s4u/io-async/s4u-io-async.tesh
 include examples/s4u/io-disk-raw/s4u-io-disk-raw.cpp
@@ -416,6 +418,8 @@ include examples/s4u/routing-get-clusters/s4u-routing-get-clusters.cpp
 include examples/s4u/routing-get-clusters/s4u-routing-get-clusters.tesh
 include examples/s4u/synchro-barrier/s4u-synchro-barrier.cpp
 include examples/s4u/synchro-barrier/s4u-synchro-barrier.tesh
+include examples/s4u/synchro-condition-variable/s4u-synchro-condition-variable.cpp
+include examples/s4u/synchro-condition-variable/s4u-synchro-condition-variable.tesh
 include examples/s4u/synchro-mutex/s4u-synchro-mutex.cpp
 include examples/s4u/synchro-mutex/s4u-synchro-mutex.tesh
 include examples/s4u/synchro-semaphore/s4u-synchro-semaphore.cpp
@@ -1780,6 +1784,7 @@ include doc/doxygen/uhood.doc
 include doc/doxygen/uhood_arch.doc
 include doc/doxygen/uhood_switch.doc
 include docs/Build.sh
+include docs/find-missing.ignore
 include docs/find-missing.py
 include docs/ignored_symbols
 include docs/manpages/smpicc.1
@@ -1796,6 +1801,7 @@ include docs/source/Experimental_Setup.rst
 include docs/source/Installing_SimGrid.rst
 include docs/source/Introduction.rst
 include docs/source/Platform_Examples.rst
+include docs/source/Platform_Routing.rst
 include docs/source/Plugins.rst
 include docs/source/Start_Your_Own_Project.rst
 include docs/source/Tutorial_Algorithms.rst
@@ -2182,7 +2188,6 @@ include src/kernel/context/ContextThread.cpp
 include src/kernel/context/ContextThread.hpp
 include src/kernel/context/ContextUnix.cpp
 include src/kernel/context/ContextUnix.hpp
-include src/kernel/context/context_private.hpp
 include src/kernel/future.cpp
 include src/kernel/lmm/fair_bottleneck.cpp
 include src/kernel/lmm/maxmin.cpp
@@ -2720,6 +2725,7 @@ include tools/cmake/test_prog/prog_asan.cpp
 include tools/cmake/test_prog/prog_makecontext.c
 include tools/cmake/test_prog/prog_stackgrowth.c
 include tools/cmake/test_prog/prog_stacksetup.c
+include tools/cmake/test_prog/prog_tsan.cpp
 include tools/doxygen/fig2dev_postprocessor.pl
 include tools/doxygen/list_routing_models_examples.sh
 include tools/doxygen/xbt_log_extract_hierarchy.pl
index bf4b880..81b862e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 50bab56..0d8e6b2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 1b9d799..2e9967f 100644 (file)
@@ -207,263 +207,6 @@ id              | yes       | string | Name of the link that is supposed to act
   @ref msg_file ; access functions are organized as a POSIX-like
   interface.
 
-@subsubsection pf_sto_conc Storage - Main Concepts
-
-The storage facilities implemented in SimGrid help to model (and account for) 
-storage devices, such as tapes, hard-drives, CD or DVD devices etc. 
-A typical situation is depicted in the figure below:
-
-@image html ./webcruft/storage_sample_scenario.png
-@image latex ./webcruft/storage_sample_scenario.png "storage_sample_scenario" width=@textwidth
-
-In this figure, two hosts called Bob and Alice are interconnected via a network
-and each host is physically attached to a disk; it is not only possible for each host to
-mount the disk they are attached to directly, but they can also mount disks
-that are in a remote location. In this example, Bob mounts Alice's disk remotely
-and accesses the storage via the network.
-
-SimGrid provides 3 different entities that can be used to model setups
-that include storage facilities:
-
-Entity name     | Description
---------------- | -----------
-@ref pf_storage_entity_storage_type "storage_type"    | Defines a template for a particular kind of storage (such as a hard-drive) and specifies important features of the storage, such as capacity, performance (read/write), contents, ... Different models of hard-drives use different storage_types (because the difference between an SSD and an HDD does matter), as they differ in some specifications (e.g., different sizes or read/write performance).
-@ref pf_tag_storage "storage"        | Defines an actual instance of a storage type (disk, RAM, ...); uses a ``storage_type`` template (see line above) so that you don't need to re-specify the same details over and over again.
-@ref pf_tag_mount "mount"          | Must be wrapped by a @ref pf_tag_host tag; declares which storage(s) this host has mounted and where (i.e., the mountpoint).
-
-
-@anchor pf_storage_content_file
-### %Storage Content File ###
-
-In order to assess exactly how much time is spent reading from the storage,
-SimGrid needs to know what is stored on the storage device (identified by distinct (file-)name, like in a file system)
-and what size this content has.
-
-@note
-    The content file is never changed by the simulation; it is parsed once
-    per simulation and kept in memory afterwards. When the content of the
-    storage changes, only the internal SimGrid data structures change.
-
-@anchor pf_storage_content_file_structure
-#### Structure of a %Storage Content File ####
-
-Here is an excerpt from two storage content file; if you want to see the whole file, check
-the file ``examples/platforms/content/storage_content.txt`` that comes with the
-SimGrid source code.
-
-SimGrid essentially supports two different formats: UNIX-style filepaths should
-follow the well known format:
-
-@verbatim
-/lib/libsimgrid.so.3.6.2  12710497
-/bin/smpicc  918
-/bin/smpirun  7292
-/bin/smpif2c  1990
-/bin/simgrid_update_xml  5018
-/bin/graphicator  66986
-/bin/simgrid-colorizer  2993
-/bin/smpiff  820
-/bin/tesh  356434
-@endverbatim
-
-Windows filepaths, unsurprisingly, use the windows style:
-
-@verbatim
-@Windows@avastSS.scr 41664
-@Windows@bfsvc.exe 75264
-@Windows@bootstat.dat 67584
-@Windows@CoreSingleLanguage.xml 31497
-@Windows@csup.txt 12
-@Windows@dchcfg64.exe 335464
-@Windows@dcmdev64.exe 93288
-@endverbatim
-
-@note
-    The different file formats come at a cost; in version 3.12 (and most likely
-    in later versions, too), copying files from windows-style storages to unix-style
-    storages (and vice versa) is not supported.
-
-@anchor pf_storage_content_file_create
-#### Generate a %Storage Content File ####
-
-If you want to generate a storage content file based on your own filesystem (or at least a filesystem you have access to),
-try running this command (works only on unix systems):
-
-@verbatim
-find . -type f -exec ls -1s --block=1 {} @; 2>/dev/null | awk '{ print $2 " " $1}' > ./content.txt
-@endverbatim
-
-@subsubsection pf_storage_entities The Storage Entities
-
-These are the entities that you can use in your platform files to include
-storage in your model. See also the list of our @ref pf_storage_example_files "example files";
-these might also help you to get started.
-
-@anchor pf_storage_entity_storage_type
-#### @<storage_type@> ####
-
-Attribute name  | Mandatory | Values | Description
---------------- | --------- | ------ | -----------
-id              | yes       | string | Identifier of this storage_type; used when referring to it
-model           | no        | string | In the future, this will allow one to change the performance model to use
-size            | yes       | string | Specifies the amount of available storage space; you can specify storage like "500GiB" or "500GB" if you want. (TODO add a link to all the available abbreviations)
-content         | yes       | string | Path to a @ref pf_storage_content_file "Storage Content File" on your system. This file must exist.
-
-This tag must contain some predefined model properties, specified via the &lt;model_prop&gt; tag. Here is a list,
-see below for an example:
-
-Property id     | Mandatory | Values | Description
---------------- | --------- | ------ | -----------
-Bwrite          | yes       | string | Bandwidth for write access; in B/s (but you can also specify e.g. "30MBps")
-Bread           | yes       | string | Bandwidth for read access; in B/s (but you can also specify e.g. "30MBps")
-
-@note
-     A storage_type can also contain the <b>&lt;prop&gt;</b> tag. The &lt;prop&gt; tag allows you
-     to associate additional information to this &lt;storage_type&gt; and follows the
-     attribute/value schema; see the example below. You may want to use it to give information to
-     the tool you use for rendering your simulation, for example.
-
-Here is a complete example for the ``storage_type`` tag:
-@verbatim
-<storage_type id="single_HDD" size="4000">
-  <model_prop id="Bwrite" value="30MBps" />
-  <model_prop id="Bread" value="100MBps" />
-  <prop id="Brand" value="Western Digital" />
-</storage_type>
-@endverbatim
-
-@subsubsection pf_tag_storage &lt;storage&gt; 
-
-Attributes     | Mandatory | Values | Description
--------------- | --------- | ------ | -----------
-id             | yes       | string | Identifier of this ``storage``; used when referring to it
-typeId         | yes       | string | Here you need to refer to an already existing @ref pf_storage_entity_storage_type "@<storage_type@>"; the storage entity defined by this tag will then inherit the properties defined there.
-attach         | yes       | string | Name of a host (see Section @ref pf_tag_host) to which this storage is <i>physically</i> attached to (e.g., a hard drive in a computer)
-content        | no        | string | When specified, overwrites the content attribute of @ref pf_storage_entity_storage_type "@<storage_type@>"
-
-Here are two examples:
-
-@verbatim
-     <storage id="Disk1" typeId="single_HDD" attach="bob" />
-
-     <storage id="Disk2" typeId="single_SSD"
-              content="content/win_storage_content.txt" />
-@endverbatim
-
-The first example is straightforward: A disk is defined and called "Disk1"; it is
-of type "single_HDD" (shown as an example of @ref pf_storage_entity_storage_type "@<storage_type@>" above) and attached
-to a host called "bob" (the definition of this host is omitted here).
-
-The second storage is called "Disk2", is still of the same type as Disk1 but
-now specifies a new content file (so the contents will be different from Disk1)
-and the filesystem uses the windows style; finally, it is attached to a second host,
-called alice (which is again not defined here).
-
-@subsubsection pf_tag_mount &lt;mount&gt;
-
-| Attribute   | Mandatory   | Values   | Description                                                                                               |
-| ----------- | ----------- | -------- | -------------                                                                                             |
-| id          | yes         | string   | Refers to a @ref pf_tag_storage "&lt;storage&gt;" entity that will be mounted on that computer |
-| name        | yes         | string   | Path/location to/of the logical reference (mount point) of this disk
-
-This tag must be enclosed by a @ref pf_tag_host tag. It then specifies where the mountpoint of a given storage device (defined by the ``id`` attribute)
-is; this location is specified by the ``name`` attribute.
-
-Here is a simple example, taken from the file ``examples/platform/storage.xml``:
-
-@verbatim
-    <storage_type id="single_SSD" size="500GiB">
-       <model_prop id="Bwrite" value="60MBps" />
-       <model_prop id="Bread" value="200MBps" />
-    </storage_type>
-
-    <storage id="Disk2" typeId="single_SSD"
-              content="content/win_storage_content.txt"
-              attach="alice" />
-    <storage id="Disk4" typeId="single_SSD"
-             content="content/small_content.txt"
-             attach="denise"/>
-
-    <host id="alice" speed="1Gf">
-      <mount storageId="Disk2" name="c:"/>
-    </host>
-
-    <host id="denise" speed="1Gf">
-      <mount storageId="Disk2" name="c:"/>
-      <mount storageId="Disk4" name="/home"/>
-    </host>
-@endverbatim
-
-This example is quite interesting, as the same device, called "Disk2", is mounted by
-two hosts at the same time! Note, however, that the host called ``alice`` is actually
-attached to this storage, as can be seen in the @ref pf_tag_storage "&lt;storage&gt;"
-tag. This means that ``denise`` must access this storage through the network, but SimGrid automatically takes
-care of that for you.
-
-Furthermore, this example shows that ``denise`` has mounted two storages with different
-filesystem types (unix and windows). In general, a host can mount as many storage devices as
-required.
-
-@note
-    Again, the difference between ``attach`` and ``mount`` is simply that
-    an attached storage is always physically inside (or connected to) that machine;
-    for instance, a USB stick is attached to one and only one machine (where it's plugged-in)
-    but it can only be mounted on others, as mounted storage can also be a remote location.
-
-###### Example files #####
-
-@verbinclude example_filelist_xmltag_mount
-
-@subsubsection pf_storage_example_files Example files
-
-Several examples were already discussed above; if you're interested in full examples,
-check the the following platforms:
-
-1. ``examples/platforms/storage.xml``
-2. ``examples/platforms/remote_io.xml``
-
-If you're looking for some examplary C code, you may find the source code
-available in the directory ``examples/msg/io/`` useful.
-
-@subsubsection pf_storage_examples_modelling Modelling different situations
-
-The storage functionality of SimGrid is type-agnostic, that is, the implementation
-does not presume any type of storage, such as HDDs/SSDs, RAM,
-CD/DVD devices, USB sticks etc.
-
-This allows the user to apply the simulator for a wide variety of scenarios; one
-common scenario would be the access of remote RAM.
-
-#### Modelling the access of remote RAM ####
-
-How can this be achieved in SimGrid? Let's assume we have a setup where three hosts
-(HostA, HostB, HostC) need to access remote RAM:
-
-@verbatim
-      Host A
-    /
-RAM -- Host B
-    @
-      Host C
-@endverbatim
-
-An easy way to model this scenario is to setup and define the RAM via the
-@ref pf_tag_storage "storage" and @ref pf_storage_entity_storage_type "storage type"
-entities and attach it to a remote dummy host; then, every host can have their own links
-to this host (modelling for instance certain scenarios, such as PCIe ...)
-
-@verbatim
-              Host A
-            /
-RAM - Dummy -- Host B
-            @
-              Host C
-@endverbatim
-
-Now, if read from this storage, the host that mounts this storage
-communicates to the dummy host which reads from RAM and
-sends the information back.
-
 
 @section pf_routing Routing
 
index 3a28d28..51ab88d 100755 (executable)
@@ -2,6 +2,8 @@
 #
 # Simplistic script to rebuild our documentation with sphinx-build
 
+# If you are missing some dependencies, try: pip3 install --requirement docs/requirements.txt
+
 # Python needs to find simgrid on my machine, but not ctest -- sorry for the hack
 if [ -e /opt/simgrid ] ; then chmod +x /opt/simgrid; fi
 
@@ -31,7 +33,10 @@ else
   echo "javasphinx relaunched"
 fi
 
-PYTHONPATH=../lib sphinx-build -M html source build ${SPHINXOPTS}
+PYTHONPATH=../lib sphinx-build -M html source build ${SPHINXOPTS} 2>&1 \
+  | grep -v 'WARNING: cpp:identifier reference target not found: simgrid$' \
+  | grep -v 'WARNING: cpp:identifier reference target not found: simgrid::s4u$' \
+  | grep -v 'WARNING: cpp:identifier reference target not found: boost' 
 
 set +x
 
diff --git a/docs/find-missing.ignore b/docs/find-missing.ignore
new file mode 100644 (file)
index 0000000..a996761
--- /dev/null
@@ -0,0 +1,174 @@
+This file lists the symbols ignored in the documentation.
+It follows the RST syntact but is completely ignored by sphinx. 
+It is only used by find-missing, that will not report any definition linked here as missing.
+
+# I don't plan to document MSG in the new way.
+.. autodoxymethod:: ::MSG_barrier_destroy(const_sg_bar_t bar)
+.. autodoxymethod:: ::MSG_barrier_init(unsigned int count)
+.. autodoxymethod:: ::MSG_barrier_wait(msg_bar_t bar)
+.. autodoxymethod:: ::MSG_comm_destroy(const_msg_comm_t comm)
+.. autodoxymethod:: ::MSG_comm_get_status(const_msg_comm_t comm)
+.. autodoxymethod:: ::MSG_comm_get_task(const_msg_comm_t comm)
+.. autodoxymethod:: ::MSG_comm_test(msg_comm_t comm)
+.. autodoxymethod:: ::MSG_comm_testany(const_xbt_dynar_t comms)
+.. autodoxymethod:: ::MSG_comm_wait(msg_comm_t comm, double timeout)
+.. autodoxymethod:: ::MSG_comm_waitall(msg_comm_t *comm, int nb_elem, double timeout)
+.. autodoxymethod:: ::MSG_comm_waitany(const_xbt_dynar_t comms)
+.. autodoxymethod:: ::MSG_config(const char *key, const char *value)
+.. autodoxymethod:: ::MSG_create_environment(const char *file)
+.. autodoxymethod:: ::MSG_function_register(const char *name, xbt_main_func_t code)
+.. autodoxymethod:: ::MSG_function_register_default(xbt_main_func_t code)
+.. autodoxymethod:: ::MSG_get_clock()
+.. autodoxymethod:: ::MSG_get_host_by_name(const char *name)
+.. autodoxymethod:: ::MSG_get_host_number()
+.. autodoxymethod:: ::MSG_get_sent_msg()
+.. autodoxymethod:: ::MSG_host_by_name(const char *name)
+.. autodoxymethod:: ::MSG_host_get_attached_storage_lists(const_sg_host_t host)
+.. autodoxymethod:: ::MSG_host_get_core_number(const_sg_host_t host)
+.. autodoxymethod:: ::MSG_host_get_data(const_sg_host_t host)
+.. autodoxymethod:: ::MSG_host_get_load(const_sg_host_t host)
+.. autodoxymethod:: ::MSG_host_get_mounted_storage_list(sg_host_t host)
+.. autodoxymethod:: ::MSG_host_get_name(const_sg_host_t host)
+.. autodoxymethod:: ::MSG_host_get_nb_pstates(const_sg_host_t host)
+.. autodoxymethod:: ::MSG_host_get_power_peak_at(const_sg_host_t host, int pstate_index)
+.. autodoxymethod:: ::MSG_host_get_process_list(const_sg_host_t host, xbt_dynar_t whereto)
+.. autodoxymethod:: ::MSG_host_get_properties(const_sg_host_t host)
+.. autodoxymethod:: ::MSG_host_get_property_value(const_sg_host_t host, const char *name)
+.. autodoxymethod:: ::MSG_host_get_pstate(const_sg_host_t host)
+.. autodoxymethod:: ::MSG_host_get_speed(const_sg_host_t host)
+.. autodoxymethod:: ::MSG_host_is_on(const_sg_host_t h)
+.. autodoxymethod:: ::MSG_host_off(sg_host_t h)
+.. autodoxymethod:: ::MSG_host_on(sg_host_t h)
+.. autodoxymethod:: ::MSG_host_self()
+.. autodoxymethod:: ::MSG_host_set_data(sg_host_t host, void *data)
+.. autodoxymethod:: ::MSG_host_set_property_value(sg_host_t host, const char *name, const char *value)
+.. autodoxymethod:: ::MSG_host_set_pstate(sg_host_t host, int pstate)
+.. autodoxymethod:: ::MSG_hosts_as_dynar()
+.. autodoxymethod:: ::MSG_init_nocheck(int *argc, char **argv)
+.. autodoxymethod:: ::MSG_launch_application(const char *file)
+.. autodoxymethod:: ::MSG_mailbox_set_async(const char *alias)
+.. autodoxymethod:: ::MSG_main()
+.. autodoxymethod:: ::MSG_parallel_task_create(const char *name, int host_nb, const msg_host_t *host_list, double *flops_amount, double *bytes_amount, void *data)
+.. autodoxymethod:: ::MSG_parallel_task_execute(msg_task_t task)
+.. autodoxymethod:: ::MSG_parallel_task_execute_with_timeout(msg_task_t task, double timeout)
+.. autodoxymethod:: ::MSG_process_attach(const char *name, void *data, msg_host_t host, xbt_dict_t properties)
+.. autodoxymethod:: ::MSG_process_auto_restart_set(msg_process_t process, int auto_restart)
+.. autodoxymethod:: ::MSG_process_create(const char *name, xbt_main_func_t code, void *data, msg_host_t host)
+.. autodoxymethod:: ::MSG_process_create_with_arguments(const char *name, xbt_main_func_t code, void *data, msg_host_t host, int argc, char **argv)
+.. autodoxymethod:: ::MSG_process_create_with_environment(const char *name, xbt_main_func_t code, void *data, msg_host_t host, int argc, char **argv, xbt_dict_t properties)
+.. autodoxymethod:: ::MSG_process_daemonize(msg_process_t process)
+.. autodoxymethod:: ::MSG_process_detach()
+.. autodoxymethod:: ::MSG_process_from_PID(int pid)
+.. autodoxymethod:: ::MSG_process_get_PID(const_sg_actor_t process)
+.. autodoxymethod:: ::MSG_process_get_PPID(const_sg_actor_t process)
+.. autodoxymethod:: ::MSG_process_get_data(const_sg_actor_t process)
+.. autodoxymethod:: ::MSG_process_get_host(const_sg_actor_t process)
+.. autodoxymethod:: ::MSG_process_get_name(const_sg_actor_t process)
+.. autodoxymethod:: ::MSG_process_get_number()
+.. autodoxymethod:: ::MSG_process_get_properties(const_sg_actor_t process)
+.. autodoxymethod:: ::MSG_process_get_property_value(const_sg_actor_t process, const char *name)
+.. autodoxymethod:: ::MSG_process_is_suspended(msg_process_t process)
+.. autodoxymethod:: ::MSG_process_join(msg_process_t process, double timeout)
+.. autodoxymethod:: ::MSG_process_kill(msg_process_t process)
+.. autodoxymethod:: ::MSG_process_killall()
+.. autodoxymethod:: ::MSG_process_migrate(msg_process_t process, msg_host_t host)
+.. autodoxymethod:: ::MSG_process_on_exit(int_f_int_pvoid_t fun, void *data)
+.. autodoxymethod:: ::MSG_process_ref(const_sg_actor_t process)
+.. autodoxymethod:: ::MSG_process_restart(msg_process_t process)
+.. autodoxymethod:: ::MSG_process_resume(msg_process_t process)
+.. autodoxymethod:: ::MSG_process_self()
+.. autodoxymethod:: ::MSG_process_self_PID()
+.. autodoxymethod:: ::MSG_process_self_PPID()
+.. autodoxymethod:: ::MSG_process_self_name()
+.. autodoxymethod:: ::MSG_process_set_data(msg_process_t process, void *data)
+.. autodoxymethod:: ::MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup)
+.. autodoxymethod:: ::MSG_process_set_kill_time(msg_process_t process, double kill_time)
+.. autodoxymethod:: ::MSG_process_sleep(double nb_sec)
+.. autodoxymethod:: ::MSG_process_suspend(msg_process_t process)
+.. autodoxymethod:: ::MSG_process_unref(const_sg_actor_t process)
+.. autodoxymethod:: ::MSG_process_yield()
+.. autodoxymethod:: ::MSG_processes_as_dynar()
+.. autodoxymethod:: ::MSG_sem_acquire(msg_sem_t sem)
+.. autodoxymethod:: ::MSG_sem_acquire_timeout(msg_sem_t sem, double timeout)
+.. autodoxymethod:: ::MSG_sem_destroy(const_sg_sem_t sem)
+.. autodoxymethod:: ::MSG_sem_get_capacity(msg_sem_t sem)
+.. autodoxymethod:: ::MSG_sem_init(int initial_value)
+.. autodoxymethod:: ::MSG_sem_release(msg_sem_t sem)
+.. autodoxymethod:: ::MSG_sem_would_block(msg_sem_t sem)
+.. autodoxymethod:: ::MSG_storage_get_by_name(const char *name)
+.. autodoxymethod:: ::MSG_storage_get_data(const_sg_storage_t storage)
+.. autodoxymethod:: ::MSG_storage_get_host(const_sg_storage_t storage)
+.. autodoxymethod:: ::MSG_storage_get_name(const_sg_storage_t storage)
+.. autodoxymethod:: ::MSG_storage_get_properties(const_sg_storage_t storage)
+.. autodoxymethod:: ::MSG_storage_get_property_value(const_sg_storage_t storage, const char *name)
+.. autodoxymethod:: ::MSG_storage_read(msg_storage_t storage, sg_size_t size)
+.. autodoxymethod:: ::MSG_storage_set_data(msg_storage_t storage, void *data)
+.. autodoxymethod:: ::MSG_storage_set_property_value(msg_storage_t storage, const char *name, const char *value)
+.. autodoxymethod:: ::MSG_storage_write(msg_storage_t storage, sg_size_t size)
+.. autodoxymethod:: ::MSG_storages_as_dynar()
+.. autodoxymethod:: ::MSG_task_cancel(msg_task_t task)
+.. autodoxymethod:: ::MSG_task_create(const char *name, double flops_amount, double bytes_amount, void *data)
+.. autodoxymethod:: ::MSG_task_destroy(msg_task_t task)
+.. autodoxymethod:: ::MSG_task_dsend(msg_task_t task, const char *alias, void_f_pvoid_t cleanup)
+.. autodoxymethod:: ::MSG_task_dsend_bounded(msg_task_t task, const char *alias, void_f_pvoid_t cleanup, double maxrate)
+.. autodoxymethod:: ::MSG_task_execute(msg_task_t task)
+.. autodoxymethod:: ::MSG_task_get_bytes_amount(const_msg_task_t task)
+.. autodoxymethod:: ::MSG_task_get_category(const_msg_task_t task)
+.. autodoxymethod:: ::MSG_task_get_data(const_msg_task_t task)
+.. autodoxymethod:: ::MSG_task_get_flops_amount(const_msg_task_t task)
+.. autodoxymethod:: ::MSG_task_get_name(const_msg_task_t task)
+.. autodoxymethod:: ::MSG_task_get_remaining_communication(const_msg_task_t task)
+.. autodoxymethod:: ::MSG_task_get_remaining_work_ratio(const_msg_task_t task)
+.. autodoxymethod:: ::MSG_task_get_sender(const_msg_task_t task)
+.. autodoxymethod:: ::MSG_task_get_source(const_msg_task_t task)
+.. autodoxymethod:: ::MSG_task_irecv(msg_task_t *task, const char *alias)
+.. autodoxymethod:: ::MSG_task_irecv_bounded(msg_task_t *task, const char *alias, double rate)
+.. autodoxymethod:: ::MSG_task_isend(msg_task_t task, const char *alias)
+.. autodoxymethod:: ::MSG_task_isend_bounded(msg_task_t task, const char *alias, double maxrate)
+.. autodoxymethod:: ::MSG_task_listen(const char *alias)
+.. autodoxymethod:: ::MSG_task_listen_from(const char *alias)
+.. autodoxymethod:: ::MSG_task_receive(msg_task_t *task, const char *alias)
+.. autodoxymethod:: ::MSG_task_receive_bounded(msg_task_t *task, const char *alias, double rate)
+.. autodoxymethod:: ::MSG_task_receive_with_timeout(msg_task_t *task, const char *alias, double timeout)
+.. autodoxymethod:: ::MSG_task_receive_with_timeout_bounded(msg_task_t *task, const char *alias, double timeout, double rate)
+.. autodoxymethod:: ::MSG_task_send(msg_task_t task, const char *alias)
+.. autodoxymethod:: ::MSG_task_send_bounded(msg_task_t task, const char *alias, double rate)
+.. autodoxymethod:: ::MSG_task_send_with_timeout(msg_task_t task, const char *alias, double timeout)
+.. autodoxymethod:: ::MSG_task_send_with_timeout_bounded(msg_task_t task, const char *alias, double timeout, double maxrate)
+.. autodoxymethod:: ::MSG_task_set_bound(msg_task_t task, double bound)
+.. autodoxymethod:: ::MSG_task_set_bytes_amount(msg_task_t task, double bytes_amount)
+.. autodoxymethod:: ::MSG_task_set_category(msg_task_t task, const char *category)
+.. autodoxymethod:: ::MSG_task_set_data(msg_task_t task, void *data)
+.. autodoxymethod:: ::MSG_task_set_flops_amount(msg_task_t task, double flops_amount)
+.. autodoxymethod:: ::MSG_task_set_name(msg_task_t task, const char *name)
+.. autodoxymethod:: ::MSG_task_set_priority(msg_task_t task, double priority)
+.. autodoxymethod:: ::MSG_vm_create_core(msg_host_t pm, const char *name)
+.. autodoxymethod:: ::MSG_vm_create_multicore(msg_host_t pm, const char *name, int coreAmount)
+.. autodoxymethod:: ::MSG_vm_destroy(msg_vm_t vm)
+.. autodoxymethod:: ::MSG_vm_get_name(const_sg_vm_t vm)
+.. autodoxymethod:: ::MSG_vm_get_pm(const_sg_vm_t vm)
+.. autodoxymethod:: ::MSG_vm_get_ramsize(const_sg_vm_t vm)
+.. autodoxymethod:: ::MSG_vm_is_created(msg_vm_t vm)
+.. autodoxymethod:: ::MSG_vm_is_running(msg_vm_t vm)
+.. autodoxymethod:: ::MSG_vm_is_suspended(msg_vm_t vm)
+.. autodoxymethod:: ::MSG_vm_resume(msg_vm_t vm)
+.. autodoxymethod:: ::MSG_vm_set_bound(msg_vm_t vm, double bound)
+.. autodoxymethod:: ::MSG_vm_set_ramsize(msg_vm_t vm, size_t size)
+.. autodoxymethod:: ::MSG_vm_shutdown(msg_vm_t vm)
+.. autodoxymethod:: ::MSG_vm_start(msg_vm_t vm)
+.. autodoxymethod:: ::MSG_vm_suspend(msg_vm_t vm)
+.. autodoxymethod:: ::MSG_zone_get_by_name(const char *name)
+.. autodoxymethod:: ::MSG_zone_get_hosts(const_sg_netzone_t zone, xbt_dynar_t whereto)
+.. autodoxymethod:: ::MSG_zone_get_name(const_sg_netzone_t zone)
+.. autodoxymethod:: ::MSG_zone_get_property_value(const_sg_netzone_t zone, const char *name)
+.. autodoxymethod:: ::MSG_zone_get_root()
+.. autodoxymethod:: ::MSG_zone_get_sons(const_sg_netzone_t zone, xbt_dict_t whereto)
+.. autodoxymethod:: ::MSG_zone_set_property_value(msg_netzone_t zone, const char *name, const char *value)
+
+# These ones are a bug of Doxygen, that parse them as variables instead of types.
+# So we don't use this bogus parse result, but go directly for cpp:type directives in app_s4u.rst
+.. autodoxyvar:: ::const_sg_actor_t
+.. autodoxyvar:: ::const_sg_bar_t
+.. autodoxyvar:: ::const_sg_mutex_t
+.. autodoxyvar:: ::const_sg_sem_t
+
index e539a74..ee0ec2c 100755 (executable)
@@ -1,8 +1,7 @@
 #! /usr/bin/env python3
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2019. The SimGrid Team.
-# All rights reserved.
+# Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
@@ -12,6 +11,8 @@ Search for symbols documented in both the XML files produced by Doxygen and the
 but not documented with autodoxy in the RST files.
 
 This script is tailored to SimGrid own needs and should be made more generic for autodoxy.
+
+If you are missing some dependencies, try:  pip3 install --requirement docs/requirements.txt
 """
 
 import fnmatch
@@ -39,7 +40,21 @@ xml_files = [
     'build/xml/classsimgrid_1_1s4u_1_1Mutex.xml',
     'build/xml/classsimgrid_1_1s4u_1_1NetZone.xml',
     'build/xml/classsimgrid_1_1s4u_1_1Semaphore.xml',
-    'build/xml/classsimgrid_1_1s4u_1_1VirtualMachine.xml'
+    'build/xml/classsimgrid_1_1s4u_1_1VirtualMachine.xml',
+    'build/xml/namespacesimgrid_1_1s4u_1_1this__actor.xml',
+    'build/xml/actor_8h.xml',
+    'build/xml/barrier_8h.xml',
+    'build/xml/cond_8h.xml',
+    'build/xml/engine_8h.xml',
+    'build/xml/forward_8h.xml',
+    'build/xml/host_8h.xml',
+    'build/xml/link_8h.xml',
+    'build/xml/mailbox_8h.xml',
+    'build/xml/msg_8h.xml',
+    'build/xml/mutex_8h.xml',
+    'build/xml/semaphore_8h.xml',
+    'build/xml/vm_8h.xml',
+    'build/xml/zone_8h.xml'
 ]
 
 python_modules = [
@@ -61,7 +76,8 @@ def handle_python_module(fullname, englobing, elm):
 
     def found_decl(kind, obj):
         """Helper function that add an object in the python_decl data structure"""
-        if kind not in python_decl: python_decl[kind] = []
+        if kind not in python_decl:
+            python_decl[kind] = []
         python_decl[kind].append(obj)
 
 
@@ -95,8 +111,17 @@ for name in python_modules:
     try:
         module = __import__(name)
     except Exception:
-        print("Cannot import {}. Did you set PYTHONPATH=../lib accordingly?".format(name))
-        sys.exit(1)
+        if os.path.exists("../lib") and "../lib" not in sys.path:
+            print("Adding ../lib to PYTHONPATH as {} cannot be imported".format(name))
+            sys.path.append("../lib")
+            try:
+                module = __import__(name)
+            except Exception:
+                print("Cannot import {}, even with PYTHONPATH=../lib".format(name))
+                sys.exit(1)
+        else:
+            print("Cannot import {}".format(name))
+            sys.exit(1)
     for sub in dir(module):
         if sub[0] == '_':
             continue
@@ -122,61 +147,80 @@ doxy_funs = {} # {classname: {func_name: [args]} }
 doxy_vars = {} # {classname: [names]}
 
 # find the declarations in the XML files
-for arg in xml_files[:3]:
+for arg in xml_files:
     if arg[-4:] != '.xml':
         print ("Argument '{}' does not end with '.xml'".format(arg))
         continue
-    print("Parse file {}".format(arg))
+    #print("Parse file {}".format(arg))
     tree = ET.parse(arg)
     for elem in tree.findall(".//compounddef"):
-        if elem.attrib["prot"] != "public":
-            continue
-        if "compoundname" in elem:
-            raise Exception("Compound {} has no 'compoundname' child tag.".format(elem))
-        compoundname = elem.find("compoundname").text
-        #print ("compoundname {}".format(compoundname))
+        if elem.attrib["kind"] == "class":
+            if elem.attrib["prot"] != "public":
+                continue
+            if "compoundname" in elem:
+                raise Exception("Compound {} has no 'compoundname' child tag.".format(elem))
+            compoundname = elem.find("compoundname").text
+            #print ("compoundname {}".format(compoundname))
+        elif elem.attrib["kind"] == "file":
+            compoundname = ""
+        elif elem.attrib["kind"] == "namespace":
+            compoundname = elem.find("compoundname").text
+        else:
+            print("Element {} is of kind {}".format(elem.attrib["id"], elem.attrib["kind"]))
+
         for member in elem.findall('.//memberdef'):
             if member.attrib["prot"] != "public":
                 continue
             kind = member.attrib["kind"]
             name = member.find("name").text
+            #print("kind:{} compoundname:{} name:{}".format( kind,compoundname, name))
             if kind == "variable":
-                if compoundname not in doxy_vars: doxy_vars[compoundname] = []
+                if compoundname not in doxy_vars:
+                    doxy_vars[compoundname] = []
                 doxy_vars[compoundname].append(name)
             elif kind == "function":
                 args = member.find('argsstring').text
                 args = re.sub('\)[^)]*$', ')', args) # ignore what's after the parameters (eg, '=0' or ' const')
 
-                if compoundname not in doxy_funs: doxy_funs[compoundname] = {}
-                if name not in doxy_funs[compoundname]: doxy_funs[compoundname][name] = []
+                if compoundname not in doxy_funs:
+                    doxy_funs[compoundname] = {}
+                if name not in doxy_funs[compoundname]:
+                    doxy_funs[compoundname][name] = []
                 doxy_funs[compoundname][name].append(args)
+            elif kind == "friend":
+                pass # Ignore friendship
             else:
                 print ("member {}::{} is of kind {}".format(compoundname, name, kind))
 
 # Forget about the declarations that are done in the RST
-with os.popen('grep autodoxymethod:: source/*rst|sed \'s/^.*autodoxymethod:: //\'') as pse:
+with os.popen('grep autodoxymethod:: find-missing.ignore source/*rst|sed \'s/^.*autodoxymethod:: //\'') as pse:
     for line in (l.strip() for l in pse):
         (klass, obj, args) = (None, None, None)
         if "(" in line:
             (line, args) = line.split('(', 1)
             args = "({}".format(args)
-        (klass, obj) = line.rsplit('::', 1)
+        if '::' in line:
+            (klass, obj) = line.rsplit('::', 1)
+        else:
+            (klass, obj) = ("", line)
 
         if klass not in doxy_funs:
             print("Warning: {} documented, but class {} not found in doxygen.".format(line, klass))
             continue
         if obj not in doxy_funs[klass]:
-            print("Warning: Object {} documented but not found in {}".format(line, klass))
+            print("Warning: Object '{}' documented but not found in '{}'".format(line, klass))
+#            for obj in doxy_funs[klass]:
+#                print("  found: {}::{}".format(klass, obj))
         elif len(doxy_funs[klass][obj])==1:
             del doxy_funs[klass][obj]
         elif args not in doxy_funs[klass][obj]:
             print("Warning: Function {}{} not found in {}".format(obj, args, klass))
         else:
-#            print("Found {} in {}".format(line, klass))
+            #print("Found {} in {}".format(line, klass))
             doxy_funs[klass][obj].remove(args)
             if len(doxy_funs[klass][obj]) == 0:
                 del doxy_funs[klass][obj]
-with os.popen('grep autodoxyvar:: source/*rst|sed \'s/^.*autodoxyvar:: //\'') as pse:
+with os.popen('grep autodoxyvar:: find-missing.ignore source/*rst|sed \'s/^.*autodoxyvar:: //\'') as pse:
     for line in (l.strip() for l in pse):
         (klass, var) = line.rsplit('::', 1)
 
index d039c80..599ae43 100644 (file)
@@ -17,3 +17,6 @@ intrusive_ptr_add_ref
 get_filtered_netzones_recursive
 simgrid::s4u::Storage
 simgrid::s4u::Activity_T
+simgrid::s4u::Engine::get_storage_count
+simgrid::s4u::Engine::storage_by_name
+simgrid::s4u::Engine::storage_by_name_or_null
\ No newline at end of file
index ed9dc5e..a315c3c 100644 (file)
@@ -10,7 +10,7 @@ All environment variables taken into account by the underlying compiler will be
 .SH AUTHORS
 The SimGrid team (simgrid-devel@lists.gforge.inria.fr)
 .SH COPYRIGHT AND LICENCE
-Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.
+Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.
 
 This program is free software; you may redistribute it and/or modify it under the terms of GNU LGPL (v2.1) license.
 .SH SEE ALSO
index 6c5b828..1a4d973 100644 (file)
@@ -10,7 +10,7 @@ All environment variables taken into account by the underlying compiler will be
 .SH AUTHORS
 The SimGrid team (simgrid-devel@lists.gforge.inria.fr)
 .SH COPYRIGHT AND LICENCE
-Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.
+Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.
 
 This program is free software; you may redistribute it and/or modify it under the terms of GNU LGPL (v2.1) license.
 .SH SEE ALSO
index df97661..cc1747d 100644 (file)
@@ -10,7 +10,7 @@ All environment variables taken into account by the underlying compiler will be
 .SH AUTHORS
 The SimGrid team (simgrid-devel@lists.gforge.inria.fr)
 .SH COPYRIGHT AND LICENCE
-Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.
+Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.
 
 This program is free software; you may redistribute it and/or modify it under the terms of GNU LGPL (v2.1) license.
 .SH SEE ALSO
index 8bed7fd..cf76cbb 100644 (file)
@@ -10,7 +10,7 @@ All environment variables taken into account by the underlying compiler will be
 .SH AUTHORS
 The SimGrid team (simgrid-devel@lists.gforge.inria.fr)
 .SH COPYRIGHT AND LICENCE
-Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.
+Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.
 
 This program is free software; you may redistribute it and/or modify it under the terms of GNU LGPL (v2.1) license.
 .SH SEE ALSO
index 01f3636..9f4ca07 100644 (file)
@@ -1,11 +1,11 @@
 .TH smpirun 1
 .SH NAME
-smpirun \- Exectute MPI programs in the SimGrid simulator
+smpirun \- Execute MPI programs in the SimGrid simulator
 .SH SYNOPSIS
 smpirun [\fISMPI OPTIONS\fR]… \fB\-platform\fR <platform.xml> \fB\-hostfile\fR <hostfile> program [\fISIMULATION OPTIONS\fR] [\fIPROGRAM OPTIONS\fR]
 .SH DESCRIPTION
-smpirun car run MPI programs that were compiled with smpicc on top of
-the simulator. Basically, it generates a deployment files from the
+smpirun can run MPI programs that were compiled with smpicc on top of
+the simulator. Basically, it generates a deployment file from the
 provided hostfile (if needed), and launches the simulation with the right
 arguments. It is intended to be easy to use to regular MPI users.
 .SH MANDATORY PARAMETERS
@@ -34,6 +34,15 @@ Do not remove the generated files after execution.
 Use command to run the program (e.g. "valgrind", "gdb --args", "rr record").
 You usually want to use the "-foreground" option as well in order to have a TTY.
 .TP
+\fB\-gdb\fR
+Run within GDB (equivalent to -wrapper "gdb --args" -keep-temps).
+.TP
+\fB\-lldb\fR
+Run within LLDB (equivalent to -wrapper "lldb --" -keep-temps).
+.TP
+\fB\-vgdb\fR
+Run within Valgrind+GDB (equivalent to -wrapper "valgrind --vgdb=yes --vgdb-error=0" -keep-temps).
+.TP
 \fB\-foreground\fR
 Run the child process in the foreground.
 This gives the child process access to the TTY.
@@ -45,10 +54,10 @@ Display the machine on which each process rank is mapped.
 Use that amount of processes. By default, there is the same number of processes as there are of hosts in the hostfile.
 .TP
 \fB\-no-privatize\fR
-Disable the globals privatization, that is activated by default.
+Disable the privatization of global variables, that is activated by default.
 This should only be necessary if you use dynamic libraries, but you
 should probably link statically instead of disabling this. Do not link
-statically against SimGrid, only the others.
+statically against SimGrid, only against the other libraries.
 .TP
 \fB\-trace\fR
 Activate the trace mechanism if available (equivalent to \fB--cfg\fR=\fItracing\fR:\fIyes\fR \fB--cfg\fR=\fItracing/smpi\fR:\fIyes\fR)
@@ -71,13 +80,22 @@ Trace resource utilization.
 \fB\-trace-file\fR <tracefile>
 Name of the tracefile
 .TP
+\fB\-replay\fR <tracefile>
+Replay a trace instead of actually executing an application.
+.TP
 \fB\-quiet\fR 
 Reduce output verbosity. This is useful to make tests reproducible.
-
+.TP
+\fB\-version\fR
+Displays the SimGrid version (human readable).
+.TP
+\fB\-git-version\fR
+Displays the git hash of SimGrid.
+.TP
 .SH SIMULATION OPTIONS
-You can change many simulation parameter on the command line by passing
+You can change many simulation parameters on command line by passing
 \fB--cfg\fR=\fIparameter\fR:\fIvalue\fR after the program name. 
-A full list of existing parameters and their meaning can be found at
+A full list of the existing parameters and their meaning can be found at
 https://simgrid.org/doc/latest/Configuring_SimGrid.html
 
 Here are some options commonly used with SMPI:
@@ -91,7 +109,7 @@ Disable the simulation of all computation chunks (that are still executed on the
 .SH AUTHORS
 The SimGrid team (simgrid-devel@lists.gforge.inria.fr)
 .SH COPYRIGHT AND LICENCE
-Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.
+Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.
 
 This program is free software; you may redistribute it and/or modify
 it under the terms of GNU LGPL (v2.1) license. 
index db03b0a..8ad746f 100644 (file)
@@ -876,24 +876,21 @@ you never used the tracing API.
 
   .. code-block:: shell
 
-     --cfg=tracing:yes --cfg=tracing/uncategorized:yes --cfg=triva/uncategorized:uncat.plist
+     --cfg=tracing:yes --cfg=tracing/uncategorized:yes
 
-  The first parameter activates the tracing subsystem, the second
+  The first parameter activates the tracing subsystem, and the second
   tells it to trace host and link utilization (without any
-  categorization) and the third creates a graph configuration file to
-  configure Triva when analysing the resulting trace file.
+  categorization).
 
 - MSG or SimDag-based simulator and categorized traces (you need to
   declare categories and classify your tasks according to them) 
 
   .. code-block:: shell
 
-     --cfg=tracing:yes --cfg=tracing/categorized:yes --cfg=triva/categorized:cat.plist
+     --cfg=tracing:yes --cfg=tracing/categorized:yes
 
-  The first parameter activates the tracing subsystem, the second
-  tells it to trace host and link categorized utilization and the
-  third creates a graph configuration file to configure Triva when
-  analysing the resulting trace file.
+  The first parameter activates the tracing subsystem, and the second
+  tells it to trace host and link categorized utilization.
 
 - SMPI simulator and traces for a space/time view:
 
index 44b2cb5..8b91326 100644 (file)
@@ -29,9 +29,11 @@ GENERATE_LATEX         = NO
 FULL_PATH_NAMES        = NO # Don't leak the path on which it was built
 XML_PROGRAMLISTING     = NO # No program listings, please
 CREATE_SUBDIRS         = NO # Mandatory for exhale
+AUTOLINK_SUPPORT       = NO # Don't try to link words that correspond to documented classes to their corresponding doc
 
 # Allow for rst directives and advanced functions e.g. grid tables
-ALIASES                = "beginrst=\verbatim "
+ALIASES                = "beginrst=\verbatim embed:rst:leading-asterisk"
+ALIASES               += "rst=\verbatim "
 ALIASES               += "endrst=\endverbatim"
 
 # Enable preprocessing and related preprocessor necessities
@@ -40,6 +42,8 @@ MACRO_EXPANSION        = YES
 EXPAND_ONLY_PREDEF     = NO
 SKIP_FUNCTION_MACROS   = NO
 
+QUIET=YES
+
 PREDEFINED             += \
     __cplusplus \
     DOXYGEN \
@@ -55,5 +59,6 @@ PREDEFINED             += \
     XBT_PRIVATE= \
     XBT_ATTRIB_NORETURN= \
     XBT_ATTRIB_UNUSED= \
+    XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s,c,l)= \
     XBT_ATTRIB_DEPRECATED_v328(m)= \
     XBT_ATTRIB_DEPRECATED_v329(m)=
index f7418a0..4aa0531 100644 (file)
@@ -1,4 +1,4 @@
-.. Copyright 2005-2019
+.. Copyright 2005-2020
 
 .. _install:
 
index c15fc54..09b34a1 100644 (file)
 Platform Examples
 =================
 
-SimGrid comes with an extensive set of platforms in the
-`examples/platforms <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms>`_
-directory.
+Simple Example with 3 hosts
+---------------------------
 
-.. todo:: Write this page of the manual.
+Imagine you want to describe a little platform with three hosts,
+interconnected as follows:
 
-   Gather here the examples described elsewhere in the doc (SMPI tutorial, Platform intro), and describe the other ones.
+.. image:: /tuto_smpi/3hosts.png
+   :align: center
+
+This can be done with the following platform file, that considers the
+simulated platform as a graph of hosts and network links.
+
+.. literalinclude:: /tuto_smpi/3hosts.xml
+   :language: xml
+
+The elements basic elements (with :ref:`pf_tag_host` and
+:ref:`pf_tag_link`) are described first, and then the routes between
+any pair of hosts are explicitly given with :ref:`pf_tag_route`. 
+
+Any host must be given a computational speed in flops while links must
+be given a latency and a bandwidth. You can write 1Gf for
+1,000,000,000 flops (full list of units in the reference guide of 
+:ref:`pf_tag_host` and :ref:`pf_tag_link`). 
+
+Routes defined with :ref:`pf_tag_route` are symmetrical by default,
+meaning that the list of traversed links from A to B is the same as
+from B to A. Explicitly define non-symmetrical routes if you prefer.
+
+The last thing you must know on SimGrid platform files is that the
+root tag must be :ref:`pf_tag_platform`. If the ``version`` attribute
+does not match what SimGrid expects, you will be hinted to use to the
+``simgrid_update_xml`` utility to update your file.
+
+Cluster with a Crossbar
+-----------------------
+
+A very common parallel computing platform is a homogeneous cluster in
+which hosts are interconnected via a crossbar switch with as many
+ports as hosts, so that any disjoint pairs of hosts can communicate
+concurrently at full speed. For instance:
+
+.. literalinclude:: ../../examples/platforms/cluster_crossbar.xml
+   :language: xml
+   :lines: 1-3,18-
+
+One specifies a name prefix and suffix for each host, and then give an
+integer range. In the example the cluster contains 65535 hosts (!),
+named ``node-0.simgrid.org`` to ``node-65534.simgrid.org``. All hosts
+have the same power (1 Gflop/sec) and are connected to the switch via
+links with same bandwidth (125 MBytes/sec) and latency (50
+microseconds).
+
+.. todo::
+
+   Add the picture.
+
+Cluster with a Shared Backbone
+------------------------------
+
+Another popular model for a parallel platform is that of a set of
+homogeneous hosts connected to a shared communication medium, a
+backbone, with some finite bandwidth capacity and on which
+communicating host pairs can experience contention. For instance:
+
+
+.. literalinclude:: ../../examples/platforms/cluster_backbone.xml
+   :language: xml
+   :lines: 1-3,18-
+
+The only differences with the crossbar cluster above are the ``bb_bw``
+and ``bb_lat`` attributes that specify the backbone characteristics
+(here, a 500 microseconds latency and a 2.25 GByte/sec
+bandwidth). This link is used for every communication within the
+cluster. The route from ``node-0.simgrid.org`` to ``node-1.simgrid.org``
+counts 3 links: the private link of ``node-0.simgrid.org``, the backbone
+and the private link of ``node-1.simgrid.org``.
+
+.. todo::
+
+   Add the picture.
+
+Torus Cluster
+-------------
+
+Many HPC facilities use torus clusters to reduce sharing and
+performance loss on concurrent internal communications. Modeling this
+in SimGrid is very easy. Simply add a ``topology="TORUS"`` attribute
+to your cluster. Configure it with the ``topo_parameters="X,Y,Z"``
+attribute, where ``X``, ``Y`` and ``Z`` are the dimension of your
+torus.
+
+.. image:: ../../examples/platforms/cluster_torus.svg
+   :align: center
+
+.. literalinclude:: ../../examples/platforms/cluster_torus.xml
+   :language: xml
+
+Note that in this example, we used ``loopback_bw`` and
+``loopback_lat`` to specify the characteristics of the loopback link
+of each node (i.e., the link allowing each node to communicate with
+itself). We could have done so in previous example too. When no
+loopback is given, the communication from a node to itself is handled
+as if it were two distinct nodes: it goes twice through the private
+link and through the backbone (if any).
+
+Fat-Tree Cluster
+----------------
+
+This topology was introduced to reduce the amount of links in the
+cluster (and thus reduce its price) while maintaining a high bisection
+bandwidth and a relatively low diameter. To model this in SimGrid,
+pass a ``topology="FAT_TREE"`` attribute to your cluster. The
+``topo_parameters=#levels;#downlinks;#uplinks;link count`` follows the
+semantic introduced in the `Figure 1B of this article
+<http://webee.eedev.technion.ac.il/wp-content/uploads/2014/08/publication_574.pdf>`_.
+
+Here is the meaning of this example: ``2 ; 4,4 ; 1,2 ; 1,2``
+
+- That's a two-level cluster (thus the initial ``2``).
+- Routers are connected to 4 elements below them, regardless of its
+  level. Thus the ``4,4`` component that is used as
+  ``#downlinks``. This means that the hosts are grouped by 4 on a
+  given router, and that there is 4 level-1 routers (in the middle of
+  the figure).
+- Hosts are connected to only 1 router above them, while these routers
+  are connected to 2 routers above them (thus the ``1,2`` used as
+  ``#uplink``).
+- Hosts have only one link to their router while every path between a
+  level-1 routers and level-2 routers use 2 parallel links. Thus the
+  ``1,2`` that is used as ``link count``.
+
+.. image:: ../../examples/platforms/cluster_fat_tree.svg
+   :align: center
+
+.. literalinclude:: ../../examples/platforms/cluster_fat_tree.xml
+   :language: xml
+   :lines: 1-3,10-
+
+
+Dragonfly Cluster
+-----------------
+
+This topology was introduced to further reduce the amount of links
+while maintaining a high bandwidth for local communications. To model
+this in SimGrid, pass a ``topology="DRAGONFLY"`` attribute to your
+cluster. It's based on the implementation of the topology used on
+Cray XC systems, described in paper
+`Cray Cascade: A scalable HPC system based on a Dragonfly network <https://dl.acm.org/citation.cfm?id=2389136>`_.
+
+System description follows the format ``topo_parameters=#groups;#chassis;#routers;#nodes``
+For example, ``3,4 ; 3,2 ; 3,1 ; 2``:
+
+- ``3,4``: There are 3 groups with 4 links between each (blue level).
+  Links to nth group are attached to the nth router of the group
+  on our implementation.
+- ``3,2``: In each group, there are 3 chassis with 2 links between each nth router
+  of each group (black level)
+- ``3,1``: In each chassis, 3 routers are connected together with a single link
+  (green level)
+- ``2``: Each router has two nodes attached (single link)
+
+.. image:: ../../examples/platforms/cluster_dragonfly.svg
+   :align: center
+
+.. literalinclude:: ../../examples/platforms/cluster_dragonfly.xml
+   :language: xml
+
+
+.. todo:: Complete this page of the manual.
+
+   SimGrid comes with an extensive set of platforms in the
+   `examples/platforms <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms>`_
+   directory that should be described here.
    
diff --git a/docs/source/Platform_Routing.rst b/docs/source/Platform_Routing.rst
new file mode 100644 (file)
index 0000000..8aa5354
--- /dev/null
@@ -0,0 +1,52 @@
+.. raw:: html
+
+   <object id="TOC" data="graphical-toc.svg" type="image/svg+xml"></object>
+   <script>
+   window.onload=function() { // Wait for the SVG to be loaded before changing it
+     var elem=document.querySelector("#TOC").contentDocument.getElementById("RoutingBox")
+     elem.style="opacity:0.93999999;fill:#ff0000;fill-opacity:0.1;stroke:#000000;stroke-width:0.35277778;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1";
+   }
+   </script>
+   <br/>
+   <br/>
+
+.. _platform_routing:
+
+Defining a Routing
+##################
+
+Networking zones (:ref:`pf_tag_zone`) are an advanced concept used to factorize the description
+to reduce the size of your platform on disk and in memory. Then, when
+a host wants to communicate with another host belonging to the same
+zone, it is the zone's duty to find the list of links that are
+involved in the communication. In the above examples, since we use
+``routing="Full"``, all routes must be explicitly given using the
+:ref:`pf_tag_route` and :ref:`pf_tag_link_ctn` tags (this :ref:`routing
+model <pf_rm>` is both simple and inefficient :) It is OK to not
+specify each and every route between hosts, as long as you do not try
+to start a communication on any of the missing routes during your
+simulation.
+
+Any zone may contain sub-zones, allowing for a hierarchical
+decomposition of the platform. Routing can be made more efficient (as the
+inter-zone routing gets factored with :ref:`pf_tag_zoneroute`), and
+allows you to have more than one routing model in your platform. For
+example, you can have a coordinate-based routing for the WAN parts
+of your platforms, a full routing within each datacenter, and a highly
+optimized routing within each cluster of the datacenter.  In this
+case, determining the route between two given hosts gets :ref:`routing_basics`
+"somewhat more complex" but SimGrid still computes
+these routes for you in a time- and space-efficient manner.
+Here is an illustration of these concepts:
+
+.. image:: img/zone_hierarchy.png
+
+Circles represent processing units and squares represent network
+routers. Bold lines represent communication links. The zone "AS2" models the core of a national network interconnecting a
+small flat cluster (AS4) and a larger hierarchical cluster (AS5), a
+subset of a LAN (AS6), and a set of peers scattered around the world
+(AS7).
+
+.. todo:: Add more examples, such as the cloud example described in
+          previous paragraph
+
index 8f55ae3..2b9f596 100644 (file)
@@ -12,8 +12,8 @@ SimGrid Plugins
      elem.style="opacity:0.93999999;fill:#ff0000;fill-opacity:0.1;stroke:#000000;stroke-width:0.35277778;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1";
    }
    </script>
-   <br/>
-   <br/>
+   <br>
+   <br>
 
 You can extend SimGrid without modifying it, thanks to our plugin
 mechanism. This page describes how to write your own plugin, and
@@ -101,23 +101,38 @@ to explore the other ones.
 
 .. _plugin_host_energy:
 
-Host Energy Plugin
-==================
+Host Energy
+===========
+
+.. doxygengroup:: plugin_host_energy
+
 
-.. doxygengroup:: Plugin_host_energy
 
 .. _plugin_link_energy:
 
-Link Energy Plugin
-==================
+Link Energy
+===========
+
+.. doxygengroup:: plugin_link_energy
+
 
-.. doxygengroup:: Plugin_link_energy
 
 .. _plugin_host_load:
 
-Host Load Plugin
-================
+Host Load
+=========
+
+.. doxygengroup:: plugin_host_load
+
+
+
+.. _plugin_filesystem:
+
+File System
+===========
+
+.. doxygengroup:: plugin_filesystem
 
-.. doxygengroup:: Plugin_host_load
 
 ..  LocalWords:  SimGrid
+
index 2e09bb2..7036d53 100644 (file)
@@ -20,6 +20,48 @@ Your platform description should follow the specification presented in the
 
 -------------------------------------------------------------------------------
 
+.. _pf_tag_disk:
+
+<disk>
+------
+
+SimGrid can simulate the time it takes to read or write data on disk, even if the stored data is not made persistent in
+any way by SimGrid. This means that your application will correctly be slowed down when doing simulated I/O, but there
+is no way to get the data stored this way. 
+
+We decided to not model anything beyond raw access in SimGrid because we believe that there is not single way of doing so.
+We provide an example model of file system as a plugin, (sparsely) documented in :ref:`plugin_filesystem`.
+
+**Parent tags:** :ref:`pf_tag_host` |br|
+**Children tags:** :ref:`pf_tag_prop` |br|
+**Attributes:**
+
+:``id``: A name of your choice (must be unique on this host).
+:``read_bw``: Read bandwidth for this disk. You must specify a unit as follows.
+
+   **Units in bytes and powers of 2** (1 KiBps = 1,024 Bps):
+     Bps, KiBps, MiBps, GiBps, TiBps, PiBps, or EiBps. |br|
+   **Units in bits  and powers of 2** (1 Bps = 8 bps):
+     bps, Kibps, Mibps, Gibps, Tibps, Pibps, or Eibps. |br|
+   **Units in bytes and powers of 10**  (1 KBps = 1,000 Bps):
+     Bps, KBps, MBps, GBps, TBps, PBps, or EBps. |br|
+   **Units in bits  and powers of 10:**
+     bps, Kbps, Mbps, Gbps, Tbps, Pbps, or Ebps.
+
+:``write_bw``: Write bandwidth for this disk. You must specify a unit as for the read bandwidth.
+
+.. code-block:: xml
+
+    <host id="alice" speed="1Gf">
+      <disk id="Disk1" read_bw="200MBps" write_bw="80MBps">
+        <!-- you can add properties for anything you want: they are not used by SimGrid -->
+        <prop id="content" value="storage/content/small_content.txt"/>
+      </disk>
+      <prop id="ram" value="100B" />
+    </host>
+
+-------------------------------------------------------------------------------
+
 .. _pf_tag_config:
 
 <config>
index ea3d805..f562a23 100644 (file)
@@ -130,7 +130,7 @@ class _DoxygenXmlParagraphFormatter(object):
         self.continue_line = True
 
     def visit_parameterlist(self, node):
-        lines = [l for l in type(self)().generic_visit(node).lines if l is not '']
+        lines = [l for l in type(self)().generic_visit(node).lines if l != '']
         self.lines.extend([':parameters:', ''] + ['* %s' % l for l in lines] + [''])
 
     def visit_simplesect(self, node):
@@ -191,12 +191,12 @@ class DoxygenDocumenter(Documenter):
         'members': members_option,
     }
 
-    def __init__(self, directive, name, indent=u'', id=None):
+    def __init__(self, directive, name, indent=u'', my_id = None):
         super(DoxygenDocumenter, self).__init__(directive, name, indent)
-        if id is not None:
-            self.parse_id(id)
+        if my_id is not None:
+            self.parse_id(my_id)
 
-    def parse_id(self, id):
+    def parse_id(self, id_to_parse):
         return False
 
     def parse_name(self):
@@ -238,6 +238,7 @@ class DoxygenDocumenter(Documenter):
         directive = getattr(self, 'directivetype', self.objtype)
         name = self.format_name()
         sourcename = self.get_sourcename()
+        #print('.. %s:%s:: %s%s' % (domain, directive, name, sig))
         self.add_line(u'.. %s:%s:: %s%s' % (domain, directive, name, sig),
                       sourcename)
 
@@ -333,12 +334,9 @@ class DoxygenClassDocumenter(DoxygenDocumenter):
 
         if want_all:
             return False, ((m.find('name').text, m) for m in all_members)
-        else:
-            if not self.options.members:
-                return False, []
-            else:
-                return False, ((m.find('name').text, m) for m in all_members
-                               if m.find('name').text in self.options.members)
+        if not self.options.members:
+            return False, []
+        return False, ((m.find('name').text, m) for m in all_members if m.find('name').text in self.options.members)
 
     def filter_members(self, members, want_all):
         ret = []
@@ -363,10 +361,10 @@ class DoxygenMethodDocumenter(DoxygenDocumenter):
             return True
         return False
 
-    def parse_id(self, id):
-        xp = './/*[@id="%s"]' % id
+    def parse_id(self, id_to_parse):
+        xp = './/*[@id="%s"]' % id_to_parse
         match = get_doxygen_root().xpath(xp)
-        if len(match) > 0:
+        if match:
             match = match[0]
             self.fullname = match.find('./definition').text.split()[-1]
             self.modname = self.fullname
@@ -381,33 +379,40 @@ class DoxygenMethodDocumenter(DoxygenDocumenter):
             # classname or method name
             return True
 
-        (obj, meth) = self.fullname.rsplit('::', 1)
+        if '::' in self.fullname:
+            (obj, meth) = self.fullname.rsplit('::', 1)
+            # 'public-func' and 'public-static-func' are for classes while 'func' alone is for namespaces
+            prefix = './/compoundname[text()="{:s}"]/../sectiondef[@kind="public-func" or @kind="public-static-func" or @kind="func"]'.format(obj)
+            obj = "{:s}::".format(obj)
+        else:
+            meth = self.fullname
+            prefix = './'
+            obj = ''
 
-        xpath_query_noparam = ('.//compoundname[text()="{:s}"]/../sectiondef[@kind="public-func" or @kind="public-static-func"]'
-                               '/memberdef[@kind="function"]/name[text()="{:s}"]/..').format(obj, meth)
+        xpath_query_noparam = ('{:s}/memberdef[@kind="function"]/name[text()="{:s}"]/..').format(prefix, meth)
         xpath_query = ""
-#        print("fullname {}".format(self.fullname))
         if self.argsstring != None:
-            xpath_query = ('.//compoundname[text()="{:s}"]/../sectiondef[@kind="public-func" or @kind="public-static-func"]'
-                           '/memberdef[@kind="function" and argsstring/text()="{:s}"]/name[text()="{:s}"]/..').format(obj,self.argsstring,meth)
+            xpath_query = ('{:s}/memberdef[@kind="function" and argsstring/text()="{:s}"]/name[text()="{:s}"]/..').format(prefix,self.argsstring,meth)
         else:
             xpath_query = xpath_query_noparam
         match = get_doxygen_root().xpath(xpath_query)
-        if len(match) == 0:
+        if not match:
             logger = logging.getLogger(__name__)
 
             if self.argsstring != None:
                 candidates = get_doxygen_root().xpath(xpath_query_noparam)
                 if len(candidates) == 1:
-                    logger.warning("[autodoxy] Using method '{}::{}{}' instead of '{}::{}{}'. You may want to drop your specification of the signature, or to fix it."
+                    logger.warning("[autodoxy] Using method '{}{}{}' instead of '{}{}{}'. You may want to drop your specification of the signature, or to fix it."
                                    .format(obj, meth, candidates[0].find('argsstring').text, obj, meth, self.argsstring))
                     self.object = candidates[0]
                     return True
-                logger.warning("[autodoxy] WARNING: Could not find method {}::{}{}".format(obj, meth, self.argsstring))
+                logger.warning("[autodoxy] WARNING: Could not find method {}{}{}".format(obj, meth, self.argsstring))
+                if not candidates:
+                    logger.warning("[autodoxy] WARNING:  (no candidate found)")
                 for cand in candidates:
-                    logger.warning("[autodoxy] WARNING:   Existing candidate: {}::{}{}".format(obj, meth, cand.find('argsstring').text))
+                    logger.warning("[autodoxy] WARNING:   Existing candidate: {}{}{}".format(obj, meth, cand.find('argsstring').text))
             else:
-                logger.warning("[autodoxy] WARNING: could not find method {}::{} in Doxygen files".format(obj, meth))
+                logger.warning("[autodoxy] WARNING: Could not find method {}{} in Doxygen files\nQuery: {}".format(obj, meth, xpath_query))
             return False
         self.object = match[0]
         return True
@@ -441,7 +446,7 @@ class DoxygenMethodDocumenter(DoxygenDocumenter):
 
     def format_template_name(self):
         types = [e.text for e in self.object.findall('templateparamlist/param/type')]
-        if len(types) == 0:
+        if not types:
             return ''
         ret = 'template <%s>' % ','.join(types)
 #        print ("template: {}".format(ret))
@@ -479,7 +484,7 @@ class DoxygenVariableDocumenter(DoxygenDocumenter):
                        '/memberdef[@kind="variable"]/name[text()="{:s}"]/..').format(obj, var)
 #        print("fullname {}".format(self.fullname))
         match = get_doxygen_root().xpath(xpath_query)
-        if len(match) == 0:
+        if not match:
             logger = logging.getLogger(__name__)
 
             logger.warning("[autodoxy] WARNING: could not find variable {}::{} in Doxygen files".format(obj, var))
@@ -487,10 +492,10 @@ class DoxygenVariableDocumenter(DoxygenDocumenter):
         self.object = match[0]
         return True
 
-    def parse_id(self, id):
-        xp = './/*[@id="%s"]' % id
+    def parse_id(self, id_to_parse):
+        xp = './/*[@id="%s"]' % id_to_parse
         match = get_doxygen_root().xpath(xp)
-        if len(match) > 0:
+        if match:
             match = match[0]
             self.fullname = match.find('./definition').text.split()[-1]
             self.modname = self.fullname
@@ -527,7 +532,7 @@ class DoxygenVariableDocumenter(DoxygenDocumenter):
 
     def format_template_name(self):
         types = [e.text for e in self.object.findall('templateparamlist/param/type')]
-        if len(types) == 0:
+        if not types:
             return ''
         ret = 'template <%s>' % ','.join(types)
 #        print ("template: {}".format(ret))
@@ -554,12 +559,12 @@ def set_doxygen_xml(app):
     files = [os.path.join(app.config.doxygen_xml, f)
              for f in os.listdir(app.config.doxygen_xml)
              if f.lower().endswith('.xml') and not f.startswith('._')]
-    if len(files) == 0:
+    if not files:
         raise err
 
     setup.DOXYGEN_ROOT = ET.ElementTree(ET.Element('root')).getroot()
-    for file in files:
-        root = ET.parse(file).getroot()
+    for current_file in files:
+        root = ET.parse(current_file).getroot()
         for node in root:
             setup.DOXYGEN_ROOT.append(node)
 
index 01aada4..8b0c009 100644 (file)
@@ -338,6 +338,8 @@ that marked as permanent receiver, you should call
 memory gets properly reclaimed. This call should be at the end of the
 actor's function, not in a on_exit callback.
 
+.. _s4u_raii:
+
 Memory Management
 *****************
 
@@ -376,61 +378,24 @@ shouldn't), using :cpp:func:`simgrid::s4u::Host::destroy`.
 API Reference
 *************
 
-.. _API_s4u_this_actor:
-
-==================================
-Interacting with the current actor
-==================================
-
-Static methods working on the current actor (see :ref:`API_s4u_Actor`).
+.. _API_s4u_simulation_object:
 
-.. doxygennamespace:: simgrid::s4u::this_actor
+==================
+Simulation objects
+==================
 
-.. _API_s4u_Activity:
+.. _API_s4u_Actor:
 
 ==============
-class Activity
+⁣  class Actor
 ==============
 
-.. autodoxyclass:: simgrid::s4u::Activity
-
-   **Known subclasses:**
-   :ref:`Communications <API_s4u_Comm>` (started on Mailboxes and consuming links),
-   :ref:`Executions <API_s4u_Exec>` (started on Host and consuming CPU resources)
-   :ref:`I/O <API_s4u_Io>` (started on and consumming disks).
-   See also the :ref:`section on activities <s4u_Activities>` above.
-
-Querying info about activities
-------------------------------
-
-   .. autodoxymethod:: simgrid::s4u::Activity::get_remaining()
-   .. autodoxymethod:: simgrid::s4u::Activity::get_state()
-   .. autodoxymethod:: simgrid::s4u::Activity::set_remaining(double remains)
-   .. autodoxymethod:: simgrid::s4u::Activity::get_impl
-
-Activities lifecycle
---------------------
-
-   .. autodoxymethod:: simgrid::s4u::Activity::start
-   .. autodoxymethod:: simgrid::s4u::Activity::cancel
-   .. autodoxymethod:: simgrid::s4u::Activity::test
-   .. autodoxymethod:: simgrid::s4u::Activity::wait
-   .. autodoxymethod:: simgrid::s4u::Activity::wait_for
-   .. autodoxymethod:: simgrid::s4u::Activity::wait_until(double time_limit)
-
-
-.. _API_s4u_Actor:
-
-===========
-class Actor
-===========
+.. autodoxyclass:: simgrid::s4u::Actor
 
 .. doxygentypedef:: ActorPtr
 
 .. doxygentypedef:: aid_t
 
-.. autodoxyclass:: simgrid::s4u::Actor
-
 Creating actors
 ---------------
 
@@ -438,6 +403,10 @@ Creating actors
 
    .. group-tab:: C++
 
+      .. code:: C++
+
+         #include <simgrid/s4u/Engine.hpp>
+
       .. autodoxymethod:: simgrid::s4u::Actor::create(const std::string &name, s4u::Host *host, const std::function< void()> &code)
       .. autodoxymethod:: simgrid::s4u::Actor::create(const std::string &name, s4u::Host *host, F code)
       .. autodoxymethod:: simgrid::s4u::Actor::create(const std::string &name, s4u::Host *host, F code, Args... args)
@@ -448,8 +417,32 @@ Creating actors
 
    .. group-tab:: Python
 
+      .. code:: Python
+
+         from simgrid import Actor
+
       .. automethod:: simgrid.Actor.create
 
+   .. group-tab:: C
+
+      .. code:: C
+
+         #include <simgrid/actor.h>
+
+      .. doxygentypedef:: sg_actor_t
+      .. cpp:type:: const s4u_Actor* const_sg_actor_t
+
+         Pointer to a constant actor object.
+
+      .. autodoxymethod:: sg_actor_init(const char *name, sg_host_t host)
+      .. autodoxymethod:: sg_actor_start(sg_actor_t actor, xbt_main_func_t code, int argc, char **argv)
+
+      .. autodoxymethod:: sg_actor_attach(const char *name, void *data, sg_host_t host, xbt_dict_t properties)
+      .. autodoxymethod:: sg_actor_detach()
+
+      .. autodoxymethod:: sg_actor_ref(const_sg_actor_t actor)
+      .. autodoxymethod:: sg_actor_unref(const_sg_actor_t actor)
+
 Searching specific actors
 -------------------------
 
@@ -465,6 +458,11 @@ Searching specific actors
       .. automethod:: simgrid.Actor.by_pid
       .. automethod:: simgrid.Actor.self
 
+   .. group-tab:: C
+
+      .. autodoxymethod:: sg_actor_by_PID(aid_t pid)
+      .. autodoxymethod:: sg_actor_self()
+
 Querying info about actors
 --------------------------
 
@@ -493,7 +491,19 @@ Querying info about actors
       .. autoattribute:: simgrid.Actor.pid
       .. autoattribute:: simgrid.Actor.ppid
 
-      .. automethod:: simgrid.Actor.migrate
+   .. group-tab:: C
+
+      .. autodoxymethod:: sg_actor_get_name(const_sg_actor_t actor)
+      .. autodoxymethod:: sg_actor_get_PID(const_sg_actor_t actor)
+      .. autodoxymethod:: sg_actor_get_PPID(const_sg_actor_t actor)
+      .. autodoxymethod:: sg_actor_get_properties(const_sg_actor_t actor)
+      .. autodoxymethod:: sg_actor_get_property_value(const_sg_actor_t actor, const char *name)
+
+      .. autodoxymethod:: sg_actor_get_host(const_sg_actor_t actor)
+      .. autodoxymethod:: sg_actor_set_host(sg_actor_t actor, sg_host_t host)
+
+      .. autodoxymethod:: sg_actor_data(const_sg_actor_t actor)
+      .. autodoxymethod:: sg_actor_data_set(sg_actor_t actor, void *userdata)        
 
 Suspending and resuming actors
 ------------------------------
@@ -512,6 +522,12 @@ Suspending and resuming actors
       .. automethod:: simgrid.Actor.suspend
       .. automethod:: simgrid.Actor.is_suspended
 
+   .. group-tab:: C
+
+      .. autodoxymethod:: sg_actor_suspend(sg_actor_t actor)
+      .. autodoxymethod:: sg_actor_resume(sg_actor_t actor)
+      .. autodoxymethod:: sg_actor_is_suspended(sg_actor_t actor)
+
 Specifying when actors should terminate
 ---------------------------------------
 
@@ -536,6 +552,17 @@ Specifying when actors should terminate
       .. automethod:: simgrid.Actor.daemonize
       .. automethod:: simgrid.Actor.is_daemon
 
+   .. group-tab:: C
+
+      .. autodoxymethod:: sg_actor_kill(sg_actor_t actor)
+      .. autodoxymethod:: sg_actor_kill_all()
+      .. autodoxymethod:: sg_actor_set_kill_time(sg_actor_t actor, double kill_time)
+
+      .. autodoxymethod:: sg_actor_restart(sg_actor_t actor)
+      .. autodoxymethod:: sg_actor_daemonize(sg_actor_t actor)
+
+.. _API_s4u_Actor_end:
+
 Reacting to the end of actors
 -----------------------------
 
@@ -552,6 +579,11 @@ Reacting to the end of actors
 
       .. automethod:: simgrid.Actor.join
 
+   .. group-tab:: C
+
+      .. autodoxymethod:: sg_actor_join(sg_actor_t actor, double timeout)
+      .. autodoxymethod:: sg_actor_set_auto_restart(sg_actor_t actor, int auto_restart)
+
 Signals
 -------
 
@@ -564,83 +596,507 @@ Signals
       .. autodoxyvar:: simgrid::s4u::Actor::on_resume
       .. autodoxyvar:: simgrid::s4u::Actor::on_sleep
       .. autodoxyvar:: simgrid::s4u::Actor::on_wake_up
-      .. autodoxyvar:: simgrid::s4u::Actor::on_migration_start
-      .. autodoxyvar:: simgrid::s4u::Actor::on_migration_end
       .. autodoxyvar:: simgrid::s4u::Actor::on_termination
       .. autodoxyvar:: simgrid::s4u::Actor::on_destruction
 
-.. _API_s4u_Barrier:
+.. _API_s4u_this_actor:
 
-=============
-class Barrier
-=============
+====================
+⁣  The current actor
+====================
 
-.. doxygentypedef:: BarrierPtr
+These functions can be used in your user code to interact with the actor
+currently running (the one retrieved with :cpp:func:`simgrid::s4u::Actor::self`).
+Using these functions can greatly improve the code readability.
 
-.. autodoxyclass:: simgrid::s4u::Barrier
+Querying info
+-------------
 
-   .. tabs::
+.. tabs::
 
-      .. group-tab:: C++
+   .. group-tab:: C++
 
-         .. autodoxymethod:: simgrid::s4u::Barrier::Barrier(unsigned int count)
-         .. autodoxymethod:: simgrid::s4u::Barrier::create(unsigned int expected_actors)
-         .. autodoxymethod:: simgrid::s4u::Barrier::wait()
+      .. autodoxymethod:: simgrid::s4u::this_actor::get_cname()
+      .. autodoxymethod:: simgrid::s4u::this_actor::get_name()
+      .. autodoxymethod:: simgrid::s4u::this_actor::get_pid()
+      .. autodoxymethod:: simgrid::s4u::this_actor::get_ppid()
+      .. autodoxymethod:: simgrid::s4u::this_actor::is_maestro()
 
+      .. autodoxymethod:: simgrid::s4u::this_actor::get_host()
+      .. autodoxymethod:: simgrid::s4u::this_actor::set_host(Host *new_host)
 
-.. _API_s4u_Comm:
+   .. group-tab:: Python
+
+      .. autofunction:: simgrid.this_actor.get_host
+      .. autofunction:: simgrid.this_actor.set_host
+
+   .. group-tab:: C
+
+      .. autodoxymethod:: sg_actor_self_data()
+      .. autodoxymethod:: sg_actor_self_data_set(void *data)
+      .. autodoxymethod:: sg_actor_self_get_name()
+      .. autodoxymethod:: sg_actor_self_get_pid()
+      .. autodoxymethod:: sg_actor_self_get_ppid()
+      .. autodoxymethod:: sg_host_self()
+      .. autodoxymethod:: sg_host_self_get_name()
+
+Suspending and resuming
+-----------------------
+
+.. tabs::
+
+   .. group-tab:: C++
+
+      .. autodoxymethod:: simgrid::s4u::this_actor::suspend()
+      .. autodoxymethod:: simgrid::s4u::this_actor::yield()
+
+   .. group-tab:: Python
+
+      .. autofunction:: simgrid.this_actor.suspend
+      .. autofunction:: simgrid.this_actor.yield_
+
+Logging messages
+----------------
+
+.. tabs::
+
+   .. group-tab:: Python
+
+       .. autofunction:: simgrid.this_actor.info
+       .. autofunction:: simgrid.this_actor.error
+
+Sleeping
+--------
+
+.. tabs::
+
+   .. group-tab:: C++
+
+      .. autodoxymethod:: simgrid::s4u::this_actor::sleep_for(double duration)
+      .. autodoxymethod:: simgrid::s4u::this_actor::sleep_for(std::chrono::duration< Rep, Period > duration)
+      .. autodoxymethod:: simgrid::s4u::this_actor::sleep_until(const SimulationTimePoint< Duration > &wakeup_time)
+      .. autodoxymethod:: simgrid::s4u::this_actor::sleep_until(double wakeup_time)
+
+   .. group-tab:: Python
+
+      .. autofunction:: simgrid.this_actor.sleep_for
+      .. autofunction:: simgrid.this_actor.sleep_until
+
+   .. group-tab:: C
+
+      .. autodoxymethod:: sg_actor_sleep_for(double duration)
+
+Simulating executions
+---------------------
+
+Simulate the execution of some code on this actor. You can either simulate
+parallel or sequential code, and you can either block upon the termination of
+the execution, or start an asynchronous activity.
+
+.. tabs::
+
+   .. group-tab:: C++
+
+      .. autodoxymethod:: simgrid::s4u::this_actor::exec_async(double flops_amounts)
+      .. autodoxymethod:: simgrid::s4u::this_actor::exec_init(const std::vector< s4u::Host * > &hosts, const std::vector< double > &flops_amounts, const std::vector< double > &bytes_amounts)
+      .. autodoxymethod:: simgrid::s4u::this_actor::exec_init(double flops_amounts)
+      .. autodoxymethod:: simgrid::s4u::this_actor::execute(double flop)
+      .. autodoxymethod:: simgrid::s4u::this_actor::execute(double flop, double priority)
+      .. autodoxymethod:: simgrid::s4u::this_actor::parallel_execute(const std::vector< s4u::Host * > &hosts, const std::vector< double > &flops_amounts, const std::vector< double > &bytes_amounts)
+      .. autodoxymethod:: simgrid::s4u::this_actor::parallel_execute(const std::vector< s4u::Host * > &hosts, const std::vector< double > &flops_amounts, const std::vector< double > &bytes_amounts, double timeout)
+
+   .. group-tab:: Python
+
+      .. autofunction:: simgrid.this_actor.exec_init
+      .. autofunction:: simgrid.this_actor.execute
+
+   .. group-tab:: C
+
+      .. autodoxymethod:: sg_actor_self_execute(double flops)
+
+Exiting
+-------
+
+.. tabs::
+
+   .. group-tab:: C++
+
+      .. autodoxymethod:: simgrid::s4u::this_actor::exit()
+      .. autodoxymethod:: simgrid::s4u::this_actor::on_exit(const std::function< void(bool)> &fun)
+
+   .. group-tab:: Python
+
+      .. autofunction:: simgrid.this_actor.exit
+      .. autofunction:: simgrid.this_actor.on_exit
+
+.. _API_s4u_Engine:
+
+====================
+⁣  Simulation Engine
+====================
+
+.. autodoxyclass:: simgrid::s4u::Engine
+
+Initialization
+--------------
+
+.. tabs::
+
+   .. group-tab:: C++
+
+      .. autodoxymethod:: simgrid::s4u::Engine::Engine(int *argc, char **argv)
+      .. autodoxymethod:: simgrid::s4u::Engine::is_initialized()
+      .. autodoxymethod:: simgrid::s4u::Engine::shutdown()
+      .. autodoxymethod:: simgrid::s4u::Engine::set_config(const std::string &str)
+
+      .. autodoxymethod:: simgrid::s4u::Engine::load_deployment(const std::string &deploy)
+      .. autodoxymethod:: simgrid::s4u::Engine::load_platform(const std::string &platf)
+      .. autodoxymethod:: simgrid::s4u::Engine::register_actor(const std::string &name)
+      .. autodoxymethod:: simgrid::s4u::Engine::register_actor(const std::string &name, F code)
+      .. autodoxymethod:: simgrid::s4u::Engine::register_default(int(*code)(int, char **))
+      .. autodoxymethod:: simgrid::s4u::Engine::register_function(const std::string &name, int(*code)(int, char **))
+      .. autodoxymethod:: simgrid::s4u::Engine::register_function(const std::string &name, void(*code)(std::vector< std::string >))
+
+   .. group-tab:: Python
+   
+       .. automethod:: simgrid.Engine.load_deployment
+       .. automethod:: simgrid.Engine.load_platform
+       .. automethod:: simgrid.Engine.register_actor
+
+   .. group-tab:: C
+
+      .. autodoxymethod:: simgrid_init
+
+      .. autodoxymethod:: simgrid_load_deployment
+      .. autodoxymethod:: simgrid_load_platform
+      .. autodoxymethod:: simgrid_register_default
+      .. autodoxymethod:: simgrid_register_function
+
+Run the simulation
+------------------
+
+.. tabs::
+
+   .. group-tab:: C++
+
+      .. autodoxymethod:: simgrid::s4u::Engine::get_clock()
+      .. autodoxymethod:: simgrid::s4u::Engine::run()
+
+   .. group-tab:: Python
+   
+      .. automethod:: simgrid.Engine.get_clock
+      .. automethod:: simgrid.Engine.run
+
+   .. group-tab:: C
+
+      .. autodoxymethod:: simgrid_get_clock
+      .. autodoxymethod:: simgrid_run
+
+Retrieving actors
+-----------------
+
+.. tabs::
+
+   .. group-tab:: C++
+
+      .. autodoxymethod:: simgrid::s4u::Engine::get_actor_count()
+      .. autodoxymethod:: simgrid::s4u::Engine::get_all_actors()
+      .. autodoxymethod:: simgrid::s4u::Engine::get_filtered_actors(const std::function< bool(ActorPtr)> &filter)
+
+   .. group-tab:: C
+
+      .. autodoxymethod:: simgrid_get_actor_count()
+
+Retrieving hosts
+----------------
+
+.. tabs::
+
+   .. group-tab:: C++
+
+      .. autodoxymethod:: simgrid::s4u::Engine::get_all_hosts()
+      .. autodoxymethod:: simgrid::s4u::Engine::get_host_count()
+      .. autodoxymethod:: simgrid::s4u::Engine::get_filtered_hosts(const std::function< bool(Host *)> &filter)
+      .. autodoxymethod:: simgrid::s4u::Engine::host_by_name(const std::string &name)
+      .. autodoxymethod:: simgrid::s4u::Engine::host_by_name_or_null(const std::string &name)
+
+   .. group-tab:: Python
+
+      .. automethod:: simgrid.Engine.get_all_hosts
+
+Retrieving links
+----------------
+
+.. tabs::
+
+   .. group-tab:: C++
+
+      .. autodoxymethod:: simgrid::s4u::Engine::get_all_links()
+      .. autodoxymethod:: simgrid::s4u::Engine::get_link_count()
+      .. autodoxymethod:: simgrid::s4u::Engine::get_filtered_links
+      .. autodoxymethod:: simgrid::s4u::Engine::link_by_name(const std::string &name)
+      .. autodoxymethod:: simgrid::s4u::Engine::link_by_name_or_null(const std::string &name)
+
+Interacting with the routing
+----------------------------
+
+.. tabs::
+
+   .. group-tab:: C++
+
+      .. autodoxymethod:: simgrid::s4u::Engine::get_all_netpoints()
+      .. autodoxymethod:: simgrid::s4u::Engine::get_filtered_netzones()
+      .. autodoxymethod:: simgrid::s4u::Engine::get_instance()
+      .. autodoxymethod:: simgrid::s4u::Engine::get_netzone_root()
+      .. autodoxymethod:: simgrid::s4u::Engine::netpoint_by_name_or_null(const std::string &name)
+      .. autodoxymethod:: simgrid::s4u::Engine::netzone_by_name_or_null(const std::string &name)
+      .. autodoxymethod:: simgrid::s4u::Engine::set_netzone_root(const NetZone *netzone)
+
+Signals
+-------
+
+.. tabs::
+
+   .. group-tab:: C++
+
+      .. autodoxyvar:: simgrid::s4u::Engine::on_deadlock
+      .. autodoxyvar:: simgrid::s4u::Engine::on_platform_created
+      .. autodoxyvar:: simgrid::s4u::Engine::on_platform_creation
+      .. autodoxyvar:: simgrid::s4u::Engine::on_simulation_end
+      .. autodoxyvar:: simgrid::s4u::Engine::on_time_advance
+
+.. _API_s4u_Mailbox:
+
+================
+⁣  class Mailbox
+================
+
+.. autodoxyclass:: simgrid::s4u::Mailbox
+
+Please also refer to the :ref:`full doc on s4u::Mailbox <s4u_mailbox>`.
+
+Basic management
+----------------
+
+.. tabs::
+
+   .. group-tab:: C++
+
+      .. code-block:: C++
+
+         #include <simgrid/s4u/Mailbox.hpp>
+
+      Note that there is no MailboxPtr type, and that you cannot use the RAII
+      idiom on mailboxes because they are internal objects to the simulation
+      engine. Once created, there is no way to destroy a mailbox before the end
+      of the simulation.
+         
+      .. autodoxymethod:: simgrid::s4u::Mailbox::by_name(const std::string &name)
+
+   .. group-tab:: Python
+
+      .. automethod:: simgrid.Mailbox.by_name
+
+Querying info
+.............
+
+.. tabs::
+
+   .. group-tab:: C++
+
+      .. autodoxymethod:: simgrid::s4u::Mailbox::get_cname()
+      .. autodoxymethod:: simgrid::s4u::Mailbox::get_name()
+
+   .. group-tab:: Python
+
+      .. autoattribute:: simgrid.Mailbox.name
+
+Sending data
+............
+
+.. tabs::
+
+   .. group-tab:: C++
+
+      .. autodoxymethod:: simgrid::s4u::Mailbox::put(void *payload, uint64_t simulated_size_in_bytes)
+      .. autodoxymethod:: simgrid::s4u::Mailbox::put(void *payload, uint64_t simulated_size_in_bytes, double timeout)
+      .. autodoxymethod:: simgrid::s4u::Mailbox::put_async(void *data, uint64_t simulated_size_in_bytes)
+      .. autodoxymethod:: simgrid::s4u::Mailbox::put_init()
+      .. autodoxymethod:: simgrid::s4u::Mailbox::put_init(void *data, uint64_t simulated_size_in_bytes)
+
+   .. group-tab:: Python
+
+      .. automethod:: simgrid.Mailbox.put
+      .. automethod:: simgrid.Mailbox.put_async
+
+
+Receiving data
+..............
+
+.. tabs::
+
+   .. group-tab:: C++
+
+      .. autodoxymethod:: simgrid::s4u::Mailbox::empty()
+      .. autodoxymethod:: simgrid::s4u::Mailbox::front()
+      .. autodoxymethod:: simgrid::s4u::Mailbox::get()
+      .. autodoxymethod:: simgrid::s4u::Mailbox::get(double timeout)
+      .. autodoxymethod:: simgrid::s4u::Mailbox::get_async(void **data)
+      .. autodoxymethod:: simgrid::s4u::Mailbox::get_init()
+      .. autodoxymethod:: simgrid::s4u::Mailbox::iprobe(int type, bool(*match_fun)(void *, void *, kernel::activity::CommImpl *), void *data)
+      .. autodoxymethod:: simgrid::s4u::Mailbox::listen()
+      .. autodoxymethod:: simgrid::s4u::Mailbox::ready()
+
+   .. group-tab:: Python
+
+       .. automethod:: simgrid.Mailbox.get
+
+   .. group-tab:: C
+
+      .. autodoxymethod:: sg_mailbox_listen(const char *alias)
+
+Receiving actor
+...............
+
+See :ref:`s4u_receiving_actor`.
+
+.. tabs::
+
+   .. group-tab:: C++
+
+      .. autodoxymethod:: simgrid::s4u::Mailbox::get_receiver()
+      .. autodoxymethod:: simgrid::s4u::Mailbox::set_receiver(ActorPtr actor)
+
+   .. group-tab:: C
+
+      .. autodoxymethod:: ::sg_mailbox_set_receiver(const char *alias)
+                  
+.. _API_s4u_Resource:
 
 =========
-s4u::Comm
+Resources
 =========
 
-.. doxygentypedef:: CommPtr
+.. _API_s4u_Disk:
 
-.. doxygenclass:: simgrid::s4u::Comm
+=============
+⁣  class Disk
+=============
+
+.. doxygenclass:: simgrid::s4u::Disk
    :members:
    :protected-members:
    :undoc-members:
 
-.. _API_s4u_ConditionVariable:
 
-======================
-s4u::ConditionVariable
-======================
 
-.. doxygentypedef:: ConditionVariablePtr
+.. _API_s4u_Host:
 
-.. doxygenclass:: simgrid::s4u::ConditionVariable
+=============
+⁣  class Host
+=============
+
+.. doxygenclass:: simgrid::s4u::Host
    :members:
    :protected-members:
    :undoc-members:
 
-.. _API_s4u_Disk:
+.. _API_s4u_Link:
+
+=============
+⁣  class Link
+=============
+
+.. doxygenclass:: simgrid::s4u::Link
+   :members:
+   :protected-members:
+   :undoc-members:
 
-============
-s4u::Disk
-============
+.. _API_s4u_NetZone:
 
-.. doxygenclass:: simgrid::s4u::Disk
+================
+⁣  class NetZone
+================
+
+.. doxygenclass:: simgrid::s4u::NetZone
    :members:
    :protected-members:
    :undoc-members:
 
-.. _API_s4u_Engine:
+.. _API_s4u_VirtualMachine:
 
-===========
-s4u::Engine
-===========
+=======================
+⁣  class VirtualMachine
+=======================
 
-.. doxygenclass:: simgrid::s4u::Engine
+.. doxygenclass:: simgrid::s4u::VirtualMachine
+   :members:
+   :protected-members:
+   :undoc-members:
+
+.. autodoxymethod:: sg_vm_create_core
+.. autodoxymethod:: sg_vm_create_multicore
+.. autodoxymethod:: sg_vm_get_name
+.. autodoxymethod:: sg_vm_get_pm
+.. autodoxymethod:: sg_vm_is_created
+.. autodoxymethod:: sg_vm_is_running
+.. autodoxymethod:: sg_vm_is_suspended
+.. autodoxymethod:: sg_vm_start
+.. autodoxymethod:: sg_vm_suspend
+.. autodoxymethod:: sg_vm_resume
+.. autodoxymethod:: sg_vm_shutdown
+.. autodoxymethod:: sg_vm_destroy
+
+.. _API_s4u_Activity:
+
+==============
+class Activity
+==============
+
+.. autodoxyclass:: simgrid::s4u::Activity
+
+   **Known subclasses:**
+   :ref:`Communications <API_s4u_Comm>` (started on Mailboxes and consuming links),
+   :ref:`Executions <API_s4u_Exec>` (started on Host and consuming CPU resources)
+   :ref:`I/O <API_s4u_Io>` (started on and consumming disks).
+   See also the :ref:`section on activities <s4u_Activities>` above.
+
+Querying info about activities
+------------------------------
+
+   .. autodoxymethod:: simgrid::s4u::Activity::get_remaining()
+   .. autodoxymethod:: simgrid::s4u::Activity::get_state()
+   .. autodoxymethod:: simgrid::s4u::Activity::set_remaining(double remains)
+   .. autodoxymethod:: simgrid::s4u::Activity::get_impl
+
+Activities lifecycle
+--------------------
+
+   .. autodoxymethod:: simgrid::s4u::Activity::start
+   .. autodoxymethod:: simgrid::s4u::Activity::cancel
+   .. autodoxymethod:: simgrid::s4u::Activity::test
+   .. autodoxymethod:: simgrid::s4u::Activity::wait
+   .. autodoxymethod:: simgrid::s4u::Activity::wait_for
+   .. autodoxymethod:: simgrid::s4u::Activity::wait_until(double time_limit)
+
+.. _API_s4u_Comm:
+
+=============
+⁣  class Comm
+=============
+
+.. doxygentypedef:: CommPtr
+
+.. doxygenclass:: simgrid::s4u::Comm
    :members:
    :protected-members:
    :undoc-members:
 
 .. _API_s4u_Exec:
 
-=========
-s4u::Exec
-=========
+=============
+⁣  class Exec
+=============
 
 .. doxygentypedef:: ExecPtr
 
@@ -651,9 +1107,9 @@ s4u::Exec
 
 .. _API_s4u_ExecSeq:
 
-============
-s4u::ExecSeq
-============
+==================
+⁣    class ExecSeq
+==================
 
 .. doxygentypedef:: ExecSeqPtr
 
@@ -664,9 +1120,9 @@ s4u::ExecSeq
 
 .. _API_s4u_ExecPar:
 
-============
-s4u::ExecPar
-============
+==================
+⁣    class ExecPar
+==================
 
 .. doxygentypedef:: ExecParPtr
 
@@ -675,22 +1131,11 @@ s4u::ExecPar
    :protected-members:
    :undoc-members:
 
-.. _API_s4u_Host:
-
-=========
-s4u::Host
-=========
-
-.. doxygenclass:: simgrid::s4u::Host
-   :members:
-   :protected-members:
-   :undoc-members:
-
 .. _API_s4u_Io:
 
-=======
-s4u::Io
-=======
+===========
+⁣  class Io
+===========
 
 .. doxygentypedef:: IoPtr
 
@@ -699,104 +1144,226 @@ s4u::Io
    :protected-members:
    :undoc-members:
 
-.. _API_s4u_Link:
+.. _API_s4u_Synchronizations:
 
-=========
-s4u::Link
-=========
+=======================
+Synchronization Objects
+=======================
 
-.. doxygenclass:: simgrid::s4u::Link
-   :members:
-   :protected-members:
-   :undoc-members:
+.. _API_s4u_Mutex:
 
-.. _API_s4u_Mailbox:
+==============
+⁣  Mutex
+==============
 
-============
-s4u::Mailbox
-============
+.. autodoxyclass:: simgrid::s4u::Mutex
 
-Please also refer to the :ref:`full doc on s4u::Mailbox <s4u_mailbox>`.
+Basic management
+----------------
 
-.. doxygenclass:: simgrid::s4u::Mailbox
-   :members:
-   :protected-members:
-   :undoc-members:
+   .. tabs::
 
-.. _API_s4u_Mutex:
+      .. group-tab:: C++
 
-==========
-s4u::Mutex
-==========
+         .. code-block:: C++
 
-.. doxygentypedef:: MutexPtr
+            #include <simgrid/s4u/Mutex.hpp>
 
-.. doxygenclass:: simgrid::s4u::Mutex
-   :members:
-   :protected-members:
-   :undoc-members:
+         .. doxygentypedef:: MutexPtr
 
-.. _API_s4u_NetZone:
+         .. autodoxymethod:: simgrid::s4u::Mutex::Mutex(kernel::activity::MutexImpl *mutex)
+         .. autodoxymethod:: simgrid::s4u::Mutex::create()
+         .. autodoxymethod:: simgrid::s4u::Mutex::~Mutex()
 
-============
-s4u::NetZone
-============
+      .. group-tab:: C
 
-.. doxygenclass:: simgrid::s4u::NetZone
-   :members:
-   :protected-members:
-   :undoc-members:
+         .. code-block:: C
 
-.. _API_s4u_Semaphore:
+            #include <simgrid/mutex.h>
 
-==============
-s4u::Semaphore
-==============
+         .. doxygentypedef:: sg_mutex_t
+         .. cpp:type:: const s4u_Mutex* const_sg_mutex_t
 
-.. doxygentypedef:: SemaphorePtr
+            Pointer to a constant mutex object.
 
-.. doxygenclass:: simgrid::s4u::Semaphore
-   :members:
-   :protected-members:
-   :undoc-members:
+         .. autodoxymethod:: sg_mutex_init()
+         .. autodoxymethod:: sg_mutex_destroy(const_sg_mutex_t mutex)
 
-.. _API_s4u_VirtualMachine:
+Locking
+-------
 
-===================
-s4u::VirtualMachine
-===================
+   .. tabs::
 
-.. doxygenclass:: simgrid::s4u::VirtualMachine
-   :members:
-   :protected-members:
-   :undoc-members:
+      .. group-tab:: C++
 
-C API Reference
-***************
+         .. autodoxymethod:: simgrid::s4u::Mutex::lock()
+         .. autodoxymethod:: simgrid::s4u::Mutex::try_lock()
+         .. autodoxymethod:: simgrid::s4u::Mutex::unlock()
 
-==============
-Main functions
-==============
+      .. group-tab:: C
+
+         .. autodoxymethod:: sg_mutex_lock(sg_mutex_t mutex)
+         .. autodoxymethod:: sg_mutex_try_lock(sg_mutex_t mutex)
+         .. autodoxymethod:: sg_mutex_unlock(sg_mutex_t mutex)
+
+.. _API_s4u_Barrier:
+
+================
+⁣  Barrier
+================
+
+.. autodoxyclass:: simgrid::s4u::Barrier
+
+   .. tabs::
+
+      .. group-tab:: C++
+
+         .. code-block:: C++
+
+            #include <simgrid/s4u/Barrier.hpp>
+
+         .. doxygentypedef:: BarrierPtr
+
+         .. autodoxymethod:: simgrid::s4u::Barrier::Barrier(unsigned int expected_actors)
+         .. autodoxymethod:: simgrid::s4u::Barrier::create(unsigned int expected_actors)
+         .. autodoxymethod:: simgrid::s4u::Barrier::wait()
+
+      .. group-tab:: C
+
+         .. code-block:: C
+
+            #include <simgrid/barrier.hpp>
 
-.. doxygenfunction:: simgrid_init
-.. doxygenfunction:: simgrid_get_clock
-.. doxygenfunction:: simgrid_load_deployment
-.. doxygenfunction:: simgrid_load_platform
-.. doxygenfunction:: simgrid_register_default
-.. doxygenfunction:: simgrid_register_function
-.. doxygenfunction:: simgrid_run
+         .. doxygentypedef:: sg_bar_t
+         .. cpp:type:: const s4u_Barrier* const_sg_bar_t
+
+            Pointer to a constant barrier object.
+
+         .. autodoxymethod:: sg_barrier_init(unsigned int count)
+         .. autodoxymethod:: sg_barrier_destroy(const_sg_bar_t bar)
+         .. autodoxymethod:: sg_barrier_wait(sg_bar_t bar)
+
+
+.. _API_s4u_ConditionVariable:
+
+==========================
+⁣  Condition variable
+==========================
+
+.. autodoxyclass:: simgrid::s4u::ConditionVariable
+
+Basic management
+----------------
+
+   .. tabs::
+
+      .. group-tab:: C++
+
+         .. code-block:: C++
+
+            #include <simgrid/s4u/ConditionVariable.hpp>
+
+         .. doxygentypedef:: ConditionVariablePtr
+
+         .. autodoxymethod:: simgrid::s4u::ConditionVariable::create()
+
+      .. group-tab:: C
+
+         .. code-block:: C
+
+            #include <simgrid/cond.h>
+
+         .. doxygentypedef:: sg_cond_t
+         .. doxygenfunction:: sg_cond_init
+         .. doxygenfunction:: sg_cond_destroy
+
+Waiting and notifying
+---------------------
+
+   .. tabs::
+
+      .. group-tab:: C++
+
+         .. autodoxymethod:: simgrid::s4u::ConditionVariable::notify_all()
+         .. autodoxymethod:: simgrid::s4u::ConditionVariable::notify_one()
+         .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait(s4u::MutexPtr lock)
+         .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait(const std::unique_lock< s4u::Mutex > &lock)
+         .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait(const std::unique_lock< Mutex > &lock, P pred)
+         .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait_for(const std::unique_lock< s4u::Mutex > &lock, double duration)
+         .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait_for(const std::unique_lock< s4u::Mutex > &lock, double duration, P pred)
+         .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait_for(const std::unique_lock< s4u::Mutex > &lock, std::chrono::duration< Rep, Period > duration)
+         .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait_for(const std::unique_lock< s4u::Mutex > &lock, std::chrono::duration< Rep, Period > duration, P pred)
+         .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait_until(const std::unique_lock< s4u::Mutex > &lock, const SimulationTimePoint< Duration > &timeout_time)
+         .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait_until(const std::unique_lock< s4u::Mutex > &lock, const SimulationTimePoint< Duration > &timeout_time, P pred)
+         .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait_until(const std::unique_lock< s4u::Mutex > &lock, double timeout_time)
+         .. autodoxymethod:: simgrid::s4u::ConditionVariable::wait_until(const std::unique_lock< s4u::Mutex > &lock, double timeout_time, P pred)
+
+      .. group-tab:: C
+
+         .. doxygenfunction:: sg_cond_notify_all
+         .. doxygenfunction:: sg_cond_notify_one
+         .. doxygenfunction:: sg_cond_wait
+         .. doxygenfunction:: sg_cond_wait_for
+
+.. _API_s4u_Semaphore:
 
 ==================
-Condition Variable
+⁣  Semaphore
 ==================
 
-See also the :ref:`C++ API <API_s4u_ConditionVariable>`.
+.. autodoxyclass:: simgrid::s4u::Semaphore
+
 
-.. doxygenfunction:: sg_cond_init
-.. doxygenfunction:: sg_cond_notify_all
-.. doxygenfunction:: sg_cond_notify_one
-.. doxygenfunction:: sg_cond_wait
-.. doxygenfunction:: sg_cond_wait_for
+Basic management
+----------------
+
+   .. tabs::
+
+      .. group-tab:: C++
+
+         .. code-block:: C++
+
+            #include <simgrid/s4u/Semaphore.hpp>
+
+         .. doxygentypedef:: SemaphorePtr
+         .. autodoxymethod:: simgrid::s4u::Semaphore::Semaphore(unsigned int initial_capacity)
+         .. autodoxymethod:: simgrid::s4u::Semaphore::~Semaphore()
+         .. autodoxymethod:: simgrid::s4u::Semaphore::create(unsigned int initial_capacity)
+
+      .. group-tab:: C
+
+         .. code-block:: C
+
+            #include <simgrid/semaphore.h>
+
+         .. doxygentypedef:: sg_sem_t
+         .. cpp:type:: const s4u_Semaphore* const_sg_sem_t
+
+            Pointer to a constant semaphore object.
+
+         .. autodoxymethod:: sg_sem_init(int initial_value)
+         .. autodoxymethod:: sg_sem_destroy(const_sg_sem_t sem)
+
+Locking
+-------
+
+   .. tabs::
+
+      .. group-tab:: C++
+
+         .. autodoxymethod:: simgrid::s4u::Semaphore::acquire()
+         .. autodoxymethod:: simgrid::s4u::Semaphore::acquire_timeout(double timeout)
+         .. autodoxymethod:: simgrid::s4u::Semaphore::get_capacity()
+         .. autodoxymethod:: simgrid::s4u::Semaphore::release()
+         .. autodoxymethod:: simgrid::s4u::Semaphore::would_block()
+
+      .. group-tab:: C
+
+         .. autodoxymethod:: sg_sem_acquire(sg_sem_t sem)
+         .. autodoxymethod:: sg_sem_acquire_timeout(sg_sem_t sem, double timeout)
+         .. autodoxymethod:: sg_sem_get_capacity(sg_sem_t sem)
+         .. autodoxymethod:: sg_sem_release(sg_sem_t sem)
+         .. autodoxymethod:: sg_sem_would_block(sg_sem_t sem)
 
 Python API Reference
 ********************
@@ -811,13 +1378,6 @@ this_actor
 .. automodule:: simgrid.this_actor
    :members:
 
-===========
-Class Actor
-===========
-
-.. autoclass:: simgrid.Actor
-   :members:
-
 ==========
 Class Comm
 ==========
@@ -825,13 +1385,6 @@ Class Comm
 .. autoclass:: simgrid.Comm
    :members:
 
-============
-Class Engine
-============
-
-.. autoclass:: simgrid.Engine
-   :members:
-
 ==========
 Class Exec
 ==========
index 89a8b65..795206e 100644 (file)
@@ -186,7 +186,7 @@ Most of these are best described in `STAR-MPI's white paper <https://doi.org/10.
  - mvapich2: use mvapich2 selector for the alltoall operations
  - impi: use intel mpi selector for the alltoall operations
  - automatic (experimental): use an automatic self-benchmarking algorithm
- - bruck: Described by Bruck et.al. in <a href="http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=642949">this paper</a>
+ - bruck: Described by Bruck et.al. in `this paper <http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=642949>`_
  - 2dmesh: organizes the nodes as a two dimensional mesh, and perform allgather
    along the dimensions
  - 3dmesh: adds a third dimension to the previous algorithm
@@ -313,9 +313,9 @@ MPI_Allreduce
  - impi: use intel mpi selector for the allreduce operations
  - automatic (experimental): use an automatic self-benchmarking algorithm
  - lr: logical ring reduce-scatter then logical ring allgather
- - rab1: variations of the  <a href="https://fs.hlrs.de/projects/par/mpi//myreduce.html">Rabenseifner</a> algorithm: reduce_scatter then allgather
- - rab2: variations of the  <a href="https://fs.hlrs.de/projects/par/mpi//myreduce.html">Rabenseifner</a> algorithm: alltoall then allgather
- - rab_rsag: variation of the  <a href="https://fs.hlrs.de/projects/par/mpi//myreduce.html">Rabenseifner</a> algorithm: recursive doubling
+ - rab1: variations of the  `Rabenseifner <https://fs.hlrs.de/projects/par/mpi//myreduce.html>`_ algorithm: reduce_scatter then allgather
+ - rab2: variations of the  `Rabenseifner <https://fs.hlrs.de/projects/par/mpi//myreduce.html>`_ algorithm: alltoall then allgather
+ - rab_rsag: variation of the  `Rabenseifner <https://fs.hlrs.de/projects/par/mpi//myreduce.html>`_ algorithm: recursive doubling
    reduce_scatter then recursive doubling allgather
  - rdb: recursive doubling
  - smp_binomial: binomial tree with smp: binomial intra
index eee9b19..4f2554a 100644 (file)
@@ -32,7 +32,7 @@ if read_the_docs_build:
 # -- Project information -----------------------------------------------------
 
 project = u'SimGrid'
-copyright = u'2002-2019, The SimGrid Team'
+copyright = u'2002-2020, The SimGrid Team'
 author = u'The SimGrid Team'
 
 # The short X.Y version
@@ -144,3 +144,7 @@ html_context = {
     "gitlab_version": "master",  # Version
     "conf_py_path": "/docs/source/",  # Path in the checkout to the docs root
 }
+
+# -- Other options
+
+nitpicky = True # Generate a warning for all a cross-reference (such as :func:`myfunc`) that cannot be found
index ce04250..bce43f4 100644 (file)
@@ -63,21 +63,22 @@ of every page. Bugs in the code should be reported
    :caption: User Manual:
 
       Introduction <Introduction.rst>
-         Installing SimGrid <Installing_SimGrid.rst>
-         Start your Own Project <Start_Your_Own_Project.rst>
+         Installing SimGrid <Installing_SimGrid.rst>
+         Start your Own Project <Start_Your_Own_Project.rst>
       Describing your Application <application.rst>
-         The S4U Interface <app_s4u.rst>
-         The SMPI Interface <app_smpi.rst>
-         The MSG Interface <app_msg.rst>
+         The S4U Interface <app_s4u.rst>
+         The SMPI Interface <app_smpi.rst>
+         The MSG Interface <app_msg.rst>
       Describing the Simulated Platform <platform.rst>
-         Examples <Platform_Examples.rst>
-         Modeling Hints <platform_howtos.rst>
-         XML Reference <XML_Reference.rst>
+         Examples <Platform_Examples.rst>
+         Modeling Hints <platform_howtos.rst>
+         Defining a Routing <Platform_Routing.rst>
+         XML Reference <XML_Reference.rst>
       Describing the Experimental Setup <Experimental_Setup.rst>
-         Configuring SimGrid <Configuring_SimGrid.rst>
-         Deploying your Application <Deploying_your_Application.rst>
+         Configuring SimGrid <Configuring_SimGrid.rst>
+         Deploying your Application <Deploying_your_Application.rst>
       The SimGrid Models <models.rst>
-         ns-3 as a SimGrid model <ns3.rst>
+         ns-3 as a SimGrid model <ns3.rst>
       SimGrid Plugins <Plugins.rst>
       Simulation Outcomes <outcomes.rst>
       The SimGrid Community <community.rst>
index 758990f..b8779f5 100644 (file)
@@ -23,90 +23,20 @@ work. When XML is too limiting, you may describe your platforms using
 the :ref:`lua bindings <platform_lua>` (it is not yet possible to do so in
 python or directly in C++).
 
-We understand that writing a complex platform description can be tricky, we thus included 
-:ref:`many examples <platform_examples>` in the archive. This
-documentation also contains some :ref:`hints and howtos <howto>`, as well
-as the full :ref:`XML reference guide <platform_reference>`.
-
-
-Any simulated platform must contain **basic elements**, such as hosts, links, disks, etc. SimGrid gives you a great
-liberty when defining the **routing of your platform**, i.e., the network path taken between each pair of hosts.
+Any simulated platform must contain **basic elements**, such as
+:ref:`pf_tag_host`, :ref:`pf_tag_link`, :ref:`pf_tag_disk`, and similar.
+SimGrid makes no assumption about the **routing of your platform**, so you must declare
+explicitly the network path taken between each pair of hosts. 
+This can be done through a flat list of :ref:`pf_tag_route` for each pair of hosts (routes
+are symmetrical by default), or you may use the advanced concept of :ref:`networking zone <platform_routing>`
+to efficiently express the routing of your platform.
 Finally, you may also describe an **experimental scenario**, with qualitative (e.g., bandwidth variations representing
 an external load) and qualitative (e.g., representing how some elements fail and restart over time) changes.
 
-
-First Example
-*************
-
-Imagine you want to describe a little platform with three hosts,
-interconnected as follows:
-
-.. image:: /tuto_smpi/3hosts.png
-   :align: center
-
-This can be done with the following platform file, that considers the
-simulated platform as a graph of hosts and network links.
-          
-.. literalinclude:: /tuto_smpi/3hosts.xml
-   :language: xml
-
-The most important elements are the basic ones: :ref:`pf_tag_host`,
-:ref:`pf_tag_link`, and similar. Then come the routes between any pair
-of hosts, that are given explicitly with :ref:`pf_tag_route` (routes
-are symmetrical by default). Any host must be given a computational
-speed (in flops) while links must be given a latency (in seconds) and
-a bandwidth (in bytes per second). Note that you can write 1Gflops
-instead of 1000000000flops, and similar.
-
-Every platform element must be located within a given **networking
-zone** .  Zones are in
-charge of the routing, see below.
-
-The last thing you must know on SimGrid platform files is that the
-root tag must be :ref:`pf_tag_platform`. If the ``version`` attribute
-does not match what SimGrid expects, you will be hinted to use to the
-``simgrid_update_xml`` utility to update your file.
-
-
-Defining a Routing
-******************
-
-Networking zones (:ref:`pf_tag_zone`) are used to factorize the description
-to reduce the size of your platform on disk and in memory. Then, when
-a host wants to communicate with another host belonging to the same
-zone, it is the zone's duty to find the list of links that are
-involved in the communication. In the above examples, since we use
-``routing="Full"``, all routes must be explicitly given using the
-:ref:`pf_tag_route` and :ref:`pf_tag_link_ctn` tags (this :ref:`routing
-model <pf_rm>` is both simple and inefficient :) It is OK to not
-specify each and every route between hosts, as long as you do not try
-to start a communication on any of the missing routes during your
-simulation.
-
-Any zone may contain sub-zones, allowing for a hierarchical
-decomposition of the platform. Routing can be made more efficient (as the
-inter-zone routing gets factored with :ref:`pf_tag_zoneroute`), and
-allows you to have more than one routing model in your platform. For
-example, you can have a coordinate-based routing for the WAN parts
-of your platforms, a full routing within each datacenter, and a highly
-optimized routing within each cluster of the datacenter.  In this
-case, determining the route between two given hosts gets :ref:`routing_basics`
-"somewhat more complex" but SimGrid still computes
-these routes for you in a time- and space-efficient manner.
-Here is an illustration of these concepts:
-
-.. image:: img/zone_hierarchy.png
-
-Circles represent processing units and squares represent network
-routers. Bold lines represent communication links. The zone "AS2" models the core of a national network interconnecting a
-small flat cluster (AS4) and a larger hierarchical cluster (AS5), a
-subset of a LAN (AS6), and a set of peers scattered around the world
-(AS7).
-
-.. todo:: Add more examples, such as the cloud example described in
-          previous paragraph
-
-Performance Profiles and Churn
-******************************
+The most efficient way to learn about platform description is to look at the
+:ref:`many examples <platform_examples>` included in the archive and described
+in the next section. This documentation also contains some :ref:`hints and
+howtos <howto>`, as well as the full :ref:`XML reference guide
+<platform_reference>`.
 
 ..  LocalWords:  SimGrid
index 577ef26..0cd01b4 100644 (file)
@@ -1,5 +1,3 @@
-.. _platform:
-
 .. raw:: html
 
    <object id="TOC" data="graphical-toc.svg" type="image/svg+xml"></object>
@@ -194,13 +192,13 @@ by the obtained simulation time. Lets consider the following platform:
 
 .. code-block:: xml
 
-   <host id="A" speed="1Gf"/>
-   <host id="B" speed="1Gf"/>
+   <host id="A" speed="1Gf" />
+   <host id="B" speed="1Gf" />
 
-   <link id="link1" latency="10ms" bandwidth="1Mbps"/>
+   <link id="link1" latency="10ms" bandwidth="1Mbps" />
 
-   <route src="A" dst="B>
-     <link_ctn id="link1/>
+   <route src="A" dst="B">
+     <link_ctn id="link1/>
    </route>
 
 If host `A` sends `100kB` (a hundred kilobytes) to host `B`, one could expect
index 9a40c14..b6505ba 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 9380eb2..64176fa 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 2f439be..3061942 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 819fd4e..bfb4168 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index ecd2ab4..810c7b9 100644 (file)
@@ -360,6 +360,8 @@ Executions on the CPU
 
        .. example-tab:: examples/platforms/energy_platform.xml
 
+.. _s4u_ex_disk_io:
+
 I/O on Disks and Files
 ----------------------
 
@@ -405,22 +407,29 @@ result in short reads and short write, as in reality.
 Classical synchronization objects
 ---------------------------------
 
- - **Mutex:**
-   Shows how to use simgrid::s4u::Mutex synchronization objects.
+ - **Barrier:**
+   Shows how to use :cpp:type:`simgrid::s4u::Barrier` synchronization objects.
 
    .. tabs::
 
-      .. example-tab:: examples/s4u/synchro-mutex/s4u-synchro-mutex.cpp
+      .. example-tab:: examples/s4u/synchro-barrier/s4u-synchro-barrier.cpp
 
- - **Barrier:**
-   Shows how to use simgrid::s4u::Barrier synchronization objects.
+ - **Condition variable:**
+   Shows how to use :cpp:type:`simgrid::s4u::ConditionVariable` synchronization objects.
 
    .. tabs::
 
-      .. example-tab:: examples/s4u/synchro-barrier/s4u-synchro-barrier.cpp
+      .. example-tab:: examples/s4u/synchro-condition-variable/s4u-synchro-condition-variable.cpp
+
+ - **Mutex:**
+   Shows how to use :cpp:type:`simgrid::s4u::Mutex` synchronization objects.
+
+   .. tabs::
+
+      .. example-tab:: examples/s4u/synchro-mutex/s4u-synchro-mutex.cpp
 
  - **Semaphore:**
-   Shows how to use simgrid::s4u::Semaphore synchronization objects.
+   Shows how to use :cpp:type:`simgrid::s4u::Semaphore` synchronization objects.
 
    .. tabs::
 
index 52df077..cc95e7e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index fad0942..9f64bd6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 11773d4..1c02e7d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 4e303f0..06fda67 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index d72b3d0..b937889 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 6621939..e7adae4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 0913e90..8b39e42 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index feaea00..d479fff 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-# Copyright (c) 2013-2019. The SimGrid Team.
+# Copyright (c) 2013-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
index 956ce2f..20b82dc 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 54036b8..3a20587 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 6f54bfc..1d4de31 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 00f54e4..1dea543 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 8339980..e3d766c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 7b246ad..578fec5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 604f5c4..b90339e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 383b183..404b424 100644 (file)
@@ -1,6 +1,6 @@
 /* Master of a basic master/worker example in Java */
 
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 70dfc74..0a7d194 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index e41873d..d436995 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 641f2fc..cb81689 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index d4d5951..bdacc3d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 1608e89..e9ebb6f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index b05045e..bc382b3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 1420bd8..7deb445 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 5227afa..4b3e244 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 34ea0fe..5d89d57 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 04ebe76..9f3053a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 5e1a27c..d183627 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 6e528c6..38be1dd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 6552f86..729d480 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index c9af13a..837f4e0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index e828ce0..52a5037 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 5b983c9..352b5aa 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 3b4fa3a..73ff1df 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 48218cb..1c48834 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 2ad557f..7013adb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team.
+/* Copyright (c) 2014-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 5732968..cf4c9b4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team.
+/* Copyright (c) 2014-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index cbc51d4..d4bd4a6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 54fa18e..e5f7a92 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 34d7048..ce90ac7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index dd163e3..854912a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index a264576..0c94d78 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index af26262..3f0141c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 1a63143..a88079c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index dbda7b5..0612cad 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 8bbe1bb..a1bcbed 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 9d4ab36..f3bb660 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index dee7290..c554eb8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 28a9d4c..54bd4c0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 2fe2fc6..8828107 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 6f5a72b..74c61a0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 150c998..26852dd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index d31f505..855ce81 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 23389ef..bb90ebd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 965d58c..70aa924 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 0c8540a..b0d7be8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index ebc43a7..f7552d4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index b18ee0c..b7a11d3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index e726ce1..0de3cd9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 1e87be0..dc6447a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index a52336c..6b036fa 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 0091e72..87c0ab0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index c768469..58b9d6d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -35,7 +35,7 @@ public class EnergyVMRunner extends Process {
     }
   }
 
-  EnergyVMRunner(Host host, String name, String[] args) throws HostNotFoundException {
+  EnergyVMRunner(Host host, String name, String[] args) {
     super(host, name, args);
   }
 
index 1e788ce..5bf8d2e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -6,7 +6,6 @@
 package energy.vm;
 
 import org.simgrid.msg.Host;
-import org.simgrid.msg.HostNotFoundException;
 import org.simgrid.msg.Msg;
 
 class Main {
@@ -14,7 +13,7 @@ class Main {
     throw new IllegalAccessError("Utility class");
   }
 
-  public static void main(String[] args) throws HostNotFoundException {
+  public static void main(String[] args) {
     Msg.energyInit();
     Msg.init(args);
 
index 4d1e8d0..76567aa 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 086a719..5890465 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index df82e6d..457fab0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 8e5c380..ab90eae 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 1133f6e..381e7b0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -16,7 +16,6 @@
 package io.storage;
 
 import java.util.Arrays;
-import java.util.Comparator;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.Host;
 import org.simgrid.msg.Process;
@@ -32,11 +31,7 @@ public class Client extends Process {
    // Retrieve all mount points of current host
     Storage[] storages = getHost().getMountedStorage();
 
-    Arrays.sort(storages, new Comparator<Storage>() {
-        public int compare(Storage a, Storage b) {
-          return a.getName().compareTo(b.getName());
-        }
-      });
+    Arrays.sort(storages, (Storage a, Storage b) -> a.getName().compareTo(b.getName()));
     for (int i = 0; i < storages.length; i++) {
       // For each disk mounted on host
       Msg.info("------------------------------------");
index 3558869..a167c8b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index b813700..2b09d0b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index d6e086f..5d23aa6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index a34d4f5..a63cff5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 7ca62cb..164e928 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index e7f1ae9..026cb21 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 6d44798..ea6d2fd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index b9cc10e..be70093 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 1ab7253..b8bd68b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 62363b9..4eb9dac 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 33b3bb0..2d7f316 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 65fd0c2..9f90c41 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index dc69ca1..7940f77 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index efadb98..bb3fd2c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 67029cb..70cf5a0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index a08b13a..76cd067 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index cc7151e..0b5e100 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 5467316..21d82dc 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 6100fb3..9d3b643 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index cb9bfb5..dfe25f8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -70,7 +70,7 @@ static int master_fun(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[]
   msg_vm_t vm;
   unsigned int i;
 
-  xbt_dynar_t worker_pms = MSG_process_get_data(MSG_process_self());
+  const_xbt_dynar_t worker_pms = MSG_process_get_data(MSG_process_self());
   int nb_workers = xbt_dynar_length(worker_pms);
 
   xbt_dynar_t vms = xbt_dynar_new(sizeof(msg_vm_t), NULL);
index d420bb9..8b61b75 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -32,7 +32,7 @@ void answer_free(answer_t answer)
 }
 
 /** @brief Prints a answer_t, for debugging purposes */
-void answer_print(answer_t answer)
+void answer_print(const_answer_t answer)
 {
   unsigned int cpt;
   node_contact_t contact;
@@ -46,7 +46,7 @@ void answer_print(answer_t answer)
   * @param destination the destination in which the nodes will be put
   * @param source the source of the nodes to add
   */
-unsigned int answer_merge(answer_t destination, answer_t source)
+unsigned int answer_merge(answer_t destination, const_answer_t source)
 {
   node_contact_t contact;
   node_contact_t contact_copy;
@@ -69,8 +69,8 @@ unsigned int answer_merge(answer_t destination, answer_t source)
 /** Helper to sort answer_t objects */
 static int _answer_sort_function(const void *e1, const void *e2)
 {
-  node_contact_t c1 = *(void **) e1;
-  node_contact_t c2 = *(void **) e2;
+  const s_node_contact_t* c1 = *(const node_contact_t*)e1;
+  const s_node_contact_t* c2 = *(const node_contact_t*)e2;
   if (c1->distance == c2->distance)
     return 0;
   else
@@ -84,7 +84,7 @@ static int _answer_sort_function(const void *e1, const void *e2)
   * @param answer the answer to sort
   * @param destination_id the id of the guy we are trying to find
   */
-void answer_sort(answer_t answer)
+void answer_sort(const_answer_t answer)
 {
   xbt_dynar_sort(answer->nodes, &_answer_sort_function);
 }
@@ -108,7 +108,7 @@ void answer_trim(answer_t answer)
   * @param answer the answer object we're going  to put the data in
   * @param destination_id the id of the guy we are trying to find.
   */
-void answer_add_bucket(bucket_t bucket, answer_t answer)
+void answer_add_bucket(const_bucket_t bucket, answer_t answer)
 {
   xbt_assert((bucket != NULL), "Provided a NULL bucket");
   xbt_assert((bucket->nodes != NULL), "Provided a bucket which nodes are NULL");
@@ -126,7 +126,7 @@ void answer_add_bucket(bucket_t bucket, answer_t answer)
 /** @brief Returns if the id supplied is in the answer.
   * @param id : id we're looking for
   */
-unsigned int answer_contains(answer_t answer, unsigned int id)
+unsigned int answer_contains(const_answer_t answer, unsigned int id)
 {
   unsigned int i = 0;
   node_contact_t contact;
@@ -142,11 +142,11 @@ unsigned int answer_contains(answer_t answer, unsigned int id)
   * @param answer the answer
   * @return if the destination is found.
   */
-unsigned int answer_destination_found(answer_t answer)
+unsigned int answer_destination_found(const_answer_t answer)
 {
   if (xbt_dynar_is_empty(answer->nodes)) {
     return 0;
   }
-  node_contact_t contact_tail = xbt_dynar_get_as(answer->nodes, 0, node_contact_t);
+  const s_node_contact_t* contact_tail = xbt_dynar_get_as(answer->nodes, 0, node_contact_t);
   return contact_tail->distance == 0;
 }
index e67bd62..97838e0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -17,15 +17,16 @@ typedef struct s_node_answer {
 } s_answer_t;
 
 typedef s_answer_t *answer_t;
+typedef const s_answer_t* const_answer_t;
 
 answer_t answer_init(unsigned int destination_id);
 void answer_free(answer_t answer);
-void answer_print(answer_t answer);
-unsigned int answer_merge(answer_t destination, answer_t source);
-void answer_sort(answer_t answer);
+void answer_print(const_answer_t answer);
+unsigned int answer_merge(answer_t destination, const_answer_t source);
+void answer_sort(const_answer_t answer);
 void answer_trim(answer_t answer);
-void answer_add_bucket(bucket_t bucket, answer_t answer);
-unsigned int answer_contains(answer_t answer, unsigned int id);
-unsigned int answer_destination_found(answer_t answer);
+void answer_add_bucket(const_bucket_t bucket, answer_t answer);
+unsigned int answer_contains(const_answer_t answer, unsigned int id);
+unsigned int answer_destination_found(const_answer_t answer);
 
 #endif                          /* _KADEMLIA_EXAMPLES_ANSWER_H_ */
index eec2820..6e54aeb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 3ffb289..9129794 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -111,7 +111,7 @@ static int node(int argc, char *argv[])
   */
 unsigned int join(node_t node, unsigned int id_known)
 {
-  answer_t node_list;
+  const s_answer_t* node_list;
   msg_error_t status;
   unsigned int trial = 0;
   unsigned int i;
@@ -137,7 +137,7 @@ unsigned int join(node_t node, unsigned int id_known)
           XBT_DEBUG("Received an answer from the node I know.");
           answer_got = 1;
           //retrieve the node list and ping them.
-          task_data_t data = MSG_task_get_data(node->task_received);
+          const s_task_data_t* data = MSG_task_get_data(node->task_received);
           xbt_assert((data != NULL), "Null data received");
           if (data->type == TASK_FIND_NODE_ANSWER) {
             node_contact_t contact;
@@ -217,7 +217,7 @@ unsigned int find_node(node_t node, unsigned int id_to_find, unsigned int count_
           if (status == MSG_OK) {
             xbt_assert((node->task_received != NULL), "Invalid task received");
             //Figure out if we received an answer or something else
-            task_data_t data = MSG_task_get_data(node->task_received);
+            const s_task_data_t* data = MSG_task_get_data(node->task_received);
             xbt_assert((data != NULL), "No data in the task");
 
             //Check if what we have received is what we are looking for.
@@ -301,7 +301,7 @@ void send_find_node(node_t node, unsigned int id, unsigned int destination)
   * Sends to the best "KADEMLIA_ALPHA" nodes in the "node_list" array a "FIND_NODE" request, to ask them for their best
  * nodes
   */
-unsigned int send_find_node_to_best(node_t node, answer_t node_list)
+unsigned int send_find_node_to_best(node_t node, const_answer_t node_list)
 {
   unsigned int i = 0;
   unsigned int j = 0;
@@ -309,7 +309,7 @@ unsigned int send_find_node_to_best(node_t node, answer_t node_list)
   while (j < KADEMLIA_ALPHA && i < node_list->size) {
     /* We need to have at most "KADEMLIA_ALPHA" requests each time, according to the protocol */
     /* Gets the node we want to send the query to */
-    node_contact_t node_to_query = xbt_dynar_get_as(node_list->nodes, i, node_contact_t);
+    const s_node_contact_t* node_to_query = xbt_dynar_get_as(node_list->nodes, i, node_contact_t);
     if (node_to_query->id != node->id) {        /* No need to query ourselves */
       send_find_node(node, node_to_query->id, destination);
       j++;
@@ -322,7 +322,7 @@ unsigned int send_find_node_to_best(node_t node, answer_t node_list)
 /** @brief Handles an incoming received task */
 void handle_task(node_t node, msg_task_t task)
 {
-  task_data_t data = MSG_task_get_data(task);
+  const_task_data_t data = MSG_task_get_data(task);
   xbt_assert((data != NULL), "Received NULL data");
   //Adding/updating the guy to our routing table
   node_routing_table_update(node, data->sender_id);
@@ -340,7 +340,7 @@ void handle_task(node_t node, msg_task_t task)
 }
 
 /** @brief Handles the answer to an incoming "find_node" task */
-void handle_find_node(node_t node, task_data_t data)
+void handle_find_node(node_t node, const_task_data_t data)
 {
   XBT_VERB("Received a FIND_NODE from %s (%s), he's trying to find %08x",
            data->answer_to, data->issuer_host_name, data->destination_id);
index 62f550c..6d59131 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -15,9 +15,9 @@ unsigned int find_node(node_t node, unsigned int id_to_find, unsigned int count_
 void random_lookup(node_t node);
 
 void send_find_node(node_t node, unsigned int id, unsigned int destination);
-unsigned int send_find_node_to_best(node_t node, answer_t node_list);
+unsigned int send_find_node_to_best(node_t node, const_answer_t node_list);
 
 void handle_task(node_t node, msg_task_t task);
-void handle_find_node(node_t node, task_data_t data);
+void handle_find_node(node_t node, const_task_data_t data);
 
 #endif                          /* _MSG_EXAMPLES_KADEMLIA_H */
index bf86345..694ce51 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-# Copyright (c) 2012-2019. The SimGrid Team.
+# Copyright (c) 2012-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
index 629f277..286f513 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -42,11 +42,11 @@ void node_free(node_t node)
   * @param node Our node data
   * @param id The id of the node we need to add unsigned into our routing table
   */
-void node_routing_table_update(node_t node, unsigned int id)
+void node_routing_table_update(const_node_t node, unsigned int id)
 {
-  routing_table_t table = node->table;
+  const_routing_table_t table = node->table;
   //retrieval of the bucket in which the should be
-  bucket_t bucket = routing_table_find_bucket(table, id);
+  const_bucket_t bucket = routing_table_find_bucket(table, id);
 
   //check if the id is already in the bucket.
   unsigned int id_pos = bucket_find_id(bucket, id);
@@ -74,12 +74,12 @@ void node_routing_table_update(node_t node, unsigned int id)
   * @param node : our node
   * @param destination_id : the id of the guy we are trying to find
   */
-answer_t node_find_closest(node_t node, unsigned int destination_id)
+answer_t node_find_closest(const_node_t node, unsigned int destination_id)
 {
   int i;
   answer_t answer = answer_init(destination_id);
   /* We find the corresponding bucket for the id */
-  bucket_t bucket = routing_table_find_bucket(node->table, destination_id);
+  const_bucket_t bucket = routing_table_find_bucket(node->table, destination_id);
   int bucket_id = bucket->id;
   xbt_assert((bucket_id <= IDENTIFIER_SIZE), "Bucket found has a wrong identifier");
   /* So, we copy the contents of the bucket unsigned into our result dynar */
@@ -91,12 +91,12 @@ answer_t node_find_closest(node_t node, unsigned int destination_id)
   for (i = 1; answer->size < BUCKET_SIZE && ((bucket_id - i > 0) || (bucket_id + i < IDENTIFIER_SIZE)); i++) {
     /* We check the previous buckets */
     if (bucket_id - i >= 0) {
-      bucket_t bucket_p = &node->table->buckets[bucket_id - i];
+      const_bucket_t bucket_p = &node->table->buckets[bucket_id - i];
       answer_add_bucket(bucket_p, answer);
     }
     /* We check the next buckets */
     if (bucket_id + i <= IDENTIFIER_SIZE) {
-      bucket_t bucket_n = &node->table->buckets[bucket_id + i];
+      const_bucket_t bucket_n = &node->table->buckets[bucket_id + i];
       answer_add_bucket(bucket_n, answer);
     }
   }
@@ -155,7 +155,7 @@ node_contact_t node_contact_new(unsigned int id, unsigned int distance)
 }
 
 /** Builds a contact information from a contact information */
-node_contact_t node_contact_copy(node_contact_t node_contact)
+node_contact_t node_contact_copy(const_node_contact_t node_contact)
 {
   node_contact_t contact = xbt_new(s_node_contact_t, 1);
 
index e8f97c6..0a33730 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -20,6 +20,7 @@ typedef struct s_node_contact {
 } s_node_contact_t;
 
 typedef s_node_contact_t *node_contact_t;
+typedef const s_node_contact_t* const_node_contact_t;
 
 /* Node data */
 typedef struct s_node {
@@ -35,12 +36,13 @@ typedef struct s_node {
 } s_node_t;
 
 typedef s_node_t *node_t;
+typedef const s_node_t* const_node_t;
 
 // node functions
 node_t node_init(unsigned int id);
 void node_free(node_t node);
-void node_routing_table_update(node_t node, unsigned int id);
-answer_t node_find_closest(node_t node, unsigned int destination_id);
+void node_routing_table_update(const_node_t node, unsigned int id);
+answer_t node_find_closest(const_node_t node, unsigned int destination_id);
 
 // identifier functions
 unsigned int get_id_in_prefix(unsigned int id, unsigned int prefix);
@@ -49,6 +51,6 @@ void get_node_mailbox(unsigned int id, char *mailbox);
 
 // node contact functions
 node_contact_t node_contact_new(unsigned int id, unsigned int distance);
-node_contact_t node_contact_copy(node_contact_t node_contact);
+node_contact_t node_contact_copy(const_node_contact_t node_contact);
 void node_contact_free(node_contact_t contact);
 #endif                          /* _MSG_EXAMPLES_ROUTING_H */
index 5672b26..418040b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -35,15 +35,8 @@ void routing_table_free(routing_table_t table)
   xbt_free(table);
 }
 
-/** Returns if the routing table contains the id. */
-unsigned int routing_table_contains(routing_table_t table, unsigned int node_id)
-{
-  bucket_t bucket = routing_table_find_bucket(table, node_id);
-  return bucket_contains(bucket, node_id);
-}
-
 /**@brief prints the routing table, to debug stuff. */
-void routing_table_print(routing_table_t table)
+void routing_table_print(const_routing_table_t table)
 {
   unsigned int j;
   unsigned int value;
@@ -63,7 +56,7 @@ void routing_table_print(routing_table_t table)
   * @param bucket the bucket in which we try to find our identifier
   * @param id the id
   */
-unsigned int bucket_find_id(bucket_t bucket, unsigned int id)
+unsigned int bucket_find_id(const_bucket_t bucket, unsigned int id)
 {
   unsigned int i;
   unsigned int current_id;
@@ -75,18 +68,12 @@ unsigned int bucket_find_id(bucket_t bucket, unsigned int id)
   return -1;
 }
 
-/** Returns if the bucket contains an identifier.  */
-unsigned int bucket_contains(bucket_t bucket, unsigned int id)
-{
-  return xbt_dynar_member(bucket->nodes, &id);
-}
-
 /** @brief Finds the corresponding bucket in a routing table for a given identifier
   * @param table the routing table
   * @param id the identifier
   * @return the bucket in which the the identifier would be.
   */
-bucket_t routing_table_find_bucket(routing_table_t table, unsigned int id)
+bucket_t routing_table_find_bucket(const_routing_table_t table, unsigned int id)
 {
   unsigned int xor_number = table->id ^ id;
   unsigned int prefix     = get_node_prefix(xor_number, IDENTIFIER_SIZE);
index 1f0a677..95048b8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -16,6 +16,7 @@ typedef struct s_bucket {
 } s_bucket_t;
 
 typedef s_bucket_t *bucket_t;
+typedef const s_bucket_t* const_bucket_t;
 
 /* Node routing table */
 typedef struct s_routing_table {
@@ -24,16 +25,15 @@ typedef struct s_routing_table {
 } s_routing_table_t;
 
 typedef s_routing_table_t *routing_table_t;
+typedef const s_routing_table_t* const_routing_table_t;
 
 // bucket functions
-unsigned int bucket_find_id(bucket_t bucket, unsigned int id);
-unsigned int bucket_contains(bucket_t bucket, unsigned int id);
+unsigned int bucket_find_id(const_bucket_t bucket, unsigned int id);
 
 // routing table functions
 routing_table_t routing_table_init(unsigned int node_id);
 void routing_table_free(routing_table_t table);
-unsigned int routing_table_contains(routing_table_t table, unsigned int node_id);
-void routing_table_print(routing_table_t table);
-bucket_t routing_table_find_bucket(routing_table_t table, unsigned int id);
+void routing_table_print(const_routing_table_t table);
+bucket_t routing_table_find_bucket(const_routing_table_t table, unsigned int id);
 
 #endif                          /* _MSG_KADEMLIA_EXAMPLES_ROUTING_TABLE */
index bcfc228..cbe8b64 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 8490388..80141d4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@ typedef struct s_task_data {
 } s_task_data_t;
 
 typedef s_task_data_t *task_data_t;
+typedef const s_task_data_t* const_task_data_t;
 
 //Task handling functions
 msg_task_t task_new_find_node(unsigned int sender_id, unsigned int destination_id, char *mailbox, const char *hostname);
index ba71a21..012d353 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -43,6 +43,7 @@ typedef struct s_node {
   xbt_dynar_t pending_tasks;
 } s_node_t;
 typedef s_node_t* node_t;
+typedef const s_node_t* const_node_t;
 
 typedef struct s_state {
   int id;
@@ -72,11 +73,6 @@ typedef struct s_task_data {
 } s_task_data_t;
 typedef s_task_data_t* task_data_t;
 
-static int domain(unsigned int a, unsigned int level);
-static int shl(int a, int b);
-static int closest_in_namespace_set(node_t node, int dest);
-static int routing_next(node_t node, int dest);
-
 /**
  * @brief Gets the mailbox name of a host given its chord id.
  * @param node_id id of a node
@@ -118,7 +114,8 @@ static void task_free(void* task)
 }
 
 /* Get the closest id to the dest in the node namespace_set */
-static int closest_in_namespace_set(node_t node, int dest) {
+static int closest_in_namespace_set(const_node_t node, int dest)
+{
   int res = -1;
   if ((node->namespace_set[NAMESPACE_SIZE-1] <= dest) && (dest <= node->namespace_set[0])) {
     int best_dist = abs(node->id - dest);
@@ -137,7 +134,8 @@ static int closest_in_namespace_set(node_t node, int dest) {
 }
 
 /* Find the next node to forward a message to */
-static int routing_next(node_t node, int dest) {
+static int routing_next(const_node_t node, int dest)
+{
   int closest = closest_in_namespace_set(node, dest);
   if (closest!=-1)
     return closest;
@@ -173,7 +171,8 @@ static int routing_next(node_t node, int dest) {
 }
 
 /* Get the corresponding state of a node */
-static state_t node_get_state(node_t node) {
+static state_t node_get_state(const_node_t node)
+{
   state_t state = xbt_new0(s_state_t,1);
   state->id = node->id;
   for (int i=0; i<NEIGHBORHOOD_SIZE; i++)
@@ -189,17 +188,20 @@ static state_t node_get_state(node_t node) {
   return state;
 }
 
-static void print_node_id(node_t node) {
+static void print_node_id(const_node_t node)
+{
   XBT_INFO(" Id: %i '%08x' ", node->id, (unsigned)node->id);
 }
 
-static void print_node_neighborood_set(node_t node) {
+static void print_node_neighborood_set(const_node_t node)
+{
   XBT_INFO(" Neighborhood:");
   for (int i=0; i<NEIGHBORHOOD_SIZE; i++)
     XBT_INFO("  %08x", (unsigned)node->neighborhood_set[i]);
 }
 
-static void print_node_routing_table(node_t node) {
+static void print_node_routing_table(const_node_t node)
+{
   XBT_INFO(" Routing table:");
   for (int i=0; i<LEVELS_COUNT; i++){
     for (int j=0; j<LEVEL_SIZE; j++)
@@ -207,14 +209,16 @@ static void print_node_routing_table(node_t node) {
   }
 }
 /* Print the node namespace set */
-static void print_node_namespace_set(node_t node) {
+static void print_node_namespace_set(const_node_t node)
+{
   XBT_INFO(" Namespace:");
   for (int i=0; i<NAMESPACE_SIZE; i++)
     XBT_INFO("  %08x", (unsigned)node->namespace_set[i]);
 }
 
 /* Print the node information */
-static void print_node(node_t node) {
+static void print_node(const_node_t node)
+{
   XBT_INFO("Node:");
   print_node_id(node);
   print_node_neighborood_set(node);
@@ -427,7 +431,8 @@ static void handle_task(node_t node, msg_task_t task) {
 }
 
 /* Join the ring */
-static int join(node_t node){
+static int join(const_node_t node)
+{
   task_data_t req_data = xbt_new0(s_task_data_t,1);
   req_data->type = TASK_JOIN;
   req_data->sender_id = node->id;
index cc0d24f..ea834bd 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-# Copyright (c) 2011-2019. The SimGrid Team.
+# Copyright (c) 2011-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
index 1f35d8b..208f366 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 0390959..efc27d6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 8fd8490..f0b9fdd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -17,6 +17,7 @@
 
 #include <simgrid/modelchecker.h>
 #include <simgrid/msg.h>
+#include <xbt/dynar.h>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(bugged1_liveness, "my log messages");
 
index aaf1dc1..448c054 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 2b68854..2926b46 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -25,7 +25,7 @@ static int coordinator(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[
     MSG_task_receive(&task, "coordinator");
     const char *kind = MSG_task_get_name(task); //is it a request or a release?
     if (!strcmp(kind, "request")) {     // that's a request
-      char *req = MSG_task_get_data(task);
+      const char* req = MSG_task_get_data(task);
       if (CS_used) {
         XBT_INFO("CS already used.");
         msg_task_t answer = MSG_task_create("not grant", 0, 1000, NULL);
index c223704..57cd689 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index bf21be1..38f9d3b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 57c72f0..edc2233 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 276e901..a0f3163 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 9ce18b4..542f034 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 8e4e386..81fb1b9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 107e250..c85973b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index f4f7421..ac1838f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index ae8a333..c09b24a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -76,25 +76,5 @@ int main(int argc, char *argv[])
     }
     xbt_dynar_free (&link_variables);
   }
-
-  xbt_dynar_t nodes_type = TRACE_get_node_types ();
-  if (nodes_type){
-    XBT_INFO ("Node types in the trace:");
-    char *node_type;
-    xbt_dynar_foreach (nodes_type, cursor, node_type){
-      XBT_INFO ("%s", node_type);
-    }
-    xbt_dynar_free (&nodes_type);
-  }
-  xbt_dynar_t edges_type = TRACE_get_edge_types ();
-  if (edges_type){
-    XBT_INFO("Edge types in the trace:");
-    char *edge_type;
-    xbt_dynar_foreach (edges_type, cursor, edge_type){
-      XBT_INFO ("%s", edge_type);
-    }
-    xbt_dynar_free (&edges_type);
-  }
-
   return 0;
 }
index 6124de2..3b79c77 100644 (file)
@@ -8,13 +8,6 @@ $ ${bindir:=.}/trace-host-user-variables --cfg=tracing:yes --cfg=tracing/platfor
 > [0.004078] [msg_test/INFO] HDD_capacity
 > [0.004078] [msg_test/INFO] HDD_utilization
 > [0.004078] [msg_test/INFO] Declared link variables:
-> [0.004078] [msg_test/INFO] Node types in the trace:
-> [0.004078] [msg_test/INFO] HOST
-> [0.004078] [msg_test/INFO] LINK
-> [0.004078] [msg_test/INFO] Edge types in the trace:
-> [0.004078] [msg_test/INFO] 0-HOST1-LINK4
-> [0.004078] [msg_test/INFO] 0-LINK4-HOST1
-> [0.004078] [msg_test/INFO] 0-LINK4-LINK4
 
 $ rm -f simgrid.trace
 
index 3c90c28..0dd63de 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 906fd19..fcd6dff 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 065ba52..cdc4eb2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index b3722e0..f86e1ba 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 95c8d81..5293ef0 100644 (file)
@@ -1,6 +1,6 @@
 /* simple test trying to load a DOT file.                                   */
 
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@ int main(int argc, char **argv)
   }
 
   char *tracefilename;
-  char *last = strrchr(argv[2], '.');
+  const char* last = strrchr(argv[2], '.');
   tracefilename = bprintf("%.*s.trace", (int) (last == NULL ? strlen(argv[2]) : last - argv[2]),argv[2]);
   if (argc == 4)
     tracefilename = xbt_strdup(argv[3]);
index 388b690..d6a29f8 100644 (file)
@@ -1,6 +1,6 @@
 /* simple test trying to load a DAX file.                                   */
 
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -15,7 +15,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Logging specific to this SimDag example");
 
 static int name_compare_hosts(const void *n1, const void *n2)
 {
-  return strcmp(sg_host_get_name(*(sg_host_t *) n1), sg_host_get_name(*(sg_host_t *) n2));
+  return strcmp(sg_host_get_name(*(const sg_host_t*)n1), sg_host_get_name(*(const sg_host_t*)n2));
 }
 
 int main(int argc, char **argv)
@@ -31,7 +31,7 @@ int main(int argc, char **argv)
   xbt_assert(argc > 2, "Usage: %s platform_file dax_file [jedule_file]\n"
        "\tExample: %s simulacrum_7_hosts.xml Montage_25.xml Montage_25.jed", argv[0], argv[0]);
 
-  char *last = strrchr(argv[2], '.');
+  const char* last     = strrchr(argv[2], '.');
   char * tracefilename = bprintf("%.*s.trace",(int) (last == NULL ? strlen(argv[2]):last - argv[2]), argv[2]);
   if (argc == 4)
     tracefilename = xbt_strdup(argv[3]);
@@ -81,7 +81,7 @@ int main(int argc, char **argv)
   XBT_INFO("------------------- Run the schedule ---------------------------");
   SD_simulate(-1);
   XBT_INFO("------------------- Produce the trace file---------------------------");
-  char* basename = strrchr(tracefilename, '/');
+  const char* basename = strrchr(tracefilename, '/');
   XBT_INFO("Producing the trace of the run into %s", basename ? basename + 1 : tracefilename);
   FILE *out = fopen(tracefilename, "w");
   xbt_assert(out, "Cannot write to %s", tracefilename);
index 9a20782..60f3e43 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 4ab268a..f6f7545 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 5a57ec0..8a595de 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 7a50b4c..21e1e4f 100644 (file)
@@ -1,6 +1,6 @@
 /* simple test trying to load a DOT file.                                   */
 
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -38,7 +38,7 @@ int main(int argc, char **argv)
   }
 
   char *tracefilename;
-  char *last = strrchr(argv[2], '.');
+  const char* last = strrchr(argv[2], '.');
   tracefilename = bprintf("%.*s.trace", (int) (last == NULL ? strlen(argv[2]) : last - argv[2]),argv[2]);
   if (argc == 4)
     tracefilename = xbt_strdup(argv[3]);
index c7cd717..927e7a5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -22,9 +22,9 @@ struct _HostAttribute {
   SD_task_t last_scheduled_task;
 };
 
-static double sg_host_get_available_at(sg_host_t host)
+static double sg_host_get_available_at(const_sg_host_t host)
 {
-  HostAttribute attr = (HostAttribute)sg_host_data(host);
+  const struct _HostAttribute* attr = (HostAttribute)sg_host_data(host);
   return attr->available_at;
 }
 
@@ -35,8 +35,9 @@ static void sg_host_set_available_at(sg_host_t host, double time)
   sg_host_data_set(host, attr);
 }
 
-static SD_task_t sg_host_get_last_scheduled_task( sg_host_t host){
-  HostAttribute attr = (HostAttribute)sg_host_data(host);
+static SD_task_t sg_host_get_last_scheduled_task(const_sg_host_t host)
+{
+  const struct _HostAttribute* attr = (HostAttribute)sg_host_data(host);
   return attr->last_scheduled_task;
 }
 
@@ -46,7 +47,7 @@ static void sg_host_set_last_scheduled_task(sg_host_t host, SD_task_t task){
   sg_host_data_set(host, attr);
 }
 
-static xbt_dynar_t get_ready_tasks(xbt_dynar_t dax)
+static xbt_dynar_t get_ready_tasks(const_xbt_dynar_t dax)
 {
   unsigned int i;
   xbt_dynar_t ready_tasks;
@@ -63,7 +64,7 @@ static xbt_dynar_t get_ready_tasks(xbt_dynar_t dax)
   return ready_tasks;
 }
 
-static double finish_on_at(SD_task_t task, sg_host_t host)
+static double finish_on_at(const_SD_task_t task, const_sg_host_t host)
 {
   double result;
 
@@ -111,7 +112,7 @@ static double finish_on_at(SD_task_t task, sg_host_t host)
   return result;
 }
 
-static sg_host_t SD_task_get_best_host(SD_task_t task)
+static sg_host_t SD_task_get_best_host(const_SD_task_t task)
 {
   sg_host_t *hosts = sg_host_list();
   int nhosts = sg_host_count();
index 59fead5..a2727ae 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -119,7 +119,7 @@ int main(int argc, char **argv)
   SD_task_schedule(taskC, 2, host_list, computation_amount, communication_amount, -1);
   SD_task_schedule(taskD, 2, host_list, computation_amount, communication_amount, -1);
 
-  std::set<SD_task_t> *changed_tasks = simgrid::sd::simulate(-1.0);
+  const std::set<SD_task_t>* changed_tasks = simgrid::sd::simulate(-1.0);
   for (auto const& task : *changed_tasks) {
     XBT_INFO("Task '%s' start time: %f, finish time: %f", SD_task_get_name(task),
           SD_task_get_start_time(task), SD_task_get_finish_time(task));
index 46d7264..6a9b7b8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 0351004..9e754f5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 4a00e41..d2844d2 100644 (file)
@@ -14,7 +14,7 @@
    viewBox="0 0 150.00001 99.999999"
    version="1.1"
    id="svg8"
-   inkscape:version="0.92.3 (2405546, 2018-03-11)"
+   inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
    sodipodi:docname="cluster_dragonfly.svg">
   <defs
      id="defs2">
      borderopacity="1.0"
      inkscape:pageopacity="0.0"
      inkscape:pageshadow="2"
-     inkscape:zoom="2.5600001"
-     inkscape:cx="230.61674"
-     inkscape:cy="214.04712"
+     inkscape:zoom="4.012"
+     inkscape:cx="239.60111"
+     inkscape:cy="213.26587"
      inkscape:document-units="mm"
-     inkscape:current-layer="g995-3"
+     inkscape:current-layer="layer1"
      showgrid="true"
      showguides="true"
-     inkscape:window-width="1920"
-     inkscape:window-height="1001"
-     inkscape:window-x="-9"
-     inkscape:window-y="-9"
+     inkscape:window-width="3700"
+     inkscape:window-height="2032"
+     inkscape:window-x="140"
+     inkscape:window-y="54"
      inkscape:window-maximized="1"
      fit-margin-top="0"
      fit-margin-left="0"
          y="23.342285"
          x="114.7258"
          sodipodi:role="line">...</tspan></text>
+    <path
+       inkscape:connector-curvature="0"
+       id="path967-0-1-3-8-3"
+       d="m 132.29167,13.895832 c -11.55606,-11.9062503 -22.06158,-11.9062503 -35.71875,0"
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.23615019;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       sodipodi:nodetypes="cc" />
+    <path
+       inkscape:connector-curvature="0"
+       id="path967-0-1-3-8-3-6"
+       d="m 133.61458,13.895832 c -11.55605,-11.9062504 -22.06157,-11.9062504 -35.718743,0"
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.23615018;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       sodipodi:nodetypes="cc" />
   </g>
 </svg>
index 0d6e816..e95fbd2 100644 (file)
@@ -1,4 +1,4 @@
--- Copyright (c) 2011-2019. The SimGrid Team.
+-- Copyright (c) 2011-2020. The SimGrid Team.
 -- All rights reserved.
 
 -- This program is free software; you can redistribute it and/or modify it
index 554f4c8..53d7a6d 100644 (file)
@@ -2,22 +2,21 @@
 <!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
 
 <!-- Describe a dogbone graph, with 4 hosts:
-  --
-  -- S1 ---[ 1 ]---                 ---[ 3 ]--- C1
-  --               \               /
-  --                R1 --[ 2 ]-- R2
-  --               /               \
-  -- S2 ---[ 4 ]---                 ---[ 5 ]--- C2
-  --
-  --
-  -- This platform is a valid ns-3 platform, even if it exhibits routes of length >1,
-  -- because when you only keep the routes of length 1,
-  -- you get a graph where every host can speak to any other host.
-  --
-  -- For example, S1--C1 is (l1,l2,l3) of length >1
-  -- But it's also S1--C1 = S1--R1, R1--R2, R2--C1 which are all of length 1
-  --
-  -- https://simgrid.org/doc/latest/ns3.html
+  -
+  -  S1 ___[ 1 ]___                 ___[ 3 ]___ C1
+  -                \               /
+  -                 R1 __[ 2 ]__ R2
+  -                /               \
+  -  S2 ___[ 4 ]__/                 \__[ 5 ]___ C2
+  -
+  -  This platform is a valid ns-3 platform, even if it exhibits routes of length >1,
+  -  because when you only keep the routes of length 1,
+  -  you get a graph where every host can speak to any other host.
+  -
+  -  For example, S1__C1 is (l1,l2,l3) of length >1
+  -  But it's also S1__C1 = S1__R1, R1__R2, R2__C1 which are all of length 1
+  -
+  -  https://simgrid.org/doc/latest/ns3.html
   -->
 
 <platform version="4.1">
index 8273b04..0a4766b 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/env perl
 
-# Copyright (c) 2011-2019. The SimGrid Team.
+# Copyright (c) 2011-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
index 359c0f3..7d6161a 100644 (file)
@@ -1,4 +1,4 @@
--- Copyright (c) 2011-2019. The SimGrid Team.
+-- Copyright (c) 2011-2020. The SimGrid Team.
 -- All rights reserved.
 
 -- This program is free software; you can redistribute it and/or modify it
index 91c062c..7b7d5c0 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env perl
 
-# Copyright (c) 2011-2019. The SimGrid Team.
+# Copyright (c) 2011-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
index 28bb728..9a99d64 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
index 4389d3f..99a30ba 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.
 #
 # This program is free software you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
index b7a7f55..f322a84 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.
 #
 # This program is free software you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
@@ -14,26 +14,26 @@ def sleeper():
 
 
 def master():
-    this_actor.info("Start sleeper")
-    actor = Actor.create("sleeper from master", Host.current(), sleeper)
-    this_actor.info("Join the sleeper (timeout 2)")
+    this_actor.info("Start 1st sleeper")
+    actor = Actor.create("1st sleeper from master", Host.current(), sleeper)
+    this_actor.info("Join the 1st sleeper (timeout 2)")
     actor.join(2)
 
-    this_actor.info("Start sleeper")
-    actor = Actor.create("sleeper from master", Host.current(), sleeper)
-    this_actor.info("Join the sleeper (timeout 4)")
+    this_actor.info("Start 2nd sleeper")
+    actor = Actor.create("2nd sleeper from master", Host.current(), sleeper)
+    this_actor.info("Join the 2nd sleeper (timeout 4)")
     actor.join(4)
 
-    this_actor.info("Start sleeper")
-    actor = Actor.create("sleeper from master", Host.current(), sleeper)
-    this_actor.info("Join the sleeper (timeout 2)")
+    this_actor.info("Start 3rd sleeper")
+    actor = Actor.create("3rd sleeper from master", Host.current(), sleeper)
+    this_actor.info("Join the 3rd sleeper (timeout 2)")
     actor.join(2)
 
-    this_actor.info("Start sleeper")
-    actor = Actor.create("sleeper from master", Host.current(), sleeper)
+    this_actor.info("Start 4th sleeper")
+    actor = Actor.create("4th sleeper from master", Host.current(), sleeper)
     this_actor.info("Waiting 4")
     this_actor.sleep_for(4)
-    this_actor.info("Join the sleeper after its end (timeout 1)")
+    this_actor.info("Join the 4th sleeper after its end (timeout 1)")
     actor.join(1)
 
     this_actor.info("Goodbye now!")
index a9f6a31..85b6884 100644 (file)
@@ -1,21 +1,21 @@
 $ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/actor-join.py ${platfdir}/small_platform.xml
-> [Tremblay:master:(1) 0.000000] [python/INFO] Start sleeper
-> [Tremblay:sleeper from master:(2) 0.000000] [python/INFO] Sleeper started
-> [Tremblay:master:(1) 0.000000] [python/INFO] Join the sleeper (timeout 2)
-> [Tremblay:master:(1) 2.000000] [python/INFO] Start sleeper
-> [Tremblay:sleeper from master:(3) 2.000000] [python/INFO] Sleeper started
-> [Tremblay:master:(1) 2.000000] [python/INFO] Join the sleeper (timeout 4)
-> [Tremblay:sleeper from master:(2) 3.000000] [python/INFO] I'm done. See you!
-> [Tremblay:sleeper from master:(3) 5.000000] [python/INFO] I'm done. See you!
-> [Tremblay:master:(1) 5.000000] [python/INFO] Start sleeper
-> [Tremblay:sleeper from master:(4) 5.000000] [python/INFO] Sleeper started
-> [Tremblay:master:(1) 5.000000] [python/INFO] Join the sleeper (timeout 2)
-> [Tremblay:master:(1) 7.000000] [python/INFO] Start sleeper
-> [Tremblay:sleeper from master:(5) 7.000000] [python/INFO] Sleeper started
+> [Tremblay:master:(1) 0.000000] [python/INFO] Start 1st sleeper
+> [Tremblay:1st sleeper from master:(2) 0.000000] [python/INFO] Sleeper started
+> [Tremblay:master:(1) 0.000000] [python/INFO] Join the 1st sleeper (timeout 2)
+> [Tremblay:master:(1) 2.000000] [python/INFO] Start 2nd sleeper
+> [Tremblay:2nd sleeper from master:(3) 2.000000] [python/INFO] Sleeper started
+> [Tremblay:master:(1) 2.000000] [python/INFO] Join the 2nd sleeper (timeout 4)
+> [Tremblay:1st sleeper from master:(2) 3.000000] [python/INFO] I'm done. See you!
+> [Tremblay:2nd sleeper from master:(3) 5.000000] [python/INFO] I'm done. See you!
+> [Tremblay:master:(1) 5.000000] [python/INFO] Start 3rd sleeper
+> [Tremblay:3rd sleeper from master:(4) 5.000000] [python/INFO] Sleeper started
+> [Tremblay:master:(1) 5.000000] [python/INFO] Join the 3rd sleeper (timeout 2)
+> [Tremblay:master:(1) 7.000000] [python/INFO] Start 4th sleeper
+> [Tremblay:4th sleeper from master:(5) 7.000000] [python/INFO] Sleeper started
 > [Tremblay:master:(1) 7.000000] [python/INFO] Waiting 4
-> [Tremblay:sleeper from master:(4) 8.000000] [python/INFO] I'm done. See you!
-> [Tremblay:sleeper from master:(5) 10.000000] [python/INFO] I'm done. See you!
-> [Tremblay:master:(1) 11.000000] [python/INFO] Join the sleeper after its end (timeout 1)
+> [Tremblay:3rd sleeper from master:(4) 8.000000] [python/INFO] I'm done. See you!
+> [Tremblay:4th sleeper from master:(5) 10.000000] [python/INFO] I'm done. See you!
+> [Tremblay:master:(1) 11.000000] [python/INFO] Join the 4th sleeper after its end (timeout 1)
 > [Tremblay:master:(1) 11.000000] [python/INFO] Goodbye now!
 > [Tremblay:master:(1) 12.000000] [python/INFO] Goodbye now!
 > [12.000000] [python/INFO] Simulation time 12.0
index ec51e8e..a0d0d4f 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
index b64e9b5..8a11d06 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
@@ -14,8 +14,7 @@ class Sleeper:
     """This actor just sleeps until termination"""
 
     def __init__(self, *args):
-        # sys.exit(1); simgrid.info("Exiting now (done sleeping or got killed)."))
-        this_actor.on_exit(lambda: print("BAAA"))
+        this_actor.on_exit(lambda: this_actor.info("Exiting now (done sleeping or got killed)."))
 
     def __call__(self):
         this_actor.info("Hello! I go to sleep.")
index c48a0eb..d5213f4 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
index 1e6a16e..95e055b 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.
 #
 # This program is free software you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
index e1df6ad..f42135b 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
index 5a3a37b..c9338a9 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
index f6fc401..04c1443 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
index 0b45a12..722d678 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
index 6132e63..c0d9a73 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.
 #
 # This program is free software you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
@@ -12,12 +12,12 @@ class Waiter:
 
     def __call__(self):
         computation_amount = this_actor.get_host().speed
-        this_actor.info("Execute {:.0f} flops, should take 1 second.".format(computation_amount))
+        this_actor.info("Waiter executes {:.0f} flops, should take 1 second.".format(computation_amount))
         activity = this_actor.exec_init(computation_amount)
         activity.start()
         activity.wait()
 
-        this_actor.info("Goodbye now!")
+        this_actor.info("Goodbye from waiter!")
 
 
 class Monitor:
@@ -25,7 +25,7 @@ class Monitor:
 
     def __call__(self):
         computation_amount = this_actor.get_host().speed
-        this_actor.info("Execute {:.0f} flops, should take 1 second.".format(computation_amount))
+        this_actor.info("Monitor executes {:.0f} flops, should take 1 second.".format(computation_amount))
         activity = this_actor.exec_init(computation_amount).start()
 
         while not activity.test():
@@ -34,7 +34,7 @@ class Monitor:
             this_actor.sleep_for(0.3)
         activity.wait()
 
-        this_actor.info("Goodbye now!")
+        this_actor.info("Goodbye from monitor!")
 
 
 class Canceller:
@@ -42,14 +42,14 @@ class Canceller:
 
     def __call__(self):
         computation_amount = this_actor.get_host().speed
-        this_actor.info("Execute {:.0f} flops, should take 1 second.".format(computation_amount))
+        this_actor.info("Canceller executes {:.0f} flops, should take 1 second.".format(computation_amount))
         activity = this_actor.exec_init(computation_amount).start()
 
         this_actor.sleep_for(0.5)
         this_actor.info("I changed my mind, cancel!")
         activity.cancel()
 
-        this_actor.info("Goodbye now!")
+        this_actor.info("Goodbye from canceller!")
 
 
 if __name__ == '__main__':
index d18f11c..4df63cb 100644 (file)
@@ -1,14 +1,14 @@
 #!/usr/bin/env tesh
 
 $ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/exec-async.py ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
-> [  0.000000] (1:wait@Fafard) Execute 76296000 flops, should take 1 second.
-> [  0.000000] (2:monitor@Ginette) Execute 48492000 flops, should take 1 second.
-> [  0.000000] (3:cancel@Boivin) Execute 98095000 flops, should take 1 second.
+> [  0.000000] (1:wait@Fafard) Waiter executes 76296000 flops, should take 1 second.
+> [  0.000000] (2:monitor@Ginette) Monitor executes 48492000 flops, should take 1 second.
+> [  0.000000] (3:cancel@Boivin) Canceller executes 98095000 flops, should take 1 second.
 > [  0.000000] (2:monitor@Ginette) Remaining amount of flops: 48492000 (100%)
 > [  0.300000] (2:monitor@Ginette) Remaining amount of flops: 33944400 (70%)
 > [  0.500000] (3:cancel@Boivin) I changed my mind, cancel!
-> [  0.500000] (3:cancel@Boivin) Goodbye now!
+> [  0.500000] (3:cancel@Boivin) Goodbye from canceller!
 > [  0.600000] (2:monitor@Ginette) Remaining amount of flops: 19396800 (40%)
 > [  0.900000] (2:monitor@Ginette) Remaining amount of flops: 4849200 (10%)
-> [  1.000000] (1:wait@Fafard) Goodbye now!
-> [  1.200000] (2:monitor@Ginette) Goodbye now!
+> [  1.000000] (1:wait@Fafard) Goodbye from waiter!
+> [  1.200000] (2:monitor@Ginette) Goodbye from monitor!
index 60e0bf6..579c3f4 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
@@ -30,13 +30,11 @@ def privileged():
     # quite quickly.
 
 
-i = 0
-if "--" in sys.argv:
-    i = sys.argv.index("--")
-e = Engine(sys.argv[0:i])
-e.load_platform(sys.argv[i + 1])
+if __name__ == '__main__':
+    e = Engine(sys.argv)
+    e.load_platform(sys.argv[1])
 
-Actor.create("executor", Host.by_name("Tremblay"), executor)
-Actor.create("privileged", Host.by_name("Tremblay"), privileged)
+    Actor.create("executor", Host.by_name("Tremblay"), executor)
+    Actor.create("privileged", Host.by_name("Tremblay"), privileged)
 
-e.run()
+    e.run()
index e712791..a912916 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
@@ -30,7 +30,7 @@ class Dvfs:
 
         host.pstate = new_pstate
 
-        this_actor.info("Current power peak={:f}".format(host.speed))
+        this_actor.info("Changed power peak={:f}".format(host.speed))
 
         # Run a second task
         this_actor.execute(workload)
@@ -42,7 +42,7 @@ class Dvfs:
         host2 = Host.by_name("MyHost2")
         this_actor.info("Count of Processor states={:d}".format(host2.get_pstate_count()))
 
-        this_actor.info("Current power peak={:f}".format(host2.speed))
+        this_actor.info("Final power peak={:f}".format(host2.speed))
 
 if __name__ == '__main__':
     e = Engine(sys.argv)
index 215897b..b3b5e2e 100644 (file)
@@ -11,14 +11,14 @@ $ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/exec-dvfs.py ${pla
 > [  1.000000] (1:dvfs_test@MyHost1) Changing power peak value to 20000000.000000 (at index 2)
 > [  1.000000] (2:dvfs_test@MyHost2) Task1 duration: 1.00
 > [  1.000000] (2:dvfs_test@MyHost2) Changing power peak value to 20000000.000000 (at index 2)
-> [  1.000000] (1:dvfs_test@MyHost1) Current power peak=20000000.000000
-> [  1.000000] (2:dvfs_test@MyHost2) Current power peak=20000000.000000
+> [  1.000000] (1:dvfs_test@MyHost1) Changed power peak=20000000.000000
+> [  1.000000] (2:dvfs_test@MyHost2) Changed power peak=20000000.000000
 > [  6.000000] (1:dvfs_test@MyHost1) Task2 duration: 5.00
 > [  6.000000] (1:dvfs_test@MyHost1) Count of Processor states=3
-> [  6.000000] (1:dvfs_test@MyHost1) Current power peak=20000000.000000
+> [  6.000000] (1:dvfs_test@MyHost1) Final power peak=20000000.000000
 > [  6.000000] (2:dvfs_test@MyHost2) Task2 duration: 5.00
 > [  6.000000] (2:dvfs_test@MyHost2) Count of Processor states=3
-> [  6.000000] (2:dvfs_test@MyHost2) Current power peak=20000000.000000
+> [  6.000000] (2:dvfs_test@MyHost2) Final power peak=20000000.000000
 
 $ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/exec-dvfs.py ${platfdir}/energy_cluster.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
 > [  0.000000] (1:dvfs_test@MyHost1) Count of Processor states=3
@@ -29,11 +29,11 @@ $ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/exec-dvfs.py ${pla
 > [  1.000000] (1:dvfs_test@MyHost1) Changing power peak value to 20000000.000000 (at index 2)
 > [  1.000000] (2:dvfs_test@MyHost2) Task1 duration: 1.00
 > [  1.000000] (2:dvfs_test@MyHost2) Changing power peak value to 20000000.000000 (at index 2)
-> [  1.000000] (1:dvfs_test@MyHost1) Current power peak=20000000.000000
-> [  1.000000] (2:dvfs_test@MyHost2) Current power peak=20000000.000000
+> [  1.000000] (1:dvfs_test@MyHost1) Changed power peak=20000000.000000
+> [  1.000000] (2:dvfs_test@MyHost2) Changed power peak=20000000.000000
 > [  6.000000] (1:dvfs_test@MyHost1) Task2 duration: 5.00
 > [  6.000000] (1:dvfs_test@MyHost1) Count of Processor states=3
-> [  6.000000] (1:dvfs_test@MyHost1) Current power peak=20000000.000000
+> [  6.000000] (1:dvfs_test@MyHost1) Final power peak=20000000.000000
 > [  6.000000] (2:dvfs_test@MyHost2) Task2 duration: 5.00
 > [  6.000000] (2:dvfs_test@MyHost2) Count of Processor states=3
-> [  6.000000] (2:dvfs_test@MyHost2) Current power peak=20000000.000000
+> [  6.000000] (2:dvfs_test@MyHost2) Final power peak=20000000.000000
index 45475ee..0c59426 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.
 #
 # This program is free software you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
index 839e9cb..e87da01 100644 (file)
@@ -9,13 +9,13 @@ foreach (example actor-create actor-daemon actor-exiting actor-join actor-kill
                  cloud-capping cloud-migration cloud-simple
                  energy-exec energy-boot energy-link energy-vm energy-exec-ptask
                  engine-filtering
-                 exec-async exec-basic exec-dvfs exec-ptask exec-remote exec-waitany exec-dependent
+                 exec-async exec-basic exec-dvfs exec-ptask exec-remote exec-waitany exec-waitfor exec-dependent
                  io-async io-file-system io-file-remote io-disk-raw
                  platform-failures platform-profile platform-properties
                  plugin-hostload
                  replay-comm replay-io
                  routing-get-clusters
-                 synchro-barrier synchro-mutex synchro-semaphore)
+                 synchro-barrier synchro-condition-variable synchro-mutex synchro-semaphore)
   add_executable       (s4u-${example} EXCLUDE_FROM_ALL ${example}/s4u-${example}.cpp)
   add_dependencies     (tests s4u-${example})
   target_link_libraries(s4u-${example} simgrid)
index b587f42..9809d5f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -33,9 +33,9 @@ static void receiver(const std::string& mailbox_name)
 
   XBT_INFO("Hello s4u, I'm ready to get any message you'd want on %s", mailbox->get_cname());
 
-  std::string* msg1 = static_cast<std::string*>(mailbox->get());
-  std::string* msg2 = static_cast<std::string*>(mailbox->get());
-  std::string* msg3 = static_cast<std::string*>(mailbox->get());
+  const std::string* msg1 = static_cast<std::string*>(mailbox->get());
+  const std::string* msg2 = static_cast<std::string*>(mailbox->get());
+  const std::string* msg3 = static_cast<std::string*>(mailbox->get());
   XBT_INFO("I received '%s', '%s' and '%s'", msg1->c_str(), msg2->c_str(), msg3->c_str());
   delete msg1;
   delete msg2;
index 4372bd4..1262f9f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index cc7e9f6..dfd0f80 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 2be0244..06dc277 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 34ec395..a9ec98b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index d73b509..d53a4ad 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index be035df..4cc22db 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -21,7 +21,7 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor_migration, "Messages specific for this s4u example");
 
-static void worker(simgrid::s4u::Host* first, simgrid::s4u::Host* second)
+static void worker(simgrid::s4u::Host* first, const simgrid::s4u::Host* second)
 {
   double flopAmount = first->get_speed() * 5 + second->get_speed() * 5;
 
index 3e1a93e..b91a91a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 44a465e..5574c8a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 47ecad6..22757ec 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 126017a..1c53685 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index a5e59bb..2962df6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -160,9 +160,9 @@ void Peer::sendRequestTo(Connection* remote_peer, unsigned int piece)
 
 std::string Peer::getStatus()
 {
-  std::string res = std::string("");
-  for (int i = FILE_PIECES - 1; i >= 0; i--)
-    res = std::string((bitfield_ & (1U << i)) ? "1" : "0") + res;
+  std::string res;
+  for (unsigned i = 0; i < FILE_PIECES; i++)
+    res += (bitfield_ & (1U << i)) ? '1' : '0';
   return res;
 }
 
@@ -172,12 +172,12 @@ bool Peer::hasFinished()
 }
 
 /** Indicates if the remote peer has a piece not stored by the local peer */
-bool Peer::isInterestedBy(Connection* remote_peer)
+bool Peer::isInterestedBy(const Connection* remote_peer) const
 {
   return remote_peer->bitfield & (bitfield_ ^ ((1 << FILE_PIECES) - 1));
 }
 
-bool Peer::isInterestedByFree(Connection* remote_peer)
+bool Peer::isInterestedByFree(const Connection* remote_peer) const
 {
   for (unsigned int i = 0; i < FILE_PIECES; i++)
     if (hasNotPiece(i) && remote_peer->hasPiece(i) && isNotDownloadingPiece(i))
@@ -429,7 +429,7 @@ void Peer::removeCurrentPiece(Connection* remote_peer, unsigned int current_piec
  * @param remote_peer: information about the connection
  * @return the piece to download if possible. -1 otherwise
  */
-int Peer::selectPieceToDownload(Connection* remote_peer)
+int Peer::selectPieceToDownload(const Connection* remote_peer)
 {
   int piece = partiallyDownloadedPiece(remote_peer);
   // strict priority policy
@@ -441,7 +441,7 @@ int Peer::selectPieceToDownload(Connection* remote_peer)
     int nb_interesting_pieces = 0;
     // compute the number of interesting pieces
     for (unsigned int i = 0; i < FILE_PIECES; i++)
-      if (hasNotPiece(i) && remote_peer->hasPiece(i))
+      if (remotePeerHasMissingPiece(remote_peer, i))
         nb_interesting_pieces++;
 
     xbt_assert(nb_interesting_pieces != 0);
@@ -449,7 +449,7 @@ int Peer::selectPieceToDownload(Connection* remote_peer)
     int random_piece_index = simgrid::xbt::random::uniform_int(0, nb_interesting_pieces - 1);
     int current_index      = 0;
     for (unsigned int i = 0; i < FILE_PIECES; i++) {
-      if (hasNotPiece(i) && remote_peer->hasPiece(i)) {
+      if (remotePeerHasMissingPiece(remote_peer, i)) {
         if (random_piece_index == current_index) {
           piece = i;
           break;
@@ -465,14 +465,14 @@ int Peer::selectPieceToDownload(Connection* remote_peer)
     int nb_interesting_pieces = 0;
     // compute the number of interesting pieces
     for (unsigned int i = 0; i < FILE_PIECES; i++)
-      if (hasNotPiece(i) && remote_peer->hasPiece(i) && isNotDownloadingPiece(i))
+      if (remotePeerHasMissingPiece(remote_peer, i) && isNotDownloadingPiece(i))
         nb_interesting_pieces++;
     xbt_assert(nb_interesting_pieces != 0);
     // get a random interesting piece
     int random_piece_index = simgrid::xbt::random::uniform_int(0, nb_interesting_pieces - 1);
     int current_index      = 0;
     for (unsigned int i = 0; i < FILE_PIECES; i++) {
-      if (hasNotPiece(i) && remote_peer->hasPiece(i) && isNotDownloadingPiece(i)) {
+      if (remotePeerHasMissingPiece(remote_peer, i) && isNotDownloadingPiece(i)) {
         if (random_piece_index == current_index) {
           piece = i;
           break;
@@ -488,14 +488,14 @@ int Peer::selectPieceToDownload(Connection* remote_peer)
     int current_index = 0;
     // compute the smallest number of copies of available pieces
     for (unsigned int i = 0; i < FILE_PIECES; i++) {
-      if (pieces_count[i] < min && hasNotPiece(i) && remote_peer->hasPiece(i) && isNotDownloadingPiece(i))
+      if (pieces_count[i] < min && remotePeerHasMissingPiece(remote_peer, i) && isNotDownloadingPiece(i))
         min = pieces_count[i];
     }
 
     xbt_assert(min != SHRT_MAX || not isInterestedByFree(remote_peer));
     // compute the number of rarest pieces
     for (unsigned int i = 0; i < FILE_PIECES; i++)
-      if (pieces_count[i] == min && hasNotPiece(i) && remote_peer->hasPiece(i) && isNotDownloadingPiece(i))
+      if (pieces_count[i] == min && remotePeerHasMissingPiece(remote_peer, i) && isNotDownloadingPiece(i))
         nb_min_pieces++;
 
     xbt_assert(nb_min_pieces != 0 || not isInterestedByFree(remote_peer));
@@ -505,7 +505,7 @@ int Peer::selectPieceToDownload(Connection* remote_peer)
       random_rarest_index = simgrid::xbt::random::uniform_int(0, nb_min_pieces - 1);
     }
     for (unsigned int i = 0; i < FILE_PIECES; i++)
-      if (pieces_count[i] == min && hasNotPiece(i) && remote_peer->hasPiece(i) && isNotDownloadingPiece(i)) {
+      if (pieces_count[i] == min && remotePeerHasMissingPiece(remote_peer, i) && isNotDownloadingPiece(i)) {
         if (random_rarest_index == current_index) {
           piece = i;
           break;
@@ -606,7 +606,7 @@ void Peer::updateInterestedAfterReceive()
       bool interested = false;
       // Check if the peer still has a piece we want.
       for (unsigned int i = 0; i < FILE_PIECES; i++)
-        if (hasNotPiece(i) && remote_peer.hasPiece(i)) {
+        if (remotePeerHasMissingPiece(&remote_peer, i)) {
           interested = true;
           break;
         }
@@ -645,10 +645,10 @@ int Peer::getFirstMissingBlockFrom(int piece)
 }
 
 /** Returns a piece that is partially downloaded and stored by the remote peer if any -1 otherwise. */
-int Peer::partiallyDownloadedPiece(Connection* remote_peer)
+int Peer::partiallyDownloadedPiece(const Connection* remote_peer)
 {
   for (unsigned int i = 0; i < FILE_PIECES; i++)
-    if (hasNotPiece(i) && remote_peer->hasPiece(i) && isNotDownloadingPiece(i) && getFirstMissingBlockFrom(i) > 0)
+    if (remotePeerHasMissingPiece(remote_peer, i) && isNotDownloadingPiece(i) && getFirstMissingBlockFrom(i) > 0)
       return i;
   return -1;
 }
index ecc5994..e828e1d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@ public:
 
   explicit Connection(int id) : id(id), mailbox_(simgrid::s4u::Mailbox::by_name(std::to_string(id))){};
   void addSpeedValue(double speed) { peer_speed = peer_speed * 0.6 + speed * 0.4; }
-  bool hasPiece(unsigned int piece) { return bitfield & 1U << piece; }
+  bool hasPiece(unsigned int piece) const { return bitfield & 1U << piece; }
 };
 
 class Peer {
@@ -53,23 +53,27 @@ public:
   std::string getStatus();
   bool hasFinished();
   int nbInterestedPeers();
-  bool isInterestedBy(Connection* remote_peer);
-  bool isInterestedByFree(Connection* remote_peer);
+  bool isInterestedBy(const Connection* remote_peer) const;
+  bool isInterestedByFree(const Connection* remote_peer) const;
   void updateActivePeersSet(Connection* remote_peer);
   void updateInterestedAfterReceive();
   void updateChokedPeers();
 
-  bool hasNotPiece(unsigned int piece) { return not(bitfield_ & 1U << piece); }
+  bool hasNotPiece(unsigned int piece) const { return not(bitfield_ & 1U << piece); }
+  bool remotePeerHasMissingPiece(const Connection* remote_peer, unsigned int piece)
+  {
+    return hasNotPiece(piece) && remote_peer->hasPiece(piece);
+  }
   bool hasCompletedPiece(unsigned int piece);
   unsigned int countPieces(unsigned int bitfield);
   /** Check that a piece is not currently being download by the peer. */
-  bool isNotDownloadingPiece(unsigned int piece) { return not(current_pieces & 1U << piece); }
-  int partiallyDownloadedPiece(Connection* remote_peer);
+  bool isNotDownloadingPiece(unsigned int piece) const { return not(current_pieces & 1U << piece); }
+  int partiallyDownloadedPiece(const Connection* remote_peer);
   void updatePiecesCountFromBitfield(unsigned int bitfield);
   void removeCurrentPiece(Connection* remote_peer, unsigned int current_piece);
   void updateBitfieldBlocks(int piece, int block_index, int block_length);
   int getFirstMissingBlockFrom(int piece);
-  int selectPieceToDownload(Connection* remote_peer);
+  int selectPieceToDownload(const Connection* remote_peer);
   void requestNewPieceTo(Connection* remote_peer);
 
   bool getPeersFromTracker();
index c4bfc16..e807d29 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 2beffd4..08fd911 100644 (file)
@@ -1,11 +1,11 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#ifndef BITTORRENT_TRACKER_HPP_
-#define BITTORRENT_TRACKER_HPP_
+#ifndef BITTORRENT_TRACKER_HPP
+#define BITTORRENT_TRACKER_HPP
 
 #include "s4u-bittorrent.hpp"
 #include <set>
index dc1abf5..6da10d6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -47,7 +47,7 @@ public:
 
   void joinChain()
   {
-    ChainMessage* msg = static_cast<ChainMessage*>(me->get());
+    const ChainMessage* msg = static_cast<ChainMessage*>(me->get());
     prev              = msg->prev_;
     next              = msg->next_;
     total_pieces      = msg->num_pieces;
index a91f203..cf43661 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -67,7 +67,7 @@ public:
   {
     double compute_cost;
     do {
-      double* msg  = static_cast<double*>(mailbox->get());
+      const double* msg = static_cast<double*>(mailbox->get());
       compute_cost = *msg;
       delete msg;
 
index 40780fc..072903b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -49,12 +49,12 @@ static void worker(std::vector<std::string> args)
 {
   xbt_assert(args.size() == 1, "The worker expects no argument");
 
-  simgrid::s4u::Host* my_host      = simgrid::s4u::this_actor::get_host();
+  const simgrid::s4u::Host* my_host = simgrid::s4u::this_actor::get_host();
   simgrid::s4u::Mailbox* mailbox   = simgrid::s4u::Mailbox::by_name(my_host->get_name());
 
   double compute_cost;
   do {
-    double* msg  = static_cast<double*>(mailbox->get());
+    const double* msg = static_cast<double*>(mailbox->get());
     compute_cost = *msg;
     delete msg;
 
index 019d6b2..0bd9737 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -17,7 +17,7 @@ static void pinger(simgrid::s4u::Mailbox* mailbox_in, simgrid::s4u::Mailbox* mai
 
   mailbox_out->put(payload, 1);
   /* - ... then wait for the (large) pong */
-  double* sender_time = static_cast<double*>(mailbox_in->get());
+  const double* sender_time = static_cast<double*>(mailbox_in->get());
 
   double communication_time = simgrid::s4u::Engine::get_clock() - *sender_time;
   XBT_INFO("Task received : large communication (bandwidth bound)");
@@ -30,7 +30,7 @@ static void ponger(simgrid::s4u::Mailbox* mailbox_in, simgrid::s4u::Mailbox* mai
   XBT_INFO("Pong from mailbox %s to mailbox %s", mailbox_in->get_name().c_str(), mailbox_out->get_name().c_str());
 
   /* - Receive the (small) ping first ....*/
-  double* sender_time       = static_cast<double*>(mailbox_in->get());
+  const double* sender_time = static_cast<double*>(mailbox_in->get());
   double communication_time = simgrid::s4u::Engine::get_clock() - *sender_time;
   XBT_INFO("Task received : small communication (latency bound)");
   XBT_INFO(" Ping time (latency bound) %f", communication_time);
index 2774114..5d245bf 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -24,7 +24,7 @@ public:
   {
     try {
       rank = std::stoi(simgrid::s4u::this_actor::get_name());
-    } catch (std::invalid_argument& ia) {
+    } catch (const std::invalid_argument& ia) {
       throw std::invalid_argument(std::string("Processes of this example must have a numerical name, not ") +
                                   ia.what());
     }
@@ -41,7 +41,7 @@ public:
       XBT_INFO("Host \"%u\" send 'Token' to Host \"%s\"", rank, neighbor_mailbox->get_cname());
       std::string msg = "Token";
       neighbor_mailbox->put(&msg, task_comm_size);
-      std::string* res = static_cast<std::string*>(my_mailbox->get());
+      const std::string* res = static_cast<std::string*>(my_mailbox->get());
       XBT_INFO("Host \"%u\" received \"%s\"", rank, res->c_str());
     } else {
       std::string* res = static_cast<std::string*>(my_mailbox->get());
index d73f2ce..8bebb50 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -72,7 +72,7 @@ static int peer(int argc, char** argv)
   while (pending_finalize_messages > 0) {
     if (my_mbox->ready()) {
       double start          = simgrid::s4u::Engine::get_clock();
-      std::string* received = static_cast<std::string*>(my_mbox->get());
+      const std::string* received = static_cast<std::string*>(my_mbox->get());
       double waiting_time   = simgrid::s4u::Engine::get_clock() - start;
       xbt_assert(waiting_time == 0, "Expecting the waiting time to be 0 because the communication was supposedly ready, but got %f instead", waiting_time);
       XBT_INFO("I got a '%s'.", received->c_str());
index 009c9fa..24a3e2b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -74,7 +74,7 @@ static int receiver(int argc, char** argv)
 
   XBT_INFO("Wait for my first message");
   for (bool cont = true; cont;) {
-    std::string* received = static_cast<std::string*>(mbox->get());
+    const std::string* received = static_cast<std::string*>(mbox->get());
     XBT_INFO("I got a '%s'.", received->c_str());
     if (*received == "finalize")
       cont = false; // If it's a finalize message, we're done.
index f23e55c..14d53cc 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -89,7 +89,7 @@ public:
   {
     XBT_INFO("Wait for my first message");
     for (bool cont = true; cont;) {
-      std::string* received = static_cast<std::string*>(mbox->get());
+      const std::string* received = static_cast<std::string*>(mbox->get());
       XBT_INFO("I got a '%s'.", received->c_str());
       cont = (*received != "finalize"); // If it's a finalize message, we're done
       // Receiving the message was all we were supposed to do
index 407b4e5..dba580e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -102,7 +102,7 @@ public:
   {
     XBT_INFO("Wait for my first message");
     for (bool cont = true; cont;) {
-      std::string* received = static_cast<std::string*>(mbox->get());
+      const std::string* received = static_cast<std::string*>(mbox->get());
       XBT_INFO("I got a '%s'.", received->c_str());
       cont = (*received != "finalize"); // If it's a finalize message, we're done
       // Receiving the message was all we were supposed to do
index 3397408..3b2975b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -72,7 +72,7 @@ static int receiver(int argc, char** argv)
 
   XBT_INFO("Wait for my first message");
   for (bool cont = true; cont;) {
-    std::string* received = static_cast<std::string*>(mbox->get());
+    const std::string* received = static_cast<std::string*>(mbox->get());
     XBT_INFO("I got a '%s'.", received->c_str());
     if (*received == "finalize")
       cont = false; // If it's a finalize message, we're done.
index 69f3323..8a958a9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 8add881..11c690b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -11,7 +11,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_cloud_migration, "Messages specific for this ex
 
 static void vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm)
 {
-  simgrid::s4u::Host* src_pm = vm->get_pm();
+  const simgrid::s4u::Host* src_pm = vm->get_pm();
   double mig_sta             = simgrid::s4u::Engine::get_clock();
   sg_vm_migrate(vm, dst_pm);
   double mig_end = simgrid::s4u::Engine::get_clock();
index 08a341a..9e355c4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -47,7 +47,7 @@ static void communication_rx_fun(std::vector<std::string> args)
   const char* host_name         = simgrid::s4u::this_actor::get_host()->get_cname();
   simgrid::s4u::Mailbox* mbox   = simgrid::s4u::Mailbox::by_name(args.at(0));
 
-  struct s_payload* payload = static_cast<struct s_payload*>(mbox->get());
+  const s_payload* payload  = static_cast<struct s_payload*>(mbox->get());
   double clock_end          = simgrid::s4u::Engine::get_clock();
 
   XBT_INFO("%s:%s to %s:%s => %g sec", payload->tx_host->get_cname(), payload->tx_actor_name, host_name, actor_name,
index f76484c..8eda1ef 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -20,9 +20,9 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(s4u_chord);
  * @param id id to check
  * @param start lower bound
  * @param end upper bound
- * @return a non-zero value if id in in [start, end]
+ * @return true if id in in [start, end]
  */
-static int is_in_interval(int id, int start, int end)
+static bool is_in_interval(int id, int start, int end)
 {
   int i = id % nb_keys;
   int s = start % nb_keys;
@@ -267,7 +267,7 @@ int Node::remoteGetPredecessor(int ask_to)
 
   try {
     comm->wait_for(timeout);
-    ChordMessage* answer = static_cast<ChordMessage*>(data);
+    const ChordMessage* answer = static_cast<ChordMessage*>(data);
     XBT_DEBUG("Received the answer to my 'Get Predecessor' request: the predecessor of node %d is %d", ask_to,
               answer->answer_id);
     predecessor_id = answer->answer_id;
@@ -314,7 +314,7 @@ int Node::findSuccessor(int id)
 int Node::remoteFindSuccessor(int ask_to, int id)
 {
   int successor                           = -1;
-  void* data                              = nullptr;
+  ChordMessage* data                      = nullptr;
   simgrid::s4u::Mailbox* mailbox          = simgrid::s4u::Mailbox::by_name(std::to_string(ask_to));
   simgrid::s4u::Mailbox* return_mailbox   = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_succ");
 
@@ -333,18 +333,18 @@ 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::CommPtr comm = return_mailbox->get_async(&data);
+  simgrid::s4u::CommPtr comm = return_mailbox->get_async(reinterpret_cast<void**>(&data));
 
   try {
     comm->wait_for(timeout);
-    ChordMessage* answer = static_cast<ChordMessage*>(data);
+    const ChordMessage* answer = data;
     XBT_DEBUG("Received the answer to my 'Find Successor' request for id %d: the successor of key %d is %d",
               answer->request_id, id_, answer->answer_id);
     successor = answer->answer_id;
     delete answer;
   } catch (const simgrid::TimeoutException&) {
     XBT_DEBUG("Failed to receive the answer to my 'Find Successor' request");
-    delete static_cast<ChordMessage*>(data);
+    delete data;
   }
 
   return successor;
index 372c509..c2128f1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index eea1f2f..8165e28 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -37,16 +37,13 @@ enum e_message_type_t {
 class ChordMessage {
 public:
   e_message_type_t type;              // type of message
-  std::string issuer_host_name;       // used for logging
+  std::string issuer_host_name     = simgrid::s4u::this_actor::get_host()->get_name(); // used for logging
   int request_id     = -1;            // id (used by some types of messages)
   int request_finger = 1;             // finger parameter (used by some types of messages)
   int answer_id      = -1;            // answer (used by some types of messages)
   simgrid::s4u::Mailbox* answer_to = nullptr;       // mailbox to send an answer to (if any)
 
-  explicit ChordMessage(e_message_type_t type)
-      : type(type), issuer_host_name(simgrid::s4u::this_actor::get_host()->get_name())
-  {
-  }
+  explicit ChordMessage(e_message_type_t type) : type(type) {}
 
   static void destroy(void* message);
 };
index 0afc935..7fa8655 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -10,37 +10,30 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(kademlia_node);
 
 namespace kademlia {
 
-bool sortbydistance(const std::pair<unsigned int, unsigned int>& a, const std::pair<unsigned int, unsigned int>& b)
-{
-  return (a.second < b.second);
-}
-
 /** @brief Prints a answer_t, for debugging purposes */
 void Answer::print()
 {
-  XBT_INFO("Searching %08x, size %u", destination_id_, size_);
+  XBT_INFO("Searching %08x, size %zu", destination_id_, nodes_.size());
   unsigned int i = 0;
-  for (auto contact : nodes)
+  for (auto const& contact : nodes_)
     XBT_INFO("Node %08x: %08x is at distance %u", i++, contact.first, contact.second);
 }
 
 /** @brief Merge two answers together, only keeping the best nodes
   * @param source the source of the nodes to add
   */
-unsigned int Answer::merge(Answer* source)
+unsigned int Answer::merge(const Answer* source)
 {
   if (this == source)
     return 0;
 
   unsigned int nb_added = 0;
-  for (auto contact : source->nodes) {
-    if (std::find(nodes.begin(), nodes.end(), contact) == nodes.end()) {
-      nodes.push_back(contact);
-      size_++;
+  for (auto const& contact : source->nodes_) {
+    if (std::find(nodes_.begin(), nodes_.end(), contact) == nodes_.end()) {
+      nodes_.push_back(contact);
       nb_added++;
     }
   }
-  std::sort(nodes.begin(), nodes.end(), sortbydistance);
   trim();
   return nb_added;
 }
@@ -48,22 +41,21 @@ unsigned int Answer::merge(Answer* source)
 /** @brief Trims an Answer, in order for it to have a size of less or equal to "bucket_size" */
 void Answer::trim()
 {
-  while (size_ > BUCKET_SIZE) {
-    nodes.pop_back();
-    size_--;
-  }
-  xbt_assert(nodes.size() == size_, "Wrong size for the answer");
+  // sort by distance
+  std::sort(nodes_.begin(), nodes_.end(),
+            [](const std::pair<unsigned int, unsigned int>& a, const std::pair<unsigned int, unsigned int>& b) {
+              return (a.second < b.second);
+            });
+  if (nodes_.size() > BUCKET_SIZE)
+    nodes_.resize(BUCKET_SIZE);
 }
 
 /** @brief Returns if the destination we are trying to find is found
   * @return if the destination is found.
   */
-bool Answer::destinationFound()
+bool Answer::destinationFound() const
 {
-  if (nodes.empty())
-    return 0;
-
-  return (*nodes.begin()).second == 0;
+  return not nodes_.empty() && nodes_.begin()->second == 0;
 }
 
 /** @brief Adds the content of a bucket unsigned into a answer object.
@@ -73,10 +65,9 @@ void Answer::addBucket(const Bucket* bucket)
 {
   xbt_assert((bucket != nullptr), "Provided a NULL bucket");
 
-  for (auto id : bucket->nodes) {
+  for (auto const& id : bucket->nodes) {
     unsigned int distance = id ^ destination_id_;
-    nodes.push_back(std::pair<unsigned int, unsigned int>(id, distance));
-    size_++;
+    nodes_.push_back(std::pair<unsigned int, unsigned int>(id, distance));
   }
 }
 }
index ab93e99..34896d6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
 #include <set>
 
 namespace kademlia {
-bool sortbydistance(const std::pair<unsigned int, unsigned int>& a, const std::pair<unsigned int, unsigned int>& b);
-
 /* Node query answer. contains the elements closest to the id given. */
 class Answer {
   unsigned int destination_id_;
-  unsigned int size_ = 0;
+  std::vector<std::pair<unsigned int, unsigned int>> nodes_;
 
 public:
-  std::vector<std::pair<unsigned int, unsigned int>> nodes;
   explicit Answer(unsigned int destination_id) : destination_id_(destination_id) {}
   virtual ~Answer() = default;
-  unsigned int getDestinationId() { return destination_id_; }
-  unsigned int getSize() { return size_; }
+  unsigned int getDestinationId() const { return destination_id_; }
+  size_t getSize() const { return nodes_.size(); }
+  const std::vector<std::pair<unsigned int, unsigned int>>& getNodes() const { return nodes_; }
   void print();
-  unsigned int merge(Answer* a);
+  unsigned int merge(const Answer* a);
   void trim();
-  bool destinationFound();
+  bool destinationFound() const;
   void addBucket(const kademlia::Bucket* bucket);
 };
 }
index bf86345..694ce51 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-# Copyright (c) 2012-2019. The SimGrid Team.
+# Copyright (c) 2012-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
index c1b6434..35ec478 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 617f382..9b09d69 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -11,7 +11,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(kademlia_node, "Messages specific for this example"
 namespace kademlia {
 static void destroy(void* message)
 {
-  Message* msg = static_cast<Message*>(message);
+  const Message* msg = static_cast<Message*>(message);
   delete msg->answer_;
   delete msg;
 }
@@ -22,7 +22,7 @@ static void destroy(void* message)
   */
 bool Node::join(unsigned int known_id)
 {
-  Answer* node_list;
+  const Answer* node_list;
   unsigned int i;
   bool got_answer = false;
 
@@ -41,10 +41,10 @@ bool Node::join(unsigned int known_id)
       XBT_DEBUG("Received an answer from the node I know.");
       got_answer = true;
       // retrieve the node list and ping them.
-      Message* msg = static_cast<Message*>(received_msg);
+      const Message* msg = static_cast<Message*>(received_msg);
       node_list    = msg->answer_;
       if (node_list) {
-        for (auto contact : node_list->nodes)
+        for (auto const& contact : node_list->getNodes())
           routingTableUpdate(contact.first);
       } else {
         handleFindNode(msg);
@@ -93,12 +93,12 @@ void Node::sendFindNode(unsigned int id, unsigned int destination)
   * Sends to the best "KADEMLIA_ALPHA" nodes in the "node_list" array a "FIND_NODE" request, to ask them for their best
   * nodes
   */
-unsigned int Node::sendFindNodeToBest(Answer* node_list)
+unsigned int Node::sendFindNodeToBest(const Answer* node_list)
 {
   unsigned int i           = 0;
   unsigned int j           = 0;
   unsigned int destination = node_list->getDestinationId();
-  for (auto node_to_query : node_list->nodes) {
+  for (auto const& node_to_query : node_list->getNodes()) {
     /* We need to have at most "KADEMLIA_ALPHA" requests each time, according to the protocol */
     /* Gets the node we want to send the query to */
     if (node_to_query.first != id_) { /* No need to query ourselves */
@@ -168,7 +168,6 @@ Answer* Node::findClosest(unsigned int destination_id)
     }
   }
   /* We trim the array to have only BUCKET_SIZE or less elements */
-  std::sort(answer->nodes.begin(), answer->nodes.end(), sortbydistance);
   answer->trim();
 
   return answer;
@@ -206,18 +205,18 @@ bool Node::findNode(unsigned int id_to_find, bool count_in_stats)
         receive_comm = mailbox->get_async(&received_msg);
 
       if (receive_comm->test()) {
-        Message* msg = static_cast<Message*>(received_msg);
+        const Message* msg = static_cast<Message*>(received_msg);
         // Check if what we have received is what we are looking for.
         if (msg->answer_ && msg->answer_->getDestinationId() == id_to_find) {
           routingTableUpdate(msg->sender_id_);
           // Handle the answer
-          for (auto contact : node_list->nodes)
+          for (auto const& contact : node_list->getNodes())
             routingTableUpdate(contact.first);
           answers++;
 
           nodes_added = node_list->merge(msg->answer_);
           XBT_DEBUG("Received an answer from %s (%s) with %zu nodes on it", msg->answer_to_->get_cname(),
-                    msg->issuer_host_name_.c_str(), msg->answer_->nodes.size());
+                    msg->issuer_host_name_.c_str(), msg->answer_->getSize());
         } else {
           if (msg->answer_) {
             routingTableUpdate(msg->sender_id_);
@@ -268,7 +267,7 @@ void Node::randomLookup()
 }
 
 /** @brief Handles the answer to an incoming "find_node" task */
-void Node::handleFindNode(Message* msg)
+void Node::handleFindNode(const Message* msg)
 {
   routingTableUpdate(msg->sender_id_);
   XBT_VERB("Received a FIND_NODE from %s (%s), he's trying to find %08x", msg->answer_to_->get_cname(),
index 0aa8d80..dc36ae2 100644 (file)
@@ -1,11 +1,11 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#ifndef _KADEMLIA_NODE_HPP
-#define _KADEMLIA_NODE_HPP
+#ifndef KADEMLIA_NODE_HPP
+#define KADEMLIA_NODE_HPP
 #include "answer.hpp"
 #include "message.hpp"
 #include "routing_table.hpp"
@@ -17,27 +17,27 @@ class Node {
   unsigned int id_;              // node id - 160 bits
   RoutingTable table;            // node routing table
 public:
-  simgrid::s4u::CommPtr receive_comm;
+  simgrid::s4u::CommPtr receive_comm = nullptr;
   void* received_msg             = nullptr;
   unsigned int find_node_success = 0; // Number of find_node which have succeeded.
   unsigned int find_node_failed  = 0; // Number of find_node which have failed.
-  explicit Node(unsigned int node_id) : id_(node_id), table(node_id), receive_comm(nullptr) {}
+  explicit Node(unsigned int node_id) : id_(node_id), table(node_id) {}
   Node(const Node&) = delete;
   Node& operator=(const Node&) = delete;
   unsigned int getId() { return id_; }
 
   bool join(unsigned int known_id);
   void sendFindNode(unsigned int id, unsigned int destination);
-  unsigned int sendFindNodeToBest(Answer* node_list);
+  unsigned int sendFindNodeToBest(const Answer* node_list);
   void routingTableUpdate(unsigned int id);
   Answer* findClosest(unsigned int destination_id);
   bool findNode(unsigned int id_to_find, bool count_in_stats);
   void randomLookup();
-  void handleFindNode(Message* msg);
+  void handleFindNode(const Message* msg);
 };
 }
 // identifier functions
 unsigned int get_id_in_prefix(unsigned int id, unsigned int prefix);
 unsigned int get_node_prefix(unsigned int id, unsigned int nb_bits);
 
-#endif /* _MSG_EXAMPLES_ROUTING_H */
+#endif /* KADEMLIA_NODE_HPP */
index ffc664c..c94ae3c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 4d8258a..c77b216 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index c6c8fc1..50349e1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -52,7 +52,7 @@ static int node(int argc, char* argv[])
 
       if (node->receive_comm->test()) {
         // There has been a message, we need to handle it !
-        kademlia::Message* msg = static_cast<kademlia::Message*>(node->received_msg);
+        const kademlia::Message* msg = static_cast<kademlia::Message*>(node->received_msg);
         if (msg) {
           node->handleFindNode(msg);
           delete msg->answer_;
index 05a5078..c1fae17 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 91a453d..ba6f6e3 100644 (file)
@@ -4,8 +4,8 @@
   <zone  id="AS0"  routing="Full">
 
     <!-- Use the pstate mechanism to encode the boot/shutdown time and energy.
-      --
-      -- See the C++ file in the same directory for more information.
+      -
+      -  See the C++ file in the same directory for more information.
       -->
 
     <!-- pstate values:
index 26e3421..f5d031d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 0c0d57a..db14d38 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 8f79846..badbfd4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index aba7a9d..eb7d36a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -27,7 +27,6 @@ static void sender(std::vector<std::string> args)
   /* Sleep a while before starting the example */
   simgrid::s4u::this_actor::sleep_for(10);
 
-
   if (flow_amount == 1) {
     /* - Send the task to the @ref worker */
     char* payload = bprintf("%f", comm_size);
@@ -71,7 +70,6 @@ static void receiver(std::vector<std::string> args)
 
 int main(int argc, char* argv[])
 {
-
   simgrid::s4u::Engine e(&argc, argv);
 
   XBT_INFO("Activating the SimGrid link energy plugin");
@@ -92,6 +90,7 @@ int main(int argc, char* argv[])
     argSender.push_back("1"); // Default value
     argReceiver.push_back("1");
   }
+
   if (argc > 3) {
     if (strcmp(argv[3], "random") == 0) { // We're asked to get a random size
       /* Initialize the random number generator */
index 81a8c19..ab770ee 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index d03ea86..639e1ed 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -19,7 +19,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_engine_filtering, "Messages specific for this s
 
 namespace filter {
 /* First example of thing that we can use as a filtering criteria: a simple boolean function */
-static bool filter_speed_more_than_50Mf(simgrid::s4u::Host* host)
+static bool filter_speed_more_than_50Mf(const simgrid::s4u::Host* host)
 {
   return host->get_speed() > 50E6;
 }
@@ -29,7 +29,7 @@ static bool filter_speed_more_than_50Mf(simgrid::s4u::Host* host)
  */
 class SingleCore {
 public:
-  bool operator()(simgrid::s4u::Host* host) { return host->get_core_count() == 1; }
+  bool operator()(const simgrid::s4u::Host* host) { return host->get_core_count() == 1; }
 };
 
 /* This functor is a bit more complex, as it saves the current state when created.
@@ -60,7 +60,7 @@ int main(int argc, char* argv[])
   /* Use a lambda function to filter hosts: We only want multicore hosts */
   XBT_INFO("Hosts currently registered with this engine: %zu", e.get_host_count());
   std::vector<simgrid::s4u::Host*> list =
-      e.get_filtered_hosts([](simgrid::s4u::Host* host) { return host->get_core_count() > 1; });
+      e.get_filtered_hosts([](const simgrid::s4u::Host* host) { return host->get_core_count() > 1; });
 
   for (auto& host : list)
     XBT_INFO("The following hosts have more than one core: %s", host->get_cname());
index 05b9a33..6b45285 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index ba018ef..c9727e8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 9f373a1..67b32b9 100644 (file)
@@ -4,38 +4,47 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/s4u.hpp"
+#include <vector>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
 
-simgrid::s4u::ExecPtr child;
-
 static void worker()
 {
+  // Define an amount of work that should take 1 second to execute.
   double computation_amount = simgrid::s4u::this_actor::get_host()->get_speed();
 
+  std::vector<simgrid::s4u::ExecPtr> pending_execs;
+  // Create a small DAG
+  // + Two parents and a child
+  // + First parent ends after 1 second and the Second parent after 2 seconds.
   simgrid::s4u::ExecPtr first_parent  = simgrid::s4u::this_actor::exec_init(computation_amount);
+  pending_execs.push_back(first_parent);
   simgrid::s4u::ExecPtr second_parent = simgrid::s4u::this_actor::exec_init(2 * computation_amount);
+  pending_execs.push_back(second_parent);
+  simgrid::s4u::ExecPtr child = simgrid::s4u::this_actor::exec_init(computation_amount);
+  pending_execs.push_back(child);
 
-  child = simgrid::s4u::this_actor::exec_init(computation_amount);
+  // Name the activities (for logging purposes only)
+  first_parent->set_name("parent 1");
+  second_parent->set_name("parent 2");
+  child->set_name("child");
 
+  // Create the dependencies by declaring 'child' as a successor of first_parent and second_parent
   first_parent->add_successor(child.get());
   second_parent->add_successor(child.get());
-  second_parent->start();
-  first_parent->wait();
-  second_parent->wait();
-}
 
-static void vetoed_worker()
-{
+  // Start the activities.
+  first_parent->start();
+  second_parent->start();
+  // child uses a vetoable start to force it to wait for the completion of its predecessors
   child->vetoable_start();
-  while (not child->test()) {
-    if (child->get_state() == simgrid::s4u::Exec::State::STARTING)
-      XBT_INFO("child cannot start yet");
-    else
-      XBT_INFO("child is now in state %d", (int)child->get_state());
-    simgrid::s4u::this_actor::sleep_for(0.25);
+
+  // wait for the completion of all activities
+  while (not pending_execs.empty()) {
+    int changed_pos = simgrid::s4u::Exec::wait_any_for(&pending_execs, -1);
+    XBT_INFO("Exec '%s' is complete", pending_execs[changed_pos]->get_cname());
+    pending_execs.erase(pending_execs.begin() + changed_pos);
   }
-  XBT_INFO("Should be okay now, child is in state %d", (int)child->get_state());
 }
 
 int main(int argc, char* argv[])
@@ -44,7 +53,6 @@ int main(int argc, char* argv[])
   e.load_platform(argv[1]);
 
   simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Fafard"), worker);
-  simgrid::s4u::Actor::create("vetoed_worker", simgrid::s4u::Host::by_name("Fafard"), vetoed_worker);
 
   e.run();
 
index 2c274ff..dab01ae 100644 (file)
@@ -1,21 +1,11 @@
 #!/usr/bin/env tesh
 
-$ ${bindir:=.}/s4u-exec-dependent ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
-> [  0.000000] (2:vetoed_worker@Fafard) child cannot start yet
-> [  0.250000] (2:vetoed_worker@Fafard) child cannot start yet
-> [  0.500000] (2:vetoed_worker@Fafard) child cannot start yet
-> [  0.750000] (2:vetoed_worker@Fafard) child cannot start yet
-> [  1.000000] (2:vetoed_worker@Fafard) child cannot start yet
-> [  1.250000] (2:vetoed_worker@Fafard) child cannot start yet
-> [  1.500000] (2:vetoed_worker@Fafard) child cannot start yet
-> [  1.750000] (2:vetoed_worker@Fafard) child cannot start yet
-> [  2.000000] (2:vetoed_worker@Fafard) child cannot start yet
-> [  2.250000] (2:vetoed_worker@Fafard) child cannot start yet
-> [  2.500000] (2:vetoed_worker@Fafard) child cannot start yet
-> [  2.750000] (2:vetoed_worker@Fafard) child cannot start yet
-> [  3.000000] (2:vetoed_worker@Fafard) child is now in state 2
-> [  3.250000] (2:vetoed_worker@Fafard) child is now in state 2
-> [  3.500000] (2:vetoed_worker@Fafard) child is now in state 2
-> [  3.750000] (2:vetoed_worker@Fafard) child is now in state 2
-> [  4.000000] (2:vetoed_worker@Fafard) Should be okay now, child is in state 5
+! output sort
+$ ${bindir:=.}/s4u-exec-dependent ${platfdir}/small_platform.xml --log=s4u_activity.t:debug "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  2.000000] (1:worker@Fafard) Remove a dependency from 'parent 1' on 'child'
+> [  2.000000] (1:worker@Fafard) Exec 'parent 1' is complete
+> [  3.000000] (1:worker@Fafard) Remove a dependency from 'parent 2' on 'child'
+> [  3.000000] (1:worker@Fafard) All dependencies are solved, let's start 'child'
+> [  3.000000] (1:worker@Fafard) Exec 'parent 2' is complete
+> [  4.000000] (1:worker@Fafard) Exec 'child' is complete
 > [  4.000000] (0:maestro@) Simulation time 4
index 8ae88ea..17acdc9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 146753e..2b1aa13 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -52,8 +52,8 @@ static void runner()
       communication_amounts[i * hosts_count + j] = 1e7; // 10 MB
 
   try {
-    simgrid::s4u::this_actor::parallel_execute(hosts, computation_amounts, communication_amounts,
-                                               10.0 /* timeout (in seconds)*/);
+    simgrid::s4u::this_actor::exec_init(hosts, computation_amounts, communication_amounts)
+        ->wait_for(10.0 /* timeout (in seconds)*/);
     xbt_die("Woops, this did not timeout as expected... Please report that bug.");
   } catch (const simgrid::TimeoutException&) {
     XBT_INFO("Caught the expected timeout exception.");
@@ -61,7 +61,7 @@ static void runner()
 
   /* ------[ test 3 ]----------------- */
   XBT_INFO("Then, build a parallel task involving only computations (of different amounts) and no communication");
-  computation_amounts = {3e8, 6e8, 1e9}; // 300Mflop, 6Mflop, 1Gflop
+  computation_amounts = {3e8, 6e8, 1e9}; // 300Mflop, 600Mflop, 1Gflop
   communication_amounts.clear();         // no comm
   simgrid::s4u::this_actor::parallel_execute(hosts, computation_amounts, communication_amounts);
 
@@ -71,6 +71,20 @@ static void runner()
   communication_amounts.clear();
   simgrid::s4u::this_actor::parallel_execute(hosts, computation_amounts, communication_amounts);
 
+  /* ------[ test 5 ]----------------- */
+  XBT_INFO("Then, Monitor the execution of a parallel task");
+  computation_amounts.assign(hosts_count, 1e6 /*1Mflop*/);
+  communication_amounts = {0, 1e6, 0, 0, 0, 1e6, 1e6, 0, 0};
+  simgrid::s4u::ExecPtr activity =
+      simgrid::s4u::this_actor::exec_init(hosts, computation_amounts, communication_amounts);
+  activity->start();
+
+  while (not activity->test()) {
+    XBT_INFO("Remaining flop ratio: %.0f%%", 100 * activity->get_remaining_ratio());
+    simgrid::s4u::this_actor::sleep_for(5);
+  }
+  activity->wait();
+
   XBT_INFO("Goodbye now!");
 }
 
index d7cb538..fbb3d4e 100644 (file)
@@ -17,5 +17,16 @@ $ ${bindir:=.}/s4u-exec-ptask ${platfdir}/energy_platform.xml --cfg=host/model:p
 > [320.000000] (0:maestro@) UNCAT HOST [310.000000 - 320.000000] MyHost2 speed_used 60000000.000000
 > [320.000000] (0:maestro@) UNCAT HOST [310.000000 - 320.000000] MyHost3 speed_used 100000000.000000
 > [320.000000] (1:test@MyHost1) Then, build a parallel task with no computation nor communication (synchro only)
-> [320.000000] (1:test@MyHost1) Goodbye now!
-> [320.000000] (0:maestro@) Simulation done.
+> [320.000000] (1:test@MyHost1) Then, Monitor the execution of a parallel task
+> [320.000000] (1:test@MyHost1) Remaining flop ratio: 100%
+> [325.000000] (1:test@MyHost1) Remaining flop ratio: 83%
+> [330.000000] (1:test@MyHost1) Remaining flop ratio: 67%
+> [335.000000] (1:test@MyHost1) Remaining flop ratio: 50%
+> [340.000000] (1:test@MyHost1) Remaining flop ratio: 33%
+> [345.000000] (1:test@MyHost1) Remaining flop ratio: 17%
+> [350.000000] (0:maestro@) UNCAT HOST [320.000000 - 350.000000] MyHost1 speed_used 33333.333333
+> [350.000000] (0:maestro@) UNCAT HOST [320.000000 - 350.000000] MyHost2 speed_used 33333.333333
+> [350.000000] (0:maestro@) UNCAT HOST [320.000000 - 350.000000] MyHost3 speed_used 33333.333333
+> [350.000000] (0:maestro@) UNCAT LINK [320.000000 - 350.000000] bus bandwidth_used 100000.000000
+> [350.000000] (1:test@MyHost1) Goodbye now!
+> [350.000000] (0:maestro@) Simulation done.
index 4c0699c..d2a3f68 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -9,7 +9,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example")
 
 static void wizard()
 {
-  simgrid::s4u::Host* fafard  = simgrid::s4u::Host::by_name("Fafard");
+  const simgrid::s4u::Host* fafard = simgrid::s4u::Host::by_name("Fafard");
   simgrid::s4u::Host* ginette = simgrid::s4u::Host::by_name("Ginette");
   simgrid::s4u::Host* boivin  = simgrid::s4u::Host::by_name("Boivin");
 
index 2771a2f..d9d61a6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
diff --git a/examples/s4u/exec-waitfor/s4u-exec-waitfor.cpp b/examples/s4u/exec-waitfor/s4u-exec-waitfor.cpp
new file mode 100644 (file)
index 0000000..b28397d
--- /dev/null
@@ -0,0 +1,66 @@
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.          */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "simgrid/s4u.hpp"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_exec_waitfor, "Messages specific for this s4u example");
+
+static void worker()
+{
+  simgrid::s4u::ExecPtr exec;
+  double amount = 5 * simgrid::s4u::this_actor::get_host()->get_speed();
+  XBT_INFO("Create an activity that should run for 5 seconds");
+
+  exec = simgrid::s4u::this_actor::exec_async(amount);
+
+  /* Now that execution is started, wait for 3 seconds. */
+  XBT_INFO("But let it end after 3 seconds");
+  try {
+    exec->wait_for(3);
+    XBT_INFO("Execution complete");
+  } catch (const simgrid::TimeoutException&) {
+    XBT_INFO("Execution Timeout!");
+  }
+
+  /* do it again, but this time with a timeout greater than the duration of the execution */
+  XBT_INFO("Create another activity that should run for 5 seconds and wait for it for 6 seconds");
+  exec = simgrid::s4u::this_actor::exec_async(amount);
+  try {
+    exec->wait_for(6);
+    XBT_INFO("Execution complete");
+  } catch (const simgrid::TimeoutException&) {
+    XBT_INFO("Execution Timeout!");
+  }
+
+  XBT_INFO("Finally test with a parallel execution");
+  auto hosts         = simgrid::s4u::Engine::get_instance()->get_all_hosts();
+  size_t hosts_count = hosts.size();
+  std::vector<double> computation_amounts;
+  std::vector<double> communication_amounts;
+
+  computation_amounts.assign(hosts_count, 1e9 /*1Gflop*/);
+  communication_amounts.assign(hosts_count * hosts_count, 0);
+  for (size_t i = 0; i < hosts_count; i++)
+    for (size_t j = i + 1; j < hosts_count; j++)
+      communication_amounts[i * hosts_count + j] = 1e7; // 10 MB
+
+  exec = simgrid::s4u::this_actor::exec_init(hosts, computation_amounts, communication_amounts);
+  try {
+    exec->wait_for(2);
+    XBT_INFO("Parallel Execution complete");
+  } catch (const simgrid::TimeoutException&) {
+    XBT_INFO("Parallel Execution Timeout!");
+  }
+}
+
+int main(int argc, char* argv[])
+{
+  simgrid::s4u::Engine e(&argc, argv);
+  e.load_platform(argv[1]);
+  simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Tremblay"), worker);
+  e.run();
+
+  return 0;
+}
diff --git a/examples/s4u/exec-waitfor/s4u-exec-waitfor.tesh b/examples/s4u/exec-waitfor/s4u-exec-waitfor.tesh
new file mode 100644 (file)
index 0000000..c58d048
--- /dev/null
@@ -0,0 +1,10 @@
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/s4u-exec-waitfor ${platfdir}/multicore_machine.xml "--log=root.fmt:[%10.6r]%e[%14P]%e%m%n"
+> [  0.000000] [        worker] Create an activity that should run for 5 seconds
+> [  0.000000] [        worker] But let it end after 3 seconds
+> [  3.000000] [        worker] Execution Timeout!
+> [  3.000000] [        worker] Create another activity that should run for 5 seconds and wait for it for 6 seconds
+> [  8.000000] [        worker] Execution complete
+> [  8.000000] [        worker] Finally test with a parallel execution
+> [ 10.000000] [        worker] Parallel Execution Timeout!
index 597284f..86a2358 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -19,9 +19,25 @@ static void test(sg_size_t size)
   XBT_INFO("Goodbye now!");
 }
 
+static void test_waitfor(sg_size_t size)
+{
+  simgrid::s4u::Disk* disk = simgrid::s4u::Host::current()->get_disks().front();
+  XBT_INFO("Hello! write %llu bytes from %s", size, disk->get_cname());
+
+  simgrid::s4u::IoPtr activity = disk->write_async(size);
+  try {
+    activity->wait_for(0.5);
+  } catch (const simgrid::TimeoutException&) {
+    XBT_INFO("Asynchronous write: Timeout!");
+  }
+
+  XBT_INFO("Goodbye now!");
+}
+
 static void test_cancel(sg_size_t size)
 {
   simgrid::s4u::Disk* disk = simgrid::s4u::Host::current()->get_disks().front();
+  simgrid::s4u::this_actor::sleep_for(0.5);
   XBT_INFO("Hello! write %llu bytes from %s", size, disk->get_cname());
 
   simgrid::s4u::IoPtr activity = disk->write_async(size);
@@ -32,12 +48,29 @@ static void test_cancel(sg_size_t size)
   XBT_INFO("Goodbye now!");
 }
 
+static void test_monitor(sg_size_t size)
+{
+  simgrid::s4u::Disk* disk = simgrid::s4u::Host::current()->get_disks().front();
+  simgrid::s4u::this_actor::sleep_for(1);
+  simgrid::s4u::IoPtr activity = disk->write_async(size);
+
+  while (not activity->test()) {
+    XBT_INFO("Remaining amount of bytes to write: %g", activity->get_remaining());
+    simgrid::s4u::this_actor::sleep_for(0.2);
+  }
+  activity->wait();
+
+  XBT_INFO("Goodbye now!");
+}
+
 int main(int argc, char* argv[])
 {
   simgrid::s4u::Engine e(&argc, argv);
   e.load_platform(argv[1]);
   simgrid::s4u::Actor::create("test", simgrid::s4u::Host::by_name("bob"), test, 2e7);
+  simgrid::s4u::Actor::create("test_waitfor", simgrid::s4u::Host::by_name("alice"), test_waitfor, 5e7);
   simgrid::s4u::Actor::create("test_cancel", simgrid::s4u::Host::by_name("alice"), test_cancel, 5e7);
+  simgrid::s4u::Actor::create("test_monitor", simgrid::s4u::Host::by_name("alice"), test_monitor, 5e7);
 
   e.run();
 
index 0ff50eb..a1ca8d7 100644 (file)
@@ -2,8 +2,16 @@
 
 $ ${bindir:=.}/s4u-io-async ${platfdir}/hosts_with_disks.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
 > [  0.000000] (1:test@bob) Hello! read 20000000 bytes from Disk1
-> [  0.000000] (2:test_cancel@alice) Hello! write 50000000 bytes from Disk1
+> [  0.000000] (2:test_waitfor@alice) Hello! write 50000000 bytes from Disk1
 > [  0.200000] (1:test@bob) Goodbye now!
-> [  0.500000] (2:test_cancel@alice) I changed my mind, cancel!
-> [  0.500000] (2:test_cancel@alice) Goodbye now!
-> [  0.500000] (0:maestro@) Simulation time 0.5
+> [  0.500000] (2:test_waitfor@alice) Asynchronous write: Timeout!
+> [  0.500000] (2:test_waitfor@alice) Goodbye now!
+> [  0.500000] (3:test_cancel@alice) Hello! write 50000000 bytes from Disk1
+> [  1.000000] (3:test_cancel@alice) I changed my mind, cancel!
+> [  1.000000] (3:test_cancel@alice) Goodbye now!
+> [  1.000000] (4:test_monitor@alice) Remaining amount of bytes to write: 5e+07
+> [  1.200000] (4:test_monitor@alice) Remaining amount of bytes to write: 3.4e+07
+> [  1.400000] (4:test_monitor@alice) Remaining amount of bytes to write: 1.8e+07
+> [  1.600000] (4:test_monitor@alice) Remaining amount of bytes to write: 2e+06
+> [  1.800000] (4:test_monitor@alice) Goodbye now!
+> [  1.800000] (0:maestro@) Simulation time 1.8
index d51781a..7ec2999 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -18,7 +18,7 @@ static void host()
   std::vector<simgrid::s4u::Disk*> const& disk_list = simgrid::s4u::Host::current()->get_disks();
 
   /* - For each disk mounted on host, display disk name and mount point */
-  for (auto disk : disk_list)
+  for (auto const& disk : disk_list)
     XBT_INFO("Disk name: %s (read: %.0f B/s -- write: %.0f B/s ", disk->get_cname(), disk->get_read_bandwidth(),
              disk->get_write_bandwidth());
 
@@ -34,7 +34,7 @@ static void host()
   /* - Attach some user data to disk1 */
   XBT_INFO("*** Get/set data for storage element: Disk1 ***");
 
-  std::string* data = static_cast<std::string*>(disk->get_data());
+  const std::string* data = static_cast<std::string*>(disk->get_data());
 
   XBT_INFO("Get storage data: '%s'", data ? data->c_str() : "No user data");
 
index 3579324..7994ee0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 6a74e1b..46f1e02 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -57,7 +57,7 @@ public:
 
     // Test attaching some user data to the file
     file->set_data(new std::string("777"));
-    std::string* file_data = static_cast<std::string*>(file->get_data());
+    const std::string* file_data = static_cast<std::string*>(file->get_data());
     XBT_INFO("User data attached to the file: %s", file_data->c_str());
     delete file_data;
 
index 1088559..65162cb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -48,7 +48,7 @@ static void receiver()
 {
   ensure_other_tid();
 
-  std::string* payload = static_cast<std::string*>(simgrid::s4u::Mailbox::by_name("some mailbox")->get());
+  const std::string* payload = static_cast<std::string*>(simgrid::s4u::Mailbox::by_name("some mailbox")->get());
   XBT_INFO("Task received");
   delete payload;
 }
index b87e6f4..7efc445 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -18,7 +18,7 @@ static int server(int worker_amount)
   int value_got             = -1;
   simgrid::s4u::Mailbox* mb = simgrid::s4u::Mailbox::by_name("server");
   for (int count = 0; count < worker_amount; count++) {
-    int* msg  = static_cast<int*>(mb->get());
+    const int* msg = static_cast<int*>(mb->get());
     value_got = *msg;
     delete msg;
   }
index 0c5bf2d..e33bdbd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -75,7 +75,7 @@ static int worker(int argc, char* argv[])
   xbt_assert(argc == 2, "Expecting one parameter");
   long id                          = xbt_str_parse_int(argv[1], "Invalid argument %s");
   simgrid::s4u::Mailbox* mailbox   = simgrid::s4u::Mailbox::by_name(std::string("worker-") + std::to_string(id));
-  double* payload                  = nullptr;
+  const double* payload            = nullptr;
   double comp_size                 = -1;
   while (1) {
     try {
index 5483c2f..6efe94a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -15,10 +15,10 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_platform_profile, "Messages specific for this s
 /* Main function of the Yielder process */
 static void watcher()
 {
-  simgrid::s4u::Host* jupiter = simgrid::s4u::Host::by_name("Jupiter");
-  simgrid::s4u::Host* fafard  = simgrid::s4u::Host::by_name("Fafard");
-  simgrid::s4u::Link* link1   = simgrid::s4u::Link::by_name("1");
-  simgrid::s4u::Link* link2   = simgrid::s4u::Link::by_name("2");
+  const simgrid::s4u::Host* jupiter = simgrid::s4u::Host::by_name("Jupiter");
+  const simgrid::s4u::Host* fafard  = simgrid::s4u::Host::by_name("Fafard");
+  const simgrid::s4u::Link* link1   = simgrid::s4u::Link::by_name("1");
+  const simgrid::s4u::Link* link2   = simgrid::s4u::Link::by_name("2");
 
   for (int i = 0; i < 10; i++) {
     XBT_INFO("Fafard: %.0fGflops, Jupiter: % 3.0fGflops, Link1: (%.2fMB/s %.0fms), Link2: (%.2fMB/s %.0fms)",
index 12e793d..1720303 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -84,7 +84,7 @@ static void david(std::vector<std::string> /*args*/)
 static void bob(std::vector<std::string> /*args*/)
 {
   /* this host also tests the properties of the AS*/
-  simgrid::s4u::NetZone* root = simgrid::s4u::Engine::get_instance()->get_netzone_root();
+  const simgrid::s4u::NetZone* root = simgrid::s4u::Engine::get_instance()->get_netzone_root();
   XBT_INFO("== Print the properties of the root zone");
   XBT_INFO("   Zone property: filename -> %s", root->get_property("filename"));
   XBT_INFO("   Zone property: date -> %s", root->get_property("date"));
index 27ecdda..33460b5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 95affd0..5f3071c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -18,7 +18,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(replay_comm, "Messages specific for this msg exampl
   } else                                                                                                               \
   ((void)0)
 
-static void log_action(simgrid::xbt::ReplayAction& action, double date)
+static void log_action(const simgrid::xbt::ReplayAction& action, double date)
 {
   if (XBT_LOG_ISENABLED(replay_comm, xbt_log_priority_verbose)) {
     std::string s = boost::algorithm::join(action, " ");
index 93af1ff..f5205e4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -21,7 +21,7 @@ static std::unordered_map<std::string, simgrid::s4u::File*> opened_files;
   } else                                                                                                               \
     ((void)0)
 
-static void log_action(simgrid::xbt::ReplayAction& action, double date)
+static void log_action(const simgrid::xbt::ReplayAction& action, double date)
 {
   if (XBT_LOG_ISENABLED(replay_io, xbt_log_priority_verbose)) {
     std::string s = boost::algorithm::join(action, " ");
@@ -83,7 +83,7 @@ public:
     std::string file_name = action[2];
     double clock          = simgrid::s4u::Engine::get_clock();
 
-    simgrid::s4u::File* file = get_file_descriptor(file_name);
+    const simgrid::s4u::File* file = get_file_descriptor(file_name);
 
     ACT_DEBUG("Entering Close: %s (filename: %s)", NAME.c_str(), file_name.c_str());
     delete file;
index 1710fee..ff89948 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 3e5e1ec..d816f50 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
diff --git a/examples/s4u/synchro-condition-variable/s4u-synchro-condition-variable.cpp b/examples/s4u/synchro-condition-variable/s4u-synchro-condition-variable.cpp
new file mode 100644 (file)
index 0000000..1f8d850
--- /dev/null
@@ -0,0 +1,50 @@
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include <mutex>           /* std::mutex and std::lock_guard */
+#include <simgrid/s4u.hpp> /* All of S4U */
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "a sample log category");
+
+std::string data;
+bool done = false;
+
+static void worker_fun(simgrid::s4u::ConditionVariablePtr cv, simgrid::s4u::MutexPtr mutex)
+{
+  std::unique_lock<simgrid::s4u::Mutex> lock(*mutex);
+
+  XBT_INFO("Start processing data which is '%s'.", data.c_str());
+  data += std::string(" after processing");
+
+  // Send data back to main()
+  XBT_INFO("Signal to master that the data processing is completed, and exit.");
+
+  done = true;
+  cv->notify_one();
+}
+
+static void master_fun()
+{
+  auto mutex  = simgrid::s4u::Mutex::create();
+  auto cv     = simgrid::s4u::ConditionVariable::create();
+  data        = std::string("Example data");
+  auto worker = simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Jupiter"), worker_fun, cv, mutex);
+
+  // wait for the worker
+  cv->wait(std::unique_lock<simgrid::s4u::Mutex>(*mutex), []() { return done; });
+  XBT_INFO("data is now '%s'.", data.c_str());
+
+  worker->join();
+}
+
+int main(int argc, char** argv)
+{
+  simgrid::s4u::Engine e(&argc, argv);
+  e.load_platform("../../platforms/two_hosts.xml");
+  simgrid::s4u::Actor::create("main", simgrid::s4u::Host::by_name("Tremblay"), master_fun);
+  e.run();
+
+  return 0;
+}
diff --git a/examples/s4u/synchro-condition-variable/s4u-synchro-condition-variable.tesh b/examples/s4u/synchro-condition-variable/s4u-synchro-condition-variable.tesh
new file mode 100644 (file)
index 0000000..3b54bf0
--- /dev/null
@@ -0,0 +1,6 @@
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/s4u-synchro-condition-variable
+> [Jupiter:worker:(2) 0.000000] [s4u_test/INFO] Start processing data which is 'Example data'.
+> [Jupiter:worker:(2) 0.000000] [s4u_test/INFO] Signal to master that the data processing is completed, and exit.
+> [Tremblay:main:(1) 0.000000] [s4u_test/INFO] data is now 'Example data after processing'.
index f518817..3cf2862 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index f129940..3921539 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -16,8 +16,7 @@ const char* buffer;                                                        /* Wh
 simgrid::s4u::SemaphorePtr sem_empty = simgrid::s4u::Semaphore::create(1); /* indicates whether the buffer is empty */
 simgrid::s4u::SemaphorePtr sem_full  = simgrid::s4u::Semaphore::create(0); /* indicates whether the buffer is full */
 
-
-static void producer(std::vector<std::string>* args)
+static void producer(const std::vector<std::string>* args)
 {
   for (auto str : *args) {
     sem_empty->acquire();
index c01dd8b..72cdf22 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index debb98a..6229b50 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team.
+/* Copyright (c) 2016-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 65be026..4da962e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team.
+/* Copyright (c) 2016-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 05b2efa..78d132a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index b00bcfb..ba3eeac 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 1675b9a..342b12d 100644 (file)
@@ -1,6 +1,6 @@
 /* A simple bugged MPI_ISend and MPI_IRecv test */
 
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 7b34808..4c232a3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include <mpi.h>
 #include <simgrid/modelchecker.h>
+#include <xbt/dynar.h>
 
 #define GRANT_TAG 0
 #define REQUEST_TAG 1
index 2741da9..7101331 100644 (file)
@@ -1,6 +1,6 @@
 /* A simple bugged MPI_ISend and MPI_IRecv test */
 
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 9a3de8c..5481c91 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team.
+/* Copyright (c) 2014-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -7,6 +7,7 @@
 #include <stdio.h>
 #include <mpi.h>
 #include <simgrid/modelchecker.h>
+#include <xbt/dynar.h>
 
 #define GRANT_TAG 0
 #define REQUEST_TAG 1
index 52f6760..d734a37 100644 (file)
@@ -1,6 +1,6 @@
 /* ../../../smpi_script/bin/smpirun -hostfile hostfile_send_deterministic -platform ../../platforms/cluster_backbone.xml -np 3 --cfg=smpi/send-is-detached-thresh:0 gdb\ --args\ ./send_deterministic */
 
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index cf83ee3..f1793ab 100644 (file)
@@ -1,6 +1,6 @@
 /* A simple bugged MPI_Send and MPI_Recv test: it deadlocks when MPI_Send are blocking */
 
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 429a3a2..50b515e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -14,7 +14,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example")
 
 /* This shows how to extend the trace format by adding a new kind of events.
    This function is registered through xbt_replay_action_register() below. */
-static void action_blah(simgrid::xbt::ReplayAction& /*args*/)
+static void action_blah(const simgrid::xbt::ReplayAction& /*args*/)
 {
   /* Add your answer to the blah event here.
      args is a strings array containing the blank-separated parameters found in the trace for this event instance. */
index 62a3fa3..5de54b4 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env sh
 
-# Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
index d258fe5..469a68a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 8524a1a..191b857 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -65,7 +65,7 @@ static void smpi_replay_process(Job* job, simgrid::s4u::BarrierPtr barrier, int
 }
 
 // Sleeps for a given amount of time
-static int sleeper_process(int* param)
+static int sleeper_process(const int* param)
 {
   XBT_DEBUG("Sleeping for %d seconds", *param);
   simgrid::s4u::this_actor::sleep_for(*param);
@@ -106,7 +106,7 @@ static int job_executor_process(Job* job)
 }
 
 // Executes a workload of SMPI processes
-static int workload_executor_process(std::vector<Job*>* workload)
+static int workload_executor_process(const std::vector<Job*>* workload)
 {
   for (Job* job : *workload) {
     // Let's wait until the job's waiting time if needed
index 5fe9cc1..1947029 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index c3172ff..c9839fe 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index f2c5081..307ab2f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 8e3cc57..3209a5e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 785a9f1..613ca5a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 90836fa..eac34be 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -25,13 +25,13 @@ XBT_PUBLIC sg_actor_t sg_actor_init(const char* name, sg_host_t host);
  *
  * Note that argv is copied over, so you should free your own copy once the actor is started. */
 XBT_PUBLIC void sg_actor_start(sg_actor_t actor, xbt_main_func_t code, int argc, char** argv);
-XBT_PUBLIC aid_t sg_actor_get_PID(sg_actor_t actor);
-XBT_PUBLIC aid_t sg_actor_get_PPID(sg_actor_t actor);
+XBT_PUBLIC aid_t sg_actor_get_PID(const_sg_actor_t actor);
+XBT_PUBLIC aid_t sg_actor_get_PPID(const_sg_actor_t actor);
 XBT_PUBLIC sg_actor_t sg_actor_by_PID(aid_t pid);
-XBT_PUBLIC const char* sg_actor_get_name(sg_actor_t actor);
-XBT_PUBLIC sg_host_t sg_actor_get_host(sg_actor_t actor);
-XBT_PUBLIC const char* sg_actor_get_property_value(sg_actor_t actor, const char* name);
-XBT_PUBLIC xbt_dict_t sg_actor_get_properties(sg_actor_t actor);
+XBT_PUBLIC const char* sg_actor_get_name(const_sg_actor_t actor);
+XBT_PUBLIC sg_host_t sg_actor_get_host(const_sg_actor_t actor);
+XBT_PUBLIC const char* sg_actor_get_property_value(const_sg_actor_t actor, const char* name);
+XBT_PUBLIC xbt_dict_t sg_actor_get_properties(const_sg_actor_t actor);
 XBT_PUBLIC void sg_actor_suspend(sg_actor_t actor);
 XBT_PUBLIC void sg_actor_resume(sg_actor_t actor);
 XBT_PUBLIC int sg_actor_is_suspended(sg_actor_t actor);
@@ -39,8 +39,10 @@ XBT_PUBLIC sg_actor_t sg_actor_restart(sg_actor_t actor);
 void sg_actor_set_auto_restart(sg_actor_t actor, int auto_restart);
 XBT_PUBLIC void sg_actor_daemonize(sg_actor_t actor);
 
+#ifndef DOXYGEN
 XBT_ATTRIB_DEPRECATED_v329("Please use sg_actor_set_host() instead") XBT_PUBLIC
     void sg_actor_migrate(sg_actor_t process, sg_host_t host);
+#endif
 
 XBT_PUBLIC void sg_actor_set_host(sg_actor_t actor, sg_host_t host);
 XBT_PUBLIC void sg_actor_join(sg_actor_t actor, double timeout);
@@ -58,8 +60,8 @@ XBT_PUBLIC const char* sg_actor_self_get_name();
 XBT_PUBLIC void* sg_actor_self_data();
 XBT_PUBLIC void sg_actor_self_data_set(void* data);
 XBT_PUBLIC void sg_actor_self_execute(double flops);
-XBT_PUBLIC void sg_actor_ref(sg_actor_t actor);
-XBT_PUBLIC void sg_actor_unref(sg_actor_t actor);
+XBT_PUBLIC void sg_actor_ref(const_sg_actor_t actor);
+XBT_PUBLIC void sg_actor_unref(const_sg_actor_t actor);
 XBT_PUBLIC void* sg_actor_data(const_sg_actor_t actor);
 XBT_PUBLIC void sg_actor_data_set(sg_actor_t actor, void* userdata);
 
index 83347fe..cef5eb5 100644 (file)
@@ -1,6 +1,6 @@
 /* Public interface to the Link datatype                                    */
 
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -20,7 +20,7 @@ constexpr int SG_BARRIER_SERIAL_THREAD = -1;
 SG_BEGIN_DECL
 
 XBT_PUBLIC sg_bar_t sg_barrier_init(unsigned int count);
-XBT_PUBLIC void sg_barrier_destroy(sg_bar_t bar);
+XBT_PUBLIC void sg_barrier_destroy(const_sg_bar_t bar);
 XBT_PUBLIC int sg_barrier_wait(sg_bar_t bar);
 
 SG_END_DECL
index 72d9fa8..3d8ea5a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 2bdfc41..b798624 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -18,12 +18,12 @@ XBT_PUBLIC void sg_cond_wait(sg_cond_t cond, sg_mutex_t mutex);
 /** @brief Blocks onto the given condition variable, but only for the given amount of time.
  *  @return 0 on success, 1 on timeout */
 XBT_PUBLIC int sg_cond_wait_for(sg_cond_t cond, sg_mutex_t mutex, double delay);
-/** @brief Signals the given mutex variable */
+/** @brief Signals the given condition variable */
 XBT_PUBLIC void sg_cond_notify_one(sg_cond_t cond);
-/** @brief Broadcasts the given mutex variable */
+/** @brief Broadcasts the given condition variable */
 XBT_PUBLIC void sg_cond_notify_all(sg_cond_t cond);
-/** @brief Destroys the given mutex variable */
-XBT_PUBLIC void sg_cond_destroy(sg_cond_t cond);
+/** @brief Destroys the given condition variable */
+XBT_PUBLIC void sg_cond_destroy(const_sg_cond_t cond);
 
 SG_END_DECL
 
index b1cc822..9d7589a 100644 (file)
@@ -1,6 +1,6 @@
 /* simgrid/config.h - Results of the configure made visible to user code.   */
 
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 4a2247e..736ba3b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -14,14 +14,14 @@ XBT_PUBLIC void simgrid_init(int* argc, char** argv);
 
 /** Creates a new platform, including hosts, links, and the routing table.
  *
- * \rst
+ * \beginrst
  * See also: :ref:`platform`.
  * \endrst
  */
 XBT_PUBLIC void simgrid_load_platform(const char* filename);
 /** Load a deployment file and launch the actors that it contains
  *
- * \rst
+ * \beginrst
  * See also: :ref:`deploy`.
  * \endrst
  */
index b6a2b5c..5d97079 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -20,8 +20,8 @@ class Activity;
 class Actor;
 /** Smart pointer to a simgrid::s4u::Actor */
 typedef boost::intrusive_ptr<Actor> ActorPtr;
-XBT_PUBLIC void intrusive_ptr_release(Actor* actor);
-XBT_PUBLIC void intrusive_ptr_add_ref(Actor* actor);
+XBT_PUBLIC void intrusive_ptr_release(const Actor* actor);
+XBT_PUBLIC void intrusive_ptr_add_ref(const Actor* actor);
 
 class Barrier;
 /** Smart pointer to a simgrid::s4u::Barrier */
@@ -36,10 +36,13 @@ XBT_PUBLIC void intrusive_ptr_release(Comm* c);
 XBT_PUBLIC void intrusive_ptr_add_ref(Comm* c);
 
 class ConditionVariable;
-/** Smart pointer to a simgrid::s4u::ConditionVariable */
+/** @beginrst
+ * Smart pointer to a :cpp:type:`simgrid::s4u::ConditionVariable`
+ * @endrst
+ */
 typedef boost::intrusive_ptr<ConditionVariable> ConditionVariablePtr;
-XBT_PUBLIC void intrusive_ptr_release(ConditionVariable* c);
-XBT_PUBLIC void intrusive_ptr_add_ref(ConditionVariable* c);
+XBT_PUBLIC void intrusive_ptr_release(const ConditionVariable* c);
+XBT_PUBLIC void intrusive_ptr_add_ref(const ConditionVariable* c);
 
 class Engine;
 
@@ -66,9 +69,13 @@ class Link;
 class Mailbox;
 
 class Mutex;
-XBT_PUBLIC void intrusive_ptr_release(Mutex* m);
-XBT_PUBLIC void intrusive_ptr_add_ref(Mutex* m);
-/** Smart pointer to a simgrid::s4u::Mutex */
+XBT_PUBLIC void intrusive_ptr_release(const Mutex* m);
+XBT_PUBLIC void intrusive_ptr_add_ref(const Mutex* m);
+/**
+ * @beginrst
+ * Smart pointer to a :cpp:type:`simgrid::s4u::Mutex`
+ * @endrst
+ */
 typedef boost::intrusive_ptr<Mutex> MutexPtr;
 
 class NetZone;
@@ -226,17 +233,30 @@ typedef struct s_smx_sem* smx_sem_t;
 
 #endif
 
+/** Pointer to a SimGrid barrier object */
 typedef s4u_Barrier* sg_bar_t;
+/** Constant pointer to a SimGrid barrier object */
+typedef const s4u_Barrier* const_sg_bar_t;
 typedef s4u_ConditionVariable* sg_cond_t;
+typedef const s4u_ConditionVariable* const_sg_cond_t;
 typedef s4u_Mutex* sg_mutex_t;
+typedef const s4u_Mutex* const_sg_mutex_t;
 typedef s4u_Semaphore* sg_sem_t;
+typedef const s4u_Semaphore* const_sg_sem_t;
 typedef s4u_NetZone* sg_netzone_t;
+typedef const s4u_NetZone* const_sg_netzone_t;
 typedef s4u_Host* sg_host_t;
+typedef const s4u_Host* const_sg_host_t;
 typedef s4u_Link* sg_link_t;
+typedef const s4u_Link* const_sg_link_t;
 typedef s4u_Disk* sg_disk_t;
+typedef const s4u_Disk* const_sg_disk_t;
 typedef s4u_Storage* sg_storage_t;
+typedef const s4u_Storage* const_sg_storage_t;
 typedef s4u_File* sg_file_t;
+typedef const s4u_File* const_sg_file_t;
 typedef s4u_VM* sg_vm_t;
+typedef const s4u_VM* const_sg_vm_t;
 typedef s4u_Actor* sg_actor_t;
 typedef const s4u_Actor* const_sg_actor_t;
 
index a7cce00..c228722 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -31,7 +31,7 @@ XBT_PUBLIC size_t sg_host_count();
 XBT_PUBLIC xbt_dynar_t sg_hosts_as_dynar();
 
 XBT_PUBLIC size_t sg_host_extension_create(void (*deleter)(void*));
-XBT_PUBLIC void* sg_host_extension_get(sg_host_t host, size_t rank);
+XBT_PUBLIC void* sg_host_extension_get(const_sg_host_t host, size_t rank);
 
 /** @brief Finds a sg_host_t using its name.
  *
@@ -42,14 +42,14 @@ XBT_PUBLIC void* sg_host_extension_get(sg_host_t host, size_t rank);
 XBT_PUBLIC sg_host_t sg_host_by_name(const char* name);
 
 /** @brief Return the name of the #sg_host_t. */
-XBT_PUBLIC const char* sg_host_get_name(sg_host_t host);
+XBT_PUBLIC const char* sg_host_get_name(const_sg_host_t host);
 
 // ========== User Data ==============
 /** @brief Return the user data of a #sg_host_t.
  *
  * This functions returns the user data associated to @a host if any.
  */
-XBT_PUBLIC void* sg_host_data(sg_host_t host);
+XBT_PUBLIC void* sg_host_data(const_sg_host_t host);
 XBT_ATTRIB_DEPRECATED_v328("Please use sg_host_data()") XBT_PUBLIC void* sg_host_user(sg_host_t host);
 /** @brief Set the user data of a #sg_host_t.
  *
@@ -71,39 +71,43 @@ XBT_PUBLIC xbt_dict_t sg_host_get_mounted_storage_list(sg_host_t host);
  * @param host a host
  * @return a dynar containing all storages (name) attached to the host
  */
-XBT_PUBLIC xbt_dynar_t sg_host_get_attached_storage_list(sg_host_t host);
+XBT_PUBLIC xbt_dynar_t sg_host_get_attached_storage_list(const_sg_host_t host);
 
 // =========== user-level functions ===============
 /** @brief Return the speed of the processor (in flop/s), regardless of the current load on the machine. */
-XBT_PUBLIC double sg_host_speed(sg_host_t host);
-XBT_PUBLIC double sg_host_get_pstate_speed(sg_host_t host, int pstate_index);
+XBT_PUBLIC double sg_host_speed(const_sg_host_t host);
+XBT_PUBLIC double sg_host_get_pstate_speed(const_sg_host_t host, int pstate_index);
 
-XBT_PUBLIC double sg_host_get_available_speed(sg_host_t host);
+XBT_PUBLIC double sg_host_get_available_speed(const_sg_host_t host);
 
-XBT_PUBLIC int sg_host_core_count(sg_host_t host);
+XBT_PUBLIC int sg_host_core_count(const_sg_host_t host);
 
 /** @brief Returns the current computation load (in flops per second).
  * @param host a host
  */
-XBT_PUBLIC double sg_host_load(sg_host_t host);
+XBT_PUBLIC double sg_host_load(const_sg_host_t host);
 
 /** @brief Return the location on which the current process is running. */
 XBT_PUBLIC sg_host_t sg_host_self();
 
 XBT_PUBLIC const char* sg_host_self_get_name();
 
-/** @brief Return the total count of pstates defined for a host. See also @ref plugin_energy.
+/** @brief Return the total count of pstates defined for a host.
+ *
+ * @beginrst
+ * See also :ref:`plugin_host_energy`.
+ * @endrst
  *
  * @param  host host to test
  */
-XBT_PUBLIC int sg_host_get_nb_pstates(sg_host_t host);
+XBT_PUBLIC int sg_host_get_nb_pstates(const_sg_host_t host);
 
-XBT_PUBLIC int sg_host_get_pstate(sg_host_t host);
+XBT_PUBLIC int sg_host_get_pstate(const_sg_host_t host);
 XBT_PUBLIC void sg_host_set_pstate(sg_host_t host, int pstate);
 
 XBT_PUBLIC void sg_host_turn_on(sg_host_t host);
 XBT_PUBLIC void sg_host_turn_off(sg_host_t host);
-XBT_PUBLIC int sg_host_is_on(sg_host_t host);
+XBT_PUBLIC int sg_host_is_on(const_sg_host_t host);
 
 /** @ingroup m_host_management
  * @brief Returns a xbt_dict_t consisting of the list of properties assigned to this host
@@ -111,7 +115,7 @@ XBT_PUBLIC int sg_host_is_on(sg_host_t host);
  * @param host a host
  * @return a dict containing the properties
  */
-XBT_PUBLIC xbt_dict_t sg_host_get_properties(sg_host_t host);
+XBT_PUBLIC xbt_dict_t sg_host_get_properties(const_sg_host_t host);
 
 /** @ingroup m_host_management
  * @brief Returns the value of a given host property
@@ -120,7 +124,7 @@ XBT_PUBLIC xbt_dict_t sg_host_get_properties(sg_host_t host);
  * @param name a property name
  * @return value of a property (or nullptr if property not set)
  */
-XBT_PUBLIC const char* sg_host_get_property_value(sg_host_t host, const char* name);
+XBT_PUBLIC const char* sg_host_get_property_value(const_sg_host_t host, const char* name);
 
 /** @ingroup m_host_management
  * @brief Change the value of a given host property
@@ -131,14 +135,14 @@ XBT_PUBLIC const char* sg_host_get_property_value(sg_host_t host, const char* na
  */
 XBT_PUBLIC void sg_host_set_property_value(sg_host_t host, const char* name, const char* value);
 
-XBT_PUBLIC void sg_host_route(sg_host_t from, sg_host_t to, xbt_dynar_t links);
-XBT_PUBLIC double sg_host_route_latency(sg_host_t from, sg_host_t to);
-XBT_PUBLIC double sg_host_route_bandwidth(sg_host_t from, sg_host_t to);
+XBT_PUBLIC void sg_host_route(const_sg_host_t from, const_sg_host_t to, xbt_dynar_t links);
+XBT_PUBLIC double sg_host_route_latency(const_sg_host_t from, const_sg_host_t to);
+XBT_PUBLIC double sg_host_route_bandwidth(const_sg_host_t from, const_sg_host_t to);
 void sg_host_send_to(sg_host_t from, sg_host_t to, double byte_amount);
 
-XBT_PUBLIC void sg_host_dump(sg_host_t ws);
+XBT_PUBLIC void sg_host_dump(const_sg_host_t ws);
 
-XBT_PUBLIC void sg_host_get_actor_list(sg_host_t host, xbt_dynar_t whereto);
+XBT_PUBLIC void sg_host_get_actor_list(const_sg_host_t host, xbt_dynar_t whereto);
 SG_END_DECL
 
 #endif /* SIMGRID_HOST_H_ */
index 211df99..5c8ddd2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -76,10 +76,6 @@ XBT_PUBLIC void TRACE_host_set_state(const char* host, const char* state, const
 XBT_PUBLIC void TRACE_host_push_state(const char* host, const char* state, const char* value);
 XBT_PUBLIC void TRACE_host_pop_state(const char* host, const char* state);
 
-/* for creating graph configuration files for Viva by hand */
-XBT_PUBLIC xbt_dynar_t TRACE_get_node_types();
-XBT_PUBLIC xbt_dynar_t TRACE_get_edge_types();
-
 SG_END_DECL
 
 #endif                          /* INSTR_H_ */
index 007c970..55b84eb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -8,6 +8,7 @@
 
 #include <simgrid/jedule/jedule_events.hpp>
 #include <simgrid/jedule/jedule_platform.hpp>
+#include <simgrid/s4u/Engine.hpp>
 
 #include <cstdio>
 
@@ -15,20 +16,23 @@ namespace simgrid {
 namespace jedule{
 
 class XBT_PUBLIC Jedule {
-public:
-  explicit Jedule(const std::string& name) : root_container_(name) {}
+  std::unordered_map<char*, char*> meta_info_;
   std::vector<Event> event_set_;
   Container root_container_;
+
+public:
+  explicit Jedule(const std::string& name) : root_container_(name)
+  {
+    root_container_.create_hierarchy(s4u::Engine::get_instance()->get_netzone_root());
+  }
   void add_meta_info(char* key, char* value);
+  void add_event(const Event& event);
   void cleanup_output();
   void write_output(FILE* file);
-
-private:
-  std::unordered_map<char*, char*> meta_info_;
 };
 
-}
-}
+} // namespace jedule
+} // namespace simgrid
 
 typedef simgrid::jedule::Jedule *jedule_t;
 
index 5af7f4e..e7987cb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -23,7 +23,7 @@ public:
       : name_(name), start_time_(start_time), end_time_(end_time), type_(type)
   {
   }
-  void add_characteristic(char* characteristic);
+  void add_characteristic(const char* characteristic);
   void add_resources(const std::vector<sg_host_t>& host_selection);
   void add_info(char* key, char* value);
   void print(FILE* file) const;
index cf5b0e0..9079e9e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -7,7 +7,6 @@
 #define JED_SIMGRID_PLATFORM_H_
 
 #include <simgrid/forward.h>
-#include <xbt/dynar.h>
 
 #include <memory>
 #include <string>
 namespace simgrid {
 namespace jedule{
 class XBT_PUBLIC Container {
+  int last_id_ = 0;
+  std::string name;
+  std::unordered_map<const char*, unsigned int> name2id;
+  Container* parent_ = nullptr;
+  std::vector<std::unique_ptr<Container>> children_;
+  std::vector<sg_host_t> resource_list;
+
 public:
   explicit Container(const std::string& name);
   Container(const Container&) = delete;
   Container& operator=(const Container&) = delete;
 
-private:
-  int last_id_;
-  int is_lowest_ = 0;
+  const char* get_cname() const { return name.c_str(); }
+  void set_parent(Container* parent) { parent_ = parent; }
+  bool has_children() { return not children_.empty(); }
+  int get_child_position(const Container* child) const;
+  unsigned int get_id_by_name(const char* name) { return name2id.at(name); }
 
-public:
-  std::string name;
-  std::unordered_map<const char*, unsigned int> name2id;
-  Container *parent = nullptr;
-  std::vector<std::unique_ptr<Container>> children;
-  std::vector<sg_host_t> resource_list;
   void add_child(Container* child);
   void add_resources(std::vector<sg_host_t> hosts);
-  void create_hierarchy(sg_netzone_t from_as);
+  void create_hierarchy(const_sg_netzone_t from_as);
   std::vector<int> get_hierarchy();
   std::string get_hierarchy_as_string();
   void print(FILE *file);
@@ -49,8 +51,8 @@ public:
   Container *parent;
 };
 
-}
-}
+} // namespace jedule
+} // namespace simgrid
 typedef simgrid::jedule::Container * jed_container_t;
 void get_resource_selection_by_hosts(std::vector<simgrid::jedule::Subset>& subset_list,
                                      const std::vector<sg_host_t>& host_list);
index c570bfc..359dc22 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -9,7 +9,7 @@
 #include <simgrid/simdag.h>
 
 SG_BEGIN_DECL
-XBT_PUBLIC void jedule_log_sd_event(SD_task_t task);
+XBT_PUBLIC void jedule_log_sd_event(const_SD_task_t task);
 XBT_PUBLIC void jedule_sd_init(void);
 XBT_PUBLIC void jedule_sd_exit(void);
 XBT_PUBLIC void jedule_sd_dump(const char* filename);
index 7b2941e..7a1a1d3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team.
+/* Copyright (c) 2016-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -142,7 +142,6 @@ private:
 template<class T>
 class FutureState : public FutureStateBase {
 public:
-
   void set_value(T value)
   {
     if (this->get_status() != FutureStatus::not_ready)
@@ -446,17 +445,13 @@ template <class T> Future<T> unwrap_future(Future<Future<T>> future)
 template<class T>
 class Promise {
 public:
-  Promise() : state_(std::make_shared<FutureState<T>>()) {}
+  Promise() = default;
   explicit Promise(std::shared_ptr<FutureState<T>> state) : state_(std::move(state)) {}
 
   // Move type
   Promise(Promise const&) = delete;
   Promise& operator=(Promise const&) = delete;
-  Promise(Promise&& that) :
-    state_(std::move(that.state_)), future_get_(that.future_get_)
-  {
-    that.future_get_ = false;
-  }
+  Promise(Promise&& that) : state_(std::move(that.state_)) { std::swap(future_get_, that.future_get_); }
 
   Promise& operator=(Promise&& that)
   {
@@ -494,14 +489,14 @@ public:
   }
 
 private:
-  std::shared_ptr<FutureState<T>> state_;
+  std::shared_ptr<FutureState<T>> state_{new FutureState<T>()};
   bool future_get_ = false;
 };
 
 template<>
 class Promise<void> {
 public:
-  Promise() : state_(std::make_shared<FutureState<void>>()) {}
+  Promise() = default;
   explicit Promise(std::shared_ptr<FutureState<void>> state) : state_(std::move(state)) {}
   ~Promise()
   {
@@ -513,11 +508,7 @@ public:
   // Move type
   Promise(Promise const&) = delete;
   Promise& operator=(Promise const&) = delete;
-  Promise(Promise&& that) :
-    state_(std::move(that.state_)), future_get_(that.future_get_)
-  {
-    that.future_get_ = false;
-  }
+  Promise(Promise&& that) : state_(std::move(that.state_)) { std::swap(future_get_, that.future_get_); }
   Promise& operator=(Promise&& that)
   {
     this->state_ = std::move(that.state_);
@@ -549,7 +540,7 @@ public:
   }
 
 private:
-  std::shared_ptr<FutureState<void>> state_;
+  std::shared_ptr<FutureState<void>> state_{new FutureState<void>()};
   bool future_get_ = false;
 };
 
index 00ae0df..a8f2177 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -20,12 +20,12 @@ namespace simgrid {
 namespace kernel {
 namespace resource {
 
-typedef std::pair<double, simgrid::kernel::resource::Action*> heap_element_type;
+typedef std::pair<double, Action*> heap_element_type;
 typedef boost::heap::pairing_heap<heap_element_type, boost::heap::constant_time_size<false>, boost::heap::stable<true>,
                                   boost::heap::compare<simgrid::xbt::HeapComparator<heap_element_type>>>
     heap_type;
 
-typedef std::pair<double, simgrid::kernel::resource::Action*> heap_element_type;
+typedef std::pair<double, Action*> heap_element_type;
 class XBT_PUBLIC ActionHeap : public heap_type {
   friend Action;
 
@@ -207,7 +207,7 @@ public:
   /** @brief Get the state set in which the action is */
   StateSet* get_state_set() const { return state_set_; };
 
-  simgrid::kernel::resource::Model* get_model() const { return model_; }
+  Model* get_model() const { return model_; }
 
 private:
   StateSet* state_set_;
@@ -221,14 +221,14 @@ private:
   std::string category_;     /**< tracing category for categorized resource utilization monitoring */
 
   double cost_;
-  simgrid::kernel::resource::Model* model_;
+  Model* model_;
   void* data_                       = nullptr; /**< for your convenience */
   activity::ActivityImpl* activity_ = nullptr;
 
   /* LMM */
-  double last_update_                                = 0;
-  double last_value_                                 = 0;
-  kernel::lmm::Variable* variable_                   = nullptr;
+  double last_update_      = 0;
+  double last_value_       = 0;
+  lmm::Variable* variable_ = nullptr;
 
   ActionHeap::Type type_                              = ActionHeap::Type::unset;
   boost::optional<ActionHeap::handle_type> heap_hook_ = boost::none;
index ee23a15..63c2542 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -34,6 +34,8 @@ public:
 
   virtual ~Model();
 
+  bool is_update_lazy() { return update_algorithm_ == UpdateAlgo::LAZY; }
+
   /** @brief Get the set of [actions](@ref Action) in *inited* state */
   Action::StateSet* get_inited_action_set() { return &inited_action_set_; }
 
@@ -59,7 +61,10 @@ public:
   void set_maxmin_system(lmm::System* system);
 
   /** @brief Get the update algorithm of the current Model */
-  UpdateAlgo get_update_algorithm() const { return update_algorithm_; }
+  XBT_ATTRIB_DEPRECATED_v329("Please use is_update_lazy()") UpdateAlgo get_update_algorithm() const
+  {
+    return update_algorithm_;
+  }
 
   /** @brief Get Action heap */
   ActionHeap& get_action_heap() { return action_heap_; }
index 9f2c97b..f2b4fc1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -22,6 +22,20 @@ namespace resource {
  * @details This is the ancestor class of every resources in SimGrid, such as links, CPU or storage
  */
 class XBT_PUBLIC Resource {
+  std::string name_;
+  Model* model_;
+  bool is_on_ = true;
+
+  lmm::Constraint* const constraint_;
+
+protected:
+  struct Metric {
+    double peak;           /**< The peak of the metric, ie its max value */
+    double scale;          /**< Current availability of the metric according to the profiles, in [0,1] */
+    profile::Event* event; /**< The associated profile event associated to the metric */
+  };
+  profile::Event* state_event_ = nullptr;
+
 public:
   /**
    * @brief Constructor of LMM Resources
@@ -35,7 +49,7 @@ public:
   {
   }
 
-  virtual ~Resource();
+  virtual ~Resource() = default;
 
   /** @brief Get the Model of the current Resource */
   Model* get_model() const { return model_; }
@@ -67,27 +81,8 @@ public:
   /** @brief setup the profile file with states events (ON or OFF). The profile must contain boolean values. */
   virtual void set_state_profile(profile::Profile* profile);
 
-private:
-  std::string name_;
-  Model* model_;
-  bool is_on_ = true;
-
-public: /* LMM */
   /** @brief Get the lmm constraint associated to this Resource if it is part of a LMM component (or null if none) */
   lmm::Constraint* get_constraint() const { return constraint_; }
-
-private:
-  kernel::lmm::Constraint* const constraint_;
-
-public:
-  profile::Event* state_event_ = nullptr;
-
-protected:
-  struct Metric {
-    double peak;       /**< The peak of the metric, ie its max value */
-    double scale;      /**< Current availability of the metric according to the profiles, in [0,1] */
-    profile::Event* event; /**< The associated profile event associated to the metric */
-  };
 };
 } // namespace resource
 } // namespace kernel
index e342aca..e8e72c1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -70,7 +70,7 @@ public:
   explicit ClusterZone(NetZoneImpl* father, const std::string& name, resource::NetworkModel* netmodel);
 
   void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override;
-  void get_graph(xbt_graph_t graph, std::map<std::string, xbt_node_t>* nodes,
+  void get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t>* nodes,
                  std::map<std::string, xbt_edge_t>* edges) override;
 
   virtual void create_links_for_node(ClusterCreationArgs* cluster, int id, int rank, unsigned int position);
index c7a2cc8..b4d5258 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -23,19 +23,22 @@ namespace routing {
  * long path resolution times.
  */
 class XBT_PRIVATE DijkstraZone : public RoutedZone {
-public:
-  DijkstraZone(NetZoneImpl* father, const std::string& name, resource::NetworkModel* netmodel, bool cached);
-  DijkstraZone(const DijkstraZone&) = delete;
-  DijkstraZone& operator=(const DijkstraZone&) = delete;
+private:
+  static void route_graph_delete(xbt_graph_t);
 
-  ~DijkstraZone() override;
+  std::unique_ptr<s_xbt_graph_t, decltype(&DijkstraZone::route_graph_delete)> route_graph_{
+      xbt_graph_new_graph(1, nullptr), &DijkstraZone::route_graph_delete};
+  std::map<int, xbt_node_t> graph_node_map_;
+  bool cached_;
+  std::map<int, std::vector<int>> route_cache_;
 
-private:
   xbt_node_t route_graph_new_node(int id);
   xbt_node_t node_map_search(int id);
   void new_edge(int src_id, int dst_id, RouteCreationArgs* e_route);
 
 public:
+  DijkstraZone(NetZoneImpl* father, const std::string& name, resource::NetworkModel* netmodel, bool cached);
+
   /* For each vertex (node) already in the graph,
    * make sure it also has a loopback link; this loopback
    * can potentially already be in the graph, and in that
@@ -51,11 +54,6 @@ public:
   void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat) override;
   void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
                  std::vector<resource::LinkImpl*>& link_list, bool symmetrical) override;
-
-  xbt_graph_t route_graph_ = nullptr;          /* xbt_graph */
-  std::map<int, xbt_node_t> graph_node_map_;   /* map */
-  bool cached_;                                /* cache mode */
-  std::map<int, std::vector<int>> route_cache_; /* use in cache mode */
 };
 } // namespace routing
 } // namespace kernel
index 25dd2ba..adde19c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 63a62ff..8255827 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -29,7 +29,7 @@ public:
     /* There can't be route in an Empty zone */
   }
 
-  void get_graph(xbt_graph_t graph, std::map<std::string, xbt_node_t>* /*nodes*/,
+  void get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t>* /*nodes*/,
                  std::map<std::string, xbt_edge_t>* /*edges*/) override;
 };
 } // namespace routing
index 0e69e0d..ebf200b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -51,7 +51,7 @@ public:
    * instead of passing by an upper level switch.
    */
   resource::LinkImpl* loopback;
-  FatTreeNode(ClusterCreationArgs* cluster, int id, int level, int position);
+  FatTreeNode(const ClusterCreationArgs* cluster, int id, int level, int position);
 };
 
 /** @brief Link in a fat tree (@ref FatTreeZone).
@@ -61,7 +61,7 @@ public:
  */
 class FatTreeLink {
 public:
-  FatTreeLink(ClusterCreationArgs* cluster, FatTreeNode* source, FatTreeNode* destination);
+  FatTreeLink(const ClusterCreationArgs* cluster, FatTreeNode* source, FatTreeNode* destination);
   /** Link going up in the tree */
   resource::LinkImpl* up_link_;
   /** Link going down in the tree */
index b16ea00..9a57778 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -35,9 +35,9 @@ public:
 
 private:
   /* vars to compute the Floyd algorithm. */
-  int* predecessor_table_;
-  double* cost_table_;
-  RouteCreationArgs** link_table_;
+  int* predecessor_table_         = nullptr;
+  double* cost_table_             = nullptr;
+  RouteCreationArgs** link_table_ = nullptr;
 };
 } // namespace routing
 } // namespace kernel
index d15c74e..16631b4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 0b239f7..bddc556 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -13,6 +13,9 @@
 #include <simgrid/kernel/routing/NetZoneImpl.hpp>
 
 namespace simgrid {
+
+extern template class XBT_PUBLIC xbt::Extendable<kernel::routing::NetPoint>;
+
 namespace kernel {
 namespace routing {
 
index 4c48344..66c9790 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.               */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.               */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 namespace simgrid {
 namespace kernel {
 namespace routing {
-class BypassRoute;
+
+class BypassRoute {
+public:
+  explicit BypassRoute(NetPoint* gwSrc, NetPoint* gwDst) : gw_src(gwSrc), gw_dst(gwDst) {}
+  NetPoint* gw_src;
+  NetPoint* gw_dst;
+  std::vector<resource::LinkImpl*> links;
+};
 
 /** @ingroup ROUTING_API
  *  @brief Private implementation of the Networking Zones
@@ -50,6 +57,18 @@ class BypassRoute;
  */
 class XBT_PUBLIC NetZoneImpl : public xbt::PropertyHolder {
   friend EngineImpl; // it destroys netRoot_
+  s4u::NetZone piface_;
+
+  // our content, as known to our graph routing algorithm (maps vertex_id -> vertex)
+  std::vector<kernel::routing::NetPoint*> vertices_;
+
+  NetZoneImpl* father_ = nullptr;
+  std::vector<NetZoneImpl*> children_; // sub-netzones
+  std::string name_;
+  bool sealed_ = false; // We cannot add more content when sealed
+
+  std::map<std::pair<NetPoint*, NetPoint*>, BypassRoute*> bypass_routes_; // src x dst -> route
+  routing::NetPoint* netpoint_ = nullptr;                                 // Our representative in the father NetZone
 
 protected:
   explicit NetZoneImpl(NetZoneImpl* father, const std::string& name, resource::NetworkModel* network_model);
@@ -57,24 +76,6 @@ protected:
   NetZoneImpl& operator=(const NetZoneImpl&) = delete;
   virtual ~NetZoneImpl();
 
-public:
-  s4u::NetZone* get_iface() { return &piface_; }
-
-  /** @brief Make a host within that NetZone */
-  s4u::Host* create_host(const std::string& name, const std::vector<double>& speed_per_pstate, int core_count,
-                         const std::map<std::string, std::string>* props);
-  /** @brief Creates a new route in this NetZone */
-  virtual void add_bypass_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
-                                std::vector<resource::LinkImpl*>& link_list, bool symmetrical);
-
-  /** @brief Seal your netzone once you're done adding content, and before routing stuff through it */
-  virtual void seal();
-  virtual int add_component(kernel::routing::NetPoint* elm); /* A host, a router or a netzone, whatever */
-  virtual void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
-                         kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
-                         std::vector<kernel::resource::LinkImpl*>& link_list, bool symmetrical);
-
-protected:
   /**
    * @brief Probe the routing path between two points that are local to the called NetZone.
    *
@@ -90,39 +91,46 @@ protected:
                         /* OUT */ std::vector<resource::LinkImpl*>& links, double* latency);
 
 public:
-  resource::NetworkModel* network_model_;
-
-private:
-  s4u::NetZone piface_;
-
-  // our content, as known to our graph routing algorithm (maps vertex_id -> vertex)
-  std::vector<kernel::routing::NetPoint*> vertices_;
+  enum class RoutingMode {
+    unset = 0, /**< Undefined type                                   */
+    base,      /**< Base case: use simple link lists for routing     */
+    recursive  /**< Recursive case: also return gateway information  */
+  };
 
-  NetZoneImpl* father_ = nullptr;
+  /* FIXME: protect the following fields once the construction madness is sorted out */
+  RoutingMode hierarchy_ = RoutingMode::unset;
 
-  std::vector<NetZoneImpl*> children_; // sub-netzones
+  resource::NetworkModel* network_model_;
 
-public:
+  s4u::NetZone* get_iface() { return &piface_; }
   unsigned int get_table_size() { return vertices_.size(); }
   std::vector<kernel::routing::NetPoint*> get_vertices() { return vertices_; }
-
-  NetZoneImpl* get_father();
-
-  std::vector<NetZoneImpl*>* get_children(); // Sub netzones
-
-private:
-  std::string name_;
-  bool sealed_ = false; // We cannot add more content when sealed
-
-public:
+  NetZoneImpl* get_father() { return father_; }
+  /** @brief Returns the list of direct children (no grand-children). This returns the internal data, no copy.
+   * Don't mess with it.*/
+  std::vector<NetZoneImpl*>* get_children() { return &children_; }
   /** @brief Retrieves the name of that netzone as a C++ string */
   const std::string& get_name() const { return name_; }
   /** @brief Retrieves the name of that netzone as a C string */
-  const char* get_cname() const;
+  const char* get_cname() const { return name_.c_str(); };
 
   std::vector<s4u::Host*> get_all_hosts();
   int get_host_count();
 
+  /** @brief Make a host within that NetZone */
+  s4u::Host* create_host(const std::string& name, const std::vector<double>& speed_per_pstate, int core_count,
+                         const std::map<std::string, std::string>* props);
+  /** @brief Creates a new route in this NetZone */
+  virtual void add_bypass_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
+                                std::vector<resource::LinkImpl*>& link_list, bool symmetrical);
+
+  /** @brief Seal your netzone once you're done adding content, and before routing stuff through it */
+  virtual void seal() { sealed_ = true; };
+  virtual int add_component(kernel::routing::NetPoint* elm); /* A host, a router or a netzone, whatever */
+  virtual void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
+                         kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
+                         std::vector<kernel::resource::LinkImpl*>& link_list, bool symmetrical);
+
   /* @brief get the route between two nodes in the full platform
    *
    * @param src where from
@@ -133,19 +141,8 @@ public:
   static void get_global_route(routing::NetPoint* src, routing::NetPoint* dst,
                                /* OUT */ std::vector<resource::LinkImpl*>& links, double* latency);
 
-  virtual void get_graph(xbt_graph_t graph, std::map<std::string, xbt_node_t>* nodes,
+  virtual void get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t>* nodes,
                          std::map<std::string, xbt_edge_t>* edges) = 0;
-  enum class RoutingMode {
-    unset = 0, /**< Undefined type                                   */
-    base,      /**< Base case: use simple link lists for routing     */
-    recursive  /**< Recursive case: also return gateway information  */
-  };
-  /* FIXME: protect the following fields once the construction madness is sorted out */
-  RoutingMode hierarchy_ = RoutingMode::unset;
-
-private:
-  std::map<std::pair<NetPoint*, NetPoint*>, BypassRoute*> bypass_routes_; // src x dst -> route
-  routing::NetPoint* netpoint_ = nullptr;                                // Our representative in the father NetZone
 };
 } // namespace routing
 } // namespace kernel
index 55995aa..27ff684 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -52,7 +52,7 @@ class XBT_PRIVATE RoutedZone : public NetZoneImpl {
 public:
   explicit RoutedZone(NetZoneImpl* father, const std::string& name, resource::NetworkModel* netmodel);
 
-  void get_graph(xbt_graph_t graph, std::map<std::string, xbt_node_t>* nodes,
+  void get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t>* nodes,
                  std::map<std::string, xbt_edge_t>* edges) override;
 
 protected:
@@ -61,15 +61,15 @@ protected:
                                                 bool symmetrical, bool change_order);
   void get_route_check_params(NetPoint* src, NetPoint* dst);
   void add_route_check_params(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
-                              std::vector<resource::LinkImpl*>& link_list, bool symmetrical);
+                              const std::vector<resource::LinkImpl*>& link_list, bool symmetrical);
 };
 } // namespace routing
 } // namespace kernel
 } // namespace simgrid
 
-XBT_PRIVATE xbt_node_t new_xbt_graph_node(xbt_graph_t graph, const char* name,
+XBT_PRIVATE xbt_node_t new_xbt_graph_node(const s_xbt_graph_t* graph, const char* name,
                                           std::map<std::string, xbt_node_t>* nodes);
-XBT_PRIVATE xbt_edge_t new_xbt_graph_edge(xbt_graph_t graph, xbt_node_t s, xbt_node_t d,
+XBT_PRIVATE xbt_edge_t new_xbt_graph_edge(const s_xbt_graph_t* graph, xbt_node_t s, xbt_node_t d,
                                           std::map<std::string, xbt_edge_t>* edges);
 
 #endif /* SIMGRID_ROUTING_GENERIC_HPP_ */
index 3868b2f..f4a6880 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 38c89db..aa9cffb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -55,7 +55,7 @@ public:
 namespace vivaldi {
 class XBT_PRIVATE Coords {
 public:
-  static simgrid::xbt::Extension<NetPoint, Coords> EXTENSION_ID;
+  static xbt::Extension<NetPoint, Coords> EXTENSION_ID;
   explicit Coords(NetPoint* host, const std::string& str);
   virtual ~Coords() = default;
 
index 2664a53..4c4cf86 100644 (file)
@@ -1,6 +1,6 @@
 /* Public interface to the Link datatype                                    */
 
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* C interface */
 SG_BEGIN_DECL
-XBT_PUBLIC const char* sg_link_name(sg_link_t link);
+XBT_PUBLIC const char* sg_link_name(const_sg_link_t link);
 XBT_PUBLIC sg_link_t sg_link_by_name(const char* name);
-XBT_PUBLIC int sg_link_is_shared(sg_link_t link);
-XBT_PUBLIC double sg_link_bandwidth(sg_link_t link);
-XBT_PUBLIC double sg_link_latency(sg_link_t link);
-XBT_PUBLIC void* sg_link_data(sg_link_t link);
+XBT_PUBLIC int sg_link_is_shared(const_sg_link_t link);
+XBT_PUBLIC double sg_link_bandwidth(const_sg_link_t link);
+XBT_PUBLIC double sg_link_latency(const_sg_link_t link);
+XBT_PUBLIC void* sg_link_data(const_sg_link_t link);
 XBT_PUBLIC void sg_link_data_set(sg_link_t link, void* data);
 XBT_PUBLIC int sg_link_count();
 XBT_PUBLIC sg_link_t* sg_link_list();
index a21900a..d3ed4c6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index b4eb10c..6138567 100644 (file)
@@ -1,6 +1,6 @@
 /* simgrid/modelchecker.h - Formal Verification made possible in SimGrid    */
 
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index aa2f024..70bc569 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -39,17 +39,10 @@ class Task;
 }
 }
 typedef simgrid::msg::Comm sg_msg_Comm;
-/** @brief Task datatype.
- *
- *  Since most scheduling algorithms rely on a concept of task  that can be either <em>computed</em> locally or
- *  <em>transferred</em> on another processor, it seems to be the right level of abstraction for our purposes.
- *  A <em>task</em> may then be defined by a <em>computing amount</em>, a <em>message size</em> and
- *  some <em>private data</em>.
- */
-typedef simgrid::msg::Task* msg_task_t;
+typedef simgrid::msg::Task sg_msg_Task;
 #else
 typedef struct msg_Comm sg_msg_Comm;
-typedef struct msg_Task* msg_task_t;
+typedef struct msg_Task sg_msg_Task;
 #endif
 
 #ifdef __cplusplus
@@ -74,12 +67,12 @@ typedef enum {
 typedef sg_netzone_t msg_netzone_t;
 
 XBT_PUBLIC msg_netzone_t MSG_zone_get_root();
-XBT_PUBLIC const char* MSG_zone_get_name(msg_netzone_t zone);
+XBT_PUBLIC const char* MSG_zone_get_name(const_sg_netzone_t zone);
 XBT_PUBLIC msg_netzone_t MSG_zone_get_by_name(const char* name);
-XBT_PUBLIC void MSG_zone_get_sons(msg_netzone_t zone, xbt_dict_t whereto);
-XBT_PUBLIC const char* MSG_zone_get_property_value(msg_netzone_t zone, const char* name);
-XBT_PUBLIC void MSG_zone_set_property_value(msg_netzone_t zone, const char* name, char* value);
-XBT_PUBLIC void MSG_zone_get_hosts(msg_netzone_t zone, xbt_dynar_t whereto);
+XBT_PUBLIC void MSG_zone_get_sons(const_sg_netzone_t zone, xbt_dict_t whereto);
+XBT_PUBLIC const char* MSG_zone_get_property_value(const_sg_netzone_t zone, const char* name);
+XBT_PUBLIC void MSG_zone_set_property_value(msg_netzone_t zone, const char* name, const char* value);
+XBT_PUBLIC void MSG_zone_get_hosts(const_sg_netzone_t zone, xbt_dynar_t whereto);
 
 /* ******************************** Hosts ************************************ */
 /** @brief Host datatype.
@@ -105,40 +98,44 @@ XBT_PUBLIC size_t MSG_get_host_number();
 XBT_PUBLIC xbt_dynar_t MSG_hosts_as_dynar();
 
 /** @brief Returns the name of this host */
-XBT_PUBLIC const char* MSG_host_get_name(sg_host_t host);
+XBT_PUBLIC const char* MSG_host_get_name(const_sg_host_t host);
 /** @brief Returns the user data of this host */
-XBT_PUBLIC void* MSG_host_get_data(sg_host_t host);
+XBT_PUBLIC void* MSG_host_get_data(const_sg_host_t host);
 /** @brief Sets the user data of this host */
 XBT_PUBLIC void MSG_host_set_data(sg_host_t host, void* data);
 XBT_PUBLIC xbt_dict_t MSG_host_get_mounted_storage_list(sg_host_t host);
-XBT_PUBLIC xbt_dynar_t MSG_host_get_attached_storage_lists(sg_host_t host);
-XBT_PUBLIC double MSG_host_get_speed(sg_host_t host);
-XBT_PUBLIC double MSG_host_get_power_peak_at(sg_host_t host, int pstate_index);
-XBT_PUBLIC int MSG_host_get_core_number(sg_host_t host);
-XBT_PUBLIC int MSG_host_get_nb_pstates(sg_host_t host);
-XBT_PUBLIC int MSG_host_get_pstate(sg_host_t host);
+XBT_PUBLIC xbt_dynar_t MSG_host_get_attached_storage_lists(const_sg_host_t host);
+XBT_PUBLIC double MSG_host_get_speed(const_sg_host_t host);
+XBT_PUBLIC double MSG_host_get_power_peak_at(const_sg_host_t host, int pstate_index);
+XBT_PUBLIC int MSG_host_get_core_number(const_sg_host_t host);
+XBT_PUBLIC int MSG_host_get_nb_pstates(const_sg_host_t host);
+XBT_PUBLIC int MSG_host_get_pstate(const_sg_host_t host);
 XBT_PUBLIC void MSG_host_set_pstate(sg_host_t host, int pstate);
 /** @brief Start the host if it is off
  *
- * See also #MSG_host_is_on() to test the current state of the host and @ref SURF_plugin_energy
+ * @beginrst
+ * See also :cpp:func:`MSG_host_is_on()` to test the current state of the host, and :ref:`plugin_host_energy`
  * for more info on DVFS.
+ * @endrst
  */
 XBT_PUBLIC void MSG_host_on(sg_host_t h);
 /** @brief Stop the host if it is on
  *
- * See also MSG_host_is_on() to test the current state of the host and @ref SURF_plugin_energy
+ * @beginrst
+ * See also :cpp:func:`MSG_host_is_on()` to test the current state of the host, and :ref:`plugin_host_energy`
  * for more info on DVFS.
+ * @endrst
  */
 XBT_PUBLIC void MSG_host_off(sg_host_t h);
-XBT_PUBLIC int MSG_host_is_on(sg_host_t h);
-XBT_PUBLIC xbt_dict_t MSG_host_get_properties(sg_host_t host);
-XBT_PUBLIC const char* MSG_host_get_property_value(sg_host_t host, const char* name);
+XBT_PUBLIC int MSG_host_is_on(const_sg_host_t h);
+XBT_PUBLIC xbt_dict_t MSG_host_get_properties(const_sg_host_t host);
+XBT_PUBLIC const char* MSG_host_get_property_value(const_sg_host_t host, const char* name);
 XBT_PUBLIC void MSG_host_set_property_value(sg_host_t host, const char* name, const char* value);
-XBT_PUBLIC void MSG_host_get_process_list(sg_host_t host, xbt_dynar_t whereto);
+XBT_PUBLIC void MSG_host_get_process_list(const_sg_host_t host, xbt_dynar_t whereto);
 
 /** @brief Return the location on which the current process is executed */
 XBT_PUBLIC sg_host_t MSG_host_self();
-XBT_PUBLIC double MSG_host_get_load(sg_host_t host);
+XBT_PUBLIC double MSG_host_get_load(const_sg_host_t host);
 
 /* ******************************** VMs ************************************* */
 typedef sg_vm_t msg_vm_t;
@@ -150,10 +147,10 @@ XBT_PUBLIC int MSG_vm_is_created(msg_vm_t vm);
 XBT_PUBLIC int MSG_vm_is_running(msg_vm_t vm);
 XBT_PUBLIC int MSG_vm_is_suspended(msg_vm_t vm);
 
-XBT_PUBLIC const char* MSG_vm_get_name(msg_vm_t vm);
+XBT_PUBLIC const char* MSG_vm_get_name(const_sg_vm_t vm);
 XBT_PUBLIC void MSG_vm_set_ramsize(msg_vm_t vm, size_t size);
-XBT_PUBLIC size_t MSG_vm_get_ramsize(msg_vm_t vm);
-XBT_PUBLIC msg_host_t MSG_vm_get_pm(msg_vm_t vm);
+XBT_PUBLIC size_t MSG_vm_get_ramsize(const_sg_vm_t vm);
+XBT_PUBLIC msg_host_t MSG_vm_get_pm(const_sg_vm_t vm);
 XBT_PUBLIC void MSG_vm_set_bound(msg_vm_t vm, double bound);
 
 XBT_PUBLIC void MSG_vm_start(msg_vm_t vm);
@@ -165,15 +162,15 @@ XBT_PUBLIC void MSG_vm_destroy(msg_vm_t vm);
 /* ******************************** Storage ********************************* */
 typedef sg_storage_t msg_storage_t;
 
-XBT_PUBLIC const char* MSG_storage_get_name(msg_storage_t storage);
+XBT_PUBLIC const char* MSG_storage_get_name(const_sg_storage_t storage);
 XBT_PUBLIC msg_storage_t MSG_storage_get_by_name(const char* name);
-XBT_PUBLIC xbt_dict_t MSG_storage_get_properties(msg_storage_t storage);
+XBT_PUBLIC xbt_dict_t MSG_storage_get_properties(const_sg_storage_t storage);
 XBT_PUBLIC void MSG_storage_set_property_value(msg_storage_t storage, const char* name, const char* value);
-XBT_PUBLIC const char* MSG_storage_get_property_value(msg_storage_t storage, const char* name);
+XBT_PUBLIC const char* MSG_storage_get_property_value(const_sg_storage_t storage, const char* name);
 XBT_PUBLIC xbt_dynar_t MSG_storages_as_dynar();
 XBT_PUBLIC void MSG_storage_set_data(msg_storage_t storage, void* data);
-XBT_PUBLIC void* MSG_storage_get_data(msg_storage_t storage);
-XBT_PUBLIC const char* MSG_storage_get_host(msg_storage_t storage);
+XBT_PUBLIC void* MSG_storage_get_data(const_sg_storage_t storage);
+XBT_PUBLIC const char* MSG_storage_get_host(const_sg_storage_t storage);
 XBT_PUBLIC sg_size_t MSG_storage_read(msg_storage_t storage, sg_size_t size);
 XBT_PUBLIC sg_size_t MSG_storage_write(msg_storage_t storage, sg_size_t size);
 
@@ -188,19 +185,19 @@ XBT_PUBLIC sg_size_t MSG_storage_write(msg_storage_t storage, sg_size_t size);
  */
 typedef sg_actor_t msg_process_t;
 
-XBT_PUBLIC int MSG_process_get_PID(msg_process_t process);
-XBT_PUBLIC int MSG_process_get_PPID(msg_process_t process);
+XBT_PUBLIC int MSG_process_get_PID(const_sg_actor_t process);
+XBT_PUBLIC int MSG_process_get_PPID(const_sg_actor_t process);
 /** @brief Return a process from its PID (or NULL if not found).
  *
  * Note that the PID are unique in the whole simulation, not only on a given host.
  */
 XBT_PUBLIC sg_actor_t MSG_process_from_PID(int pid);
-XBT_PUBLIC const char* MSG_process_get_name(msg_process_t process);
-XBT_PUBLIC sg_host_t MSG_process_get_host(msg_process_t process);
+XBT_PUBLIC const char* MSG_process_get_name(const_sg_actor_t process);
+XBT_PUBLIC sg_host_t MSG_process_get_host(const_sg_actor_t process);
 
 /*property handlers*/
-XBT_PUBLIC xbt_dict_t MSG_process_get_properties(msg_process_t process);
-XBT_PUBLIC const char* MSG_process_get_property_value(msg_process_t process, const char* name);
+XBT_PUBLIC xbt_dict_t MSG_process_get_properties(const_sg_actor_t process);
+XBT_PUBLIC const char* MSG_process_get_property_value(const_sg_actor_t process, const char* name);
 
 XBT_PUBLIC void MSG_process_suspend(msg_process_t process);
 XBT_PUBLIC void MSG_process_resume(msg_process_t process);
@@ -238,8 +235,8 @@ XBT_PUBLIC msg_process_t MSG_process_self();
 XBT_PUBLIC aid_t MSG_process_self_PID();
 XBT_PUBLIC aid_t MSG_process_self_PPID();
 XBT_PUBLIC const char* MSG_process_self_name();
-XBT_PUBLIC void MSG_process_ref(msg_process_t process);
-XBT_PUBLIC void MSG_process_unref(msg_process_t process);
+XBT_PUBLIC void MSG_process_ref(const_sg_actor_t process);
+XBT_PUBLIC void MSG_process_unref(const_sg_actor_t process);
 
 /** @brief Object representing an ongoing communication between processes.
  *
@@ -248,6 +245,17 @@ XBT_PUBLIC void MSG_process_unref(msg_process_t process);
  * \endrst
  */
 typedef sg_msg_Comm* msg_comm_t;
+typedef const sg_msg_Comm* const_msg_comm_t;
+
+/** @brief Task datatype.
+ *
+ *  Since most scheduling algorithms rely on a concept of task  that can be either <em>computed</em> locally or
+ *  <em>transferred</em> on another processor, it seems to be the right level of abstraction for our purposes.
+ *  A <em>task</em> may then be defined by a <em>computing amount</em>, a <em>message size</em> and
+ *  some <em>private data</em>.
+ */
+typedef sg_msg_Task* msg_task_t;
+typedef const sg_msg_Task* const_msg_task_t;
 
 /* ******************************** Task ************************************ */
 
@@ -258,8 +266,10 @@ typedef sg_msg_Comm* msg_comm_t;
 /************************** Global ******************************************/
 /** @brief set a configuration variable
  *
- * Do --help on any simgrid binary to see the list of currently existing configuration variables, and see Section @ref
- * options.
+ * @beginrst
+ * Do --help on any simgrid binary to see the list of currently existing configuration variables, and see Section
+ * :ref:`options`.
+ * @endrst
  *
  * Example:
  * MSG_config("host/model","ptask_L07");
@@ -331,7 +341,7 @@ XBT_PUBLIC void MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup);
 XBT_PUBLIC xbt_dynar_t MSG_processes_as_dynar();
 XBT_PUBLIC int MSG_process_get_number();
 
-XBT_PUBLIC void* MSG_process_get_data(msg_process_t process);
+XBT_PUBLIC void* MSG_process_get_data(const_sg_actor_t process);
 XBT_PUBLIC msg_error_t MSG_process_set_data(msg_process_t process, void* data);
 
 XBT_PUBLIC void MSG_process_on_exit(int_f_int_pvoid_t fun, void* data);
@@ -340,11 +350,11 @@ XBT_PUBLIC void MSG_process_on_exit(int_f_int_pvoid_t fun, void* data);
 XBT_PUBLIC msg_task_t MSG_task_create(const char* name, double flops_amount, double bytes_amount, void* data);
 XBT_PUBLIC msg_task_t MSG_parallel_task_create(const char* name, int host_nb, const msg_host_t* host_list,
                                                double* flops_amount, double* bytes_amount, void* data);
-XBT_PUBLIC void* MSG_task_get_data(msg_task_t task);
+XBT_PUBLIC void* MSG_task_get_data(const_msg_task_t task);
 XBT_PUBLIC void MSG_task_set_data(msg_task_t task, void* data);
-XBT_PUBLIC msg_process_t MSG_task_get_sender(msg_task_t task);
-XBT_PUBLIC msg_host_t MSG_task_get_source(msg_task_t task);
-XBT_PUBLIC const char* MSG_task_get_name(msg_task_t task);
+XBT_PUBLIC msg_process_t MSG_task_get_sender(const_msg_task_t task);
+XBT_PUBLIC msg_host_t MSG_task_get_source(const_msg_task_t task);
+XBT_PUBLIC const char* MSG_task_get_name(const_msg_task_t task);
 XBT_PUBLIC void MSG_task_set_name(msg_task_t task, const char* name);
 XBT_PUBLIC msg_error_t MSG_task_cancel(msg_task_t task);
 XBT_PUBLIC msg_error_t MSG_task_destroy(msg_task_t task);
@@ -356,12 +366,12 @@ XBT_PUBLIC void MSG_task_set_priority(msg_task_t task, double priority);
 XBT_PUBLIC void MSG_task_set_bound(msg_task_t task, double bound);
 
 XBT_PUBLIC void MSG_task_set_flops_amount(msg_task_t task, double flops_amount);
-XBT_PUBLIC double MSG_task_get_flops_amount(msg_task_t task);
-XBT_PUBLIC double MSG_task_get_remaining_work_ratio(msg_task_t task);
+XBT_PUBLIC double MSG_task_get_flops_amount(const_msg_task_t task);
+XBT_PUBLIC double MSG_task_get_remaining_work_ratio(const_msg_task_t task);
 XBT_PUBLIC void MSG_task_set_bytes_amount(msg_task_t task, double bytes_amount);
 
-XBT_PUBLIC double MSG_task_get_remaining_communication(msg_task_t task);
-XBT_PUBLIC double MSG_task_get_bytes_amount(msg_task_t task);
+XBT_PUBLIC double MSG_task_get_remaining_communication(const_msg_task_t task);
+XBT_PUBLIC double MSG_task_get_bytes_amount(const_msg_task_t task);
 
 XBT_PUBLIC msg_error_t MSG_task_receive_with_timeout(msg_task_t* task, const char* alias, double timeout);
 
@@ -381,13 +391,13 @@ XBT_PUBLIC void MSG_task_dsend_bounded(msg_task_t task, const char* alias, void_
 XBT_PUBLIC msg_comm_t MSG_task_irecv(msg_task_t* task, const char* alias);
 XBT_PUBLIC msg_comm_t MSG_task_irecv_bounded(msg_task_t* task, const char* alias, double rate);
 XBT_PUBLIC int MSG_comm_test(msg_comm_t comm);
-XBT_PUBLIC int MSG_comm_testany(xbt_dynar_t comms);
-XBT_PUBLIC void MSG_comm_destroy(msg_comm_t comm);
+XBT_PUBLIC int MSG_comm_testany(const_xbt_dynar_t comms);
+XBT_PUBLIC void MSG_comm_destroy(const_msg_comm_t comm);
 XBT_PUBLIC msg_error_t MSG_comm_wait(msg_comm_t comm, double timeout);
 XBT_PUBLIC void MSG_comm_waitall(msg_comm_t* comm, int nb_elem, double timeout);
-XBT_PUBLIC int MSG_comm_waitany(xbt_dynar_t comms);
-XBT_PUBLIC msg_task_t MSG_comm_get_task(msg_comm_t comm);
-XBT_PUBLIC msg_error_t MSG_comm_get_status(msg_comm_t comm);
+XBT_PUBLIC int MSG_comm_waitany(const_xbt_dynar_t comms);
+XBT_PUBLIC msg_task_t MSG_comm_get_task(const_msg_comm_t comm);
+XBT_PUBLIC msg_error_t MSG_comm_get_status(const_msg_comm_t comm);
 
 /** @brief Check if there is a communication going on in a mailbox.
  *
@@ -403,7 +413,7 @@ XBT_PUBLIC msg_error_t MSG_task_send(msg_task_t task, const char* alias);
 XBT_PUBLIC msg_error_t MSG_task_send_bounded(msg_task_t task, const char* alias, double rate);
 XBT_PUBLIC int MSG_task_listen_from(const char* alias);
 XBT_PUBLIC void MSG_task_set_category(msg_task_t task, const char* category);
-XBT_PUBLIC const char* MSG_task_get_category(msg_task_t task);
+XBT_PUBLIC const char* MSG_task_get_category(const_msg_task_t task);
 
 /************************** Mailbox handling ************************************/
 
@@ -423,7 +433,7 @@ XBT_PUBLIC void MSG_sem_acquire(msg_sem_t sem);
 XBT_PUBLIC int MSG_sem_acquire_timeout(msg_sem_t sem, double timeout);
 XBT_PUBLIC void MSG_sem_release(msg_sem_t sem);
 XBT_PUBLIC int MSG_sem_get_capacity(msg_sem_t sem);
-XBT_PUBLIC void MSG_sem_destroy(msg_sem_t sem);
+XBT_PUBLIC void MSG_sem_destroy(const_sg_sem_t sem);
 XBT_PUBLIC int MSG_sem_would_block(msg_sem_t sem);
 
 /** @brief Opaque type representing a barrier identifier */
@@ -431,7 +441,7 @@ typedef sg_bar_t msg_bar_t;
 /** @brief Initializes a barrier, with count elements */
 XBT_PUBLIC msg_bar_t MSG_barrier_init(unsigned int count);
 /** @brief Destroys barrier */
-XBT_PUBLIC void MSG_barrier_destroy(msg_bar_t bar);
+XBT_PUBLIC void MSG_barrier_destroy(const_sg_bar_t bar);
 /** @brief Performs a barrier already initialized */
 XBT_PUBLIC int MSG_barrier_wait(msg_bar_t bar);
 
index 29ca335..83b61b2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -14,7 +14,7 @@ XBT_PUBLIC sg_mutex_t sg_mutex_init();
 XBT_PUBLIC void sg_mutex_lock(sg_mutex_t mutex);
 XBT_PUBLIC void sg_mutex_unlock(sg_mutex_t mutex);
 XBT_PUBLIC int sg_mutex_try_lock(sg_mutex_t mutex);
-XBT_PUBLIC void sg_mutex_destroy(sg_mutex_t mutex);
+XBT_PUBLIC void sg_mutex_destroy(const_sg_mutex_t mutex);
 
 SG_END_DECL
 
index ba35740..3f7ed88 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team.
+/* Copyright (c) 2017-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 630d327..ea436c6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -13,16 +13,16 @@ SG_BEGIN_DECL
 
 XBT_PUBLIC void sg_host_energy_plugin_init();
 XBT_PUBLIC void sg_host_energy_update_all();
-XBT_PUBLIC double sg_host_get_consumed_energy(sg_host_t host);
-XBT_PUBLIC double sg_host_get_idle_consumption(sg_host_t host);
-XBT_PUBLIC double sg_host_get_idle_consumption_at(sg_host_t host, int pstate);
-XBT_PUBLIC double sg_host_get_wattmin_at(sg_host_t host, int pstate);
-XBT_PUBLIC double sg_host_get_wattmax_at(sg_host_t host, int pstate);
-XBT_PUBLIC double sg_host_get_power_range_slope_at(sg_host_t host, int pstate);
-XBT_PUBLIC double sg_host_get_current_consumption(sg_host_t host);
+XBT_PUBLIC double sg_host_get_consumed_energy(const_sg_host_t host);
+XBT_PUBLIC double sg_host_get_idle_consumption(const_sg_host_t host);
+XBT_PUBLIC double sg_host_get_idle_consumption_at(const_sg_host_t host, int pstate);
+XBT_PUBLIC double sg_host_get_wattmin_at(const_sg_host_t host, int pstate);
+XBT_PUBLIC double sg_host_get_wattmax_at(const_sg_host_t host, int pstate);
+XBT_PUBLIC double sg_host_get_power_range_slope_at(const_sg_host_t host, int pstate);
+XBT_PUBLIC double sg_host_get_current_consumption(const_sg_host_t host);
 
 XBT_PUBLIC void sg_link_energy_plugin_init();
-XBT_PUBLIC double sg_link_get_consumed_energy(sg_link_t link);
+XBT_PUBLIC double sg_link_get_consumed_energy(const_sg_link_t link);
 
 XBT_PUBLIC int sg_link_energy_is_inited();
 
index 179ab9f..6c92f19 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -16,7 +16,7 @@
 #include <map>
 #include <memory>
 #include <string>
-#endif
+#endif /* C++ */
 
 // C interface
 ////////////////
@@ -27,12 +27,12 @@ XBT_PUBLIC void sg_storage_file_system_init();
 XBT_PUBLIC sg_file_t sg_file_open(const char* fullpath, void* data);
 XBT_PUBLIC sg_size_t sg_file_read(sg_file_t fd, sg_size_t size);
 XBT_PUBLIC sg_size_t sg_file_write(sg_file_t fd, sg_size_t size);
-XBT_PUBLIC void sg_file_close(sg_file_t fd);
+XBT_PUBLIC void sg_file_close(const_sg_file_t fd);
 
 XBT_PUBLIC const char* sg_file_get_name(sg_file_t fd);
 XBT_PUBLIC sg_size_t sg_file_get_size(sg_file_t fd);
 XBT_PUBLIC void sg_file_dump(sg_file_t fd);
-XBT_PUBLIC void* sg_file_get_data(sg_file_t fd);
+XBT_PUBLIC void* sg_file_get_data(const_sg_file_t fd);
 XBT_PUBLIC void sg_file_set_data(sg_file_t fd, void* data);
 XBT_PUBLIC void sg_file_seek(sg_file_t fd, sg_offset_t offset, int origin);
 XBT_PUBLIC sg_size_t sg_file_tell(sg_file_t fd);
@@ -41,15 +41,15 @@ XBT_PUBLIC void sg_file_unlink(sg_file_t fd);
 XBT_PUBLIC int sg_file_rcopy(sg_file_t file, sg_host_t host, const char* fullpath);
 XBT_PUBLIC int sg_file_rmove(sg_file_t file, sg_host_t host, const char* fullpath);
 
-XBT_PUBLIC sg_size_t sg_disk_get_size_free(sg_disk_t d);
-XBT_PUBLIC sg_size_t sg_disk_get_size_used(sg_disk_t d);
-XBT_PUBLIC sg_size_t sg_disk_get_size(sg_disk_t d);
-XBT_PUBLIC const char* sg_disk_get_mount_point(sg_disk_t d);
+XBT_PUBLIC sg_size_t sg_disk_get_size_free(const_sg_disk_t d);
+XBT_PUBLIC sg_size_t sg_disk_get_size_used(const_sg_disk_t d);
+XBT_PUBLIC sg_size_t sg_disk_get_size(const_sg_disk_t d);
+XBT_PUBLIC const char* sg_disk_get_mount_point(const_sg_disk_t d);
 
-XBT_PUBLIC sg_size_t sg_storage_get_size_free(sg_storage_t st);
-XBT_PUBLIC sg_size_t sg_storage_get_size_used(sg_storage_t st);
-XBT_PUBLIC sg_size_t sg_storage_get_size(sg_storage_t st);
-XBT_PUBLIC xbt_dict_t sg_storage_get_content(sg_storage_t storage);
+XBT_PUBLIC sg_size_t sg_storage_get_size_free(const_sg_storage_t st);
+XBT_PUBLIC sg_size_t sg_storage_get_size_used(const_sg_storage_t st);
+XBT_PUBLIC sg_size_t sg_storage_get_size(const_sg_storage_t st);
+XBT_PUBLIC xbt_dict_t sg_storage_get_content(const_sg_storage_t storage);
 
 XBT_PUBLIC xbt_dict_t sg_host_get_storage_content(sg_host_t host);
 
@@ -85,9 +85,13 @@ SG_END_DECL
 #ifdef __cplusplus
 
 namespace simgrid {
+
+extern template class XBT_PUBLIC xbt::Extendable<s4u::File>;
+
 namespace s4u {
 
 /** @brief A simulated file
+ *  @addtogroup Plugin_filesystem
  *
  * Used to simulate the time it takes to access to a file, but does not really store any information.
  *
@@ -96,6 +100,20 @@ namespace s4u {
  * For now, you cannot change the mountpoints programmatically, and must declare them from your platform file.
  */
 class XBT_PUBLIC File : public xbt::Extendable<File> {
+  sg_size_t size_;
+  std::string path_;
+  std::string fullpath_;
+  sg_size_t current_position_ = SEEK_SET;
+  int desc_id                 = 0;
+  Disk* local_disk_           = nullptr;
+  Storage* local_storage_     = nullptr;
+  std::string mount_point_;
+
+  Storage* find_local_storage_on(Host* host);
+  Disk* find_local_disk_on(const Host* host);
+  sg_size_t write_on_storage(sg_size_t size, bool write_inside);
+  sg_size_t write_on_disk(sg_size_t size, bool write_inside);
+
 public:
   File(const std::string& fullpath, void* userdata);
   File(const std::string& fullpath, sg_host_t host, void* userdata);
@@ -110,7 +128,7 @@ public:
   sg_size_t read(sg_size_t size);
 
   /** Simulates a write action. Returns the size of data actually written. */
-  sg_size_t write(sg_size_t size, int write_inside=0);
+  sg_size_t write(sg_size_t size, bool write_inside = false);
 
   /** Allows to store user data on that host */
   XBT_ATTRIB_DEPRECATED_v329("Please use set_data()") void set_userdata(void* data) { set_data(data); }
@@ -129,23 +147,18 @@ public:
 
   int unlink(); /** Remove a file from the contents of a disk */
   void dump();
-
-  int desc_id = 0;
-  Disk* local_disk_       = nullptr;
-  Storage* local_storage_ = nullptr;
-  std::string mount_point_;
-
-private:
-  sg_size_t size_;
-  std::string path_;
-  std::string fullpath_;
-  sg_size_t current_position_ = SEEK_SET;
 };
 
 class XBT_PUBLIC FileSystemDiskExt {
+  std::unique_ptr<std::map<std::string, sg_size_t>> content_;
+  std::map<Host*, std::string> remote_mount_points_;
+  std::string mount_point_;
+  sg_size_t used_size_ = 0;
+  sg_size_t size_      = static_cast<sg_size_t>(500 * 1024) * 1024 * 1024;
+
 public:
   static simgrid::xbt::Extension<Disk, FileSystemDiskExt> EXTENSION_ID;
-  explicit FileSystemDiskExt(Disk* ptr);
+  explicit FileSystemDiskExt(const Disk* ptr);
   FileSystemDiskExt(const FileSystemDiskExt&) = delete;
   FileSystemDiskExt& operator=(const FileSystemDiskExt&) = delete;
   std::map<std::string, sg_size_t>* parse_content(const std::string& filename);
@@ -160,19 +173,16 @@ public:
   sg_size_t get_used_size() const { return used_size_; }
   void decr_used_size(sg_size_t size) { used_size_ -= size; }
   void incr_used_size(sg_size_t size) { used_size_ += size; }
+};
 
-private:
+class XBT_PUBLIC FileSystemStorageExt {
   std::unique_ptr<std::map<std::string, sg_size_t>> content_;
-  std::map<Host*, std::string> remote_mount_points_;
-  std::string mount_point_;
   sg_size_t used_size_ = 0;
-  sg_size_t size_      = static_cast<sg_size_t>(500 * 1024) * 1024 * 1024;
-};
+  sg_size_t size_      = 0;
 
-class XBT_PUBLIC FileSystemStorageExt {
 public:
   static simgrid::xbt::Extension<Storage, FileSystemStorageExt> EXTENSION_ID;
-  explicit FileSystemStorageExt(Storage* ptr);
+  explicit FileSystemStorageExt(const Storage* ptr);
   FileSystemStorageExt(const FileSystemStorageExt&) = delete;
   FileSystemStorageExt& operator=(const FileSystemStorageExt&) = delete;
   std::map<std::string, sg_size_t>* parse_content(const std::string& filename);
@@ -181,11 +191,6 @@ public:
   sg_size_t get_used_size() { return used_size_; }
   void decr_used_size(sg_size_t size) { used_size_ -= size; }
   void incr_used_size(sg_size_t size) { used_size_ += size; }
-
-private:
-  std::unique_ptr<std::map<std::string, sg_size_t>> content_;
-  sg_size_t used_size_ = 0;
-  sg_size_t size_     = 0;
 };
 
 class XBT_PUBLIC FileDescriptorHostExt {
index 18e747b..4b32738 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -13,18 +13,18 @@ SG_BEGIN_DECL
 
 XBT_PUBLIC void sg_vm_live_migration_plugin_init();
 XBT_PRIVATE void sg_vm_dirty_page_tracking_init();
-XBT_PUBLIC void sg_vm_start_dirty_page_tracking(sg_vm_t vm);
-XBT_PUBLIC void sg_vm_stop_dirty_page_tracking(sg_vm_t vm);
-XBT_PUBLIC double sg_vm_lookup_computed_flops(sg_vm_t vm);
+XBT_PUBLIC void sg_vm_start_dirty_page_tracking(const_sg_vm_t vm);
+XBT_PUBLIC void sg_vm_stop_dirty_page_tracking(const_sg_vm_t vm);
+XBT_PUBLIC double sg_vm_lookup_computed_flops(const_sg_vm_t vm);
 XBT_PUBLIC void sg_vm_migrate(sg_vm_t vm, sg_host_t dst_pm);
-XBT_PUBLIC void sg_vm_set_dirty_page_intensity(sg_vm_t vm, double intensity);
-XBT_PUBLIC double sg_vm_get_dirty_page_intensity(sg_vm_t vm);
-XBT_PUBLIC void sg_vm_set_working_set_memory(sg_vm_t vm, sg_size_t size);
-XBT_PUBLIC sg_size_t sg_vm_get_working_set_memory(sg_vm_t vm);
-XBT_PUBLIC void sg_vm_set_migration_speed(sg_vm_t vm, double speed);
-XBT_PUBLIC double sg_vm_get_migration_speed(sg_vm_t vm);
-XBT_PUBLIC double sg_vm_get_max_downtime(sg_vm_t vm);
-XBT_PUBLIC int sg_vm_is_migrating(sg_vm_t vm);
+XBT_PUBLIC void sg_vm_set_dirty_page_intensity(const_sg_vm_t vm, double intensity);
+XBT_PUBLIC double sg_vm_get_dirty_page_intensity(const_sg_vm_t vm);
+XBT_PUBLIC void sg_vm_set_working_set_memory(const_sg_vm_t vm, sg_size_t size);
+XBT_PUBLIC sg_size_t sg_vm_get_working_set_memory(const_sg_vm_t vm);
+XBT_PUBLIC void sg_vm_set_migration_speed(const_sg_vm_t vm, double speed);
+XBT_PUBLIC double sg_vm_get_migration_speed(const_sg_vm_t vm);
+XBT_PUBLIC double sg_vm_get_max_downtime(const_sg_vm_t vm);
+XBT_PUBLIC int sg_vm_is_migrating(const_sg_vm_t vm);
 XBT_PUBLIC sg_vm_t sg_vm_create_migratable(sg_host_t pm, const char* name, int coreAmount, int ramsize,
                                            int mig_netspeed, int dp_intensity);
 
index 8880e9d..d8b9a7f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 SG_BEGIN_DECL
 
 XBT_PUBLIC void sg_host_load_plugin_init();
-XBT_PUBLIC double sg_host_get_current_load(sg_host_t host);
-XBT_PUBLIC double sg_host_get_avg_load(sg_host_t host);
-XBT_PUBLIC double sg_host_get_idle_time(sg_host_t host);
-XBT_PUBLIC double sg_host_get_total_idle_time(sg_host_t host);
-XBT_PUBLIC double sg_host_get_computed_flops(sg_host_t host);
-XBT_PUBLIC void sg_host_load_reset(sg_host_t host);
+XBT_PUBLIC double sg_host_get_current_load(const_sg_host_t host);
+XBT_PUBLIC double sg_host_get_avg_load(const_sg_host_t host);
+XBT_PUBLIC double sg_host_get_idle_time(const_sg_host_t host);
+XBT_PUBLIC double sg_host_get_total_idle_time(const_sg_host_t host);
+XBT_PUBLIC double sg_host_get_computed_flops(const_sg_host_t host);
+XBT_PUBLIC void sg_host_load_reset(const_sg_host_t host);
 
 #define MSG_host_load_plugin_init() sg_host_load_plugin_init()
 /** @brief Returns the current load of that host, as a ratio = achieved_flops / (core_current_speed * core_amount)
index 5f34d0c..e6d5f72 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 7dc4005..d437311 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index ccdcea1..76d41c0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -14,6 +14,8 @@
 #include <vector>
 #include <xbt/signal.hpp>
 
+XBT_LOG_EXTERNAL_CATEGORY(s4u_activity);
+
 namespace simgrid {
 namespace s4u {
 
@@ -89,7 +91,7 @@ private:
 
 template <class AnyActivity> class Activity_T : public Activity {
 private:
-  std::string name_             = "";
+  std::string name_             = "unnamed";
   std::string tracing_category_ = "";
   void* user_data_              = nullptr;
   std::atomic_int_fast32_t refcount_{0};
@@ -124,6 +126,7 @@ public:
   {
     while (has_successors()) {
       AnyActivity* b = get_successor();
+      XBT_CDEBUG(s4u_activity, "Remove a dependency from '%s' on '%s'", get_cname(), b->get_cname());
       b->remove_dependency_on(static_cast<AnyActivity*>(this));
       if (not b->has_dependencies()) {
         b->vetoable_start();
@@ -138,6 +141,7 @@ public:
     if (has_dependencies())
       return static_cast<AnyActivity*>(this);
     set_state(State::STARTED);
+    XBT_CDEBUG(s4u_activity, "All dependencies are solved, let's start '%s'", get_cname());
     static_cast<AnyActivity*>(this)->start();
     return static_cast<AnyActivity*>(this);
   }
index ca1183e..302d6e5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 #include <unordered_map>
 
 namespace simgrid {
+
+extern template class XBT_PUBLIC xbt::Extendable<s4u::Actor>;
+
 namespace s4u {
 
-/** \beginrst An actor is an independent stream of execution in your distributed application.
+/** An actor is an independent stream of execution in your distributed application.
+ *
+ * \beginrst
  * It is located on a (simulated) :cpp:class:`host <simgrid::s4u::Host>`, but can interact
  * with the whole simulated platform.
  *
@@ -54,8 +59,8 @@ public:
   Actor& operator=(Actor const&) = delete;
 
   // ***** Reference count *****
-  friend XBT_PUBLIC void intrusive_ptr_add_ref(Actor * actor);
-  friend XBT_PUBLIC void intrusive_ptr_release(Actor * actor);
+  friend XBT_PUBLIC void intrusive_ptr_add_ref(const Actor* actor);
+  friend XBT_PUBLIC void intrusive_ptr_release(const Actor* actor);
 #endif
   /** Retrieve the amount of references on that object. Useful to debug the automatic refcounting */
   int get_refcount();
@@ -82,9 +87,12 @@ public:
 #endif
 
   /** Signal indicating that an actor terminated its code.
+   *  @beginrst
    *  The actor may continue to exist if it is still referenced in the simulation, but it's not active anymore.
-   *  If you want to free extra data when the actor's destructor is called, use Actor::on_destruction.
-   *  If you want to register to the termination of a given actor, use this_actor::on_exit() instead.*/
+   *  If you want to free extra data when the actor's destructor is called, use :cpp:var:`Actor::on_destruction`.
+   *  If you want to register to the termination of a given actor, use :cpp:func:`this_actor::on_exit()` instead.
+   *  @endrst
+   */
   static xbt::signal<void(Actor const&)> on_termination;
   /** Signal indicating that an actor is about to disappear (its destructor was called).
    *  This signal is fired for any destructed actor, which is mostly useful when designing plugins and extensions.
@@ -284,17 +292,18 @@ XBT_PUBLIC void execute(double flop, double priority);
  * vector means that `host0` should compute 1000 flops while `host1` will compute 2000 flops. A matrix of
  * communications' sizes of ``[0, 1, 2, 3]`` specifies the following data exchanges:
  *
- *   +-----------+-------+------+
- *   |from \\ to | host0 | host1|
- *   +===========+=======+======+
- *   |host0      |   0   |  1   |
- *   +-----------+-------+------+
- *   |host1      |   2   |  3   |
- *   +-----------+-------+------+
+ * - from host0: [ to host0:  0 bytes; to host1: 1 byte ]
+ *
+ * - from host1: [ to host0: 2 bytes; to host1: 3 bytes ]
+ *
+ * Or, in other words:
  *
  * - From host0 to host0: 0 bytes are exchanged
+ *
  * - From host0 to host1: 1 byte is exchanged
+ *
  * - From host1 to host0: 2 bytes are exchanged
+ *
  * - From host1 to host1: 3 bytes are exchanged
  *
  * In a parallel execution, all parts (all executions on each hosts, all communications) progress exactly at the
@@ -308,12 +317,13 @@ XBT_PUBLIC void execute(double flop, double priority);
  *
  * \endrst
  */
+/** Block the current actor until the built parallel execution completes */
 XBT_PUBLIC void parallel_execute(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
                                  const std::vector<double>& bytes_amounts);
 
-/** Block the current actor until the built parallel execution completes, or until the timeout. */
-XBT_PUBLIC void parallel_execute(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
-                                 const std::vector<double>& bytes_amounts, double timeout);
+XBT_ATTRIB_DEPRECATED_v329("Please use exec_init(...)->wait_for(timeout)") XBT_PUBLIC
+    void parallel_execute(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
+                          const std::vector<double>& bytes_amounts, double timeout);
 
 /** Initialize a sequential execution that must then be started manually */
 XBT_PUBLIC ExecPtr exec_init(double flops_amounts);
@@ -343,9 +353,6 @@ XBT_PUBLIC void suspend();
 /** @brief Yield the current actor. */
 XBT_PUBLIC void yield();
 
-/** @brief Resume the current actor, that was suspend()ed previously. */
-XBT_PUBLIC void resume();
-
 /** @brief kill the current actor. */
 XBT_PUBLIC void exit();
 
@@ -370,8 +377,6 @@ XBT_PUBLIC void set_host(Host* new_host);
 #ifndef DOXYGEN
 XBT_ATTRIB_DEPRECATED_v329("Please use set_host() instead") XBT_PUBLIC void migrate(Host* new_host);
 #endif
-
-/** @} */
 }
 
 
index db8e05e..34c6182 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -20,8 +20,8 @@ namespace s4u {
 
 class XBT_PUBLIC Barrier {
 private:
-  MutexPtr mutex_;
-  ConditionVariablePtr cond_;
+  MutexPtr mutex_            = Mutex::create();
+  ConditionVariablePtr cond_ = ConditionVariable::create();
   unsigned int expected_actors_;
   unsigned int arrived_actors_ = 0;
 
@@ -30,7 +30,7 @@ private:
 
 public:
   /** Creates a barrier for the given amount of actors */
-  explicit Barrier(unsigned int count);
+  explicit Barrier(unsigned int expected_actors) : expected_actors_(expected_actors) {}
 #ifndef DOXYGEN
   ~Barrier()              = default;
   Barrier(Barrier const&) = delete;
index 153be7e..9869018 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -30,7 +30,7 @@ class XBT_PUBLIC Comm : public Activity_T<Comm> {
   std::string tracing_category_       = "";
   /* FIXME: expose these elements in the API */
   bool detached_                                                          = false;
-  int (*match_fun_)(void*, void*, kernel::activity::CommImpl*)            = nullptr;
+  bool (*match_fun_)(void*, void*, kernel::activity::CommImpl*)           = nullptr;
   void (*clean_fun_)(void*)                                               = nullptr;
   void (*copy_data_function_)(kernel::activity::CommImpl*, void*, size_t) = nullptr;
 
@@ -49,14 +49,14 @@ public:
 
   /*! take a vector s4u::CommPtr and return when one of them is finished.
    * The return value is the rank of the first finished CommPtr. */
-  static int wait_any(std::vector<CommPtr> * comms) { return wait_any_for(comms, -1); }
+  static int wait_any(const std::vector<CommPtr>* comms) { return wait_any_for(comms, -1); }
   /*! Same as wait_any, but with a timeout. If the timeout occurs, parameter last is returned.*/
-  static int wait_any_for(std::vector<CommPtr>* comms_in, double timeout);
+  static int wait_any_for(const std::vector<CommPtr>* comms_in, double timeout);
 
   /*! take a vector s4u::CommPtr and return when all of them is finished. */
-  static void wait_all(std::vector<CommPtr>* comms);
+  static void wait_all(const std::vector<CommPtr>* comms);
   /*! take a vector s4u::CommPtr and return the rank of the first finished one (or -1 if none is done). */
-  static int test_any(std::vector<CommPtr> * comms);
+  static int test_any(const std::vector<CommPtr>* comms);
 
   Comm* start() override;
   Comm* wait() override;
index 946a2d5..7b0cab0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 namespace simgrid {
 namespace s4u {
 
-/** @brief A condition variable
- *  @ingroup s4u_api
- *
- *  This is a drop-in replacement of `std::condition_variable` and should respect the same
- *  semantic. But we currently use (only) double for both durations and
- *  timestamp timeouts.
+/**
+ * @rst
+ * SimGrid's condition variables are meant to be drop-in replacements of ``std::condition_variable``.
+ * Please refer to the `documentation of standard C++ <https://en.cppreference.com/w/cpp/thread/condition_variable>`_
+ * for more information on condition variables. A SimGrid example is available in Section :ref:`s4u_ex_IPC`.
+ * @endrst
  */
 class XBT_PUBLIC ConditionVariable {
 private:
@@ -29,74 +29,86 @@ private:
   kernel::activity::ConditionVariableImpl* const cond_;
 
 public:
+#ifndef DOXYGEN
   explicit ConditionVariable(kernel::activity::ConditionVariableImpl* cond) : cond_(cond) {}
 
-#ifndef DOXYGEN
   ConditionVariable(ConditionVariable const&) = delete;
   ConditionVariable& operator=(ConditionVariable const&) = delete;
 
-  friend XBT_PUBLIC void intrusive_ptr_add_ref(ConditionVariable * cond);
-  friend XBT_PUBLIC void intrusive_ptr_release(ConditionVariable * cond);
+  friend XBT_PUBLIC void intrusive_ptr_add_ref(const ConditionVariable* cond);
+  friend XBT_PUBLIC void intrusive_ptr_release(const ConditionVariable* cond);
 #endif
 
+  /** Create a new condition variable and return a smart pointer
+   *
+   * @rst
+   * You should only manipulate :cpp:type:`simgrid::s4u::ConditionVariablePtr`, as created by this function (see also :ref:`s4u_raii`).
+   * @endrst
+   */
   static ConditionVariablePtr create();
 
-  //  Wait functions without time:
-
-  void wait(MutexPtr lock);
-  void wait(std::unique_lock<Mutex> & lock);
-  template <class P> void wait(std::unique_lock<Mutex> & lock, P pred)
+  ///  Wait until notification, with no timeout
+  void wait(s4u::MutexPtr lock);
+  ///  Wait until notification, with no timeout
+  void wait(const std::unique_lock<s4u::Mutex>& lock);
+  template <class P> void wait(const std::unique_lock<Mutex>& lock, P pred)
   {
     while (not pred())
       wait(lock);
   }
 
-  // Wait function taking a plain double as time:
-
-  std::cv_status wait_until(std::unique_lock<Mutex> & lock, double timeout_time);
-  std::cv_status wait_for(std::unique_lock<Mutex> & lock, double duration);
-  template <class P> bool wait_until(std::unique_lock<Mutex> & lock, double timeout_time, P pred)
+  /// Wait until the given instant (specified as a plain double)
+  std::cv_status wait_until(const std::unique_lock<s4u::Mutex>& lock, double timeout_time);
+  /// Wait for the given amount of seconds (specified as a plain double)
+  std::cv_status wait_for(const std::unique_lock<s4u::Mutex>& lock, double duration);
+  /// Wait until predicate is true, or the given instant (specified as a plain double)
+  template <class P> bool wait_until(const std::unique_lock<s4u::Mutex>& lock, double timeout_time, P pred)
   {
     while (not pred())
       if (this->wait_until(lock, timeout_time) == std::cv_status::timeout)
         return pred();
     return true;
   }
-  template <class P> bool wait_for(std::unique_lock<Mutex> & lock, double duration, P pred)
+  /// As long as the predicate is false, wait for the given amount of seconds (specified as a plain double)
+  template <class P> bool wait_for(const std::unique_lock<s4u::Mutex>& lock, double duration, P pred)
   {
     return this->wait_until(lock, SIMIX_get_clock() + duration, std::move(pred));
   }
 
   // Wait function taking a C++ style time:
 
+  /// As long as the predicate is false, wait for the given amount of seconds (specified in C++ style)
   template <class Rep, class Period, class P>
-  bool wait_for(std::unique_lock<Mutex> & lock, std::chrono::duration<Rep, Period> duration, P pred)
+  bool wait_for(const std::unique_lock<s4u::Mutex>& lock, std::chrono::duration<Rep, Period> duration, P pred)
   {
     auto seconds = std::chrono::duration_cast<SimulationClockDuration>(duration);
     return this->wait_for(lock, seconds.count(), pred);
   }
+  /// Wait for the given amount of seconds (specified in C++ style)
   template <class Rep, class Period>
-  std::cv_status wait_for(std::unique_lock<Mutex> & lock, std::chrono::duration<Rep, Period> duration)
+  std::cv_status wait_for(const std::unique_lock<s4u::Mutex>& lock, std::chrono::duration<Rep, Period> duration)
   {
     auto seconds = std::chrono::duration_cast<SimulationClockDuration>(duration);
     return this->wait_for(lock, seconds.count());
   }
+  /** Wait until the given instant (specified in C++ style) */
   template <class Duration>
-  std::cv_status wait_until(std::unique_lock<Mutex> & lock, const SimulationTimePoint<Duration>& timeout_time)
+  std::cv_status wait_until(const std::unique_lock<s4u::Mutex>& lock, const SimulationTimePoint<Duration>& timeout_time)
   {
     auto timeout_native = std::chrono::time_point_cast<SimulationClockDuration>(timeout_time);
     return this->wait_until(lock, timeout_native.time_since_epoch().count());
   }
+  /** Wait until predicate is true, or the given instant (specified in C++ style) */
   template <class Duration, class P>
-  bool wait_until(std::unique_lock<Mutex> & lock, const SimulationTimePoint<Duration>& timeout_time, P pred)
+  bool wait_until(const std::unique_lock<s4u::Mutex>& lock, const SimulationTimePoint<Duration>& timeout_time, P pred)
   {
     auto timeout_native = std::chrono::time_point_cast<SimulationClockDuration>(timeout_time);
     return this->wait_until(lock, timeout_native.time_since_epoch().count(), std::move(pred));
   }
 
-  // Notify functions
-
+  /** Unblock one actor blocked on that condition variable. If none was blocked, nothing happens. */
   void notify_one();
+  /** Unblock all actors blocked on that condition variable. If none was blocked, nothing happens. */
   void notify_all();
 };
 
index 78c4115..11651d3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -17,6 +17,9 @@
 #include <unordered_map>
 
 namespace simgrid {
+
+extern template class XBT_PUBLIC xbt::Extendable<s4u::Disk>;
+
 namespace s4u {
 
 /** Disk represent the disk resources associated to a host
@@ -50,11 +53,11 @@ public:
   /** @brief Retrieves the name of that disk as a C string */
   const char* get_cname() const { return name_.c_str(); }
   double get_read_bandwidth() const;
-  double get_write_bandwidth();
+  double get_write_bandwidth() const;
   const std::unordered_map<std::string, std::string>* get_properties() const;
   const char* get_property(const std::string& key) const;
   void set_property(const std::string&, const std::string& value);
-  Host* get_host();
+  Host* get_host() const;
 
   IoPtr io_init(sg_size_t size, s4u::Io::OpType type);
 
index 1741d9a..234a82b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -22,21 +22,23 @@ namespace simgrid {
 namespace s4u {
 /** @brief Simulation engine
  *
- * This class is an interface to the simulation engine.
+ * This is a singleton containing all the main functions of the simulation.
  */
 class XBT_PUBLIC Engine {
 public:
   /** Constructor, taking the command line parameters of your main function */
   explicit Engine(int* argc, char** argv);
-  /** Currently, only one instance is allowed to exist. This is why you can't copy or move it */
+  /* Currently, only one instance is allowed to exist. This is why you can't copy or move it */
+#ifndef DOXYGEN
   Engine(const Engine&) = delete;
   Engine(Engine&&)      = delete;
-
   ~Engine();
+#endif
+
   /** Finalize the default engine and all its dependencies */
   static void shutdown();
 
-  /** @brief Run the simulation after initialization */
+  /** Run the simulation after initialization */
   void run();
 
   /** @brief Retrieve the simulation time (in seconds) */
@@ -80,9 +82,9 @@ protected:
   friend kernel::resource::LinkImpl;
   void host_register(const std::string& name, Host* host);
   void host_unregister(const std::string& name);
-  void link_register(const std::string& name, Link* link);
+  void link_register(const std::string& name, const Link* link);
   void link_unregister(const std::string& name);
-  void storage_register(const std::string& name, Storage* storage);
+  void storage_register(const std::string& name, const Storage* storage);
   void storage_unregister(const std::string& name);
   void netpoint_register(simgrid::kernel::routing::NetPoint* card);
   void netpoint_unregister(simgrid::kernel::routing::NetPoint* card);
@@ -106,16 +108,18 @@ public:
   std::vector<ActorPtr> get_all_actors();
   std::vector<ActorPtr> get_filtered_actors(const std::function<bool(ActorPtr)>& filter);
 
+#ifndef DOXYGEN
   size_t get_storage_count();
   std::vector<Storage*> get_all_storages();
   Storage* storage_by_name(const std::string& name);
   Storage* storage_by_name_or_null(const std::string& name);
+#endif
 
   std::vector<kernel::routing::NetPoint*> get_all_netpoints();
   kernel::routing::NetPoint* netpoint_by_name_or_null(const std::string& name);
 
   NetZone* get_netzone_root();
-  void set_netzone_root(NetZone* netzone);
+  void set_netzone_root(const NetZone* netzone);
 
   NetZone* netzone_by_name_or_null(const std::string& name);
 
@@ -133,8 +137,10 @@ public:
   static bool is_initialized();
   /** @brief set a configuration variable
    *
-   * Do --help on any simgrid binary to see the list of currently existing configuration variables (see also @ref
-   * options).
+   * @beginrst
+   * Do --help on any simgrid binary to see the list of currently existing configuration variables
+   * (see also :ref:`options`).
+   * @endrst
    *
    * Example:
    * e->set_config("host/model:ptask_L07");
@@ -164,7 +170,8 @@ private:
 };
 
 #ifndef DOXYGEN /* Internal use only, no need to expose it */
-template <class T> XBT_PRIVATE void get_filtered_netzones_recursive(s4u::NetZone* current, std::vector<T*>* whereto)
+template <class T>
+XBT_PRIVATE void get_filtered_netzones_recursive(const s4u::NetZone* current, std::vector<T*>* whereto)
 {
   static_assert(std::is_base_of<kernel::routing::NetZoneImpl, T>::value,
                 "Filtering netzones is only possible for subclasses of kernel::routing::NetZoneImpl");
index 5a65e18..6923409 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -55,7 +55,7 @@ public:
 
   ExecPtr set_bound(double bound);
   ExecPtr set_priority(double priority);
-  ExecPtr set_timeout(double timeout);
+  XBT_ATTRIB_DEPRECATED_v329("Please use exec_init(...)->wait_for(timeout)") ExecPtr set_timeout(double timeout);
   Exec* cancel() override;
   Host* get_host() const;
   unsigned int get_host_number() const;
index c36c54a..4870a86 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -16,9 +16,7 @@
 
 namespace simgrid {
 
-namespace xbt {
-extern template class XBT_PUBLIC Extendable<s4u::Host>;
-} // namespace xbt
+extern template class XBT_PUBLIC xbt::Extendable<s4u::Host>;
 
 namespace s4u {
 /** @ingroup s4u_api
@@ -27,13 +25,15 @@ namespace s4u {
  *
  * Some physical resource with computing and networking capabilities on which Actors execute.
  *
+ * @beginrst
  * All hosts are automatically created during the call of the method
- * @ref simgrid::s4u::Engine::load_platform().
+ * :cpp:func:`simgrid::s4u::Engine::load_platform()`.
  * You cannot create a host yourself.
  *
- * You can retrieve a particular host using @ref simgrid::s4u::Host::by_name()
- * and actors can retrieve the host on which they run using @ref simgrid::s4u::Host::current() or
- * @ref simgrid::s4u::this_actor::get_host().
+ * You can retrieve a particular host using :cpp:func:`simgrid::s4u::Host::by_name()`
+ * and actors can retrieve the host on which they run using :cpp:func:`simgrid::s4u::Host::current()` or
+ * :cpp:func:`simgrid::s4u::this_actor::get_host()`
+ * @endrst
  */
 class XBT_PUBLIC Host : public xbt::Extendable<Host> {
   friend vm::VMModel;            // Use the pimpl_cpu to compute the VM sharing
@@ -81,8 +81,8 @@ public:
 
   kernel::routing::NetPoint* get_netpoint() const { return pimpl_netpoint_; }
 
-  int get_actor_count();
-  std::vector<ActorPtr> get_all_actors();
+  int get_actor_count() const;
+  std::vector<ActorPtr> get_all_actors() const;
 
   /** Turns that host on if it was previously off
    *
@@ -129,8 +129,8 @@ public:
    */
   std::unordered_map<std::string, Storage*> const& get_mounted_storages();
 
-  void route_to(Host* dest, std::vector<Link*>& links, double* latency);
-  void route_to(Host* dest, std::vector<kernel::resource::LinkImpl*>& links, double* latency);
+  void route_to(const Host* dest, std::vector<Link*>& links, double* latency) const;
+  void route_to(const Host* dest, std::vector<kernel::resource::LinkImpl*>& links, double* latency) const;
   void send_to(Host* dest, double byte_amount);
 
   NetZone* get_englobing_zone();
index b4ef0c2..3d54e81 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 566430e..832bd3e 100644 (file)
@@ -1,10 +1,10 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#ifndef S4U_LINK_HPP_
-#define S4U_LINK_HPP_
+#ifndef S4U_LINK_HPP
+#define S4U_LINK_HPP
 
 #include <simgrid/forward.h>
 #include <simgrid/kernel/resource/Action.hpp>
@@ -20,6 +20,9 @@
  ***********/
 
 namespace simgrid {
+
+extern template class XBT_PUBLIC xbt::Extendable<s4u::Link>;
+
 namespace s4u {
 /** @brief A Link represents the network facilities between [hosts](@ref simgrid::s4u::Host) */
 class XBT_PUBLIC Link : public xbt::Extendable<Link> {
@@ -52,13 +55,13 @@ public:
   double get_latency() const;
 
   /** @brief Describes how the link is shared between flows */
-  SharingPolicy get_sharing_policy();
+  SharingPolicy get_sharing_policy() const;
 
   /** @brief Returns the current load (in flops per second) */
-  double get_usage();
+  double get_usage() const;
 
   /** @brief Check if the Link is used (at least one flow uses the link) */
-  bool is_used();
+  bool is_used() const;
 
   void turn_on();
   bool is_on() const;
@@ -99,4 +102,4 @@ public:
 } // namespace s4u
 } // namespace simgrid
 
-#endif /* SURF_NETWORK_INTERFACE_HPP_ */
+#endif /* S4U_LINK_HPP */
index 989ae54..372b730 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -7,8 +7,8 @@
 #define SIMGRID_S4U_MAILBOX_HPP
 
 #include <simgrid/forward.h>
-
 #include <simgrid/s4u/Actor.hpp>
+#include <smpi/forward.hpp>
 #include <xbt/string.hpp>
 
 #include <string>
@@ -19,6 +19,7 @@ namespace s4u {
 /** @brief Mailboxes: Network rendez-vous points. */
 class XBT_PUBLIC Mailbox {
   friend Comm;
+  friend smpi::Request;
   friend kernel::activity::MailboxImpl;
 
   kernel::activity::MailboxImpl* const pimpl_;
@@ -26,16 +27,16 @@ class XBT_PUBLIC Mailbox {
   explicit Mailbox(kernel::activity::MailboxImpl * mbox) : pimpl_(mbox) {}
   ~Mailbox() = default;
 
-public:
-  /** private function, do not use. FIXME: make me protected */
+protected:
   kernel::activity::MailboxImpl* get_impl() const { return pimpl_; }
 
+public:
   /** @brief Retrieves the name of that mailbox as a C++ string */
   const xbt::string& get_name() const;
   /** @brief Retrieves the name of that mailbox as a C string */
   const char* get_cname() const;
 
-  /** Retrieve the mailbox associated to the given name */
+  /** Retrieve the mailbox associated to the given name. Mailboxes are created on demand. */
   static Mailbox* by_name(const std::string& name);
 
   /** Returns whether the mailbox contains queued communications */
@@ -80,7 +81,7 @@ public:
   /** Creates and start a data transmission to that mailbox */
   CommPtr put_async(void* data, uint64_t simulated_size_in_bytes);
 
-  smx_activity_t iprobe(int type, int (*match_fun)(void*, void*, kernel::activity::CommImpl*), void* data);
+  smx_activity_t iprobe(int type, bool (*match_fun)(void*, void*, kernel::activity::CommImpl*), void* data);
   /** Blocking data transmission */
   void put(void* payload, uint64_t simulated_size_in_bytes);
   /** Blocking data transmission with timeout */
index fbab117..8cf22d6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 namespace simgrid {
 namespace s4u {
 
-/** @brief A classical mutex, but blocking in the simulation world
- *  @ingroup s4u_api
+/** @brief A classical mutex, but blocking in the simulation world.
  *
+ * @rst
  * It is strictly impossible to use a real mutex, such as
- * <a href="http://en.cppreference.com/w/cpp/thread/mutex">std::mutex</a>
- * or <a href="http://pubs.opengroup.org/onlinepubs/007908775/xsh/pthread_mutex_lock.html">pthread_mutex_t</a>,
+ * `std::mutex <http://en.cppreference.com/w/cpp/thread/mutex>`_
+ * or `pthread_mutex_t <http://pubs.opengroup.org/onlinepubs/007908775/xsh/pthread_mutex_lock.html>`_,
  * because it would block the whole simulation.
- * Instead, you should use the present class, that is a drop-in replacement of
- * <a href="http://en.cppreference.com/w/cpp/thread/mutex">std::mutex</a>.
+ * Instead, you should use the present class, that is a drop-in replacement of these mechanisms.
  *
- * As for any S4U object, Mutexes are using the @ref s4u_raii "RAII idiom" for memory management.
- * Use create() to get a simgrid::s4u::MutexPtr to a newly created mutex and only manipulate simgrid::s4u::MutexPtr.
+ * An example is available in Section :ref:`s4u_ex_IPC`.
  *
+ * As for any S4U object, you can use the :ref:`RAII idiom <s4u_raii>` for memory management of Mutexes.
+ * Use :cpp:func:`create() <simgrid::s4u::Mutex::create()>` to get a :cpp:type:`simgrid::s4u::MutexPtr` to a newly
+ * created mutex, and only manipulate :cpp:type:`simgrid::s4u::MutexPtr`.
+ * @endrst
  */
 class XBT_PUBLIC Mutex {
   friend ConditionVariable;
@@ -32,17 +34,16 @@ class XBT_PUBLIC Mutex {
 
   kernel::activity::MutexImpl* const pimpl_;
   /* refcounting */
-  friend XBT_PUBLIC void intrusive_ptr_add_ref(Mutex* mutex);
-  friend XBT_PUBLIC void intrusive_ptr_release(Mutex* mutex);
+  friend XBT_PUBLIC void intrusive_ptr_add_ref(const Mutex* mutex);
+  friend XBT_PUBLIC void intrusive_ptr_release(const Mutex* mutex);
 
 public:
   explicit Mutex(kernel::activity::MutexImpl* mutex) : pimpl_(mutex) {}
   ~Mutex();
-  // No copy:
-  /** You cannot create a new mutex by copying an existing one. Use MutexPtr instead */
-  Mutex(Mutex const&) = delete;
-  /** You cannot create a new mutex by value assignment either. Use MutexPtr instead */
-  Mutex& operator=(Mutex const&) = delete;
+#ifndef DOXYGEN
+  Mutex(Mutex const&) = delete;            // No copy constructor; Use MutexPtr instead
+  Mutex& operator=(Mutex const&) = delete; // No direct assignment either. Use MutexPtr instead
+#endif
 
   /** Constructs a new mutex */
   static MutexPtr create();
index e95407b..3ec8c84 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.               */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.               */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -37,7 +37,7 @@ public:
 
   NetZone* get_father();
 
-  std::vector<Host*> get_all_hosts();
+  std::vector<Host*> get_all_hosts() const;
   int get_host_count();
 
   kernel::routing::NetZoneImpl* get_impl() const { return pimpl_; }
@@ -52,7 +52,7 @@ public:
   const char* get_property(const std::string& key) const;
   void set_property(const std::string& key, const std::string& value);
 
-  std::vector<NetZone*> get_children();
+  std::vector<NetZone*> get_children() const;
 
   /* Add content to the netzone, at parsing time. It should be sealed afterward. */
   int add_component(kernel::routing::NetPoint* elm); /* A host, a router or a netzone, whatever */
index 2525e39..602553d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -13,16 +13,19 @@ namespace simgrid {
 namespace s4u {
 
 /** @brief A classical semaphore, but blocking in the simulation world
- *  @ingroup s4u_api
  *
+ * @rst
  * It is strictly impossible to use a real semaphore, such as
- * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_init.html">sem_init</a>,
+ * `sem_init <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_init.html>`_,
  * because it would block the whole simulation.
  * Instead, you should use the present class, that offers a very similar interface.
  *
- * As for any S4U object, Semaphores are using the @ref s4u_raii "RAII idiom" for memory management.
- * Use #create() to get a simgrid::s4u::SemaphorePtr to a newly created semaphore
- * and only manipulate simgrid::s4u::SemaphorePtr.
+ * An example is available in Section :ref:`s4u_ex_IPC`.
+ *
+ * As for any S4U object, you can use the :ref:`RAII idiom <s4u_raii>` for memory management of semaphores.
+ * Use :cpp:func:`create() <simgrid::s4u::Mutex::create()>` to get a :cpp:type:`simgrid::s4u::SemaphorePtr` to a newly
+ * created semaphore, that will get automatically freed when the variable goes out of scope.
+ * @endrst
  *
  */
 class XBT_PUBLIC Semaphore {
@@ -36,11 +39,10 @@ public:
   explicit Semaphore(unsigned int initial_capacity);
   ~Semaphore();
 
-  // No copy:
-  /** You cannot create a new semaphore by copying an existing one. Use SemaphorePtr instead */
-  Semaphore(Semaphore const&) = delete;
-  /** You cannot create a new semaphore by value assignment either. Use SemaphorePtr instead */
-  Semaphore& operator=(Semaphore const&) = delete;
+#ifndef DOXYGEN
+  Semaphore(Semaphore const&) = delete;            // No copy constructor. Use SemaphorePtr instead
+  Semaphore& operator=(Semaphore const&) = delete; // No direct assignment either. Use SemaphorePtr instead
+#endif
 
   /** Constructs a new semaphore */
   static SemaphorePtr create(unsigned int initial_capacity);
index 3099a47..3247dff 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -17,6 +17,9 @@
 #include <unordered_map>
 
 namespace simgrid {
+
+extern template class XBT_PUBLIC xbt::Extendable<s4u::Storage>;
+
 namespace s4u {
 
 /** Storage represent the disk resources, usually associated to a given host
@@ -52,8 +55,8 @@ public:
   /** @brief Retrieves the name of that storage as a C string */
   const char* get_cname() const { return name_.c_str(); }
 
-  const char* get_type();
-  Host* get_host() { return attached_to_; };
+  const char* get_type() const;
+  Host* get_host() const { return attached_to_; };
   void set_host(Host* host) { attached_to_ = host; }
 
   const std::unordered_map<std::string, std::string>* get_properties() const;
index 25dfd3d..0bbc6ae 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -46,9 +46,9 @@ public:
   void shutdown();
   void destroy() override;
 
-  Host* get_pm();
+  Host* get_pm() const;
   void set_pm(Host* pm);
-  size_t get_ramsize();
+  size_t get_ramsize() const;
   void set_ramsize(size_t ramsize);
   void set_bound(double bound);
 
index a1eb19e..730a089 100644 (file)
@@ -1,6 +1,6 @@
 /* Public interface to the Link datatype                                    */
 
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -17,7 +17,7 @@ XBT_PUBLIC void sg_sem_acquire(sg_sem_t sem);
 XBT_PUBLIC int sg_sem_acquire_timeout(sg_sem_t sem, double timeout);
 XBT_PUBLIC void sg_sem_release(sg_sem_t sem);
 XBT_PUBLIC int sg_sem_get_capacity(sg_sem_t sem);
-XBT_PUBLIC void sg_sem_destroy(sg_sem_t sem);
+XBT_PUBLIC void sg_sem_destroy(const_sg_sem_t sem);
 XBT_PUBLIC int sg_sem_would_block(sg_sem_t sem);
 
 SG_END_DECL
index 8499305..1f015a8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -35,6 +35,7 @@ typedef sg_link_t SD_link_t;
 
     */
 typedef struct s_SD_task_t* SD_task_t;
+typedef const struct s_SD_task_t* const_SD_task_t;
 
 /** @brief Task states
     @ingroup SD_task_api */
@@ -73,34 +74,34 @@ typedef enum {
  *  @{
  */
 XBT_PUBLIC SD_task_t SD_task_create(const char* name, void* data, double amount);
-XBT_PUBLIC void* SD_task_get_data(SD_task_t task);
+XBT_PUBLIC void* SD_task_get_data(const_SD_task_t task);
 XBT_PUBLIC void SD_task_set_data(SD_task_t task, void* data);
-XBT_PUBLIC e_SD_task_state_t SD_task_get_state(SD_task_t task);
-XBT_PUBLIC const char* SD_task_get_name(SD_task_t task);
+XBT_PUBLIC e_SD_task_state_t SD_task_get_state(const_SD_task_t task);
+XBT_PUBLIC const char* SD_task_get_name(const_SD_task_t task);
 XBT_PUBLIC void SD_task_set_name(SD_task_t task, const char* name);
 XBT_PUBLIC void SD_task_set_rate(SD_task_t task, double rate);
 
 XBT_PUBLIC void SD_task_watch(SD_task_t task, e_SD_task_state_t state);
 XBT_PUBLIC void SD_task_unwatch(SD_task_t task, e_SD_task_state_t state);
-XBT_PUBLIC double SD_task_get_amount(SD_task_t task);
+XBT_PUBLIC double SD_task_get_amount(const_SD_task_t task);
 XBT_PUBLIC void SD_task_set_amount(SD_task_t task, double amount);
-XBT_PUBLIC double SD_task_get_alpha(SD_task_t task);
-XBT_PUBLIC double SD_task_get_remaining_amount(SD_task_t task);
-XBT_PUBLIC double SD_task_get_execution_time(SD_task_t task, int host_count, const sg_host_t* host_list,
+XBT_PUBLIC double SD_task_get_alpha(const_SD_task_t task);
+XBT_PUBLIC double SD_task_get_remaining_amount(const_SD_task_t task);
+XBT_PUBLIC double SD_task_get_execution_time(const_SD_task_t task, int host_count, const sg_host_t* host_list,
                                              const double* flops_amount, const double* bytes_amount);
-XBT_PUBLIC e_SD_task_kind_t SD_task_get_kind(SD_task_t task);
+XBT_PUBLIC e_SD_task_kind_t SD_task_get_kind(const_SD_task_t task);
 XBT_PUBLIC void SD_task_schedule(SD_task_t task, int host_count, const sg_host_t* host_list, const double* flops_amount,
                                  const double* bytes_amount, double rate);
 XBT_PUBLIC void SD_task_unschedule(SD_task_t task);
-XBT_PUBLIC double SD_task_get_start_time(SD_task_t task);
-XBT_PUBLIC double SD_task_get_finish_time(SD_task_t task);
-XBT_PUBLIC xbt_dynar_t SD_task_get_parents(SD_task_t task);
-XBT_PUBLIC xbt_dynar_t SD_task_get_children(SD_task_t task);
-XBT_PUBLIC int SD_task_get_workstation_count(SD_task_t task);
-XBT_PUBLIC sg_host_t* SD_task_get_workstation_list(SD_task_t task);
+XBT_PUBLIC double SD_task_get_start_time(const_SD_task_t task);
+XBT_PUBLIC double SD_task_get_finish_time(const_SD_task_t task);
+XBT_PUBLIC xbt_dynar_t SD_task_get_parents(const_SD_task_t task);
+XBT_PUBLIC xbt_dynar_t SD_task_get_children(const_SD_task_t task);
+XBT_PUBLIC int SD_task_get_workstation_count(const_SD_task_t task);
+XBT_PUBLIC sg_host_t* SD_task_get_workstation_list(const_SD_task_t task);
 XBT_PUBLIC void SD_task_destroy(SD_task_t task);
-XBT_PUBLIC void SD_task_dump(SD_task_t task);
-XBT_PUBLIC void SD_task_dotty(SD_task_t task, void* out_FILE);
+XBT_PUBLIC void SD_task_dump(const_SD_task_t task);
+XBT_PUBLIC void SD_task_dotty(const_SD_task_t task, void* out_FILE);
 
 XBT_PUBLIC SD_task_t SD_task_create_comp_seq(const char* name, void* data, double amount);
 XBT_PUBLIC SD_task_t SD_task_create_comp_par_amdahl(const char* name, void* data, double amount, double alpha);
@@ -131,7 +132,7 @@ XBT_PUBLIC void SD_task_schedulel(SD_task_t task, int count, ...);
  */
 XBT_PUBLIC void SD_task_dependency_add(SD_task_t src, SD_task_t dst);
 XBT_PUBLIC void SD_task_dependency_remove(SD_task_t src, SD_task_t dst);
-XBT_PUBLIC int SD_task_dependency_exists(SD_task_t src, SD_task_t dst);
+XBT_PUBLIC int SD_task_dependency_exists(const_SD_task_t src, SD_task_t dst);
 /** @} */
 
 /************************** Global *******************************************/
index 9b6ff41..abc0aed 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -114,7 +114,7 @@ XBT_PUBLIC void SIMIX_comm_copy_buffer_callback(simgrid::kernel::activity::CommI
 
 /******************************* Host simcalls ********************************/
 #ifdef __cplusplus
-XBT_PUBLIC e_smx_state_t simcall_execution_wait(const smx_activity_t& execution);
+XBT_PUBLIC e_smx_state_t simcall_execution_wait(const smx_activity_t& execution, double timeout);
 XBT_PUBLIC unsigned int simcall_execution_waitany_for(simgrid::kernel::activity::ExecImpl* execs[], size_t count,
                                                       double timeout);
 XBT_PUBLIC bool simcall_execution_test(const smx_activity_t& execution);
@@ -138,30 +138,30 @@ SG_END_DECL
 #ifdef __cplusplus
 XBT_PUBLIC void simcall_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff,
                                   size_t src_buff_size,
-                                  int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+                                  bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
                                   void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
                                   void* data, double timeout);
 
 XBT_PUBLIC smx_activity_t simcall_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate,
                                              void* src_buff, size_t src_buff_size,
-                                             int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+                                             bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
                                              void (*clean_fun)(void*),
                                              void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
                                              void* data, bool detached);
 
 XBT_PUBLIC void simcall_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size,
-                                  int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+                                  bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
                                   void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
                                   void* data, double timeout, double rate);
 
 XBT_PUBLIC smx_activity_t simcall_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff,
                                              size_t* dst_buff_size,
-                                             int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+                                             bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
                                              void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
                                              void* data, double rate);
 
 XBT_PUBLIC smx_activity_t simcall_comm_iprobe(smx_mailbox_t mbox, int type,
-                                              int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+                                              bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
                                               void* data);
 
 /* FIXME: waitany is going to be a vararg function, and should take a timeout */
@@ -191,7 +191,8 @@ SG_END_DECL
 
 /*****************************   Io   **************************************/
 #ifdef __cplusplus
-XBT_PUBLIC e_smx_state_t simcall_io_wait(const smx_activity_t& io);
+XBT_PUBLIC e_smx_state_t simcall_io_wait(const smx_activity_t& io, double timeout);
+XBT_PUBLIC bool simcall_io_test(const smx_activity_t& io);
 #endif
 /************************** MC simcalls   **********************************/
 SG_BEGIN_DECL
index 6e17fd6..685e8eb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 017b7f2..973ead8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -57,7 +57,7 @@ template <class F> auto kernel_sync(F code) -> decltype(code().get())
         try {
           auto future = code();
           future.then_([&result, self](std::shared_ptr<simgrid::kernel::FutureState<T>>&& value) {
-            simgrid::xbt::set_promise(result, simgrid::kernel::Future<T>(value));
+            simgrid::xbt::set_promise(result, simgrid::kernel::Future<T>(std::move(value)));
             simgrid::simix::unblock(self);
           });
         } catch (...) {
@@ -94,7 +94,7 @@ public:
             // When the kernel future is ready...
             this->future_.then_([&result, self](std::shared_ptr<simgrid::kernel::FutureState<T>>&& value) {
               // ... wake up the process with the result of the kernel future.
-              simgrid::xbt::set_promise(result, simgrid::kernel::Future<T>(value));
+              simgrid::xbt::set_promise(result, simgrid::kernel::Future<T>(std::move(value)));
               simgrid::simix::unblock(self);
             });
           } catch (...) {
@@ -125,7 +125,7 @@ public:
             // When the kernel future is ready...
             this->future_.then_([this, self](std::shared_ptr<simgrid::kernel::FutureState<T>>&& value) {
               // ...store it the simix kernel and wake up.
-              this->future_ = std::move(simgrid::kernel::Future<T>(value));
+              this->future_ = simgrid::kernel::Future<T>(std::move(value));
               simgrid::simix::unblock(self);
             });
           } catch (...) {
index d295586..4da7a7e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -34,7 +34,7 @@
 XBT_PRIVATE unsigned char* smpi_get_tmp_sendbuffer(size_t size);
 XBT_PRIVATE unsigned char* smpi_get_tmp_recvbuffer(size_t size);
 
-XBT_PRIVATE void log_timed_action(simgrid::xbt::ReplayAction& action, double clock);
+XBT_PRIVATE void log_timed_action(const simgrid::xbt::ReplayAction& action, double clock);
 
 namespace simgrid {
 namespace smpi {
@@ -181,22 +181,26 @@ public:
  * In other words: The logic goes here, the setup is done by the ActionArgParser.
  */
 template <class T> class ReplayAction {
+  const std::string name_;
+  const aid_t my_proc_id_ = s4u::this_actor::get_pid();
+  T args_;
+
 protected:
-  const std::string name;
-  const aid_t my_proc_id;
-  T args;
+  const std::string& get_name() const { return name_; }
+  aid_t get_pid() const { return my_proc_id_; }
+  const T& get_args() const { return args_; }
 
 public:
-  explicit ReplayAction(const std::string& name) : name(name), my_proc_id(s4u::this_actor::get_pid()) {}
+  explicit ReplayAction(const std::string& name) : name_(name) {}
   virtual ~ReplayAction() = default;
 
   void execute(xbt::ReplayAction& action)
   {
     // Needs to be re-initialized for every action, hence here
     double start_time = smpi_process()->simulated_elapsed();
-    args.parse(action, name);
+    args_.parse(action, name_);
     kernel(action);
-    if (name != "Init")
+    if (name_ != "Init")
       log_timed_action(action, start_time);
   }
 
index 8336287..5d01d18 100644 (file)
@@ -1,6 +1,6 @@
 /* Public interface to the Link datatype                                    */
 
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 /* C interface */
 SG_BEGIN_DECL
 
-XBT_PUBLIC const char* sg_storage_get_name(sg_storage_t storage);
+XBT_PUBLIC const char* sg_storage_get_name(const_sg_storage_t storage);
 XBT_PUBLIC sg_storage_t sg_storage_get_by_name(const char* name);
-XBT_PUBLIC xbt_dict_t sg_storage_get_properties(sg_storage_t storage);
+XBT_PUBLIC xbt_dict_t sg_storage_get_properties(const_sg_storage_t storage);
 XBT_PUBLIC void sg_storage_set_property_value(sg_storage_t storage, const char* name, const char* value);
-XBT_PUBLIC const char* sg_storage_get_property_value(sg_storage_t storage, const char* name);
+XBT_PUBLIC const char* sg_storage_get_property_value(const_sg_storage_t storage, const char* name);
 XBT_PUBLIC xbt_dynar_t sg_storages_as_dynar();
 XBT_PUBLIC void sg_storage_set_data(sg_storage_t host, void* data);
-XBT_PUBLIC void* sg_storage_get_data(sg_storage_t storage);
-XBT_PUBLIC const char* sg_storage_get_host(sg_storage_t storage);
+XBT_PUBLIC void* sg_storage_get_data(const_sg_storage_t storage);
+XBT_PUBLIC const char* sg_storage_get_host(const_sg_storage_t storage);
 XBT_PUBLIC sg_size_t sg_storage_read(sg_storage_t storage, sg_size_t size);
 XBT_PUBLIC sg_size_t sg_storage_write(sg_storage_t storage, sg_size_t size);
 
index e431481..352988e 100644 (file)
@@ -1,6 +1,6 @@
 /* src/simgrid/version.h - internal versioning info                        */
 
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -32,4 +32,4 @@ SG_END_DECL
 
 #define SIMGRID_VERSION_STRING "@SIMGRID_VERSION_STRING@"
 
-#endif /* SIMGRID_PUBLIC_CONFIG_H */
+#endif /* SIMGRID_VERSION_H */
index 83f180a..b9f77d0 100644 (file)
@@ -1,6 +1,6 @@
 /* Public interface to the Link datatype                                    */
 
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -29,11 +29,11 @@ XBT_PUBLIC int sg_vm_is_created(sg_vm_t vm);
 XBT_PUBLIC int sg_vm_is_running(sg_vm_t vm);
 XBT_PUBLIC int sg_vm_is_suspended(sg_vm_t vm);
 
-XBT_PUBLIC const char* sg_vm_get_name(sg_vm_t vm);
+XBT_PUBLIC const char* sg_vm_get_name(const_sg_vm_t vm);
 XBT_PUBLIC void sg_vm_set_ramsize(sg_vm_t vm, size_t size);
-XBT_PUBLIC size_t sg_vm_get_ramsize(sg_vm_t vm);
+XBT_PUBLIC size_t sg_vm_get_ramsize(const_sg_vm_t vm);
 XBT_PUBLIC void sg_vm_set_bound(sg_vm_t vm, double bound);
-XBT_PUBLIC sg_host_t sg_vm_get_pm(sg_vm_t vm);
+XBT_PUBLIC sg_host_t sg_vm_get_pm(const_sg_vm_t vm);
 
 XBT_PUBLIC void sg_vm_start(sg_vm_t vm);
 XBT_PUBLIC void sg_vm_suspend(sg_vm_t vm);
index 909f9f9..992f13b 100644 (file)
@@ -1,6 +1,6 @@
 /* Public interface to the Link datatype                                    */
 
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 SG_BEGIN_DECL
 
 XBT_PUBLIC sg_netzone_t sg_zone_get_root();
-XBT_PUBLIC const char* sg_zone_get_name(sg_netzone_t zone);
+XBT_PUBLIC const char* sg_zone_get_name(const_sg_netzone_t zone);
 XBT_PUBLIC sg_netzone_t sg_zone_get_by_name(const char* name);
-XBT_PUBLIC void sg_zone_get_sons(sg_netzone_t zone, xbt_dict_t whereto);
-XBT_PUBLIC const char* sg_zone_get_property_value(sg_netzone_t as, const char* name);
-XBT_PUBLIC void sg_zone_set_property_value(sg_netzone_t netzone, const char* name, char* value);
-XBT_PUBLIC void sg_zone_get_hosts(sg_netzone_t zone, xbt_dynar_t whereto);
+XBT_PUBLIC void sg_zone_get_sons(const_sg_netzone_t zone, xbt_dict_t whereto);
+XBT_PUBLIC const char* sg_zone_get_property_value(const_sg_netzone_t as, const char* name);
+XBT_PUBLIC void sg_zone_set_property_value(sg_netzone_t netzone, const char* name, const char* value);
+XBT_PUBLIC void sg_zone_get_hosts(const_sg_netzone_t zone, xbt_dynar_t whereto);
 
 SG_END_DECL
 
index b9e0f29..515b34f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index b2c6e2b..a9c827f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -19,7 +19,7 @@
 
 #if SIMGRID_HAVE_MC
 #undef assert
-#define assert(x) MC_assert((int)(x))
+#define assert(x) MC_assert(!!(x))
 #endif
 
 #ifdef TRACE_CALL_LOCATION /* Defined by smpicc on the command line */
index 1dee531..909a541 100644 (file)
@@ -1,5 +1,5 @@
 ! -*- fortran -*-
-! Copyright (c) 2010-2019. The SimGrid Team.
+! Copyright (c) 2010-2020. The SimGrid Team.
 ! All rights reserved.
 
 ! This program is free software; you can redistribute it and/or modify it
index 6ed1aa8..9290d99 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 3ec0953..fc350a9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -1002,9 +1002,9 @@ XBT_PUBLIC void smpi_comm_set_copy_data_callback(void (*callback)(smx_activity_t
  */
 XBT_PUBLIC void smpi_trace_set_call_location(const char* file, int line);
 /** Fortran binding **/
-XBT_PUBLIC void smpi_trace_set_call_location_(const char* file, int* line);
+XBT_PUBLIC void smpi_trace_set_call_location_(const char* file, const int* line);
 /** Fortran binding + -fsecond-underscore **/
-XBT_PUBLIC void smpi_trace_set_call_location__(const char* file, int* line);
+XBT_PUBLIC void smpi_trace_set_call_location__(const char* file, const int* line);
 
 #define SMPI_ITER_NAME1(line) _XBT_CONCAT(iter_count, line)
 #define SMPI_ITER_NAME(line) SMPI_ITER_NAME1(line)
index 1f0067d..3e693c0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 8a21ead..c24e421 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index f8dd494..8bd82ea 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 20815aa..2c3614e 100644 (file)
@@ -1,6 +1,6 @@
 /* xbt.h - Public interface to the xbt (SimGrid's toolbox)                  */
 
-/* Copyright (c) 2004-2019. The SimGrid Team.
+/* Copyright (c) 2004-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index c85201f..d47298d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team.
+/* Copyright (c) 2015-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -19,12 +19,12 @@ template<class T>          class Extendable;
 
 template<class T, class U>
 class Extension {
-  static const std::size_t INVALID_ID = std::numeric_limits<std::size_t>::max();
-  std::size_t id_;
+  static constexpr std::size_t INVALID_ID = std::numeric_limits<std::size_t>::max();
+  std::size_t id_                         = INVALID_ID;
   friend class Extendable<T>;
   explicit constexpr Extension(std::size_t id) : id_(id) {}
 public:
-  explicit constexpr Extension() : id_(INVALID_ID) {}
+  explicit constexpr Extension() {}
   std::size_t id() const { return id_; }
   bool valid() const { return id_ != INVALID_ID; }
 };
@@ -48,7 +48,8 @@ template<class T>
 class Extendable {
 private:
   static std::vector<void(*)(void*)> deleters_;
-  std::vector<void*> extensions_;
+  std::vector<void*> extensions_{(deleters_.size() > 0 ? deleters_.size() : 1), nullptr};
+
 public:
   static size_t extension_create(void (*deleter)(void*))
   {
@@ -68,7 +69,7 @@ public:
   {
     return Extension<T, U>(extension_create([](void* p) { delete static_cast<U*>(p); }));
   }
-  Extendable() : extensions_((deleters_.size() > 0 ? deleters_.size() : 1), nullptr) {}
+  Extendable() {}
   Extendable(const Extendable&) = delete;
   Extendable& operator=(const Extendable&) = delete;
   ~Extendable()
index ee00199..c252734 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 29f5625..5372224 100644 (file)
@@ -1,6 +1,6 @@
 /*  xbt/asserts.h -- assertion mechanism                                    */
 
-/* Copyright (c) 2005-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2005-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 03339f7..e22c26c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2011-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -18,6 +18,7 @@ typedef struct xbt_automaton_state {
 } s_xbt_automaton_state;
 
 typedef struct xbt_automaton_state* xbt_automaton_state_t;
+typedef const struct xbt_automaton_state* const_xbt_automaton_state_t;
 
 typedef struct xbt_automaton {
   xbt_dynar_t propositional_symbols;
@@ -27,6 +28,7 @@ typedef struct xbt_automaton {
 } s_xbt_automaton;
 
 typedef struct xbt_automaton* xbt_automaton_t;
+typedef const struct xbt_automaton* const_xbt_automaton_t;
 
 typedef struct xbt_automaton_exp_label{
   enum{AUT_OR=0, AUT_AND=1, AUT_NOT=2, AUT_PREDICAT=3, AUT_ONE=4} type;
@@ -41,6 +43,7 @@ typedef struct xbt_automaton_exp_label{
 } s_xbt_automaton_exp_label;
 
 typedef struct xbt_automaton_exp_label* xbt_automaton_exp_label_t;
+typedef const struct xbt_automaton_exp_label* const_xbt_automaton_exp_label_t;
 
 typedef struct xbt_automaton_transition {
   xbt_automaton_state_t src;
@@ -49,16 +52,18 @@ typedef struct xbt_automaton_transition {
 } s_xbt_automaton_transition;
 
 typedef struct xbt_automaton_transition* xbt_automaton_transition_t;
+typedef const struct xbt_automaton_transition* const_xbt_automaton_transition_t;
 
 typedef struct xbt_automaton_propositional_symbol* xbt_automaton_propositional_symbol_t;
+typedef const struct xbt_automaton_propositional_symbol* const_xbt_automaton_propositional_symbol_t;
 
 typedef int (*xbt_automaton_propositional_symbol_callback_type)(void*);
 typedef void (*xbt_automaton_propositional_symbol_free_function_type)(void*);
 
 XBT_PUBLIC xbt_automaton_t xbt_automaton_new(void);
 XBT_PUBLIC void xbt_automaton_load(xbt_automaton_t automaton, const char* file);
-XBT_PUBLIC xbt_automaton_state_t xbt_automaton_state_new(xbt_automaton_t a, int type, char* id);
-XBT_PUBLIC xbt_automaton_transition_t xbt_automaton_transition_new(xbt_automaton_t a, xbt_automaton_state_t src,
+XBT_PUBLIC xbt_automaton_state_t xbt_automaton_state_new(const_xbt_automaton_t a, int type, const char* id);
+XBT_PUBLIC xbt_automaton_transition_t xbt_automaton_transition_new(const_xbt_automaton_t a, xbt_automaton_state_t src,
                                                                    xbt_automaton_state_t dst,
                                                                    xbt_automaton_exp_label_t label);
 XBT_PUBLIC xbt_automaton_exp_label_t xbt_automaton_exp_label_new_or(xbt_automaton_exp_label_t left,
@@ -66,47 +71,49 @@ XBT_PUBLIC xbt_automaton_exp_label_t xbt_automaton_exp_label_new_or(xbt_automato
 XBT_PUBLIC xbt_automaton_exp_label_t xbt_automaton_exp_label_new_and(xbt_automaton_exp_label_t left,
                                                                      xbt_automaton_exp_label_t right);
 XBT_PUBLIC xbt_automaton_exp_label_t xbt_automaton_exp_label_new_not(xbt_automaton_exp_label_t exp_not);
-XBT_PUBLIC xbt_automaton_exp_label_t xbt_automaton_exp_label_new_predicat(char* p);
+XBT_PUBLIC xbt_automaton_exp_label_t xbt_automaton_exp_label_new_predicat(const char* p);
 XBT_PUBLIC xbt_automaton_exp_label_t xbt_automaton_exp_label_new_one(void);
-XBT_PUBLIC xbt_dynar_t xbt_automaton_get_states(xbt_automaton_t a);
-XBT_PUBLIC xbt_dynar_t xbt_automaton_get_transitions(xbt_automaton_t a);
-XBT_PUBLIC xbt_automaton_transition_t xbt_automaton_get_transition(xbt_automaton_t a, xbt_automaton_state_t src,
-                                                                   xbt_automaton_state_t dst);
-XBT_PUBLIC xbt_automaton_state_t xbt_automaton_transition_get_source(xbt_automaton_transition_t t);
-XBT_PUBLIC xbt_automaton_state_t xbt_automaton_transition_get_destination(xbt_automaton_transition_t t);
+XBT_PUBLIC xbt_dynar_t xbt_automaton_get_states(const_xbt_automaton_t a);
+XBT_PUBLIC xbt_dynar_t xbt_automaton_get_transitions(const_xbt_automaton_t a);
+XBT_PUBLIC xbt_automaton_transition_t xbt_automaton_get_transition(const_xbt_automaton_t a,
+                                                                   const_xbt_automaton_state_t src,
+                                                                   const_xbt_automaton_state_t dst);
+XBT_PUBLIC xbt_automaton_state_t xbt_automaton_transition_get_source(const_xbt_automaton_transition_t t);
+XBT_PUBLIC xbt_automaton_state_t xbt_automaton_transition_get_destination(const_xbt_automaton_transition_t t);
 XBT_PUBLIC void xbt_automaton_transition_set_source(xbt_automaton_transition_t t, xbt_automaton_state_t src);
 XBT_PUBLIC void xbt_automaton_transition_set_destination(xbt_automaton_transition_t t, xbt_automaton_state_t dst);
-XBT_PUBLIC xbt_dynar_t xbt_automaton_state_get_out_transitions(xbt_automaton_state_t s);
-XBT_PUBLIC xbt_dynar_t xbt_automaton_state_get_in_transitions(xbt_automaton_state_t s);
-XBT_PUBLIC xbt_automaton_state_t xbt_automaton_state_exists(xbt_automaton_t a, char* id);
-XBT_PUBLIC void xbt_automaton_display(xbt_automaton_t a);
-XBT_PUBLIC void xbt_automaton_exp_label_display(xbt_automaton_exp_label_t l);
+XBT_PUBLIC xbt_dynar_t xbt_automaton_state_get_out_transitions(const_xbt_automaton_state_t s);
+XBT_PUBLIC xbt_dynar_t xbt_automaton_state_get_in_transitions(const_xbt_automaton_state_t s);
+XBT_PUBLIC xbt_automaton_state_t xbt_automaton_state_exists(const_xbt_automaton_t a, const char* id);
+XBT_PUBLIC void xbt_automaton_display(const_xbt_automaton_t a);
+XBT_PUBLIC void xbt_automaton_exp_label_display(const_xbt_automaton_exp_label_t l);
 
 // xbt_automaton_propositional_symbol constructors:
-XBT_PUBLIC xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new(xbt_automaton_t a,
+XBT_PUBLIC xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new(const_xbt_automaton_t a,
                                                                                        const char* id,
                                                                                        int (*fct)(void));
-XBT_PUBLIC xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new_pointer(xbt_automaton_t a,
+XBT_PUBLIC xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new_pointer(const_xbt_automaton_t a,
                                                                                                const char* id,
                                                                                                int* value);
 XBT_PUBLIC xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new_callback(
-    xbt_automaton_t a, const char* id, xbt_automaton_propositional_symbol_callback_type callback, void* data,
+    const_xbt_automaton_t a, const char* id, xbt_automaton_propositional_symbol_callback_type callback, void* data,
     xbt_automaton_propositional_symbol_free_function_type free_function);
 
 // xbt_automaton_propositional_symbol accessors:
 XBT_PUBLIC xbt_automaton_propositional_symbol_callback_type
-xbt_automaton_propositional_symbol_get_callback(xbt_automaton_propositional_symbol_t symbol);
-XBT_PUBLIC void* xbt_automaton_propositional_symbol_get_data(xbt_automaton_propositional_symbol_t symbol);
-XBT_PUBLIC const char* xbt_automaton_propositional_symbol_get_name(xbt_automaton_propositional_symbol_t symbol);
+xbt_automaton_propositional_symbol_get_callback(const_xbt_automaton_propositional_symbol_t symbol);
+XBT_PUBLIC void* xbt_automaton_propositional_symbol_get_data(const_xbt_automaton_propositional_symbol_t symbol);
+XBT_PUBLIC const char* xbt_automaton_propositional_symbol_get_name(const_xbt_automaton_propositional_symbol_t symbol);
 
 // xbt_automaton_propositional_symbol methods!
-XBT_PUBLIC int xbt_automaton_propositional_symbol_evaluate(xbt_automaton_propositional_symbol_t symbol);
-
-XBT_PUBLIC xbt_automaton_state_t xbt_automaton_get_current_state(xbt_automaton_t a);
-XBT_PUBLIC int xbt_automaton_state_compare(xbt_automaton_state_t s1, xbt_automaton_state_t s2);
-XBT_PUBLIC int xbt_automaton_propositional_symbols_compare_value(xbt_dynar_t s1, xbt_dynar_t s2);
-XBT_PUBLIC int xbt_automaton_transition_compare(const void* t1, const void* t2);
-XBT_PUBLIC int xbt_automaton_exp_label_compare(xbt_automaton_exp_label_t l1, xbt_automaton_exp_label_t l2);
+XBT_PUBLIC int xbt_automaton_propositional_symbol_evaluate(const_xbt_automaton_propositional_symbol_t symbol);
+
+XBT_PUBLIC xbt_automaton_state_t xbt_automaton_get_current_state(const_xbt_automaton_t a);
+XBT_PUBLIC int xbt_automaton_state_compare(const_xbt_automaton_state_t s1, const_xbt_automaton_state_t s2);
+XBT_PUBLIC int xbt_automaton_propositional_symbols_compare_value(const_xbt_dynar_t s1, const_xbt_dynar_t s2);
+XBT_PUBLIC int xbt_automaton_transition_compare(const_xbt_automaton_transition_t t1,
+                                                const_xbt_automaton_transition_t t2);
+XBT_PUBLIC int xbt_automaton_exp_label_compare(const_xbt_automaton_exp_label_t l1, const_xbt_automaton_exp_label_t l2);
 XBT_PUBLIC void xbt_automaton_state_free_voidp(void* s);
 XBT_PUBLIC void xbt_automaton_state_free(xbt_automaton_state_t s);
 XBT_PUBLIC void xbt_automaton_transition_free_voidp(void* t);
index c836942..58fdd75 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team.
+/* Copyright (c) 2015-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -19,9 +19,7 @@ namespace xbt {
  *  This API hides all the callback and dynamic allocation hell from
  *  the used which can use C++ style functors and lambda expressions.
  */
-template<class F>
-xbt_automaton_propositional_symbol_t add_proposition(
-  xbt_automaton_t a, const char* id, F f)
+template <class F> xbt_automaton_propositional_symbol_t add_proposition(const_xbt_automaton_t a, const char* id, F f)
 {
   F* callback = new F(std::move(f));
   return xbt_automaton_propositional_symbol_new_callback(
index ad83cea..4a3a589 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2005-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2005-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -8,11 +8,9 @@
 
 #include <xbt/base.h>
 
-#include <cstddef>
 #include <functional>
 #include <memory>
 #include <string>
-#include <vector>
 
 SG_BEGIN_DECL
 /** @brief Shows a backtrace of the current location */
@@ -38,15 +36,10 @@ class BacktraceImpl;
  */
 class Backtrace {
 public:
-  BacktraceImpl* impl_ = nullptr;
+  std::shared_ptr<BacktraceImpl> impl_;
   Backtrace();
-  Backtrace(const Backtrace& bt);
-  Backtrace(Backtrace&& bt);
-  Backtrace& operator=(const Backtrace& rhs);
-  Backtrace& operator=(Backtrace&& rhs);
-  ~Backtrace();
   /** @brief Translate the backtrace in a human friendly form, unmangled with source code locations. */
-  std::string const resolve() const;
+  std::string resolve() const;
   /** @brief Display the resolved backtrace on stderr */
   void display() const;
 };
index 5dbeb50..a81bdb2 100644 (file)
@@ -1,6 +1,6 @@
 /* xbt.h - Public interface to the xbt (simgrid's toolbox)                  */
 
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 #  define _GNU_SOURCE
 #endif
 
-// Teach the compiler that some code path is unreachable:
-#if defined(__has_builtin)
-#  if __has_builtin(__builtin_unreachable)
-#    define XBT_UNREACHABLE() __builtin_unreachable()
-#  else
-#    include <stdlib.h>
-#    define XBT_UNREACHABLE() abort()
-#  endif
-#elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
-#  define XBT_UNREACHABLE() __builtin_unreachable()
-#else
-#  include <stdlib.h>
-#  define XBT_UNREACHABLE() abort()
-#endif
-
 /* On MinGW, stdio.h defines __MINGW_PRINTF_FORMAT and __MINGW_SCANF_FORMAT
    which are the suitable format style (either gnu_printf or ms_printf)
    depending on which version is available (__USE_MINGW_ANSI_STDIO): */
@@ -95,7 +80,7 @@
 /* Concatenate arguments. _XBT_CONCAT2 adds a level of indirection over _XBT_CONCAT. */
 #define _XBT_CONCAT(a, b) a##b
 #define _XBT_CONCAT2(a, b) _XBT_CONCAT(a, b)
-#define _XBT_CONCAT3(a, b, c) _XBT_CONCAT2(_XBT_CONCAT(a, b), c)
+#define _XBT_CONCAT3(a, b, c) _XBT_CONCAT2(_XBT_CONCAT2(a, b), c)
 #define _XBT_CONCAT4(a, b, c, d) _XBT_CONCAT2(_XBT_CONCAT3(a, b, c), d)
 
 /*
index 517909c..2fde39a 100644 (file)
@@ -1,7 +1,7 @@
 /* config - Dictionary where the type of each cell is provided.             */
 /* This is useful to build named structs, like option or property sets.     */
 
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -70,17 +70,6 @@ XBT_PUBLIC void sg_cfg_set_boolean(const char* name, const char* val);
 XBT_PUBLIC void sg_cfg_set_string(const char* name, const char* val);
 /* @} */
 
-/** @defgroup XBT_cfg_decl Configuration type declaration and memory management
- *  @ingroup XBT_config
- *
- *  @{
- */
-
-/** @brief Callback types. They get the name of the modified entry, and the position of the changed value */
-typedef void (*xbt_cfg_cb_t)(const char* name);
-
-/** @} */
-
 /** @defgroup XBT_cfg_get Getting the stored values
  *  @ingroup XBT_config
  *
index a0406db..7dedb71 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -217,7 +217,6 @@ class Flag {
   std::string name_;
 
 public:
-
   /** Constructor
    *
    *  @param name  Flag name
@@ -287,7 +286,7 @@ public:
   template<class U>
   Flag& operator=(U const& that) { value_ = that; return *this; }
   template<class U>
-  Flag& operator=(U && that)     { value_ = that; return *this; }
+  Flag& operator=(U&& that) { value_ = std::forward<U>(that); return *this; }
   template<class U>
   bool operator==(U const& that) const { return value_ == that; }
   template<class U>
@@ -305,7 +304,7 @@ public:
 XBT_PUBLIC void finalize();
 XBT_PUBLIC void show_aliases();
 XBT_PUBLIC void help();
-}
-}
+} // namespace config
+} // namespace simgrid
 
 #endif
index e36d2b9..9100c50 100644 (file)
@@ -1,6 +1,6 @@
 /* xbt/dict.h -- api to a generic dictionary                                */
 
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -45,6 +45,7 @@ SG_BEGIN_DECL
 
 /** @brief Dictionary data type (opaque structure) */
 typedef struct s_xbt_dict *xbt_dict_t;
+typedef const struct s_xbt_dict* const_xbt_dict_t;
 typedef struct s_xbt_dictelm *xbt_dictelm_t;
 typedef struct s_xbt_dictelm {
   char *key;
@@ -58,7 +59,7 @@ typedef struct s_xbt_dictelm {
 
 XBT_PUBLIC xbt_dict_t xbt_dict_new_homogeneous(void_f_pvoid_t free_ctn);
 XBT_PUBLIC void xbt_dict_free(xbt_dict_t* dict);
-XBT_PUBLIC unsigned int xbt_dict_size(xbt_dict_t dict);
+XBT_PUBLIC unsigned int xbt_dict_size(const_xbt_dict_t dict);
 
 /** @} */
 /** @defgroup XBT_dict_basic Dictionaries basic usage
@@ -70,16 +71,11 @@ XBT_PUBLIC unsigned int xbt_dict_size(xbt_dict_t dict);
  */
 
 XBT_PUBLIC void xbt_dict_set(xbt_dict_t dict, const char* key, void* data);
-XBT_PUBLIC void* xbt_dict_get(xbt_dict_t dict, const char* key);
-XBT_PUBLIC void* xbt_dict_get_or_null(xbt_dict_t dict, const char* key);
-XBT_PUBLIC char* xbt_dict_get_key(xbt_dict_t dict, const void* data);
-XBT_PUBLIC xbt_dictelm_t xbt_dict_get_elm(xbt_dict_t dict, const char* key);
-XBT_PUBLIC xbt_dictelm_t xbt_dict_get_elm_or_null(xbt_dict_t dict, const char* key);
+XBT_PUBLIC void* xbt_dict_get_or_null(const_xbt_dict_t dict, const char* key);
+XBT_PUBLIC xbt_dictelm_t xbt_dict_get_elm_or_null(const_xbt_dict_t dict, const char* key);
 
-XBT_PUBLIC void xbt_dict_remove(xbt_dict_t dict, const char* key);
-XBT_PUBLIC void xbt_dict_reset(xbt_dict_t dict);
-XBT_PUBLIC int xbt_dict_length(xbt_dict_t dict);
-XBT_PUBLIC int xbt_dict_is_empty(xbt_dict_t dict);
+XBT_PUBLIC int xbt_dict_length(const_xbt_dict_t dict);
+XBT_PUBLIC int xbt_dict_is_empty(const_xbt_dict_t dict);
 
 /** @} */
 /** @defgroup XBT_dict_nnul Dictionaries with non-nul terminated keys
@@ -90,14 +86,13 @@ XBT_PUBLIC int xbt_dict_is_empty(xbt_dict_t dict);
  *  @{
  */
 XBT_PUBLIC void xbt_dict_set_ext(xbt_dict_t dict, const char* key, int key_len, void* data);
-XBT_PUBLIC void* xbt_dict_get_ext(xbt_dict_t dict, const char* key, int key_len);
-XBT_PUBLIC void* xbt_dict_get_or_null_ext(xbt_dict_t dict, const char* key, int key_len);
+XBT_PUBLIC void* xbt_dict_get_or_null_ext(const_xbt_dict_t dict, const char* key, int key_len);
 XBT_PUBLIC void xbt_dict_remove_ext(xbt_dict_t dict, const char* key, int key_len);
 
 struct s_xbt_dict_cursor {
   xbt_dictelm_t current;
   int line;
-  xbt_dict_t dict;
+  const_xbt_dict_t dict;
 };
 
 /** @} */
@@ -124,20 +119,17 @@ struct s_xbt_dict_cursor {
 
 /** @brief Cursor on dictionaries (opaque type) */
 typedef struct s_xbt_dict_cursor *xbt_dict_cursor_t;
+typedef const struct s_xbt_dict_cursor* const_xbt_dict_cursor_t;
 
-static inline xbt_dictelm_t xbt_dict_cursor_get_elm(xbt_dict_cursor_t cursor) {
-  return cursor->current;
-}
-
-XBT_PUBLIC xbt_dict_cursor_t xbt_dict_cursor_new(const xbt_dict_t dict);
+XBT_PUBLIC xbt_dict_cursor_t xbt_dict_cursor_new(const_xbt_dict_t dict);
 XBT_PUBLIC void xbt_dict_cursor_free(xbt_dict_cursor_t* cursor);
 
 XBT_PUBLIC void xbt_dict_cursor_rewind(xbt_dict_cursor_t cursor);
 
-XBT_PUBLIC char* xbt_dict_cursor_get_key(xbt_dict_cursor_t cursor);
-XBT_PUBLIC void* xbt_dict_cursor_get_data(xbt_dict_cursor_t cursor);
+XBT_PUBLIC char* xbt_dict_cursor_get_key(const_xbt_dict_cursor_t cursor);
+XBT_PUBLIC void* xbt_dict_cursor_get_data(const_xbt_dict_cursor_t cursor);
 
-XBT_PUBLIC void xbt_dict_cursor_first(const xbt_dict_t dict, xbt_dict_cursor_t* cursor);
+XBT_PUBLIC void xbt_dict_cursor_first(const_xbt_dict_t dict, xbt_dict_cursor_t* cursor);
 XBT_PUBLIC void xbt_dict_cursor_step(xbt_dict_cursor_t cursor);
 XBT_PUBLIC int xbt_dict_cursor_get_or_free(xbt_dict_cursor_t* cursor, char** key, void** data);
 /** @def xbt_dict_foreach
index 46fa9c8..165aa95 100644 (file)
@@ -1,6 +1,6 @@
 /* dynar - a generic dynamic array                                          */
 
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -63,15 +63,12 @@ SG_BEGIN_DECL
  */
 /** @brief Dynar data type (opaque type) */
 typedef struct xbt_dynar_s *xbt_dynar_t;
+typedef const struct xbt_dynar_s* const_xbt_dynar_t;
 
-XBT_PUBLIC xbt_dynar_t xbt_dynar_new(const unsigned long elm_size, void_f_pvoid_t const free_f);
-XBT_PUBLIC void xbt_dynar_init(xbt_dynar_t dynar, const unsigned long elmsize, void_f_pvoid_t const free_f);
+XBT_PUBLIC xbt_dynar_t xbt_dynar_new(const unsigned long elm_size, void_f_pvoid_t free_f);
 XBT_PUBLIC void xbt_dynar_free(xbt_dynar_t* dynar);
-XBT_PUBLIC void xbt_dynar_free_voidp(void* dynar);
 XBT_PUBLIC void xbt_dynar_free_container(xbt_dynar_t* dynar);
-XBT_PUBLIC void xbt_dynar_free_data(xbt_dynar_t dynar);
 XBT_PUBLIC void xbt_dynar_shrink(xbt_dynar_t dynar, int empty_slots);
-XBT_PUBLIC void xbt_dynar_dump(xbt_dynar_t dynar);
 
 /** @} */
 /** @defgroup XBT_dynar_array Dynar as a regular array
@@ -80,19 +77,14 @@ XBT_PUBLIC void xbt_dynar_dump(xbt_dynar_t dynar);
  *  @{
  */
 
-XBT_PUBLIC void xbt_dynar_get_cpy(const xbt_dynar_t dynar, const unsigned long idx, void* const dst);
-XBT_PUBLIC void xbt_dynar_set(xbt_dynar_t dynar, const int idx, const void* src);
-XBT_PUBLIC void xbt_dynar_replace(xbt_dynar_t dynar, const unsigned long idx, const void* object);
+XBT_PUBLIC void xbt_dynar_get_cpy(const_xbt_dynar_t dynar, unsigned long idx, void* dst);
 
-XBT_PUBLIC void xbt_dynar_insert_at(xbt_dynar_t const dynar, const int idx, const void* src);
-XBT_PUBLIC void xbt_dynar_remove_at(xbt_dynar_t const dynar, const int idx, void* const dst);
-XBT_PUBLIC void xbt_dynar_remove_n_at(xbt_dynar_t const dynar, const unsigned int n, const int idx);
+XBT_PUBLIC void xbt_dynar_insert_at(xbt_dynar_t dynar, int idx, const void* src);
+XBT_PUBLIC void xbt_dynar_remove_at(xbt_dynar_t dynar, int idx, void* dst);
 
-XBT_PUBLIC unsigned int xbt_dynar_search(xbt_dynar_t const dynar, void* elem);
-XBT_PUBLIC signed int xbt_dynar_search_or_negative(xbt_dynar_t const dynar, void* const elem);
-XBT_PUBLIC int xbt_dynar_member(xbt_dynar_t const dynar, void* elem);
-XBT_PUBLIC void xbt_dynar_sort(xbt_dynar_t const dynar, int_f_cpvoid_cpvoid_t compar_fn);
-XBT_PUBLIC int xbt_dynar_compare(xbt_dynar_t d1, xbt_dynar_t d2, int (*compar)(const void*, const void*));
+XBT_PUBLIC signed int xbt_dynar_search_or_negative(const_xbt_dynar_t dynar, const void* elem);
+XBT_PUBLIC int xbt_dynar_member(const_xbt_dynar_t dynar, const void* elem);
+XBT_PUBLIC void xbt_dynar_sort(const_xbt_dynar_t dynar, int_f_cpvoid_cpvoid_t compar_fn);
 XBT_PUBLIC void* xbt_dynar_to_array(xbt_dynar_t dynar);
 
 /** @} */
@@ -102,10 +94,9 @@ XBT_PUBLIC void* xbt_dynar_to_array(xbt_dynar_t dynar);
  *  @{
  */
 
-XBT_PUBLIC unsigned long xbt_dynar_length(const xbt_dynar_t dynar);
-XBT_PUBLIC int xbt_dynar_is_empty(const xbt_dynar_t dynar);
-XBT_PUBLIC void xbt_dynar_reset(xbt_dynar_t const dynar);
-XBT_PUBLIC void xbt_dynar_merge(xbt_dynar_t* d1, xbt_dynar_t* d2);
+XBT_PUBLIC unsigned long xbt_dynar_length(const_xbt_dynar_t dynar);
+XBT_PUBLIC int xbt_dynar_is_empty(const_xbt_dynar_t dynar);
+XBT_PUBLIC void xbt_dynar_reset(xbt_dynar_t dynar);
 
 /** @} */
 /** @defgroup XBT_dynar_perl Perl-like use of dynars
@@ -114,11 +105,11 @@ XBT_PUBLIC void xbt_dynar_merge(xbt_dynar_t* d1, xbt_dynar_t* d2);
  *  @{
  */
 
-XBT_PUBLIC void xbt_dynar_push(xbt_dynar_t const dynar, const void* src);
-XBT_PUBLIC void xbt_dynar_pop(xbt_dynar_t const dynar, void* const dst);
-XBT_PUBLIC void xbt_dynar_unshift(xbt_dynar_t const dynar, const void* src);
-XBT_PUBLIC void xbt_dynar_shift(xbt_dynar_t const dynar, void* const dst);
-XBT_PUBLIC void xbt_dynar_map(const xbt_dynar_t dynar, void_f_pvoid_t const op);
+XBT_PUBLIC void xbt_dynar_push(xbt_dynar_t dynar, const void* src);
+XBT_PUBLIC void xbt_dynar_pop(xbt_dynar_t dynar, void* dst);
+XBT_PUBLIC void xbt_dynar_unshift(xbt_dynar_t dynar, const void* src);
+XBT_PUBLIC void xbt_dynar_shift(xbt_dynar_t dynar, void* dst);
+XBT_PUBLIC void xbt_dynar_map(const_xbt_dynar_t dynar, void_f_pvoid_t op);
 
 /** @} */
 /** @defgroup XBT_dynar_ctn Direct manipulation to the dynars content
@@ -129,11 +120,11 @@ XBT_PUBLIC void xbt_dynar_map(const xbt_dynar_t dynar, void_f_pvoid_t const op);
  *  @{
  */
 
-XBT_PUBLIC void* xbt_dynar_set_at_ptr(const xbt_dynar_t dynar, const unsigned long idx);
-XBT_PUBLIC void* xbt_dynar_get_ptr(const xbt_dynar_t dynar, const unsigned long idx);
-XBT_PUBLIC void* xbt_dynar_insert_at_ptr(xbt_dynar_t const dynar, const int idx);
-XBT_PUBLIC void* xbt_dynar_push_ptr(xbt_dynar_t const dynar);
-XBT_PUBLIC void* xbt_dynar_pop_ptr(xbt_dynar_t const dynar);
+XBT_PUBLIC void* xbt_dynar_set_at_ptr(const xbt_dynar_t dynar, unsigned long idx);
+XBT_PUBLIC void* xbt_dynar_get_ptr(const_xbt_dynar_t dynar, unsigned long idx);
+XBT_PUBLIC void* xbt_dynar_insert_at_ptr(xbt_dynar_t dynar, int idx);
+XBT_PUBLIC void* xbt_dynar_push_ptr(xbt_dynar_t dynar);
+XBT_PUBLIC void* xbt_dynar_pop_ptr(xbt_dynar_t dynar);
 
 /** @} */
 /** @defgroup XBT_dynar_speed Speed optimized access to dynars of scalars
@@ -160,9 +151,6 @@ XBT_PUBLIC void* xbt_dynar_pop_ptr(xbt_dynar_t const dynar);
  *  @hideinitializer */
 #  define xbt_dynar_getfirst_as(dynar,type) \
           (*(type*)xbt_dynar_get_ptr((dynar),0))
-/** @brief Quick insertion of scalar content
- *  @hideinitializer */
-#define xbt_dynar_insert_at_as(dynar, idx, type, value) *(type*)xbt_dynar_insert_at_ptr((dynar), (idx)) = (value)
 /** @brief Quick insertion of scalar content
  *  @hideinitializer */
 #define xbt_dynar_push_as(dynar, type, value) *(type*)xbt_dynar_push_ptr(dynar) = (value)
@@ -183,7 +171,7 @@ XBT_PUBLIC void* xbt_dynar_pop_ptr(xbt_dynar_t const dynar);
  *  @{
  */
 
-XBT_PUBLIC void xbt_dynar_cursor_rm(xbt_dynar_t dynar, unsigned int* const cursor);
+XBT_PUBLIC void xbt_dynar_cursor_rm(xbt_dynar_t dynar, unsigned int* cursor);
 
 /*
  * @warning DO NOT USE THIS STRUCTURE DIRECTLY! Instead, use the public interface:
@@ -201,7 +189,7 @@ typedef struct xbt_dynar_s {
   void_f_pvoid_t free_f;
 } s_xbt_dynar_t;
 
-static inline int _xbt_dynar_cursor_get(const xbt_dynar_t dynar, unsigned int idx, void* const dst)
+static inline int _xbt_dynar_cursor_get(const_xbt_dynar_t dynar, unsigned int idx, void* dst)
 {
   if (!dynar) /* iterating over a NULL dynar is a no-op */
     return 0;
@@ -237,16 +225,6 @@ xbt_dynar_foreach (dyn,cpt,str) {
 #define xbt_dynar_foreach(_dynar, _cursor, _data)                                                                      \
   for ((_cursor) = 0; _xbt_dynar_cursor_get((_dynar), (_cursor), &(_data)); (_cursor)++)
 
-#ifndef __cplusplus
-#define xbt_dynar_foreach_ptr(_dynar, _cursor, _ptr)                                                                   \
-  for ((_cursor) = 0; ((_ptr) = (_cursor) < (_dynar)->used ? xbt_dynar_get_ptr((_dynar), (_cursor)) : NULL);           \
-       (_cursor)++)
-#else
-#define xbt_dynar_foreach_ptr(_dynar, _cursor, _ptr)                                                                   \
-  for ((_cursor) = 0;                                                                                                  \
-       ((_ptr) = (_cursor) < (_dynar)->used ? (decltype(_ptr))xbt_dynar_get_ptr((_dynar), (_cursor)) : NULL);          \
-       (_cursor)++)
-#endif
 /** @} */
 SG_END_DECL
 
index bb9ff8f..963d9b6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2005-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2005-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -58,4 +58,4 @@ XBT_ATTRIB_NORETURN XBT_PUBLIC void xbt_throw_unimplemented(const char* file, in
 SG_END_DECL
 
 /** @} */
-#endif                          /* __XBT_EX_H__ */
+#endif /* XBT_EX_H */
index 649296c..e98178f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 3bbef68..9bd7432 100644 (file)
@@ -1,6 +1,6 @@
 /* function_type.h - classical types for pointer to function                */
 
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 386830b..b7e361e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -27,7 +27,6 @@ namespace simgrid {
 namespace xbt {
 
 template <class F> class MainFunction {
-private:
   F code_;
   std::shared_ptr<const std::vector<std::string>> args_;
 
@@ -109,8 +108,6 @@ template<class T> class Task;
  */
 template<class R, class... Args>
 class Task<R(Args...)> {
-private:
-
   // Placeholder for some class type:
   struct whatever {};
 
@@ -171,8 +168,7 @@ public:
       that.vtable_->move(buffer_, that.buffer_);
     else
       std::memcpy(static_cast<void*>(&buffer_), static_cast<void*>(&that.buffer_), sizeof(buffer_));
-
-    vtable_ = that.vtable_;
+    vtable_      = std::move(that.vtable_);
     that.vtable_ = nullptr;
   }
   Task& operator=(Task const& that) = delete;
@@ -183,13 +179,12 @@ public:
       that.vtable_->move(buffer_, that.buffer_);
     else
       std::memcpy(static_cast<void*>(&buffer_), static_cast<void*>(&that.buffer_), sizeof(buffer_));
-    vtable_ = that.vtable_;
+    vtable_      = std::move(that.vtable_);
     that.vtable_ = nullptr;
     return *this;
   }
 
 private:
-
   template<class F>
   typename std::enable_if<canSBO<F>()>::type
   init(F code)
@@ -200,6 +195,7 @@ private:
         F* src = reinterpret_cast<F*>(&buffer);
         F code = std::move(*src);
         src->~F();
+        // NOTE: std::forward<Args>(args)... is correct.
         return code(std::forward<Args>(args)...);
       },
       // Destroy:
@@ -228,6 +224,7 @@ private:
       [](TaskUnion& buffer, Args... args) {
         // Delete F when we go out of scope:
         std::unique_ptr<F> code(*reinterpret_cast<F**>(&buffer));
+        // NOTE: std::forward<Args>(args)... is correct.
         return (*code)(std::forward<Args>(args)...);
       },
       // Destroy:
@@ -254,13 +251,14 @@ public:
       throw std::bad_function_call();
     const TaskVtable* vtable = vtable_;
     vtable_ = nullptr;
+    // NOTE: std::forward<Args>(args)... is correct.
+    // see C++ [func.wrap.func.inv] for an example
     return vtable->call(buffer_, std::forward<Args>(args)...);
   }
 };
 
 template<class F, class... Args>
 class TaskImpl {
-private:
   F code_;
   std::tuple<Args...> args_;
   typedef decltype(simgrid::xbt::apply(std::move(code_), std::move(args_))) result_type;
index 4d2842f..1dccc74 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team.
+/* Copyright (c) 2015-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index b60194f..e3e244e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -50,23 +50,23 @@ typedef struct xbt_graph {
 
 /* API */
 XBT_PUBLIC xbt_graph_t xbt_graph_new_graph(unsigned short int directed, void* data);
-XBT_PUBLIC xbt_node_t xbt_graph_new_node(xbt_graph_t g, void* data);
-XBT_PUBLIC xbt_edge_t xbt_graph_new_edge(xbt_graph_t g, xbt_node_t src, xbt_node_t dst, void* data);
-XBT_PUBLIC void* xbt_graph_node_get_data(xbt_node_t node);
+XBT_PUBLIC xbt_node_t xbt_graph_new_node(const s_xbt_graph_t* g, void* data);
+XBT_PUBLIC xbt_edge_t xbt_graph_new_edge(const s_xbt_graph_t* g, xbt_node_t src, xbt_node_t dst, void* data);
+XBT_PUBLIC void* xbt_graph_node_get_data(const s_xbt_node_t* node);
 XBT_PUBLIC void xbt_graph_node_set_data(xbt_node_t node, void* data);
-XBT_PUBLIC void* xbt_graph_edge_get_data(xbt_edge_t edge);
+XBT_PUBLIC void* xbt_graph_edge_get_data(const s_xbt_edge_t* edge);
 XBT_PUBLIC void xbt_graph_edge_set_data(xbt_edge_t edge, void* data);
 
-XBT_PUBLIC xbt_edge_t xbt_graph_get_edge(xbt_graph_t g, xbt_node_t src, xbt_node_t dst);
+XBT_PUBLIC xbt_edge_t xbt_graph_get_edge(const s_xbt_graph_t* g, const s_xbt_node_t* src, const s_xbt_node_t* dst);
 
 XBT_PUBLIC void xbt_graph_free_graph(xbt_graph_t g, void_f_pvoid_t node_free_function,
                                      void_f_pvoid_t edge_free_function, void_f_pvoid_t graph_free_function);
 
-XBT_PUBLIC xbt_dynar_t xbt_graph_get_nodes(xbt_graph_t g);
-XBT_PUBLIC xbt_dynar_t xbt_graph_get_edges(xbt_graph_t g);
-XBT_PUBLIC xbt_dynar_t xbt_graph_node_get_outedges(xbt_node_t n);
-XBT_PUBLIC xbt_node_t xbt_graph_edge_get_source(xbt_edge_t e);
-XBT_PUBLIC xbt_node_t xbt_graph_edge_get_target(xbt_edge_t e);
+XBT_PUBLIC xbt_dynar_t xbt_graph_get_nodes(const s_xbt_graph_t* g);
+XBT_PUBLIC xbt_dynar_t xbt_graph_get_edges(const s_xbt_graph_t* g);
+XBT_PUBLIC xbt_dynar_t xbt_graph_node_get_outedges(const s_xbt_node_t* n);
+XBT_PUBLIC xbt_node_t xbt_graph_edge_get_source(const s_xbt_edge_t* e);
+XBT_PUBLIC xbt_node_t xbt_graph_edge_get_target(const s_xbt_edge_t* e);
 
 SG_END_DECL
 #endif /* XBT_GRAPH_H */
index c5415c1..888d028 100644 (file)
@@ -1,6 +1,6 @@
 /* log - a generic logging facility in the spirit of log4j                  */
 
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -493,4 +493,4 @@ extern xbt_log_layout_t xbt_log_default_layout;
 #define XBT_HELP(...) XBT_CINFO(xbt_help, __VA_ARGS__)
 
 SG_END_DECL
-#endif                          /* ! _XBT_LOG_H_ */
+#endif /* XBT_LOG_H */
index 3f74fb5..c28f642 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -19,5 +19,6 @@ namespace xbt {
 XBT_PUBLIC void log_exception(e_xbt_log_priority_t priority, const char* context, std::exception const& exception);
 
 XBT_PUBLIC void install_exception_handler();
-}
-}
+
+} // namespace xbt
+} // namespace simgrid
index 4575ee8..e6ba911 100644 (file)
@@ -1,6 +1,6 @@
 /* xbt/mallocator.h -- api to recycle allocated objects                     */
 
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -51,4 +51,4 @@ XBT_PUBLIC void xbt_mallocator_initialization_is_done(int protect);
 /** @} */
 
 SG_END_DECL
-#endif                          /* _XBT_MALLOCATOR_H */
+#endif /* XBT_MALLOCATOR_H */
index 2af7be8..66bd597 100644 (file)
@@ -1,6 +1,6 @@
 /* xbt.h - Public interface to the xbt (simgrid's toolbox)                  */
 
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 1ad8aa6..942c6db 100644 (file)
@@ -1,6 +1,6 @@
 /* module - modularize the code                                             */
 
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 50fabfa..9a63317 100644 (file)
@@ -1,6 +1,6 @@
 /* A thread pool.                                          */
 
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index b1d8b14..4c3eff5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.               */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.               */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 872efe1..ffe7160 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team.
+/* Copyright (c) 2016-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index f612332..bb8c27e 100644 (file)
@@ -1,6 +1,6 @@
 /* xbt/replay_reader.h -- Tools to parse a replay file                */
 
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index a5e6544..4289edd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 352d544..d0bc0a6 100644 (file)
@@ -1,6 +1,6 @@
 /* str.h - XBT string related functions.                                    */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 46063e3..89311f0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -89,10 +89,8 @@ public:
   string() : string(&NUL, 0) {}
   explicit string(const char* s) : string(s, strlen(s)) {}
   string(string const& s) : string(s.c_str(), s.size()) {}
-  string(string&& s)
+  string(string&& s) : str(std::move(s.str))
   {
-    str.len    = s.str.len;
-    str.data   = s.str.data;
     s.str.len  = 0;
     s.str.data = &NUL;
   }
index d11e3e3..d882899 100644 (file)
@@ -1,6 +1,6 @@
 /* xbt/synchro.h -- Simulated synchronization                               */
 
-/* Copyright (c) 2009-2019. The SimGrid Team.                               */
+/* Copyright (c) 2009-2020. The SimGrid Team.                               */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 4f11f0e..1480cf9 100644 (file)
@@ -2,7 +2,7 @@
 /*  no system header should be loaded out of this file so that we have only */
 /*  one file to check when porting to another OS                            */
 
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 262bfa8..cc87669 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team.
+/* Copyright (c) 2016-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index e80adf5..c39cf85 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team.
+/* Copyright (c) 2016-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 98cd941..21b3d89 100644 (file)
@@ -1,6 +1,6 @@
 /* virtu - virtualization layer for the logging to know about the actors    */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -9,9 +9,22 @@
 #define XBT_VIRTU_H
 
 #include <xbt/base.h>
-#include <xbt/dynar.h>
-#include <xbt/function_types.h>
-#include <xbt/misc.h>
+
+#ifdef __cplusplus
+#include <string>
+#include <vector>
+
+namespace simgrid {
+namespace xbt {
+
+/* Get the name of the UNIX process englobing the world */
+XBT_PUBLIC_DATA std::string binary_name;
+/** Contains all the parameters we got from the command line (including argv[0]) */
+XBT_PUBLIC_DATA std::vector<std::string> cmdline;
+
+} // namespace xbt
+} // namespace simgrid
+#endif
 
 SG_BEGIN_DECL
 
@@ -19,11 +32,6 @@ XBT_PUBLIC const char* xbt_procname(void);
 
 XBT_PUBLIC int xbt_getpid(void);
 
-/* Get the name of the UNIX process englobing the world */
-XBT_PUBLIC_DATA char* xbt_binary_name;
-
-/** Contains all the parameters we got from the command line (including argv[0]) */
-XBT_PUBLIC_DATA xbt_dynar_t xbt_cmdline;
-
 SG_END_DECL
+
 #endif /* XBT_VIRTU_H */
index 77b27e1..92dc497 100644 (file)
@@ -1,6 +1,6 @@
 /*  xbt/xbt_os_timer.h -- system dependency on time functions               */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -21,10 +21,11 @@ XBT_PUBLIC double xbt_os_time(void);
 XBT_PUBLIC void xbt_os_sleep(double sec);
 
 typedef struct s_xbt_os_timer *xbt_os_timer_t;
+typedef const struct s_xbt_os_timer* const_xbt_os_timer_t;
 
 XBT_PUBLIC xbt_os_timer_t xbt_os_timer_new(void);
 XBT_PUBLIC void xbt_os_timer_free(xbt_os_timer_t timer);
-XBT_PUBLIC double xbt_os_timer_elapsed(xbt_os_timer_t timer);
+XBT_PUBLIC double xbt_os_timer_elapsed(const_xbt_os_timer_t timer);
 XBT_PUBLIC size_t xbt_os_timer_size(void);
 
 XBT_PUBLIC void xbt_os_walltimer_start(xbt_os_timer_t timer);
index 4fbd2e3..30b086f 100644 (file)
@@ -14,31 +14,31 @@ sonar.sources=src,examples,include,teshsuite
 
 
 # Disable some rules on some files
-sonar.issue.ignore.multicriteria=j1,j2,j3,j4,j5,jni1,jni2,c1,c2a,c2b,c3,c4a,c4b,c5a,c5b,c6a,c6b,c7,c8,c9,c10,f1,p1,s1,s2,s3,s4
+sonar.issue.ignore.multicriteria=j1,j2,j3,j4,j5,jni1,jni2,c1,c2a,c2b,c3,c4a,c4b,c5a,c5b,c6a,c6b,c7,c8,c9,c10,f1,p1,s1,s2,s3,s4,s5
 
 # The Object.finalize() method should not be overridden
 # But we need to clean the native memory with JNI
-sonar.issue.ignore.multicriteria.j1.ruleKey=squid:ObjectFinalizeOverridenCheck
+sonar.issue.ignore.multicriteria.j1.ruleKey=java:S1113
 sonar.issue.ignore.multicriteria.j1.resourceKey=**/*.java
 
 # Throwable.printStackTrace(...) should not be called
 # But we don't have no better mechanism, and our Java apps are not rocket science
-sonar.issue.ignore.multicriteria.j2.ruleKey=squid:S1148
+sonar.issue.ignore.multicriteria.j2.ruleKey=java:S1148
 sonar.issue.ignore.multicriteria.j2.resourceKey=**/*.java
 
 # Using command line arguments is security-sensitive
 # But the authors of the applications using our library will be their only users, so there is no security concern
-sonar.issue.ignore.multicriteria.j3.ruleKey=squid:S4823
+sonar.issue.ignore.multicriteria.j3.ruleKey=java:S4823
 sonar.issue.ignore.multicriteria.j3.resourceKey=**/*.java
 
 # Standard outputs should not be used directly to log anything
 # But this file is used before SimGrid is initialized
-sonar.issue.ignore.multicriteria.j4.ruleKey=squid:S106
+sonar.issue.ignore.multicriteria.j4.ruleKey=java:S106
 sonar.issue.ignore.multicriteria.j4.resourceKey=src/bindings/java/org/simgrid/NativeLib.java
 
 # Deprecated code should be removed
 # We do have a process to remove deprecated code
-sonar.issue.ignore.multicriteria.j5.ruleKey=squid:S1133
+sonar.issue.ignore.multicriteria.j5.ruleKey=java:S1133
 sonar.issue.ignore.multicriteria.j5.resourceKey=**/*.java
 
 # "reinterpret_cast" should not be used
@@ -138,6 +138,11 @@ sonar.issue.ignore.multicriteria.s3.resourceKey=src/smpi/**/*.cpp
 sonar.issue.ignore.multicriteria.s4.ruleKey=cpp:S859
 sonar.issue.ignore.multicriteria.s4.resourceKey=src/smpi/**/*.cpp
 
+# Pointer and reference parameters should be "const" if the corresponding object is not modified
+# AFAICT, the "constness" is required by the MPI standard and cannot be fixed.
+sonar.issue.ignore.multicriteria.s5.ruleKey=cpp:S995
+sonar.issue.ignore.multicriteria.s5.resourceKey=src/smpi/bindings/*.cpp
+
 # Exclude some files from the analysis:
 #  - our unit tests
 #  - the tests that we borrowed elsewhere (MPICH and ISP)
@@ -170,7 +175,7 @@ sonar.coverage.exclusions=teshsuite/smpi/isp/**,teshsuite/smpi/mpich3-test/**,**
 sonar.sourceEncoding=UTF-8
 
 # Version of the used prog languages
-sonar.java.source=7
+sonar.java.source=8
 sonar.java.binaries=CMakeFiles/simgrid-java_jar.dir,examples/deprecated/java
 
 # Don't talk to me: travis don't like your verbosity
@@ -184,3 +189,5 @@ sonar.java.binaries=CMakeFiles/simgrid-java_jar.dir,examples/deprecated/java
 #sonar.python.coverage.reportPaths
 #sonar.coverage.jacoco.xmlReportPaths
 #sonar.cfamily.threads
+#sonar.cfamily.cache.enabled
+#sonar.cfamily.cache.path
index ad355eb..ff99355 100644 (file)
@@ -1,6 +1,6 @@
 /* Context switching within the JVM.                                        */
 
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -29,7 +29,7 @@ ContextFactory* java_factory()
 
 JavaContextFactory::JavaContextFactory() : ContextFactory()
 {
-  xbt_assert(xbt_binary_name && strcmp(xbt_binary_name, "java") == 0); // Set by Java_org_simgrid_msg_Msg_init
+  xbt_assert(xbt::binary_name == "java");
 }
 
 JavaContextFactory::~JavaContextFactory()=default;
index 573e4f8..5a7caf6 100644 (file)
@@ -1,6 +1,6 @@
 /* Context switching within the JVM.                                        */
 
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -51,4 +51,4 @@ XBT_PRIVATE void java_main_jprocess(jobject process);
 
 }}} // namespace simgrid::kernel::context
 
-#endif                          /* !_XBT_CONTEXT_JAVA_H */
+#endif /* SIMGRID_JAVA_JAVA_CONTEXT_HPP */
index 66231b3..9533b5f 100644 (file)
@@ -1,6 +1,6 @@
 /* Java Wrappers to the MSG API.                                            */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -52,7 +52,7 @@ JavaVM *__java_vm = nullptr;
 JNIEnv *get_current_thread_env()
 {
   using simgrid::kernel::context::JavaContext;
-  JavaContext* ctx = static_cast<JavaContext*>(simgrid::kernel::context::Context::self());
+  const JavaContext* ctx = static_cast<JavaContext*>(simgrid::kernel::context::Context::self());
   if (ctx)
     return ctx->jenv_;
   else
@@ -92,7 +92,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, j
   env->GetJavaVM(&__java_vm);
 
   simgrid::kernel::context::factory_initializer = &simgrid::kernel::context::java_factory;
-  jthrowable exc = env->ExceptionOccurred();
+  const _jthrowable* exc                        = env->ExceptionOccurred();
   if (exc) {
     env->ExceptionClear();
   }
@@ -104,7 +104,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, j
     argc += static_cast<int>(env->GetArrayLength(jargs));
   xbt_assert(argc > 0);
 
-  // Need a static storage because the XBT layer saves the arguments in xbt_binary_name and xbt_cmdline.
+  // Need a static storage because the XBT layer saves the arguments in xbt::binary_name and xbt::cmdline.
   static std::vector<std::string> args;
   args.reserve(argc);
 
@@ -144,7 +144,7 @@ JNIEXPORT void JNICALL JNICALL Java_org_simgrid_msg_Msg_run(JNIEnv * env, jclass
   /* Cleanup java hosts */
   xbt_dynar_t hosts = MSG_hosts_as_dynar();
   for (unsigned long index = 0; index < xbt_dynar_length(hosts) - 1; index++) {
-    msg_host_t msg_host = xbt_dynar_get_as(hosts,index,msg_host_t);
+    auto const* msg_host = xbt_dynar_get_as(hosts, index, msg_host_t);
     jobject jhost = (jobject) msg_host->extension(JAVA_HOST_LEVEL);
     if (jhost)
       jhost_unref(env, jhost);
@@ -312,7 +312,7 @@ static int java_main(int argc, char *argv[])
   xbt_assert((jprocess != nullptr), "Process allocation failed.");
   jprocess = env->NewGlobalRef(jprocess);
   //bind the process to the context
-  msg_process_t process = MSG_process_self();
+  const_sg_actor_t process = MSG_process_self();
 
   context->jprocess_ = jprocess;
   /* sets the PID and the PPID of the process */
index a0f3a6d..992afb4 100644 (file)
@@ -1,6 +1,6 @@
 /* Java Wrappers to the MSG API.                                            */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 5d9b460..d9fddbd 100644 (file)
@@ -1,6 +1,6 @@
 /* Java bindings of the NetZones.                                           */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -55,14 +55,14 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_As_nativeInit(JNIEnv* env, jclass cl
 }
 
 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_As_getName(JNIEnv * env, jobject jas) {
-  simgrid::s4u::NetZone* as = jnetzone_get_native(env, jas);
+  const simgrid::s4u::NetZone* as = jnetzone_get_native(env, jas);
   return env->NewStringUTF(as->get_cname());
 }
 
 JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getSons(JNIEnv * env, jobject jas) {
   int index = 0;
   jobjectArray jtable;
-  sg_netzone_t self_as = jnetzone_get_native(env, jas);
+  const simgrid::s4u::NetZone* self_as = jnetzone_get_native(env, jas);
 
   jclass cls = env->FindClass("org/simgrid/msg/As");
 
@@ -96,7 +96,7 @@ 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);
+  const simgrid::s4u::NetZone* as = jnetzone_get_native(env, jas);
 
   if (not as) {
     jxbt_throw_notbound(env, "as", jas);
@@ -121,7 +121,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getHosts(JNIEnv * env, jo
   jobjectArray jtable;
   jobject jhost;
   jstring jname;
-  simgrid::s4u::NetZone* as = jnetzone_get_native(env, jas);
+  const simgrid::s4u::NetZone* as = jnetzone_get_native(env, jas);
 
   jclass cls = jxbt_get_class(env, "org/simgrid/msg/Host");
   if (not cls)
index e1034ef..e22789b 100644 (file)
@@ -1,6 +1,6 @@
 /* Functions related to the java As instances.                              */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 7de0a98..a1a06a3 100644 (file)
@@ -1,6 +1,6 @@
 /* Java bindings to the Comm API                                            */
 
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -21,7 +21,7 @@ static jfieldID jtask_field_Comm_task;
 static jfieldID jcomm_field_Comm_taskBind;
 
 void jcomm_bind_task(JNIEnv *env, jobject jcomm) {
-  msg_comm_t comm = (msg_comm_t) (uintptr_t) env->GetLongField(jcomm, jcomm_field_Comm_bind);
+  const_msg_comm_t comm = (msg_comm_t)(uintptr_t)env->GetLongField(jcomm, jcomm_field_Comm_bind);
   //test if we are receiving or sending a task.
   jboolean jreceiving = env->GetBooleanField(jcomm, jcomm_field_Comm_receiving);
   if (jreceiving == JNI_TRUE) {
@@ -59,13 +59,12 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Comm_nativeInit(JNIEnv *env, jclass
 }
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Comm_nativeFinalize(JNIEnv *env, jobject jcomm) {
-  msg_comm_t comm;
   msg_task_t *task_received;
 
   task_received = (msg_task_t*)  (uintptr_t) env->GetLongField(jcomm, jcomm_field_Comm_taskBind);
   delete task_received;
 
-  comm = (msg_comm_t) (uintptr_t) env->GetLongField(jcomm, jcomm_field_Comm_bind);
+  const_msg_comm_t comm = (msg_comm_t)(uintptr_t)env->GetLongField(jcomm, jcomm_field_Comm_bind);
   MSG_comm_destroy(comm);
 }
 
index e38f067..c9e2d61 100644 (file)
@@ -1,6 +1,6 @@
 /* Java bindings to the Comm API                                            */
 
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 5d43d22..633deef 100644 (file)
@@ -1,6 +1,6 @@
 /* Java bindings of the file API.                                           */
 
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -46,7 +46,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_File_seek(JNIEnv *env, jobject jfile
 }
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_File_close(JNIEnv *env, jobject jfile) {
-  msg_file_t file = jfile_get_native(env, jfile);
+  const_sg_file_t file = jfile_get_native(env, jfile);
 
   MSG_file_close(file);
   jfile_bind(env, jfile, nullptr);
index 6c145fb..63c4530 100644 (file)
@@ -1,6 +1,6 @@
 /* Java bindings of the file API.                                           */
 
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index cea9d22..646250e 100644 (file)
@@ -1,6 +1,6 @@
 /* Functions related to the java host instances.                            */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -53,8 +53,8 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_nativeInit(JNIEnv *env, jclass
              "Native initialization of msg/Host failed. Please report that bug");
 }
 
-JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jclass cls, jstring jname) {
-
+JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName(JNIEnv* env, jclass cls, jstring jname)
+{
   /* get the C string from the java string */
   if (jname == nullptr) {
     jxbt_throw_null(env, "No host can have a null name");
@@ -155,7 +155,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);
+  const_sg_host_t host = jhost_get_native(env, jhost);
 
   if (not host) {
     jxbt_throw_notbound(env, "host", jhost);
@@ -166,7 +166,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);
+  const_sg_host_t host = jhost_get_native(env, jhost);
 
   if (not host) {
     jxbt_throw_notbound(env, "host", jhost);
@@ -177,7 +177,7 @@ 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);
+  const_sg_host_t host = jhost_get_native(env, jhost);
 
   if (not host) {
     jxbt_throw_notbound(env, "host", jhost);
@@ -207,7 +207,7 @@ Java_org_simgrid_msg_Host_setProperty(JNIEnv *env, jobject jhost, jobject jname,
   }
   const char *name = env->GetStringUTFChars((jstring) jname, 0);
   const char *value_java = env->GetStringUTFChars((jstring) jvalue, 0);
-  char *value = xbt_strdup(value_java);
+  const char* value      = xbt_strdup(value_java);
 
   MSG_host_set_property_value(host, name, value);
 
@@ -217,7 +217,7 @@ Java_org_simgrid_msg_Host_setProperty(JNIEnv *env, jobject jhost, jobject jname,
 
 JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Host_isOn(JNIEnv * env, jobject jhost)
 {
-  msg_host_t host = jhost_get_native(env, jhost);
+  const_sg_host_t host = jhost_get_native(env, jhost);
 
   if (not host) {
     jxbt_throw_notbound(env, "host", jhost);
@@ -262,7 +262,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getMountedStorage(JNIEn
 
 JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getAttachedStorage(JNIEnv * env, jobject jhost)
 {
-  msg_host_t host = jhost_get_native(env, jhost);
+  const_sg_host_t host = jhost_get_native(env, jhost);
 
   if (not host) {
     jxbt_throw_notbound(env, "host", jhost);
@@ -297,7 +297,6 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getStorageContent(JNIEn
 
 JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_all(JNIEnv * env, jclass cls_arg)
 {
-
   xbt_dynar_t table =  MSG_hosts_as_dynar();
   int count = xbt_dynar_length(table);
 
@@ -313,7 +312,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_all(JNIEnv * env, jclas
   }
 
   for (int index = 0; index < count; index++) {
-    msg_host_t host = xbt_dynar_get_as(table, index, msg_host_t);
+    auto const* host = xbt_dynar_get_as(table, index, msg_host_t);
     jobject jhost   = static_cast<jobject>(host->extension(JAVA_HOST_LEVEL));
 
     if (not jhost) {
@@ -341,7 +340,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_updateAllEnergyConsumptions(JNI
 
 JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getConsumedEnergy (JNIEnv *env, jobject jhost)
 {
-  msg_host_t host = jhost_get_native(env, jhost);
+  const_sg_host_t host = jhost_get_native(env, jhost);
 
   if (not host) {
     jxbt_throw_notbound(env, "host", jhost);
@@ -358,34 +357,34 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_setPstate(JNIEnv* env, jobject
 }
 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Host_getPstate(JNIEnv* env, jobject jhost)
 {
-  msg_host_t host = jhost_get_native(env, jhost);
+  const_sg_host_t host = jhost_get_native(env, jhost);
   return MSG_host_get_pstate(host);
 }
 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Host_getPstatesCount(JNIEnv* env, jobject jhost)
 {
-  msg_host_t host = jhost_get_native(env, jhost);
+  const_sg_host_t host = jhost_get_native(env, jhost);
   return MSG_host_get_nb_pstates(host);
 }
 JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCurrentPowerPeak(JNIEnv* env, jobject jhost)
 {
-  msg_host_t host = jhost_get_native(env, jhost);
+  const_sg_host_t host = jhost_get_native(env, jhost);
   return MSG_host_get_speed(host);
 }
 JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getPowerPeakAt(JNIEnv* env, jobject jhost, jint pstate)
 {
-  msg_host_t host = jhost_get_native(env, jhost);
+  const_sg_host_t host = jhost_get_native(env, jhost);
   return MSG_host_get_power_peak_at(host, pstate);
 }
 
 JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getLoad(JNIEnv* env, jobject jhost)
 {
-  msg_host_t host = jhost_get_native(env, jhost);
+  const_sg_host_t host = jhost_get_native(env, jhost);
   return MSG_host_get_load(host);
 }
 
 JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCurrentLoad (JNIEnv *env, jobject jhost)
 {
-  msg_host_t host = jhost_get_native(env, jhost);
+  const_sg_host_t host = jhost_get_native(env, jhost);
 
   if (not host) {
     jxbt_throw_notbound(env, "host", jhost);
@@ -397,7 +396,7 @@ JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCurrentLoad (JNIEnv *env,
 
 JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getComputedFlops (JNIEnv *env, jobject jhost)
 {
-  msg_host_t host = jhost_get_native(env, jhost);
+  const_sg_host_t host = jhost_get_native(env, jhost);
 
   if (not host) {
     jxbt_throw_notbound(env, "host", jhost);
@@ -409,7 +408,7 @@ JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getComputedFlops (JNIEnv *en
 
 JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getAvgLoad (JNIEnv *env, jobject jhost)
 {
-  msg_host_t host = jhost_get_native(env, jhost);
+  const_sg_host_t host = jhost_get_native(env, jhost);
 
   if (not host) {
     jxbt_throw_notbound(env, "host", jhost);
index 08a48d5..03bb0b0 100644 (file)
@@ -1,6 +1,6 @@
 /* Functions related to the java host instances.                            */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index cb71bba..3e77209 100644 (file)
@@ -1,6 +1,6 @@
 /* Functions related to the java process instances.                         */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -22,9 +22,9 @@ jfieldID jprocess_field_Process_name;
 jfieldID jprocess_field_Process_pid;
 jfieldID jprocess_field_Process_ppid;
 
-jobject jprocess_from_native(msg_process_t process)
+jobject jprocess_from_native(const_sg_actor_t process)
 {
-  simgrid::kernel::context::JavaContext* context =
+  const simgrid::kernel::context::JavaContext* context =
       static_cast<simgrid::kernel::context::JavaContext*>(process->get_impl()->context_.get());
   return context->jprocess_;
 }
@@ -44,7 +44,7 @@ msg_process_t jprocess_to_native(jobject jprocess, JNIEnv* env)
   return (msg_process_t)(intptr_t)env->GetLongField(jprocess, jprocess_field_Process_bind);
 }
 
-void jprocess_bind(jobject jprocess, msg_process_t process, JNIEnv * env)
+void jprocess_bind(jobject jprocess, const_sg_actor_t process, JNIEnv* env)
 {
   env->SetLongField(jprocess, jprocess_field_Process_bind, (intptr_t)process);
 }
@@ -110,7 +110,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_killAll(JNIEnv* env, jclass
 
 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID(JNIEnv * env, jclass cls, jint pid)
 {
-  msg_process_t process = MSG_process_from_PID(pid);
+  auto const* process = MSG_process_from_PID(pid);
 
   if (not process) {
     jxbt_throw_process_not_found(env, std::string("PID = ") + std::to_string(static_cast<int>(pid)));
@@ -129,12 +129,12 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID(JNIEnv * env, jcl
 
 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_nativeGetPID(JNIEnv* env, jobject jprocess)
 {
-  msg_process_t process = jprocess_to_native(jprocess, env);
+  const_sg_actor_t process = jprocess_to_native(jprocess, env);
   return MSG_process_get_PID(process);
 }
 
 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, jobject jprocess, jobject jname) {
-  msg_process_t process = jprocess_to_native(jprocess, env);
+  const_sg_actor_t process = jprocess_to_native(jprocess, env);
 
   if (not process) {
     jxbt_throw_notbound(env, "process", jprocess);
@@ -188,9 +188,9 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_resume(JNIEnv * env, jobject
   process->resume();
 }
 
-JNIEXPORT void
-JNICALL Java_org_simgrid_msg_Process_setAutoRestart (JNIEnv *env, jobject jprocess, jboolean jauto_restart) {
-
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setAutoRestart(JNIEnv* env, jobject jprocess,
+                                                                   jboolean jauto_restart)
+{
   msg_process_t process = jprocess_to_native(jprocess, env);
   if (not process) {
     jxbt_throw_notbound(env, "process", jprocess);
index 06b38dc..58d703c 100644 (file)
@@ -1,6 +1,6 @@
 /* Functions related to the java process instances.                         */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -33,10 +33,10 @@ jobject jprocess_ref(jobject jprocess, JNIEnv* env);
 void jprocess_unref(jobject jprocess, JNIEnv* env);
 
 /** Binds a native instance to a java instance. */
-void jprocess_bind(jobject jprocess, msg_process_t process, JNIEnv* env);
+void jprocess_bind(jobject jprocess, const_sg_actor_t process, JNIEnv* env);
 
 /** Extract the java instance from the native one */
-jobject jprocess_from_native(msg_process_t process);
+jobject jprocess_from_native(const_sg_actor_t process);
 
 /** Extract the native instance from the java one */
 msg_process_t jprocess_to_native(jobject jprocess, JNIEnv* env);
index 831aeea..4132d49 100644 (file)
@@ -1,6 +1,6 @@
 /* Java bindings of the Storage API.                                        */
 
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -103,7 +103,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);
+  const_sg_storage_t storage = jstorage_get_native(env, jstorage);
 
   if (not storage) {
     jxbt_throw_notbound(env, "storage", jstorage);
@@ -114,7 +114,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);
+  const_sg_storage_t storage = jstorage_get_native(env, jstorage);
 
   if (not storage) {
     jxbt_throw_notbound(env, "storage", jstorage);
@@ -125,7 +125,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);
+  const_sg_storage_t storage = jstorage_get_native(env, jstorage);
 
   if (not storage) {
     jxbt_throw_notbound(env, "storage", jstorage);
@@ -136,7 +136,7 @@ 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);
+  const_sg_storage_t storage = jstorage_get_native(env, jstorage);
 
   if (not storage) {
     jxbt_throw_notbound(env, "storage", jstorage);
@@ -170,11 +170,10 @@ Java_org_simgrid_msg_Storage_setProperty(JNIEnv *env, jobject jstorage, jobject
 
   env->ReleaseStringUTFChars((jstring) jvalue, value_java);
   env->ReleaseStringUTFChars((jstring) jname, name);
-
 }
 
 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getHost(JNIEnv * env,jobject jstorage) {
-  msg_storage_t storage = jstorage_get_native(env, jstorage);
+  const_sg_storage_t storage = jstorage_get_native(env, jstorage);
 
   if (not storage) {
     jxbt_throw_notbound(env, "storage", jstorage);
index 77e2d14..183e109 100644 (file)
@@ -1,6 +1,6 @@
 /* Java bindings of the Storage API.                                        */
 
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index f00245c..157f37b 100644 (file)
@@ -1,6 +1,6 @@
 /* Java bindings of the Synchronization API.                                */
 
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -40,7 +40,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Mutex_release(JNIEnv * env, jobject
 }
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Mutex_nativeFinalize(JNIEnv * env, jobject obj) {
-  sg_mutex_t mutex = (sg_mutex_t)(uintptr_t)env->GetLongField(obj, jsynchro_field_Mutex_bind);
+  const_sg_mutex_t mutex = (sg_mutex_t)(uintptr_t)env->GetLongField(obj, jsynchro_field_Mutex_bind);
   sg_mutex_destroy(mutex);
 }
 
@@ -83,7 +83,7 @@ JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Semaphore_wouldBlock(JNIEnv * en
 }
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Semaphore_nativeFinalize(JNIEnv * env, jobject obj) {
-  sg_sem_t sem;
+  const_sg_sem_t sem;
 
   sem = (sg_sem_t)(uintptr_t)env->GetLongField(obj, jsynchro_field_Semaphore_bind);
   sg_sem_destroy(sem);
index 26d7c33..438ce54 100644 (file)
@@ -1,6 +1,6 @@
 /* Java bindings of the Synchronization API.                                */
 
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 448ae99..41f53c2 100644 (file)
@@ -1,6 +1,6 @@
 /* Functions related to the java task instances.                            */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -151,7 +151,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);
+  const_msg_task_t task = jtask_to_native(jtask, env);
 
   if (not task) {
     jxbt_throw_notbound(env, "task", jtask);
@@ -162,16 +162,14 @@ JNIEXPORT jstring JNICALL Java_org_simgrid_msg_Task_getName(JNIEnv * env, jobjec
 }
 
 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_getSender(JNIEnv * env, jobject jtask) {
-  msg_process_t process;
-
-  msg_task_t task = jtask_to_native(jtask, env);
+  const_msg_task_t task = jtask_to_native(jtask, env);
 
   if (not task) {
     jxbt_throw_notbound(env, "task", jtask);
     return nullptr;
   }
 
-  process = MSG_task_get_sender(task);
+  auto const* process = MSG_task_get_sender(task);
   if (process == nullptr) {
     return nullptr;
   }
@@ -180,15 +178,14 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_getSender(JNIEnv * env, jobj
 
 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_getSource(JNIEnv * env, jobject jtask)
 {
-  msg_host_t host;
-  msg_task_t task = jtask_to_native(jtask, env);
+  const_msg_task_t task = jtask_to_native(jtask, env);
 
   if (not task) {
     jxbt_throw_notbound(env, "task", jtask);
     return nullptr;
   }
 
-  host = MSG_task_get_source(task);
+  auto const* host = MSG_task_get_source(task);
   if (host == nullptr) {
     return nullptr;
   }
@@ -202,7 +199,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_getSource(JNIEnv * env, jobj
 
 JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Task_getFlopsAmount(JNIEnv * env, jobject jtask)
 {
-  msg_task_t ptask = jtask_to_native(jtask, env);
+  const_msg_task_t ptask = jtask_to_native(jtask, env);
 
   if (not ptask) {
     jxbt_throw_notbound(env, "task", jtask);
index 787384f..ff938ee 100644 (file)
@@ -1,6 +1,6 @@
 /* Functions related to the java task instances.                            */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index b917e08..0e7b60b 100644 (file)
@@ -1,6 +1,6 @@
 /* Functions related to the Virtual Machines.                               */
 
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -35,28 +35,28 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_nativeInit(JNIEnv *env, jclass cl
   xbt_assert(jvm_field_bind, "Native initialization of msg/VM failed. Please report that bug");
 }
 
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isCreated(JNIEnv * env, jobject jvm)
+JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isCreated(JNIEnv* env, jobject jvm)
 {
   msg_vm_t vm = jvm_get_native(env,jvm);
   return MSG_vm_is_created(vm);
 }
 
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isRunning(JNIEnv * env, jobject jvm)
+JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isRunning(JNIEnv* env, jobject jvm)
 {
   msg_vm_t vm = jvm_get_native(env,jvm);
-  return (jint) MSG_vm_is_running(vm);
+  return MSG_vm_is_running(vm);
 }
 
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isMigrating(JNIEnv * env, jobject jvm)
+JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isMigrating(JNIEnv* env, jobject jvm)
 {
-  msg_vm_t vm = jvm_get_native(env,jvm);
-  return (jint) MSG_vm_is_migrating(vm);
+  const_sg_vm_t vm = jvm_get_native(env, jvm);
+  return MSG_vm_is_migrating(vm);
 }
 
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isSuspended(JNIEnv * env, jobject jvm)
+JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isSuspended(JNIEnv* env, jobject jvm)
 {
   msg_vm_t vm = jvm_get_native(env,jvm);
-  return (jint) MSG_vm_is_suspended(vm);
+  return MSG_vm_is_suspended(vm);
 }
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_setBound(JNIEnv *env, jobject jvm, jdouble bound)
@@ -171,7 +171,6 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_resume(JNIEnv *env, jobject jvm)
 
 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_VM_getVMByName(JNIEnv* env, jclass cls, jstring jname)
 {
-
   /* get the C string from the java string */
   if (jname == nullptr) {
     jxbt_throw_null(env, "No VM can have a null name");
@@ -179,7 +178,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_VM_getVMByName(JNIEnv* env, jclas
   }
   const char* name = env->GetStringUTFChars(jname, 0);
   /* get the VM by name   (VMs are just special hosts, unfortunately) */
-  msg_host_t host = MSG_host_by_name(name);
+  auto const* host = MSG_host_by_name(name);
 
   if (not host) { /* invalid name */
     jxbt_throw_host_not_found(env, name);
index ec16719..b15cd89 100644 (file)
@@ -1,6 +1,6 @@
 /* Functions related to the Virtual Machines.                               */
 
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -29,11 +29,10 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_nativeInit(JNIEnv* env, jclass cl
 
 JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_VM_all(JNIEnv* env, jclass cls_arg);
 
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isCreated(JNIEnv* env, jobject jvm);
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isRunning(JNIEnv* env, jobject jvm);
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isMigrating(JNIEnv* env, jobject jvm);
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isSuspended(JNIEnv* env, jobject jvm);
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_VM_isResuming(JNIEnv* env, jobject jvm);
+JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isCreated(JNIEnv* env, jobject jvm);
+JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isRunning(JNIEnv* env, jobject jvm);
+JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isMigrating(JNIEnv* env, jobject jvm);
+JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isSuspended(JNIEnv* env, jobject jvm);
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_setBound(JNIEnv* env, jobject jvm, jdouble bound);
 
index d30e299..9d9b4e6 100644 (file)
@@ -1,6 +1,6 @@
 /* Java bindings of the Trace API.                                          */
 
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index b7b1cf4..ba586c1 100644 (file)
@@ -1,6 +1,6 @@
 /* Java bindings of the Trace API.                                          */
 
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 896c622..8109312 100644 (file)
@@ -1,6 +1,6 @@
 /* Various JNI helper functions                                             */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -32,7 +32,6 @@ jmethodID jxbt_get_jmethod(JNIEnv * env, jclass cls, const char *name, const cha
   id = env->GetMethodID(cls, name, signature);
 
   if (not id) {
-
     jmethodID tostr_id = env->GetMethodID(cls, "getName", "()Ljava/lang/String;");
     jstring jclassname = (jstring) env->CallObjectMethod(cls, tostr_id, nullptr);
     const char *classname = env->GetStringUTFChars(jclassname, 0);
index aa6495b..3a15734 100644 (file)
@@ -1,6 +1,6 @@
 /* Various JNI helper functions                                             */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index f3c9dcb..846d304 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 3c9fd5e..fa3e4b7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 3346fac..97a937a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 6d8bf9d..5263adb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 6042b04..b4aae07 100644 (file)
@@ -1,6 +1,6 @@
 /* Bindings to the MSG hosts */
 
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 1529c37..ccde603 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 2b66f78..246d1fe 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index e05677f..d435891 100644 (file)
@@ -1,6 +1,6 @@
 /* This exception is raised when there is a problem within the bindings (in JNI). */
 
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 376a390..089fda0 100644 (file)
@@ -1,6 +1,6 @@
 /* JNI interface to C code for MSG. */
 
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index dcdfa30..7826c2e 100644 (file)
@@ -1,6 +1,6 @@
 /* This exception is an abstract class grouping all MSG-related exceptions */
 
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index e23d1fc..b9457dd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index cfbc5da..5eeb952 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 9e8377e..d54ecbc 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 7a0933b..3f152d0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index c348bd4..38fbcda 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 6dbad27..cb9d9bf 100644 (file)
@@ -1,6 +1,6 @@
 /* Bindings to the MSG storage */
 
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index bc7302f..dadee20 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 033ba6e..5b1bf66 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 601272f..dcd517d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 3f0b92a..4a52203 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 11c5fb2..287e087 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 8ab6a27..1ca0445 100644 (file)
@@ -1,6 +1,6 @@
 /* Java bindings of the s4u::VirtualMachine */
 
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -78,16 +78,16 @@ public class VM extends Host {
        private native void nativeFinalize();
 
        /** Returns whether the given VM is currently suspended */      
-       public native int isCreated();
+       public native boolean isCreated();
 
        /** Returns whether the given VM is currently running */
-       public native int isRunning();
+       public native boolean isRunning();
 
        /** Returns whether the given VM is currently running */
-       public native int isMigrating();
+       public native boolean isMigrating();
 
        /** Returns whether the given VM is currently suspended */      
-       public native int isSuspended();
+       public native boolean isSuspended();
 
        /** Returns the amount of virtual CPUs provided */
        public int getCoreAmount() {
index f9f4d63..0a2ce31 100644 (file)
@@ -1,6 +1,6 @@
 /* JNI interface to C code for the TRACES part of SimGrid. */
 
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index a633422..a9a7686 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -72,7 +72,7 @@ static int l_host_get_by_name(lua_State * L)
  */
 static int l_host_get_name(lua_State * L)
 {
-  sg_host_t ht = sglua_check_host(L, 1);
+  auto const* ht = sglua_check_host(L, 1);
   lua_pushstring(L, ht->get_cname());
   return 1;
 }
@@ -126,7 +126,7 @@ static int l_host_at(lua_State * L)
  */
 static int l_host_get_property_value(lua_State * L)
 {
-  sg_host_t ht = sglua_check_host(L, 1);
+  const_sg_host_t ht = sglua_check_host(L, 1);
   const char *prop = luaL_checkstring(L, 2);
   lua_pushstring(L, sg_host_get_property_value(ht,prop));
   return 1;
index 2316b7b..239ea85 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 30db85b..e6d249b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 82a3689..1bb9e9c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
index 678bdfa..6114d3d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 0711115..e96c079 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -40,22 +40,22 @@ static int debug(lua_State* L) {
  *
  * - Argument 1 (string): the text to print
  */
-static int info(lua_State* L) {
-
+static int info(lua_State* L)
+{
   const char* str = luaL_checkstring(L, 1);
   XBT_INFO("%s", str);
   return 0;
 }
 
-static int error(lua_State* L) {
-
+static int error(lua_State* L)
+{
   const char* str = luaL_checkstring(L, 1);
   XBT_ERROR("%s", str);
   return 0;
 }
 
-static int critical(lua_State* L) {
-
+static int critical(lua_State* L)
+{
   const char* str = luaL_checkstring(L, 1);
   XBT_CRITICAL("%s", str);
   return 0;
@@ -67,7 +67,8 @@ static int critical(lua_State* L) {
  * This function can be called from within lua via "simgrid.dump(table)". It will
  * then dump the table via XBT_DEBUG
  */
-static int dump(lua_State* L) {
+static int dump(lua_State* L)
+{
   int argc = lua_gettop(L);
 
   for (int i = 1; i <= argc; i++) {
index 21ddf1e..7ffcd4a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index de65d4a..0551aa8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -44,8 +44,6 @@ using simgrid::s4u::Mailbox;
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(python, "python");
 
-PYBIND11_DECLARE_HOLDER_TYPE(T, boost::intrusive_ptr<T>)
-
 namespace {
 
 static std::string get_simgrid_version()
@@ -57,59 +55,61 @@ static std::string get_simgrid_version()
   return simgrid::xbt::string_printf("%i.%i.%i", major, minor, patch);
 }
 
-static std::string simgrid_version = get_simgrid_version();
-
 } // namespace
 
+PYBIND11_DECLARE_HOLDER_TYPE(T, boost::intrusive_ptr<T>)
+
 PYBIND11_MODULE(simgrid, m)
 {
   m.doc() = "SimGrid userspace API";
 
-  m.attr("simgrid_version") = simgrid_version;
+  m.attr("simgrid_version") = get_simgrid_version();
 
   // Internal exception used to kill actors and sweep the RAII chimney (free objects living on the stack)
   static py::object pyForcefulKillEx(py::register_exception<simgrid::ForcefulKillException>(m, "ActorKilled"));
 
   /* this_actor namespace */
-  void (*sleep_for_fun)(double) = &simgrid::s4u::this_actor::sleep_for; // pick the right overload
-  void (*sleep_until_fun)(double) = &simgrid::s4u::this_actor::sleep_until;
-
-  py::module m2 = m.def_submodule("this_actor", "Bindings of the s4u::this_actor namespace.");
-  m2.def("info", [](char* s) { XBT_INFO("%s", s); }, "Display a logging message of default priority.");
-  m2.def("error", [](char* s) { XBT_ERROR("%s", s); }, "Display a logging message of 'error' priority.");
-  m2.def("execute", py::overload_cast<double, double>(&simgrid::s4u::this_actor::execute),
-         "Block the current actor, computing the given amount of flops at the given priority, see :cpp:func:`void "
-         "simgrid::s4u::this_actor::execute(double, double)`",
-         py::arg("flops"), py::arg("priority") = 1);
-  m2.def("exec_init", [](double flops){return simgrid::s4u::this_actor::exec_init(flops);});
-  m2.def("get_host", &simgrid::s4u::this_actor::get_host, "Retrieves host on which the current actor is located");
-  m2.def("set_host", &simgrid::s4u::this_actor::set_host,
-         "Moves the current actor to another host, see :cpp:func:`void simgrid::s4u::this_actor::set_host()`",
-         py::arg("dest"));
-  m2.def("sleep_for", sleep_for_fun,
-      "Block the actor sleeping for that amount of seconds, see :cpp:func:`void simgrid::s4u::this_actor::sleep_for`", py::arg("duration"));
-  m2.def("sleep_until", sleep_until_fun,
-      "Block the actor sleeping until the specified timestamp, see :cpp:func:`void simgrid::s4u::this_actor::sleep_until`", py::arg("duration"));
-  m2.def("suspend", &simgrid::s4u::this_actor::suspend, "Suspend the current actor, that is blocked until resume()ed by another actor. see :cpp:func:`void simgrid::s4u::this_actor::suspend`");
-  m2.def("yield_", &simgrid::s4u::this_actor::yield,
-         "Yield the actor, see :cpp:func:`void simgrid::s4u::this_actor::yield()`");
-  m2.def("exit", &simgrid::s4u::this_actor::exit, "kill the current actor");
-  m2.def("on_exit",
-         [](py::object fun) {
-           ActorPtr act = Actor::self();
-           simgrid::s4u::this_actor::on_exit([act, fun](bool /*failed*/) {
-             try {
-               fun();
-             } catch (py::error_already_set& e) {
-               xbt_die("Error while executing the on_exit lambda: %s", e.what());
-             }
-           });
-         },
-         "");
+  m.def_submodule("this_actor", "Bindings of the s4u::this_actor namespace.")
+      .def("info", [](const char* s) { XBT_INFO("%s", s); }, "Display a logging message of 'info' priority.")
+      .def("error", [](const char* s) { XBT_ERROR("%s", s); }, "Display a logging message of 'error' priority.")
+      .def("execute", py::overload_cast<double, double>(&simgrid::s4u::this_actor::execute),
+           "Block the current actor, computing the given amount of flops at the given priority, "
+           "see :cpp:func:`void simgrid::s4u::this_actor::execute(double, double)`",
+           py::arg("flops"), py::arg("priority") = 1)
+      .def("exec_init", py::overload_cast<double>(&simgrid::s4u::this_actor::exec_init))
+      .def("get_host", &simgrid::s4u::this_actor::get_host, "Retrieves host on which the current actor is located")
+      .def("set_host", &simgrid::s4u::this_actor::set_host,
+           "Moves the current actor to another host, see :cpp:func:`void simgrid::s4u::this_actor::set_host()`",
+           py::arg("dest"))
+      .def("sleep_for", static_cast<void (*)(double)>(&simgrid::s4u::this_actor::sleep_for),
+           "Block the actor sleeping for that amount of seconds, "
+           "see :cpp:func:`void simgrid::s4u::this_actor::sleep_for`",
+           py::arg("duration"))
+      .def("sleep_until", static_cast<void (*)(double)>(&simgrid::s4u::this_actor::sleep_until),
+           "Block the actor sleeping until the specified timestamp, "
+           "see :cpp:func:`void simgrid::s4u::this_actor::sleep_until`",
+           py::arg("duration"))
+      .def("suspend", &simgrid::s4u::this_actor::suspend,
+           "Suspend the current actor, that is blocked until resume()ed by another actor. "
+           "see :cpp:func:`void simgrid::s4u::this_actor::suspend`")
+      .def("yield_", &simgrid::s4u::this_actor::yield,
+           "Yield the actor, see :cpp:func:`void simgrid::s4u::this_actor::yield()`")
+      .def("exit", &simgrid::s4u::this_actor::exit, "kill the current actor")
+      .def("on_exit",
+           [](py::object fun) {
+             simgrid::s4u::this_actor::on_exit([fun](bool /*failed*/) {
+               try {
+                 fun();
+               } catch (const py::error_already_set& e) {
+                 xbt_die("Error while executing the on_exit lambda: %s", e.what());
+               }
+             });
+           },
+           "");
 
   /* Class Engine */
   py::class_<Engine>(m, "Engine", "Simulation Engine, see :ref:`class s4u::Engine <API_s4u_Engine>`")
-      .def(py::init([](std::vector<std::string> args) -> simgrid::s4u::Engine* {
+      .def(py::init([](std::vector<std::string> args) {
         static char noarg[] = {'\0'};
         int argc            = args.size();
         std::unique_ptr<char* []> argv(new char*[argc + 1]);
@@ -119,7 +119,8 @@ PYBIND11_MODULE(simgrid, m)
         // Currently this can be dangling, we should wrap this somehow.
         return new simgrid::s4u::Engine(&argc, argv.get());
       }))
-      .def_static("get_clock", &Engine::get_clock, "The simulation time, ie the amount of simulated seconds since the simulation start.")
+      .def_static("get_clock", &Engine::get_clock,
+                  "The simulation time, ie the amount of simulated seconds since the simulation start.")
       .def("get_all_hosts", &Engine::get_all_hosts, "Returns the list of all hosts found in the platform")
       .def("load_platform", &Engine::load_platform,
            "Load a platform file describing the environment, see :cpp:func:`simgrid::s4u::Engine::load_platform()`")
@@ -141,7 +142,7 @@ PYBIND11_MODULE(simgrid, m)
                  /* If I was passed a class, I just built an instance, so I need to call it now */
                  if (py::isinstance<py::function>(res))
                    res();
-               } catch (py::error_already_set& ex) {
+               } catch (const py::error_already_set& ex) {
                  if (ex.matches(pyForcefulKillEx)) {
                    XBT_VERB("Actor killed");
                    /* Stop here that ForcefulKill exception which was meant to free the RAII stuff on the stack */
@@ -154,91 +155,113 @@ PYBIND11_MODULE(simgrid, m)
            "Registers the main function of an actor, see :cpp:func:`simgrid::s4u::Engine::register_actor()`");
 
   /* Class Host */
-  py::class_<simgrid::s4u::Host, std::unique_ptr<Host, py::nodelete>>(m, "Host", "Simulation Engine, see :ref:`class s4u::Host <API_s4u_Host>`")
+  py::class_<simgrid::s4u::Host, std::unique_ptr<Host, py::nodelete>>(
+      m, "Host", "Simulation Engine, see :ref:`class s4u::Host <API_s4u_Host>`")
       .def("by_name", &Host::by_name, "Retrieves a host from its name, or die")
-      .def("get_pstate_count", &Host::get_pstate_count, "Retrieve the cound of defined pstate levels, see :cpp:func:`simgrid::s4u::Host::get_pstate_count`")
-      .def("get_pstate_speed", &Host::get_pstate_speed, "Retrieve the maximal speed at the given pstate, see :cpp:func:`simgrid::s4u::Host::get_pstate_speed`")
+      .def("get_pstate_count", &Host::get_pstate_count,
+           "Retrieve the cound of defined pstate levels, see :cpp:func:`simgrid::s4u::Host::get_pstate_count`")
+      .def("get_pstate_speed", &Host::get_pstate_speed,
+           "Retrieve the maximal speed at the given pstate, see :cpp:func:`simgrid::s4u::Host::get_pstate_speed`")
       .def_property("pstate", &Host::get_pstate, &Host::set_pstate, "The current pstate")
 
-      .def("current", &Host::current, "Retrieves the host on which the running actor is located, see :cpp:func:`simgrid::s4u::Host::current()`")
-      .def_property_readonly("name", [](Host* self) -> const std::string {
-          return std::string(self->get_name().c_str()); // Convert from xbt::string because of MC
-        }, "The name of this host")
-      .def_property_readonly("load", &Host::get_load,
-          "Returns the current computation load (in flops per second). This is the currently achieved speed. See :cpp:func:`simgrid::s4u::Host::get_load()`")
-      .def_property_readonly("speed", &Host::get_speed,
-          "The peak computing speed in flops/s at the current pstate, taking the external load into account. This is the max potential speed. See :cpp:func:`simgrid::s4u::Host::get_speed()`");
+      .def("current", &Host::current,
+           "Retrieves the host on which the running actor is located, see :cpp:func:`simgrid::s4u::Host::current()`")
+      .def_property_readonly("name",
+                             [](const Host* self) {
+                               return std::string(self->get_name().c_str()); // Convert from xbt::string because of MC
+                             },
+                             "The name of this host")
+      .def_property_readonly(
+          "load", &Host::get_load,
+          "Returns the current computation load (in flops per second). This is the currently achieved speed. "
+          "See :cpp:func:`simgrid::s4u::Host::get_load()`")
+      .def_property_readonly(
+          "speed", &Host::get_speed,
+          "The peak computing speed in flops/s at the current pstate, taking the external load into account. "
+          "This is the max potential speed. See :cpp:func:`simgrid::s4u::Host::get_speed()`");
 
   /* Class Mailbox */
-  py::class_<simgrid::s4u::Mailbox, std::unique_ptr<Mailbox, py::nodelete>>(m, "Mailbox", "Mailbox, see :ref:`class s4u::Mailbox <API_s4u_Mailbox>`")
-      .def("__str__", [](Mailbox* self) -> const std::string {
-         return std::string("Mailbox(") + self->get_cname() + ")";
-      }, "Textual representation of the Mailbox`")
-      .def("by_name", &Mailbox::by_name, "Retrieve a Mailbox from its name, see :cpp:func:`simgrid::s4u::Mailbox::by_name()`")
-      .def_property_readonly("name", [](Mailbox* self) -> const std::string {
-         return std::string(self->get_name().c_str()); // Convert from xbt::string because of MC
-      }, "The name of that mailbox, see :cpp:func:`simgrid::s4u::Mailbox::get_name()`")
-      .def("put", [](Mailbox* self, py::object data, int size) {
-        data.inc_ref();
-        self->put(data.ptr(), size);
-      }, "Blocking data transmission, see :cpp:func:`void simgrid::s4u::Mailbox::put(void*, uint64_t)`")
-      .def("put_async", [](Mailbox* self, py::object data, int size) -> simgrid::s4u::CommPtr {
-        data.inc_ref();
-        return self->put_async(data.ptr(), size);
-      }, "Non-blocking data transmission, see :cpp:func:`void simgrid::s4u::Mailbox::put_async(void*, uint64_t)`")
-      .def("get", [](Mailbox* self) -> py::object {
-         py::object data = pybind11::reinterpret_steal<py::object>(static_cast<PyObject*>(self->get()));
-         data.dec_ref();
-         return data;
-      }, "Blocking data reception, see :cpp:func:`void* simgrid::s4u::Mailbox::get()`");
+  py::class_<simgrid::s4u::Mailbox, std::unique_ptr<Mailbox, py::nodelete>>(
+      m, "Mailbox", "Mailbox, see :ref:`class s4u::Mailbox <API_s4u_Mailbox>`")
+      .def("__str__", [](const Mailbox* self) { return std::string("Mailbox(") + self->get_cname() + ")"; },
+           "Textual representation of the Mailbox`")
+      .def("by_name", &Mailbox::by_name,
+           "Retrieve a Mailbox from its name, see :cpp:func:`simgrid::s4u::Mailbox::by_name()`")
+      .def_property_readonly("name",
+                             [](const Mailbox* self) {
+                               return std::string(self->get_name().c_str()); // Convert from xbt::string because of MC
+                             },
+                             "The name of that mailbox, see :cpp:func:`simgrid::s4u::Mailbox::get_name()`")
+      .def("put",
+           [](Mailbox* self, py::object data, int size) {
+             data.inc_ref();
+             self->put(data.ptr(), size);
+           },
+           "Blocking data transmission, see :cpp:func:`void simgrid::s4u::Mailbox::put(void*, uint64_t)`")
+      .def("put_async",
+           [](Mailbox* self, py::object data, int size) {
+             data.inc_ref();
+             return self->put_async(data.ptr(), size);
+           },
+           "Non-blocking data transmission, see :cpp:func:`void simgrid::s4u::Mailbox::put_async(void*, uint64_t)`")
+      .def("get",
+           [](Mailbox* self) {
+             py::object data = pybind11::reinterpret_steal<py::object>(static_cast<PyObject*>(self->get()));
+             data.dec_ref();
+             return data;
+           },
+           "Blocking data reception, see :cpp:func:`void* simgrid::s4u::Mailbox::get()`");
 
   /* Class Comm */
   py::class_<simgrid::s4u::Comm, simgrid::s4u::CommPtr>(m, "Comm",
                                                         "Communication, see :ref:`class s4u::Comm <API_s4u_Comm>`")
-      .def("test", [](simgrid::s4u::CommPtr self) { return self->test(); },
+      .def("test", &simgrid::s4u::Comm::test,
            "Test whether the communication is terminated, see :cpp:func:`simgrid::s4u::Comm::test()`")
-      .def("wait", [](simgrid::s4u::CommPtr self) { self->wait(); },
+      .def("wait", &simgrid::s4u::Comm::wait,
            "Block until the completion of that communication, see :cpp:func:`simgrid::s4u::Comm::wait()`")
-      .def("wait_all", [](std::vector<simgrid::s4u::CommPtr>* comms) { simgrid::s4u::Comm::wait_all(comms); },
+      .def("wait_all", &simgrid::s4u::Comm::wait_all,
            "Block until the completion of all communications in the list, see "
            ":cpp:func:`simgrid::s4u::Comm::wait_all()`")
-      .def(
-          "wait_any", [](std::vector<simgrid::s4u::CommPtr>* comms) { return simgrid::s4u::Comm::wait_any(comms); },
-          "Block until the completion of any communication in the list and return the index of the terminated one, see "
-          ":cpp:func:`simgrid::s4u::Comm::wait_any()`");
-  py::class_<simgrid::s4u::Exec, simgrid::s4u::ExecPtr>(m, "Exec", "Execution, see :ref:`class s4u::Exec <API_s4u_Exec>`")
-      .def_property_readonly("remaining", [](simgrid::s4u::ExecPtr self) { return self->get_remaining(); },
-          "Amount of flops that remain to be computed until completion, see :cpp:func:`simgrid::s4u::Exec::get_remaining()`")
-      .def_property_readonly("remaining_ratio", [](simgrid::s4u::ExecPtr self) { return self->get_remaining_ratio(); },
-          "Amount of work remaining until completion from 0 (completely done) to 1 (nothing done yet). See :cpp:func:`simgrid::s4u::Exec::get_remaining_ratio()`")
+      .def("wait_any", &simgrid::s4u::Comm::wait_any,
+           "Block until the completion of any communication in the list and return the index of the terminated one, "
+           "see :cpp:func:`simgrid::s4u::Comm::wait_any()`");
+
+  /* Class Exec */
+  py::class_<simgrid::s4u::Exec, simgrid::s4u::ExecPtr>(m, "Exec",
+                                                        "Execution, see :ref:`class s4u::Exec <API_s4u_Exec>`")
+      .def_property_readonly("remaining", &simgrid::s4u::Exec::get_remaining,
+                             "Amount of flops that remain to be computed until completion, see "
+                             ":cpp:func:`simgrid::s4u::Exec::get_remaining()`")
+      .def_property_readonly("remaining_ratio", &simgrid::s4u::Exec::get_remaining_ratio,
+                             "Amount of work remaining until completion from 0 (completely done) to 1 (nothing done "
+                             "yet). See :cpp:func:`simgrid::s4u::Exec::get_remaining_ratio()`")
       .def_property("host",
                     [](simgrid::s4u::ExecPtr self) {
-                        simgrid::s4u::ExecSeqPtr seq = boost::dynamic_pointer_cast<simgrid::s4u::ExecSeq>(self);
-                        if (seq != nullptr)
-                            return seq->get_host();
-                        xbt_throw_unimplemented(__FILE__, __LINE__, "host of parallel executions is not implemented in python yet.");
+                      simgrid::s4u::ExecSeqPtr seq = boost::dynamic_pointer_cast<simgrid::s4u::ExecSeq>(self);
+                      if (seq != nullptr)
+                        return seq->get_host();
+                      xbt_throw_unimplemented(__FILE__, __LINE__,
+                                              "host of parallel executions is not implemented in python yet.");
                     },
-                    [](simgrid::s4u::ExecPtr self, simgrid::s4u::Host* host) { self->set_host(host); },
-          "Host on which this execution runs. See :cpp:func:`simgrid::s4u::ExecSeq::get_host()`")
-      .def("test", [](simgrid::s4u::ExecPtr self) { return self->test(); },
-          "Test whether the execution is terminated, see :cpp:func:`simgrid::s4u::Exec::test()`")
-      .def("cancel", [](simgrid::s4u::ExecPtr self) { self->cancel(); },
-          "Cancel that execution, see :cpp:func:`simgrid::s4u::Exec::cancel()`")
-      .def("start", [](simgrid::s4u::ExecPtr self) { return self->start(); },
-          "Start that execution, see :cpp:func:`simgrid::s4u::Exec::start()`")
-      .def("wait", [](simgrid::s4u::ExecPtr self) { return self->wait(); },
-          "Block until the completion of that execution, see :cpp:func:`simgrid::s4u::Exec::wait()`");
+                    &simgrid::s4u::Exec::set_host,
+                    "Host on which this execution runs. See :cpp:func:`simgrid::s4u::ExecSeq::get_host()`")
+      .def("test", &simgrid::s4u::Exec::test,
+           "Test whether the execution is terminated, see :cpp:func:`simgrid::s4u::Exec::test()`")
+      .def("cancel", &simgrid::s4u::Exec::cancel, "Cancel that execution, see :cpp:func:`simgrid::s4u::Exec::cancel()`")
+      .def("start", &simgrid::s4u::Exec::start, "Start that execution, see :cpp:func:`simgrid::s4u::Exec::start()`")
+      .def("wait", &simgrid::s4u::Exec::wait,
+           "Block until the completion of that execution, see :cpp:func:`simgrid::s4u::Exec::wait()`");
 
   /* Class Actor */
   py::class_<simgrid::s4u::Actor, ActorPtr>(m, "Actor",
                                             "An actor is an independent stream of execution in your distributed "
                                             "application, see :ref:`class s4u::Actor <API_s4u_Actor>`")
       .def("create",
-           [](py::str name, py::object host, py::object fun, py::args args) {
-             return simgrid::s4u::Actor::create(name, host.cast<Host*>(), [fun, args]() {
+           [](py::str name, Host* host, py::object fun, py::args args) {
+             return simgrid::s4u::Actor::create(name, host, [fun, args]() {
                try {
                  fun(*args);
-               } catch (py::error_already_set& ex) {
+               } catch (const py::error_already_set& ex) {
                  if (ex.matches(pyForcefulKillEx)) {
                    XBT_VERB("Actor killed");
                    /* Stop here that ForcefulKill exception which was meant to free the RAII stuff on the stack */
@@ -263,7 +286,7 @@ PYBIND11_MODULE(simgrid, m)
            "terminates.")
       .def("join", py::overload_cast<double>(&Actor::join),
            "Wait for the actor to finish (more info in the C++ documentation).", py::arg("timeout"))
-      .def("kill", [](ActorPtr act) { act->kill(); }, "Kill that actor")
+      .def("kill", &Actor::kill, "Kill that actor")
       .def("kill_all", &Actor::kill_all, "Kill all actors but the caller.")
       .def("self", &Actor::self, "Retrieves the current actor.")
       .def("is_suspended", &Actor::is_suspended, "Returns True if that actor is currently suspended.")
index 5a7e2da..ba5f43a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index c662db5..a7d7917 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -26,8 +26,6 @@ SG_BEGIN_DECL
 
 /********************************* Global *************************************/
 XBT_ATTRIB_NORETURN XBT_PUBLIC void MC_run();
-XBT_PUBLIC void MC_process_clock_add(smx_actor_t, double);
-XBT_PUBLIC double MC_process_clock_get(smx_actor_t);
 XBT_PRIVATE void MC_automaton_load(const char *file);
 
 /********************************* Memory *************************************/
@@ -35,4 +33,9 @@ XBT_PUBLIC void MC_memory_init(); /* Initialize the memory subsystem */
 
 SG_END_DECL
 
+#ifdef __cplusplus
+XBT_PUBLIC void MC_process_clock_add(const simgrid::kernel::actor::ActorImpl*, double);
+XBT_PUBLIC double MC_process_clock_get(const simgrid::kernel::actor::ActorImpl*);
+#endif
+
 #endif
index a9c8c10..79fd52b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 410508c..8844bcd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index a3b5295..30c209e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.               */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.               */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 8e879e3..9f2402c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index ec4fdc8..7fbcd32 100644 (file)
@@ -1,6 +1,6 @@
 /* A thread pool (C++ version).                                             */
 
-/* Copyright (c) 2004-2019 The SimGrid Team. All rights reserved.           */
+/* Copyright (c) 2004-2020 The SimGrid Team. All rights reserved.           */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -138,8 +138,8 @@ private:
   Synchro* new_synchro(e_xbt_parmap_mode_t mode);
   void work();
 
-  bool destroying;                   /**< is the parmap being destroyed? */
-  std::atomic_uint work_round;       /**< index of the current round */
+  bool destroying = false;           /**< is the parmap being destroyed? */
+  std::atomic_uint work_round{0};    /**< index of the current round */
   std::vector<std::thread*> workers; /**< worker thread handlers */
   unsigned num_workers;     /**< total number of worker threads including the controller */
   Synchro* synchro;         /**< synchronization object */
@@ -147,7 +147,7 @@ private:
   std::atomic_uint thread_counter{0};   /**< number of workers that have done the work */
   std::function<void(T)> fun;           /**< function to run in parallel on each element of data */
   const std::vector<T>* data = nullptr; /**< parameters to pass to fun in parallel */
-  std::atomic_uint index;               /**< index of the next element of data to pick */
+  std::atomic_uint index{0};            /**< index of the next element of data to pick */
 };
 
 /**
@@ -160,18 +160,16 @@ template <typename T> Parmap<T>::Parmap(unsigned num_workers, e_xbt_parmap_mode_
   XBT_CDEBUG(xbt_parmap, "Create new parmap (%u workers)", num_workers);
 
   /* Initialize the thread pool data structure */
-  this->destroying  = false;
-  this->work_round  = 0;
   this->workers.resize(num_workers);
   this->num_workers = num_workers;
   this->synchro     = new_synchro(mode);
 
   /* Create the pool of worker threads (the caller of apply() will be worker[0]) */
   this->workers[0] = nullptr;
-  XBT_ATTRIB_UNUSED unsigned int core_bind = 0;
 
   for (unsigned i = 1; i < num_workers; i++) {
-    this->workers[i] = new std::thread(worker_main, new ThreadData(*this, i));
+    ThreadData* data = new ThreadData(*this, i);
+    this->workers[i] = new std::thread(worker_main, data);
 
     /* Bind the worker to a core if possible */
 #if HAVE_PTHREAD_SETAFFINITY
@@ -183,13 +181,10 @@ template <typename T> Parmap<T>::Parmap(unsigned num_workers, e_xbt_parmap_mode_
     size_t size = sizeof(cpu_set_t);
 #endif
     pthread_t pthread = this->workers[i]->native_handle();
+    int core_bind     = (i - 1) % std::thread::hardware_concurrency();
     CPU_ZERO(&cpuset);
     CPU_SET(core_bind, &cpuset);
     pthread_setaffinity_np(pthread, size, &cpuset);
-    if (core_bind != std::thread::hardware_concurrency() - 1)
-      core_bind++;
-    else
-      core_bind = 0;
 #endif
   }
 }
index fcddfde..6ca4bf4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -9,7 +9,7 @@
 #include "simgrid/version.h"
 #include "src/instr/instr_private.hpp"
 #include "surf/surf.hpp"
-#include "xbt/virtu.h" /* xbt_cmdline */
+#include "xbt/virtu.h" /* xbt::cmdline */
 
 #include <fstream>
 #include <string>
@@ -117,9 +117,7 @@ static void TRACE_start()
       tracing_file << "#This file was generated using SimGrid-" << SIMGRID_VERSION_MAJOR << "." << SIMGRID_VERSION_MINOR
                    << "." << SIMGRID_VERSION_PATCH << std::endl;
       tracing_file << "#[";
-      unsigned int cpt;
-      char* str;
-      xbt_dynar_foreach (xbt_cmdline, cpt, str) {
+      for (auto str : simgrid::xbt::cmdline) {
         tracing_file << str << " ";
       }
       tracing_file << "]" << std::endl;
@@ -151,7 +149,7 @@ static void TRACE_end()
   TRACE_last_timestamp_to_dump = surf_get_clock();
   TRACE_paje_dump_buffer(true);
 
-  simgrid::instr::Type* root_type = simgrid::instr::Container::get_root()->type_;
+  const simgrid::instr::Type* root_type = simgrid::instr::Container::get_root()->type_;
   /* destroy all data structures of tracing (and free) */
   delete simgrid::instr::Container::get_root();
   delete root_type;
index ba355e2..b523d5a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -22,16 +22,14 @@ std::set<std::string> declared_marks;
 std::set<std::string> user_host_variables;
 std::set<std::string> user_vm_variables;
 std::set<std::string> user_link_variables;
-extern std::set<std::string> trivaNodeTypes;
-extern std::set<std::string> trivaEdgeTypes;
 
-static xbt_dynar_t instr_set_to_dynar(std::set<std::string>* filter)
+static xbt_dynar_t instr_set_to_dynar(const std::set<std::string>& filter)
 {
   if (not TRACE_is_enabled() || not TRACE_needs_platform())
     return nullptr;
 
   xbt_dynar_t ret = xbt_dynar_new (sizeof(char*), &xbt_free_ref);
-  for (auto const& name : *filter)
+  for (auto const& name : filter)
     xbt_dynar_push_as(ret, char*, xbt_strdup(name.c_str()));
 
   return ret;
@@ -123,7 +121,7 @@ xbt_dynar_t TRACE_get_categories ()
 {
   if (not TRACE_is_enabled() || not TRACE_categorized())
     return nullptr;
-  return instr_set_to_dynar(&created_categories);
+  return instr_set_to_dynar(created_categories);
 }
 
 /** @ingroup TRACE_mark
@@ -258,7 +256,7 @@ xbt_dynar_t TRACE_get_marks ()
   if (not TRACE_is_enabled())
     return nullptr;
 
-  return instr_set_to_dynar(&declared_marks);
+  return instr_set_to_dynar(declared_marks);
 }
 
 static void instr_user_variable(double time, const char* resource, const char* variable_name, const char* father_type,
@@ -620,7 +618,7 @@ void TRACE_host_variable_sub_with_time (double time, const char *host, const cha
  */
 xbt_dynar_t TRACE_get_host_variables ()
 {
-  return instr_set_to_dynar(&user_host_variables);
+  return instr_set_to_dynar(user_host_variables);
 }
 
 /* for link variables */
@@ -891,7 +889,7 @@ void TRACE_link_srcdst_variable_sub_with_time (double time, const char *src, con
  */
 xbt_dynar_t TRACE_get_link_variables ()
 {
-  return instr_set_to_dynar(&user_link_variables);
+  return instr_set_to_dynar(user_link_variables);
 }
 
 /** @ingroup TRACE_user_variables
@@ -974,29 +972,3 @@ void TRACE_host_pop_state(const char* host, const char* state_name)
 {
   simgrid::instr::Container::by_name(host)->get_state(state_name)->pop_event();
 }
-
-/** @ingroup TRACE_API
- *  @brief Get Paje container types that can be mapped to the nodes of a graph.
- *
- *  This function can be used to create a user made  graph configuration file for Triva. Normally, it is used with the
- *  functions defined in @ref TRACE_user_variables.
- *
- *  @return A dynar with the types, must be freed with xbt_dynar_free.
- */
-xbt_dynar_t TRACE_get_node_types ()
-{
-  return instr_set_to_dynar(&trivaNodeTypes);
-}
-
-/** @ingroup TRACE_API
- *  @brief Get Paje container types that can be mapped to the edges of a graph.
- *
- *  This function can be used to create a user made graph configuration file for Triva. Normally, it is used with the
- *  functions defined in @ref TRACE_user_variables.
- *
- *  @return A dynar with the types, must be freed with xbt_dynar_free.
- */
-xbt_dynar_t TRACE_get_edge_types ()
-{
-  return instr_set_to_dynar(&trivaEdgeTypes);
-}
index 69bd672..14c49d9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -20,8 +20,6 @@ double prefix = 0.0;                               // TI specific
 
 static container_t rootContainer = nullptr;    /* the root container */
 static std::map<std::string, container_t> allContainers; /* all created containers indexed by name */
-std::set<std::string> trivaNodeTypes;           /* all host types defined */
-std::set<std::string> trivaEdgeTypes;           /* all link types defined */
 
 long long int instr_new_paje_id ()
 {
@@ -60,8 +58,6 @@ RouterContainer::RouterContainer(const std::string& name, Container* father)
 
   netpoint_ = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(get_name());
   xbt_assert(netpoint_, "Element '%s' not found", get_cname());
-
-  trivaNodeTypes.insert(type_->get_name());
 }
 
 HostContainer::HostContainer(simgrid::s4u::Host const& host, NetZoneContainer* father)
@@ -71,8 +67,6 @@ HostContainer::HostContainer(simgrid::s4u::Host const& host, NetZoneContainer* f
 
   netpoint_ = host.get_netpoint();
   xbt_assert(netpoint_, "Element '%s' not found", host.get_cname());
-
-  trivaNodeTypes.insert(type_->get_name());
 }
 
 Container::Container(const std::string& name, const std::string& type_name, Container* father)
@@ -99,10 +93,6 @@ Container::Container(const std::string& name, const std::string& type_name, Cont
         simgrid::xbt::string_printf("container %s already present in allContainers data structure", get_cname()));
 
   XBT_DEBUG("Add container name '%s'", get_cname());
-
-  //register NODE types for triva configuration
-  if (type_name == "LINK")
-    trivaNodeTypes.insert(type_->get_name());
 }
 
 Container::~Container()
@@ -240,5 +230,5 @@ VariableType* Container::get_variable(const std::string& name)
   ret->set_calling_container(this);
   return ret;
 }
-}
-}
+} // namespace instr
+} // namespace simgrid
index 17241ef..4a76b0c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index bba1933..bdb2146 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -19,7 +19,7 @@ PajeEvent::PajeEvent(Container* container, Type* type, double timestamp, e_event
     : container_(container), type_(type), timestamp_(timestamp), eventType_(eventType)
 {
   XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, eventType_, TRACE_precision(), timestamp_);
-  if (trace_format == simgrid::instr::TraceFormat::Paje) {
+  if (trace_format == TraceFormat::Paje) {
     stream_ << std::fixed << std::setprecision(TRACE_precision());
     stream_ << eventType_ << " " << timestamp_ << " " << type_->get_id() << " " << container_->get_id();
   }
@@ -28,7 +28,7 @@ PajeEvent::PajeEvent(Container* container, Type* type, double timestamp, e_event
 
 void PajeEvent::print()
 {
-  if (trace_format != simgrid::instr::TraceFormat::Paje)
+  if (trace_format != TraceFormat::Paje)
     return;
 
   XBT_DEBUG("Dump %s", stream_.str().c_str());
@@ -40,7 +40,7 @@ StateEvent::StateEvent(Container* container, Type* type, e_event_type event_type
 {
 #if HAVE_SMPI
   if (simgrid::config::get_value<bool>("smpi/trace-call-location")) {
-    smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
+    const smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
     filename                        = loc->filename;
     linenumber                      = loc->linenumber;
   }
@@ -49,7 +49,7 @@ StateEvent::StateEvent(Container* container, Type* type, e_event_type event_type
 
 void NewEvent::print()
 {
-  if (trace_format != simgrid::instr::TraceFormat::Paje)
+  if (trace_format != TraceFormat::Paje)
     return;
 
   stream_ << " " << value->get_id();
@@ -60,7 +60,7 @@ void NewEvent::print()
 
 void LinkEvent::print()
 {
-  if (trace_format != simgrid::instr::TraceFormat::Paje)
+  if (trace_format != TraceFormat::Paje)
     return;
 
   stream_ << " " << value_ << " " << endpoint_->get_id() << " " << key_;
@@ -74,7 +74,7 @@ void LinkEvent::print()
 
 void VariableEvent::print()
 {
-  if (trace_format != simgrid::instr::TraceFormat::Paje)
+  if (trace_format != TraceFormat::Paje)
     return;
 
   stream_ << " " << value_;
@@ -85,8 +85,7 @@ void VariableEvent::print()
 
 void StateEvent::print()
 {
-  if (trace_format == simgrid::instr::TraceFormat::Paje) {
-
+  if (trace_format == TraceFormat::Paje) {
     if (value != nullptr) // PAJE_PopState Event does not need to have a value
       stream_ << " " << value->get_id();
 
@@ -100,7 +99,7 @@ void StateEvent::print()
 #endif
     XBT_DEBUG("Dump %s", stream_.str().c_str());
     tracing_file << stream_.str() << std::endl;
-  } else if (trace_format == simgrid::instr::TraceFormat::Ti) {
+  } else if (trace_format == TraceFormat::Ti) {
     if (extra_ == nullptr)
       return;
 
@@ -112,7 +111,7 @@ void StateEvent::print()
       container_name=std::to_string(stoi(container_name.erase(0, 5)) - 1);
     }
 #if HAVE_SMPI
-    if (simgrid::config::get_value<bool>("smpi/trace-call-location")) {
+    if (config::get_value<bool>("smpi/trace-call-location")) {
       stream_ << container_name << " location " << filename << " " << linenumber << std::endl ;
     }
 #endif
@@ -121,7 +120,6 @@ void StateEvent::print()
   } else {
     THROW_IMPOSSIBLE;
   }
-
-}
-}
 }
+} // namespace instr
+} // namespace simgrid
index d1004b1..c570dbd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 9ad4852..780dc82 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 927a8db..e5fd2dc 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index bc9f521..90fe739 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 0c9c668..877abc9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 81a86d7..b2c5f6b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 9014e60..e78ac61 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index f0dd78a..565c8cb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -24,12 +24,12 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_routing, instr, "Tracing platform hierarch
 
 static std::vector<simgrid::instr::NetZoneContainer*> currentContainer; /* push and pop, used only in creation */
 
-static const char* instr_node_name(xbt_node_t node)
+static const char* instr_node_name(const s_xbt_node_t* node)
 {
   return static_cast<char*>(xbt_graph_node_get_data(node));
 }
 
-static container_t lowestCommonAncestor(container_t a1, container_t a2)
+static container_t lowestCommonAncestor(const simgrid::instr::Container* a1, const simgrid::instr::Container* a2)
 {
   // this is only an optimization (since most of a1 and a2 share the same parent)
   if (a1->father_ == a2->father_)
@@ -57,7 +57,7 @@ static container_t lowestCommonAncestor(container_t a1, container_t a2)
   int j = ancestors_a2.size() - 1;
   while (i >= 0 && j >= 0) {
     container_t a1p = ancestors_a1.at(i);
-    container_t a2p = ancestors_a2.at(j);
+    const simgrid::instr::Container* a2p = ancestors_a2.at(j);
     if (a1p == a2p) {
       p = a1p;
     } else {
@@ -106,9 +106,6 @@ static void linkContainers(container_t src, container_t dst, std::set<std::strin
   simgrid::instr::LinkType* link = father->type_->by_name_or_create(link_typename, src->type_, dst->type_);
   link->set_calling_container(father);
 
-  // register EDGE types for triva configuration
-  trivaEdgeTypes.insert(link->get_name());
-
   // create the link
   static long long counter = 0;
 
@@ -121,7 +118,7 @@ static void linkContainers(container_t src, container_t dst, std::set<std::strin
   XBT_DEBUG("  linkContainers %s <-> %s", src->get_cname(), dst->get_cname());
 }
 
-static void recursiveGraphExtraction(simgrid::s4u::NetZone* netzone, container_t container,
+static void recursiveGraphExtraction(const simgrid::s4u::NetZone* netzone, container_t container,
                                      std::set<std::string>* filter)
 {
   if (not TRACE_platform_topology()) {
@@ -138,12 +135,12 @@ static void recursiveGraphExtraction(simgrid::s4u::NetZone* netzone, container_t
   }
 
   xbt_graph_t graph                        = xbt_graph_new_graph(0, nullptr);
-  std::map<std::string, xbt_node_t>* nodes = new std::map<std::string, xbt_node_t>;
-  std::map<std::string, xbt_edge_t>* edges = new std::map<std::string, xbt_edge_t>;
+  std::map<std::string, xbt_node_t>* nodes = new std::map<std::string, xbt_node_t>();
+  std::map<std::string, xbt_edge_t>* edges = new std::map<std::string, xbt_edge_t>();
 
   netzone->get_impl()->get_graph(graph, nodes, edges);
   for (auto elm : *edges) {
-    xbt_edge_t edge = elm.second;
+    const xbt_edge* edge = elm.second;
     linkContainers(simgrid::instr::Container::by_name(static_cast<const char*>(edge->src->data)),
                    simgrid::instr::Container::by_name(static_cast<const char*>(edge->dst->data)), filter);
   }
@@ -207,8 +204,8 @@ static void instr_link_on_creation(simgrid::s4u::Link const& link)
 
 static void instr_host_on_creation(simgrid::s4u::Host const& host)
 {
-  container_t container = new simgrid::instr::HostContainer(host, currentContainer.back());
-  container_t root      = simgrid::instr::Container::get_root();
+  simgrid::instr::Container* container  = new simgrid::instr::HostContainer(host, currentContainer.back());
+  const simgrid::instr::Container* root = simgrid::instr::Container::get_root();
 
   if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_speed())) {
     simgrid::instr::VariableType* speed = container->type_->by_name_or_create("speed", "");
@@ -248,13 +245,13 @@ static void instr_action_on_state_change(simgrid::kernel::resource::Action const
     double value = action.get_variable()->get_value() * action.get_variable()->get_constraint_weight(i);
     /* Beware of composite actions: ptasks put links and cpus together. Extra pb: we cannot dynamic_cast from void* */
     simgrid::kernel::resource::Resource* resource = action.get_variable()->get_constraint(i)->get_id();
-    simgrid::kernel::resource::Cpu* cpu = dynamic_cast<simgrid::kernel::resource::Cpu*>(resource);
+    const simgrid::kernel::resource::Cpu* cpu     = dynamic_cast<simgrid::kernel::resource::Cpu*>(resource);
 
     if (cpu != nullptr)
       TRACE_surf_resource_set_utilization("HOST", "speed_used", cpu->get_cname(), action.get_category(), value,
                                           action.get_last_update(), SIMIX_get_clock() - action.get_last_update());
 
-    simgrid::kernel::resource::LinkImpl* link = dynamic_cast<simgrid::kernel::resource::LinkImpl*>(resource);
+    const simgrid::kernel::resource::LinkImpl* link = dynamic_cast<simgrid::kernel::resource::LinkImpl*>(resource);
 
     if (link != nullptr)
       TRACE_surf_resource_set_utilization("LINK", "bandwidth_used", link->get_cname(), action.get_category(), value,
@@ -278,7 +275,7 @@ static void instr_netpoint_on_creation(simgrid::kernel::routing::NetPoint const&
 static void instr_on_platform_created()
 {
   currentContainer.clear();
-  std::set<std::string>* filter = new std::set<std::string>;
+  std::set<std::string>* filter = new std::set<std::string>();
   XBT_DEBUG("Starting graph extraction.");
   recursiveGraphExtraction(simgrid::s4u::Engine::get_instance()->get_netzone_root(),
                            simgrid::instr::Container::get_root(), filter);
@@ -289,8 +286,8 @@ static void instr_on_platform_created()
 
 static void instr_actor_on_creation(simgrid::s4u::Actor const& actor)
 {
-  container_t root      = simgrid::instr::Container::get_root();
-  container_t container = simgrid::instr::Container::by_name(actor.get_host()->get_name());
+  const simgrid::instr::Container* root = simgrid::instr::Container::get_root();
+  simgrid::instr::Container* container  = simgrid::instr::Container::by_name(actor.get_host()->get_name());
 
   container->create_child(instr_pid(actor), "ACTOR");
   simgrid::instr::ContainerType* actor_type =
@@ -332,8 +329,8 @@ static void instr_actor_on_host_change(simgrid::s4u::Actor const& actor,
 
 static void instr_vm_on_creation(simgrid::s4u::Host const& host)
 {
-  container_t container             = new simgrid::instr::HostContainer(host, currentContainer.back());
-  container_t root                  = simgrid::instr::Container::get_root();
+  const simgrid::instr::Container* container = new simgrid::instr::HostContainer(host, currentContainer.back());
+  const simgrid::instr::Container* root      = simgrid::instr::Container::get_root();
   simgrid::instr::ContainerType* vm = container->type_->by_name_or_create<simgrid::instr::ContainerType>("VM");
   simgrid::instr::StateType* state  = vm->by_name_or_create<simgrid::instr::StateType>("VM_STATE");
   state->add_entity_value("suspend", "1 0 1");
@@ -490,8 +487,8 @@ void instr_new_value_for_user_state_type(const std::string& type_name, const cha
 
 #define GRAPHICATOR_SUPPORT_FUNCTIONS
 
-static void recursiveXBTGraphExtraction(xbt_graph_t graph, std::map<std::string, xbt_node_t>* nodes,
-                                        std::map<std::string, xbt_edge_t>* edges, sg_netzone_t netzone,
+static void recursiveXBTGraphExtraction(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t>* nodes,
+                                        std::map<std::string, xbt_edge_t>* edges, const_sg_netzone_t netzone,
                                         container_t container)
 {
   if (not netzone->get_children().empty()) {
@@ -508,8 +505,8 @@ static void recursiveXBTGraphExtraction(xbt_graph_t graph, std::map<std::string,
 xbt_graph_t instr_routing_platform_graph()
 {
   xbt_graph_t ret                          = xbt_graph_new_graph(0, nullptr);
-  std::map<std::string, xbt_node_t>* nodes = new std::map<std::string, xbt_node_t>;
-  std::map<std::string, xbt_edge_t>* edges = new std::map<std::string, xbt_edge_t>;
+  std::map<std::string, xbt_node_t>* nodes = new std::map<std::string, xbt_node_t>();
+  std::map<std::string, xbt_edge_t>* edges = new std::map<std::string, xbt_edge_t>();
   recursiveXBTGraphExtraction(ret, nodes, edges, simgrid::s4u::Engine::get_instance()->get_netzone_root(),
                               simgrid::instr::Container::get_root());
   delete nodes;
@@ -517,7 +514,7 @@ xbt_graph_t instr_routing_platform_graph()
   return ret;
 }
 
-void instr_routing_platform_graph_export_graphviz(xbt_graph_t g, const char* filename)
+void instr_routing_platform_graph_export_graphviz(const s_xbt_graph_t* g, const char* filename)
 {
   unsigned int cursor = 0;
   xbt_node_t node     = nullptr;
index 5d1b98c..c0319cd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -115,13 +115,14 @@ public:
 };
 
 class Pt2PtTIData : public TIData {
-  int tag;
+  int tag = 0;
+
 public:
   explicit Pt2PtTIData(const std::string& name, int endpoint, int size, int tag, const std::string& datatype)
       : TIData(name, endpoint, size, datatype), tag(tag){};
 
   explicit Pt2PtTIData(const std::string& name, int endpoint, int size, const std::string& datatype)
-      : TIData(name, endpoint, size, datatype), tag(0){};
+      : TIData(name, endpoint, size, datatype){};
   std::string print() override
   {
     std::stringstream stream;
@@ -269,8 +270,6 @@ XBT_PRIVATE void TRACE_surf_resource_set_utilization(const char* type, const cha
                                                      double delta);
 
 /* instr_paje.c */
-extern XBT_PRIVATE std::set<std::string> trivaNodeTypes;
-extern XBT_PRIVATE std::set<std::string> trivaEdgeTypes;
 XBT_PRIVATE long long int instr_new_paje_id();
 XBT_PRIVATE void instr_define_callbacks();
 void instr_new_variable_type(const std::string& new_typename, const std::string& color);
@@ -290,6 +289,6 @@ XBT_PRIVATE std::string TRACE_get_filename();
 
 /* instr_platform */
 xbt_graph_t instr_routing_platform_graph();
-void instr_routing_platform_graph_export_graphviz(xbt_graph_t g, const char* filename);
+void instr_routing_platform_graph_export_graphviz(const s_xbt_graph_t* g, const char* filename);
 
 #endif
index aa7ad8c..dddf640 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index f5f7f9f..a99c15f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -12,7 +12,7 @@
 
 /* Helper functions */
 XBT_PRIVATE container_t smpi_container(int rank);
-XBT_PRIVATE void TRACE_smpi_setup_container(int rank, sg_host_t host);
+XBT_PRIVATE void TRACE_smpi_setup_container(int rank, const_sg_host_t host);
 
 XBT_PRIVATE void TRACE_smpi_computing_init(int rank);
 XBT_PRIVATE void TRACE_smpi_computing_out(int rank);
@@ -26,7 +26,7 @@ XBT_PRIVATE void TRACE_smpi_send(int rank, int src, int dst, int tag, int size);
 XBT_PRIVATE void TRACE_smpi_recv(int src, int dst, int tag);
 XBT_PRIVATE void TRACE_smpi_init(int rank);
 /* SMPI + LB (load balancer) */
-XBT_PRIVATE void TRACE_smpi_process_change_host(int rank, sg_host_t new_host);
+XBT_PRIVATE void TRACE_smpi_process_change_host(int rank, const_sg_host_t new_host);
 
 class smpi_trace_call_location_t {
 public:
index ddbecb0..ced9110 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -20,6 +20,11 @@ void Jedule::add_meta_info(char* key, char* value)
   this->meta_info_.insert({key, value});
 }
 
+void Jedule::add_event(const Event& event)
+{
+  event_set_.emplace_back(event);
+}
+
 void Jedule::write_output(FILE* file)
 {
   if (not this->event_set_.empty()) {
@@ -45,6 +50,6 @@ void Jedule::write_output(FILE* file)
   }
 }
 
-}
-}
+} // namespace jedule
+} // namespace simgrid
 #endif
index 2744fcd..0211c84 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -17,7 +17,7 @@ void Event::add_resources(const std::vector<sg_host_t>& host_selection)
   get_resource_selection_by_hosts(this->resource_subsets_, host_selection);
 }
 
-void Event::add_characteristic(char* characteristic)
+void Event::add_characteristic(const char* characteristic)
 {
   xbt_assert( characteristic != nullptr );
   this->characteristics_list_.push_back(characteristic);
index 891b31a..c53f3dd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -19,9 +19,8 @@ std::unordered_map<std::string, jed_container_t> container_name2container;
 namespace simgrid {
 namespace jedule {
 Subset::Subset(int start_idx, int end_idx, Container* parent)
-: start_idx(start_idx), parent(parent)
+    : start_idx(start_idx), nres(end_idx - start_idx + 1), parent(parent)
 {
-  nres=end_idx-start_idx+1;
 }
 
 Container::Container(const std::string& name) : name(name)
@@ -32,15 +31,14 @@ Container::Container(const std::string& name) : name(name)
 void Container::add_child(jed_container_t child)
 {
   xbt_assert(child != nullptr);
-  this->children.emplace_back(child);
-  child->parent = this;
+  children_.emplace_back(child);
+  child->set_parent(this);
 }
 
 void Container::add_resources(std::vector<sg_host_t> hosts)
 {
-  this->is_lowest_ = 1;
-  this->children.clear();
-  this->last_id_ = 0;
+  children_.clear();
+  last_id_ = 0;
 
   for (auto const& host : hosts) {
     const char *host_name = sg_host_get_name(host);
@@ -51,9 +49,8 @@ void Container::add_resources(std::vector<sg_host_t> hosts)
   }
 }
 
-void Container::create_hierarchy(sg_netzone_t from_as)
+void Container::create_hierarchy(const_sg_netzone_t from_as)
 {
-
   if (from_as->get_children().empty()) {
     // I am no AS
     // add hosts to jedule platform
@@ -68,34 +65,28 @@ void Container::create_hierarchy(sg_netzone_t from_as)
   }
 }
 
-std::vector<int> Container::get_hierarchy()
+int Container::get_child_position(const Container* child) const
 {
-  if(this->parent != nullptr ) {
-
-    if (not this->parent->children.empty()) {
-      // we are in the last level
-      return this->parent->get_hierarchy();
-    } else {
-      unsigned int i =0;
-      int child_nb = -1;
-
-      for (auto const& child : this->parent->children) {
-        if (child.get() == this) {
-          child_nb = i;
-          break;
-        }
-        i++;
-      }
+  auto it = std::find_if(begin(children_), end(children_),
+                         [&child](const std::unique_ptr<Container>& c) { return c.get() == child; });
+  return it == end(children_) ? -1 : std::distance(begin(children_), it);
+}
 
-      xbt_assert( child_nb > - 1);
-      std::vector<int> heir_list = this->parent->get_hierarchy();
-      heir_list.insert(heir_list.begin(), child_nb);
-      return heir_list;
-    }
-  } else {
+std::vector<int> Container::get_hierarchy()
+{
+  if (parent_ == nullptr) {
     int top_level = 0;
     std::vector<int> heir_list = {top_level};
     return heir_list;
+  } else if (parent_->has_children()) {
+    int child_nb = parent_->get_child_position(this);
+    xbt_assert(child_nb > -1);
+    std::vector<int> heir_list = parent_->get_hierarchy();
+    heir_list.insert(heir_list.begin(), child_nb);
+    return heir_list;
+  } else {
+    // we are in the last level
+    return parent_->get_hierarchy();
   }
 }
 
@@ -140,8 +131,8 @@ void Container::print_resources(FILE* jed_file)
 void Container::print(FILE* jed_file)
 {
   fprintf(jed_file, "    <res name=\"%s\">\n", this->name.c_str());
-  if (not this->children.empty()) {
-    for (auto const& child : this->children) {
+  if (not children_.empty()) {
+    for (auto const& child : children_) {
       child->print(jed_file);
     }
   } else {
@@ -150,8 +141,8 @@ void Container::print(FILE* jed_file)
   fprintf(jed_file, "    </res>\n");
 }
 
-}
-}
+} // namespace jedule
+} // namespace simgrid
 
 static void add_subsets_to(std::vector<simgrid::jedule::Subset>& subset_list, std::vector<const char*> hostgroup,
                            jed_container_t parent)
@@ -168,7 +159,7 @@ static void add_subsets_to(std::vector<simgrid::jedule::Subset>& subset_list, st
   for (auto const& host_name : hostgroup) {
     xbt_assert( host_name != nullptr );
     jed_container_t parent_cont = host2_simgrid_parent_container.at(host_name);
-    unsigned int id             = parent_cont->name2id.at(host_name);
+    unsigned int id             = parent_cont->get_id_by_name(host_name);
     id_list.push_back(id);
   }
   unsigned int nb_ids = id_list.size();
@@ -193,7 +184,6 @@ static void add_subsets_to(std::vector<simgrid::jedule::Subset>& subset_list, st
       pos = i;
     }
   }
-
 }
 
 void get_resource_selection_by_hosts(std::vector<simgrid::jedule::Subset>& subset_list,
@@ -205,12 +195,12 @@ void get_resource_selection_by_hosts(std::vector<simgrid::jedule::Subset>& subse
   std::unordered_map<const char*, std::vector<const char*>> parent2hostgroup;
   for (auto const& host : host_list) {
     const char *host_name = sg_host_get_name(host);
-    jed_container_t parent = host2_simgrid_parent_container.at(host_name);
+    const simgrid::jedule::Container* parent = host2_simgrid_parent_container.at(host_name);
     xbt_assert( parent != nullptr );
 
-    auto host_group = parent2hostgroup.find(parent->name.c_str());
+    auto host_group = parent2hostgroup.find(parent->get_cname());
     if (host_group == parent2hostgroup.end())
-      parent2hostgroup.insert({parent->name.c_str(), std::vector<const char*>(1,host_name)});
+      parent2hostgroup.insert({parent->get_cname(), std::vector<const char*>(1, host_name)});
     else
       host_group->second.push_back(host_name);
   }
index 5819009..4ca1e45 100644 (file)
@@ -1,13 +1,12 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/jedule/jedule.hpp"
-#include "src/simdag/simdag_private.hpp"
-
 #include "simgrid/s4u/Engine.hpp"
 #include "simgrid/s4u/NetZone.hpp"
+#include "src/simdag/simdag_private.hpp"
 
 #if SIMGRID_HAVE_JEDULE
 
@@ -16,23 +15,22 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(jed_sd, jedule, "Logging specific to Jedule SD b
 
 jedule_t my_jedule;
 
-void jedule_log_sd_event(SD_task_t task)
+void jedule_log_sd_event(const_SD_task_t task)
 {
   xbt_assert(task != nullptr);
 
   simgrid::jedule::Event event(std::string(SD_task_get_name(task)), SD_task_get_start_time(task),
                                SD_task_get_finish_time(task), "SD");
   event.add_resources(*task->allocation);
-  my_jedule->event_set_.emplace_back(std::move(event));
+  my_jedule->add_event(std::move(event));
 }
 
 void jedule_sd_init()
 {
-  sg_netzone_t root_comp = simgrid::s4u::Engine::get_instance()->get_netzone_root();
+  const_sg_netzone_t root_comp = simgrid::s4u::Engine::get_instance()->get_netzone_root();
   XBT_DEBUG("root name %s\n", root_comp->get_cname());
 
   my_jedule = new simgrid::jedule::Jedule(root_comp->get_name());
-  my_jedule->root_container_.create_hierarchy(root_comp);
 }
 
 void jedule_sd_exit()
@@ -43,19 +41,18 @@ void jedule_sd_exit()
 void jedule_sd_dump(const char * filename)
 {
   if (my_jedule) {
-    char *fname;
+    std::string fname;
     if (not filename) {
-      fname = bprintf("%s.jed", xbt_binary_name);
+      fname = simgrid::xbt::binary_name + ".jed";
     } else {
-      fname = xbt_strdup(filename);
+      fname = filename;
     }
 
-    FILE *fh = fopen(fname, "w");
+    FILE* fh = fopen(fname.c_str(), "w");
 
     my_jedule->write_output(fh);
 
     fclose(fh);
-    xbt_free(fname);
   }
 }
 #endif
index 1f40d74..ee308f5 100644 (file)
@@ -3,7 +3,7 @@
 /* Warning: The file internal_config.h is AUTOMATICALLY GENERATED by Cmake.
  * Edit the template instead: src/internal_config.h.in                      */
 
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -24,6 +24,7 @@
 
 /* Address Sanitizer */
 #cmakedefine01 HAVE_SANITIZER_THREAD
+#cmakedefine01 HAVE_SANITIZER_THREAD_FIBER_SUPPORT
 #cmakedefine01 HAVE_SANITIZER_ADDRESS
 #cmakedefine01 HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
 
index 24459fa..07e5ab6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index c45e02f..386e921 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 2406311..baa4dc0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index df0a712..c1c8de5 100644 (file)
@@ -1,10 +1,10 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#ifndef SIMGRID_KERNEL_ACTIVITY_ACTIVITY_HPP
-#define SIMGRID_KERNEL_ACTIVITY_ACTIVITY_HPP
+#ifndef SIMGRID_KERNEL_ACTIVITY_ACTIVITYIMPL_HPP
+#define SIMGRID_KERNEL_ACTIVITY_ACTIVITYIMPL_HPP
 
 #include <string>
 #include <list>
@@ -36,6 +36,7 @@ enum class State {
 
 class XBT_PUBLIC ActivityImpl {
   std::atomic_int_fast32_t refcount_{0};
+
 public:
   virtual ~ActivityImpl();
   ActivityImpl() = default;
index e6cc960..b80dc64 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -20,7 +20,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_network, simix, "SIMIX network-related syn
 
 XBT_PRIVATE void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_actor_t src, smx_mailbox_t mbox, double task_size,
                                            double rate, unsigned char* src_buff, size_t src_buff_size,
-                                           int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+                                           bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
                                            void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
                                            void* data, double timeout)
 {
@@ -32,7 +32,8 @@ XBT_PRIVATE void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_actor_t sr
 
 XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend(
     smx_simcall_t /*simcall*/, smx_actor_t src_proc, smx_mailbox_t mbox, double task_size, double rate,
-    unsigned char* src_buff, size_t src_buff_size, int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+    unsigned char* src_buff, size_t src_buff_size,
+    bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
     void (*clean_fun)(void*), // used to free the synchro in case of problem after a detached send
     void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), // used to copy data if not default one
     void* data, bool detached)
@@ -98,7 +99,7 @@ XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend(
 
 XBT_PRIVATE void simcall_HANDLER_comm_recv(smx_simcall_t simcall, smx_actor_t receiver, smx_mailbox_t mbox,
                                            unsigned char* dst_buff, size_t* dst_buff_size,
-                                           int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+                                           bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
                                            void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
                                            void* data, double timeout, double rate)
 {
@@ -110,8 +111,8 @@ XBT_PRIVATE void simcall_HANDLER_comm_recv(smx_simcall_t simcall, smx_actor_t re
 
 XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_irecv(
     smx_simcall_t /*simcall*/, smx_actor_t receiver, smx_mailbox_t mbox, unsigned char* dst_buff, size_t* dst_buff_size,
-    simix_match_func_t match_fun, void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
-    void* data, double rate)
+    bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+    void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data, double rate)
 {
   simgrid::kernel::activity::CommImplPtr this_synchro =
       simgrid::kernel::activity::CommImplPtr(new simgrid::kernel::activity::CommImpl());
@@ -606,7 +607,7 @@ void CommImpl::finish()
     /* Check out for errors */
 
     if (not simcall->issuer_->get_host()->is_on()) {
-      simcall->issuer_->context_->iwannadie = true;
+      simcall->issuer_->context_->set_wannadie();
     } else {
       switch (state_) {
         case State::DONE:
@@ -626,7 +627,7 @@ void CommImpl::finish()
 
         case State::SRC_HOST_FAILURE:
           if (simcall->issuer_ == src_actor_)
-            simcall->issuer_->context_->iwannadie = true;
+            simcall->issuer_->context_->set_wannadie();
           else
             simcall->issuer_->exception_ =
                 std::make_exception_ptr(simgrid::NetworkFailureException(XBT_THROW_POINT, "Remote peer failed"));
@@ -634,7 +635,7 @@ void CommImpl::finish()
 
         case State::DST_HOST_FAILURE:
           if (simcall->issuer_ == dst_actor_)
-            simcall->issuer_->context_->iwannadie = true;
+            simcall->issuer_->context_->set_wannadie();
           else
             simcall->issuer_->exception_ =
                 std::make_exception_ptr(simgrid::NetworkFailureException(XBT_THROW_POINT, "Remote peer failed"));
index 7c0691a..94b3096 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -58,7 +58,7 @@ public:
 #endif
 
   void (*clean_fun)(void*) = nullptr; /* Function to clean the detached src_buf if something goes wrong */
-  int (*match_fun)(void*, void*, CommImpl*) = nullptr; /* Filter function used by the other side. It is used when
+  bool (*match_fun)(void*, void*, CommImpl*) = nullptr; /* Filter function used by the other side. It is used when
 looking if a given communication matches my needs. For that, myself must match the
 expectations of the other side, too. See  */
   void (*copy_data_fun)(CommImpl*, void*, size_t) = nullptr;
index 027ef16..04d034f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -28,9 +28,6 @@ namespace simgrid {
 namespace kernel {
 namespace activity {
 
-ConditionVariableImpl::ConditionVariableImpl() : cond_(this) {}
-ConditionVariableImpl::~ConditionVariableImpl() = default;
-
 /**
  * @brief Signalizes a condition.
  *
@@ -85,7 +82,7 @@ void ConditionVariableImpl::wait(smx_mutex_t mutex, double timeout, actor::Actor
 
   /* If there is a mutex unlock it */
   if (mutex != nullptr) {
-    xbt_assert(mutex->owner_ == issuer,
+    xbt_assert(mutex->get_owner() == issuer,
                "Actor %s cannot wait on ConditionVariable %p since it does not own the provided mutex %p",
                issuer->get_cname(), this, mutex);
     mutex_ = mutex;
index 0095699..eb6937b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -15,22 +15,23 @@ namespace kernel {
 namespace activity {
 
 class XBT_PUBLIC ConditionVariableImpl {
-public:
-  ConditionVariableImpl();
-  ~ConditionVariableImpl();
-
-  actor::SynchroList sleeping_; /* list of sleeping processes */
   MutexImpl* mutex_ = nullptr;
-  s4u::ConditionVariable cond_;
-
-  void broadcast();
-  void signal();
-  void wait(MutexImpl* mutex, double timeout, actor::ActorImpl* issuer);
+  s4u::ConditionVariable piface_;
+  actor::SynchroList sleeping_; /* list of sleeping actors*/
 
-private:
   std::atomic_int_fast32_t refcount_{1};
   friend void intrusive_ptr_add_ref(ConditionVariableImpl* cond);
   friend void intrusive_ptr_release(ConditionVariableImpl* cond);
+
+public:
+  ConditionVariableImpl() : piface_(this){};
+  ~ConditionVariableImpl() = default;
+
+  void remove_sleeping_actor(actor::ActorImpl& actor) { xbt::intrusive_erase(sleeping_, actor); }
+  s4u::ConditionVariable* get_iface() { return &piface_; }
+  void broadcast();
+  void signal();
+  void wait(MutexImpl* mutex, double timeout, actor::ActorImpl* issuer);
 };
 } // namespace activity
 } // namespace kernel
index eda2b58..5ab240d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_process);
 
-void simcall_HANDLER_execution_wait(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* synchro)
+void simcall_HANDLER_execution_wait(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* synchro, double timeout)
 {
   XBT_DEBUG("Wait for execution of synchro %p, state %d", synchro, (int)synchro->state_);
+  xbt_assert(std::isfinite(timeout), "timeout is not finite!");
 
   /* Associate this simcall to the synchro */
   synchro->register_simcall(simcall);
 
   /* set surf's synchro */
   if (MC_is_active() || MC_record_replay_is_active()) {
-    synchro->state_ = simgrid::kernel::activity::State::DONE;
+    int idx = SIMCALL_GET_MC_VALUE(*simcall);
+    if (idx == 0) {
+      synchro->state_ = simgrid::kernel::activity::State::DONE;
+    } else {
+      /* If we reached this point, the wait simcall must have a timeout */
+      /* Otherwise it shouldn't be enabled and executed by the MC */
+      if (timeout < 0.0)
+        THROW_IMPOSSIBLE;
+      synchro->state_ = simgrid::kernel::activity::State::TIMEOUT;
+    }
     synchro->finish();
     return;
   }
 
   /* If the synchro is already finished then perform the error handling */
-  if (synchro->state_ != simgrid::kernel::activity::State::RUNNING)
+  if (synchro->state_ != simgrid::kernel::activity::State::RUNNING) {
     synchro->finish();
+  } else { /* we need a sleep action (even when there is no timeout) to be notified of host failures */
+    synchro->set_timeout(timeout);
+  }
 }
 
 void simcall_HANDLER_execution_test(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* synchro)
@@ -86,13 +99,6 @@ namespace simgrid {
 namespace kernel {
 namespace activity {
 
-ExecImpl::~ExecImpl()
-{
-  if (timeout_detector_)
-    timeout_detector_->unref();
-  XBT_DEBUG("Destroy exec %p", this);
-}
-
 ExecImpl& ExecImpl::set_host(s4u::Host* host)
 {
   if (not hosts_.empty())
@@ -110,7 +116,7 @@ ExecImpl& ExecImpl::set_hosts(const std::vector<s4u::Host*>& hosts)
 ExecImpl& ExecImpl::set_timeout(double timeout)
 {
   if (timeout > 0 && not MC_is_active() && not MC_record_replay_is_active()) {
-    timeout_detector_ = hosts_.front()->pimpl_cpu->sleep(timeout);
+    timeout_detector_.reset(hosts_.front()->pimpl_cpu->sleep(timeout));
     timeout_detector_->set_activity(this);
   }
   return *this;
@@ -197,12 +203,7 @@ void ExecImpl::post()
   }
 
   clean_action();
-
-  if (timeout_detector_) {
-    timeout_detector_->unref();
-    timeout_detector_ = nullptr;
-  }
-
+  timeout_detector_.reset();
   /* Answer all simcalls associated with the synchro */
   finish();
 }
@@ -244,7 +245,6 @@ void ExecImpl::finish()
     }
 
     switch (state_) {
-
       case State::DONE:
         /* do nothing, synchro done */
         XBT_DEBUG("ExecImpl::finish(): execution successful");
@@ -252,7 +252,7 @@ void ExecImpl::finish()
 
       case State::FAILED:
         XBT_DEBUG("ExecImpl::finish(): host '%s' failed", simcall->issuer_->get_host()->get_cname());
-        simcall->issuer_->context_->iwannadie = true;
+        simcall->issuer_->context_->set_wannadie();
         if (simcall->issuer_->get_host()->is_on())
           simcall->issuer_->exception_ =
               std::make_exception_ptr(simgrid::HostFailureException(XBT_THROW_POINT, "Host failed"));
@@ -279,7 +279,7 @@ void ExecImpl::finish()
     if (simcall->issuer_->get_host()->is_on())
       simcall->issuer_->simcall_answer();
     else
-      simcall->issuer_->context_->iwannadie = true;
+      simcall->issuer_->context_->set_wannadie();
   }
 }
 
index ab92675..fe4b94a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -15,13 +15,13 @@ namespace kernel {
 namespace activity {
 
 class XBT_PUBLIC ExecImpl : public ActivityImpl_T<ExecImpl> {
-  resource::Action* timeout_detector_ = nullptr;
+  std::unique_ptr<resource::Action, std::function<void(resource::Action*)>> timeout_detector_{
+      nullptr, [](resource::Action* a) { a->unref(); }};
   double sharing_penalty_             = 1.0;
   double bound_                       = 0.0;
   std::vector<s4u::Host*> hosts_;
   std::vector<double> flops_amounts_;
   std::vector<double> bytes_amounts_;
-  ~ExecImpl();
 
 public:
   ExecImpl& set_timeout(double timeout);
index 783616f..ce4254f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 #include "src/mc/mc_replay.hpp"
 #include "src/simix/smx_private.hpp"
 #include "src/surf/StorageImpl.hpp"
+#include "src/surf/cpu_interface.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_io, simix, "Logging specific to SIMIX (io)");
 
-void simcall_HANDLER_io_wait(smx_simcall_t simcall, simgrid::kernel::activity::IoImpl* synchro)
+void simcall_HANDLER_io_wait(smx_simcall_t simcall, simgrid::kernel::activity::IoImpl* synchro, double timeout)
 {
   XBT_DEBUG("Wait for execution of synchro %p, state %d", synchro, (int)synchro->state_);
 
   /* Associate this simcall to the synchro */
   synchro->register_simcall(simcall);
 
-  if (MC_is_active() || MC_record_replay_is_active())
-    synchro->state_ = simgrid::kernel::activity::State::DONE;
+  if (MC_is_active() || MC_record_replay_is_active()) {
+    int idx = SIMCALL_GET_MC_VALUE(*simcall);
+    if (idx == 0) {
+      synchro->state_ = simgrid::kernel::activity::State::DONE;
+    } else {
+      /* If we reached this point, the wait simcall must have a timeout */
+      /* Otherwise it shouldn't be enabled and executed by the MC */
+      if (timeout < 0.0)
+        THROW_IMPOSSIBLE;
+      synchro->state_ = simgrid::kernel::activity::State::TIMEOUT;
+    }
+    synchro->finish();
+  }
 
   /* If the synchro is already finished then perform the error handling */
   if (synchro->state_ != simgrid::kernel::activity::State::RUNNING)
     synchro->finish();
+  else {
+    /* we need a sleep action (even when there is no timeout) to be notified of host failures */
+    if (synchro->get_disk() != nullptr)
+      synchro->set_timeout_detector(synchro->get_disk()->get_host()->pimpl_cpu->sleep(timeout));
+    else
+      synchro->set_timeout_detector(
+          simgrid::s4u::Host::by_name(synchro->get_storage()->get_host())->pimpl_cpu->sleep(timeout));
+  }
+}
+
+void simcall_HANDLER_io_test(smx_simcall_t simcall, simgrid::kernel::activity::IoImpl* synchro)
+{
+  bool res = (synchro->state_ != simgrid::kernel::activity::State::WAITING &&
+              synchro->state_ != simgrid::kernel::activity::State::RUNNING);
+  if (res) {
+    synchro->simcalls_.push_back(simcall);
+    synchro->finish();
+  } else {
+    simcall->issuer_->simcall_answer();
+  }
+  simcall_io_test__set__result(simcall, res);
 }
 
 namespace simgrid {
@@ -82,7 +115,15 @@ void IoImpl::post()
       state_ = State::CANCELED;
   } else if (surf_action_->get_state() == resource::Action::State::FINISHED) {
     state_ = State::DONE;
+  } else if (timeout_detector_ && timeout_detector_->get_state() == resource::Action::State::FINISHED) {
+    state_ = State::TIMEOUT;
   }
+
+  if (timeout_detector_) {
+    timeout_detector_->unref();
+    timeout_detector_ = nullptr;
+  }
+
   on_completion(*this);
 
   /* Answer all simcalls associated with the synchro */
@@ -92,20 +133,24 @@ void IoImpl::post()
 void IoImpl::finish()
 {
   while (not simcalls_.empty()) {
-    smx_simcall_t simcall = simcalls_.front();
+    const s_smx_simcall* simcall = simcalls_.front();
     simcalls_.pop_front();
     switch (state_) {
       case State::DONE:
         /* do nothing, synchro done */
         break;
       case State::FAILED:
-        simcall->issuer_->context_->iwannadie = true;
+        simcall->issuer_->context_->set_wannadie();
         simcall->issuer_->exception_ =
             std::make_exception_ptr(StorageFailureException(XBT_THROW_POINT, "Storage failed"));
         break;
       case State::CANCELED:
         simcall->issuer_->exception_ = std::make_exception_ptr(CancelException(XBT_THROW_POINT, "I/O Canceled"));
         break;
+      case State::TIMEOUT:
+        XBT_DEBUG("IoImpl::finish(): execution timeouted");
+        simcall->issuer_->exception_ = std::make_exception_ptr(simgrid::TimeoutException(XBT_THROW_POINT, "Timeouted"));
+        break;
       default:
         xbt_die("Internal error in IoImpl::finish(): unexpected synchro state %d", static_cast<int>(state_));
     }
index cbc2f0d..897cfb5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -20,6 +20,7 @@ class XBT_PUBLIC IoImpl : public ActivityImpl_T<IoImpl> {
   sg_size_t size_                 = 0;
   s4u::Io::OpType type_           = s4u::Io::OpType::READ;
   sg_size_t performed_ioops_      = 0;
+  resource::Action* timeout_detector_ = nullptr;
 
 public:
   IoImpl& set_size(sg_size_t size);
@@ -27,7 +28,15 @@ public:
   IoImpl& set_storage(resource::StorageImpl* storage);
   IoImpl& set_disk(resource::DiskImpl* disk);
 
+  void set_timeout_detector(resource::Action* action)
+  {
+    timeout_detector_ = action;
+    timeout_detector_->set_activity(this);
+  }
+
   sg_size_t get_performed_ioops() { return performed_ioops_; }
+  resource::DiskImpl* get_disk() { return disk_; }
+  resource::StorageImpl* get_storage() { return storage_; }
 
   IoImpl* start();
   void post() override;
index 3137c62..7be3b40 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -85,7 +85,7 @@ void MailboxImpl::remove(const CommImplPtr& comm)
   xbt_die("Comm %p not found in mailbox %s", comm.get(), this->get_cname());
 }
 
-CommImplPtr MailboxImpl::iprobe(int type, int (*match_fun)(void*, void*, CommImpl*), void* data)
+CommImplPtr MailboxImpl::iprobe(int type, bool (*match_fun)(void*, void*, CommImpl*), void* data)
 {
   XBT_DEBUG("iprobe from %p %p", this, &comm_queue_);
 
@@ -122,7 +122,7 @@ CommImplPtr MailboxImpl::iprobe(int type, int (*match_fun)(void*, void*, CommImp
  *  @param remove_matching whether or not to clean the found object from the queue
  *  @return The communication activity if found, nullptr otherwise
  */
-CommImplPtr MailboxImpl::find_matching_comm(CommImpl::Type type, int (*match_fun)(void*, void*, CommImpl*),
+CommImplPtr MailboxImpl::find_matching_comm(CommImpl::Type type, bool (*match_fun)(void*, void*, CommImpl*),
                                             void* this_user_data, const CommImplPtr& my_synchro, bool done,
                                             bool remove_matching)
 {
@@ -130,7 +130,7 @@ CommImplPtr MailboxImpl::find_matching_comm(CommImpl::Type type, int (*match_fun
   auto& comm_queue      = done ? done_comm_queue_ : comm_queue_;
 
   for (auto it = comm_queue.begin(); it != comm_queue.end(); it++) {
-    CommImplPtr& comm = *it;
+    const CommImplPtr& comm = *it;
 
     if (comm->type_ == CommImpl::Type::SEND) {
       other_user_data = comm->src_data_;
index ac05e66..956b021 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -29,10 +29,7 @@ class MailboxImpl {
   friend s4u::Mailbox* s4u::Mailbox::by_name(const std::string& name);
   friend mc::CommunicationDeterminismChecker;
 
-  explicit MailboxImpl(const std::string& name)
-      : piface_(this), name_(name), comm_queue_(MAX_MAILBOX_SIZE), done_comm_queue_(MAX_MAILBOX_SIZE)
-  {
-  }
+  explicit MailboxImpl(const std::string& name) : piface_(this), name_(name) {}
 
 public:
   const xbt::string& get_name() const { return name_; }
@@ -42,14 +39,14 @@ public:
   void set_receiver(s4u::ActorPtr actor);
   void push(CommImplPtr comm);
   void remove(const CommImplPtr& comm);
-  CommImplPtr iprobe(int type, int (*match_fun)(void*, void*, CommImpl*), void* data);
-  CommImplPtr find_matching_comm(CommImpl::Type type, int (*match_fun)(void*, void*, CommImpl*), void* this_user_data,
+  CommImplPtr iprobe(int type, bool (*match_fun)(void*, void*, CommImpl*), void* data);
+  CommImplPtr find_matching_comm(CommImpl::Type type, bool (*match_fun)(void*, void*, CommImpl*), void* this_user_data,
                                  const CommImplPtr& my_synchro, bool done, bool remove_matching);
 
   actor::ActorImplPtr permanent_receiver_; // actor to which the mailbox is attached
-  boost::circular_buffer_space_optimized<CommImplPtr> comm_queue_;
-  boost::circular_buffer_space_optimized<CommImplPtr> done_comm_queue_; // messages already received in the permanent
-                                                                        // receive mode
+  boost::circular_buffer_space_optimized<CommImplPtr> comm_queue_{MAX_MAILBOX_SIZE};
+  // messages already received in the permanent receive mode
+  boost::circular_buffer_space_optimized<CommImplPtr> done_comm_queue_{MAX_MAILBOX_SIZE};
 };
 } // namespace activity
 } // namespace kernel
index 9274c47..8505e91 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index f372ea7..ba85ad0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -18,6 +18,9 @@ class XBT_PUBLIC MutexImpl {
   std::atomic_int_fast32_t refcount_{1};
   s4u::Mutex piface_;
   bool locked_ = false;
+  actor::ActorImpl* owner_ = nullptr;
+  // List of sleeping actors:
+  actor::SynchroList sleeping_;
 
 public:
   MutexImpl() : piface_(this) {}
@@ -32,9 +35,8 @@ public:
   MutexImpl* ref();
   void unref();
 
-  actor::ActorImpl* owner_ = nullptr;
-  // List of sleeping actors:
-  actor::SynchroList sleeping_;
+  void remove_sleeping_actor(actor::ActorImpl& actor) { xbt::intrusive_erase(sleeping_, actor); }
+  actor::ActorImpl* get_owner() const { return owner_; }
 
   // boost::intrusive_ptr<Mutex> support:
   friend void intrusive_ptr_add_ref(MutexImpl* mutex)
index 2daeba6..ae98e55 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 961a15a..361c7cf 100644 (file)
@@ -1,10 +1,10 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#ifndef SIMGRID_KERNEL_ACTIVITY_SEMAPHORE_HPP
-#define SIMGRID_KERNEL_ACTIVITY_SEMAPHORE_HPP
+#ifndef SIMGRID_KERNEL_ACTIVITY_SEMAPHOREIMPL_HPP
+#define SIMGRID_KERNEL_ACTIVITY_SEMAPHOREIMPL_HPP
 
 #include <atomic>
 #include <boost/intrusive/list.hpp>
@@ -19,10 +19,9 @@ namespace activity {
 class XBT_PUBLIC SemaphoreImpl {
   std::atomic_int_fast32_t refcount_{1};
   unsigned int value_;
-
-public:
   actor::SynchroList sleeping_; /* list of sleeping actors*/
 
+public:
   explicit SemaphoreImpl(unsigned int value) : value_(value){};
   ~SemaphoreImpl() = default;
 
@@ -32,8 +31,10 @@ public:
   void acquire(actor::ActorImpl* issuer, double timeout);
   void release();
   bool would_block() { return (value_ == 0); }
+  void remove_sleeping_actor(actor::ActorImpl& actor) { xbt::intrusive_erase(sleeping_, actor); }
 
   unsigned int get_capacity() { return value_; }
+  bool is_used() { return not sleeping_.empty(); }
 
   friend void intrusive_ptr_add_ref(SemaphoreImpl* sem)
   {
@@ -50,4 +51,4 @@ public:
 } // namespace kernel
 } // namespace simgrid
 
-#endif /* SIMGRID_KERNEL_ACTIVITY_SEMAPHOREIMPL_HPP_ */
+#endif /* SIMGRID_KERNEL_ACTIVITY_SEMAPHOREIMPL_HPP */
index 8a3eb18..4df963b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -55,7 +55,7 @@ void SleepImpl::post()
 void SleepImpl::finish()
 {
   while (not simcalls_.empty()) {
-    smx_simcall_t simcall = simcalls_.front();
+    const s_smx_simcall* simcall = simcalls_.front();
     simcalls_.pop_front();
 
     simcall->issuer_->waiting_synchro = nullptr;
index ca267f5..b7f7968 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 8a4cb51..171199b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -71,33 +71,32 @@ void RawImpl::finish()
 
   if (state_ == State::FAILED) {
     XBT_DEBUG("RawImpl::finish(): host '%s' failed", simcall->issuer_->get_host()->get_cname());
-    simcall->issuer_->context_->iwannadie = true;
+    simcall->issuer_->context_->set_wannadie();
     simcall->issuer_->exception_ = std::make_exception_ptr(HostFailureException(XBT_THROW_POINT, "Host failed"));
   } else if (state_ != State::SRC_TIMEOUT) {
     xbt_die("Internal error in RawImpl::finish() unexpected synchro state %d", static_cast<int>(state_));
   }
 
   switch (simcall->call_) {
-
     case SIMCALL_MUTEX_LOCK:
-      simgrid::xbt::intrusive_erase(simcall_mutex_lock__get__mutex(simcall)->sleeping_, *simcall->issuer_);
+      simcall_mutex_lock__get__mutex(simcall)->remove_sleeping_actor(*simcall->issuer_);
       break;
 
     case SIMCALL_COND_WAIT:
-      simgrid::xbt::intrusive_erase(simcall_cond_wait__get__cond(simcall)->sleeping_, *simcall->issuer_);
+      simcall_cond_wait_timeout__get__cond(simcall)->remove_sleeping_actor(*simcall->issuer_);
       break;
 
     case SIMCALL_COND_WAIT_TIMEOUT:
-      simgrid::xbt::intrusive_erase(simcall_cond_wait_timeout__get__cond(simcall)->sleeping_, *simcall->issuer_);
+      simcall_cond_wait_timeout__get__cond(simcall)->remove_sleeping_actor(*simcall->issuer_);
       simcall_cond_wait_timeout__set__result(simcall, 1); // signal a timeout
       break;
 
     case SIMCALL_SEM_ACQUIRE:
-      simgrid::xbt::intrusive_erase(simcall_sem_acquire__get__sem(simcall)->sleeping_, *simcall->issuer_);
+      simcall_sem_acquire_timeout__get__sem(simcall)->remove_sleeping_actor(*simcall->issuer_);
       break;
 
     case SIMCALL_SEM_ACQUIRE_TIMEOUT:
-      simgrid::xbt::intrusive_erase(simcall_sem_acquire_timeout__get__sem(simcall)->sleeping_, *simcall->issuer_);
+      simcall_sem_acquire_timeout__get__sem(simcall)->remove_sleeping_actor(*simcall->issuer_);
       simcall_sem_acquire_timeout__set__result(simcall, 1); // signal a timeout
       break;
 
index 62b62bc..6d45f90 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 821db95..621c4c1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -60,13 +60,8 @@ ActorImpl::ActorImpl(xbt::string name, s4u::Host* host) : host_(host), name_(std
 
 ActorImpl::~ActorImpl()
 {
-  if (simix_global != nullptr && this != simix_global->maestro_) {
-    if (context_.get() != nullptr) /* the actor was not start()ed yet. This happens if its host was initially off */
-      context_->iwannadie = false; // don't let the simcall's yield() do a Context::stop(), to avoid infinite loops
-    actor::simcall([this] { s4u::Actor::on_destruction(*ciface()); });
-    if (context_.get() != nullptr)
-      context_->iwannadie = true;
-  }
+  if (simix_global != nullptr && this != simix_global->maestro_)
+    s4u::Actor::on_destruction(*ciface());
 }
 
 /* Become an actor in the simulation
@@ -136,6 +131,20 @@ void ActorImpl::detach()
   context->attach_stop();
 }
 
+void ActorImpl::cleanup_from_simix()
+{
+  const std::lock_guard<std::mutex> lock(simix_global->mutex);
+  simix_global->process_list.erase(pid_);
+  if (host_ && host_actor_list_hook.is_linked())
+    host_->pimpl_->remove_actor(this);
+  if (not smx_destroy_list_hook.is_linked()) {
+#if SIMGRID_HAVE_MC
+    xbt_dynar_push_as(simix_global->dead_actors_vector, ActorImpl*, this);
+#endif
+    simix_global->actors_to_destroy.push_back(*this);
+  }
+}
+
 void ActorImpl::cleanup()
 {
   finished_ = true;
@@ -148,7 +157,7 @@ void ActorImpl::cleanup()
 
   if (on_exit) {
     // Execute the termination callbacks
-    bool failed = context_->iwannadie;
+    bool failed = context_->wannadie();
     for (auto exit_fun = on_exit->crbegin(); exit_fun != on_exit->crend(); ++exit_fun)
       (*exit_fun)(failed);
     on_exit.reset();
@@ -172,29 +181,16 @@ void ActorImpl::cleanup()
     kill_timer->remove();
     kill_timer = nullptr;
   }
+  cleanup_from_simix();
 
-  simix_global->mutex.lock();
-
-  simix_global->process_list.erase(pid_);
-  if (host_ && host_actor_list_hook.is_linked())
-    host_->pimpl_->remove_actor(this);
-  if (not smx_destroy_list_hook.is_linked()) {
-#if SIMGRID_HAVE_MC
-    xbt_dynar_push_as(simix_global->dead_actors_vector, ActorImpl*, this);
-#endif
-    simix_global->actors_to_destroy.push_back(*this);
-  }
-
-  simix_global->mutex.unlock();
-
-  context_->iwannadie = false; // don't let the simcall's yield() do a Context::stop(), to avoid infinite loops
+  context_->set_wannadie(false); // don't let the simcall's yield() do a Context::stop(), to avoid infinite loops
   actor::simcall([this] { s4u::Actor::on_termination(*ciface()); });
-  context_->iwannadie = true;
+  context_->set_wannadie();
 }
 
 void ActorImpl::exit()
 {
-  context_->iwannadie = true;
+  context_->set_wannadie();
   suspended_          = false;
   exception_          = nullptr;
 
@@ -280,7 +276,7 @@ void ActorImpl::yield()
   /* Ok, maestro returned control to us */
   XBT_DEBUG("Control returned to me: '%s'", get_cname());
 
-  if (context_->iwannadie) {
+  if (context_->wannadie()) {
     XBT_DEBUG("Actor %s@%s is dead", get_cname(), host_->get_cname());
     context_->stop();
     THROW_IMPOSSIBLE;
@@ -375,7 +371,7 @@ void ActorImpl::resume()
 {
   XBT_IN("actor = %p", this);
 
-  if (context_->iwannadie) {
+  if (context_->wannadie()) {
     XBT_VERB("Ignoring request to suspend an actor that is currently dying.");
     return;
   }
@@ -391,7 +387,7 @@ void ActorImpl::resume()
   XBT_OUT();
 }
 
-activity::ActivityImplPtr ActorImpl::join(ActorImpl* actor, double timeout)
+activity::ActivityImplPtr ActorImpl::join(const ActorImpl* actor, double timeout)
 {
   activity::ActivityImplPtr sleep = this->sleep(timeout);
   actor->on_exit->emplace_back([sleep](bool) {
index c0883ae..74b0b8c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -107,6 +107,7 @@ public:
 private:
   s4u::Actor piface_; // Our interface is part of ourselves
 
+  void cleanup_from_simix();
   void undaemonize();
 
 public:
@@ -132,7 +133,7 @@ public:
   s4u::Actor* restart();
   void suspend();
   void resume();
-  activity::ActivityImplPtr join(ActorImpl* actor, double timeout);
+  activity::ActivityImplPtr join(const ActorImpl* actor, double timeout);
   activity::ActivityImplPtr sleep(double duration);
   /** Ask the actor to throw an exception right away */
   void throw_exception(std::exception_ptr e);
index 886b201..b53a2a0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index b5e5e64..e4f3d66 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -45,16 +45,17 @@ class XBT_PUBLIC Context {
 
   std::function<void()> code_;
   actor::ActorImpl* actor_ = nullptr;
+  bool iwannadie_          = false;
   void declare_context(std::size_t size);
 
 public:
-  bool iwannadie = false;
-
   Context(std::function<void()>&& code, actor::ActorImpl* actor);
   Context(const Context&) = delete;
   Context& operator=(const Context&) = delete;
   virtual ~Context();
 
+  bool wannadie() const { return iwannadie_; }
+  void set_wannadie(bool value = true) { iwannadie_ = value; }
   void operator()() { code_(); }
   bool has_code() const { return static_cast<bool>(code_); }
   actor::ActorImpl* get_actor() { return this->actor_; }
index afdb933..9d275c2 100644 (file)
@@ -1,10 +1,9 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "ContextBoost.hpp"
-#include "context_private.hpp"
 #include "simgrid/Exception.hpp"
 #include "src/simix/smx_private.hpp"
 
@@ -28,72 +27,36 @@ BoostContext::BoostContext(std::function<void()>&& code, actor::ActorImpl* actor
 
   /* if the user provided a function for the process then use it, otherwise it is the context for maestro */
   if (has_code()) {
-    /* We need to pass the bottom of the stack to make_fcontext,
-       depending on the stack direction it may be the lower or higher address: */
-#if PTH_STACKGROWTH == -1
-    unsigned char* stack = get_stack() + smx_context_stack_size;
-#else
-    unsigned char* stack = get_stack();
-#endif
 #if BOOST_VERSION < 106100
-    this->fc_ = boost::context::make_fcontext(stack, smx_context_stack_size, BoostContext::wrapper);
+    this->fc_ = boost::context::make_fcontext(get_stack_bottom(), smx_context_stack_size, BoostContext::wrapper);
 #else
-    this->fc_ = boost::context::detail::make_fcontext(stack, smx_context_stack_size, BoostContext::wrapper);
-#endif
-
-  } else {
-#if BOOST_VERSION < 105600
-    this->fc_ = new boost::context::fcontext_t();
+    this->fc_ =
+        boost::context::detail::make_fcontext(get_stack_bottom(), smx_context_stack_size, BoostContext::wrapper);
 #endif
   }
 }
 
-BoostContext::~BoostContext()
-{
-#if BOOST_VERSION < 105600
-  if (not get_stack())
-    delete this->fc_;
-#endif
-}
-
 void BoostContext::wrapper(BoostContext::arg_type arg)
 {
 #if BOOST_VERSION < 106100
   BoostContext* context = reinterpret_cast<BoostContext*>(arg);
 #else
   BoostContext* context = static_cast<BoostContext**>(arg.data)[1];
-  ASAN_ONLY(xbt_assert(context->asan_ctx_ == static_cast<BoostContext**>(arg.data)[0]));
-  ASAN_FINISH_SWITCH(nullptr, &context->asan_ctx_->asan_stack_, &context->asan_ctx_->asan_stack_size_);
+  context->verify_previous_context(static_cast<BoostContext**>(arg.data)[0]);
   static_cast<BoostContext**>(arg.data)[0]->fc_ = arg.fctx;
 #endif
-  try {
-    (*context)();
-    context->Context::stop();
-  } catch (ForcefulKillException const&) {
-    XBT_DEBUG("Caught a ForcefulKillException");
-  } catch (simgrid::Exception const& e) {
-    XBT_INFO("Actor killed by an uncaught exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
-    throw;
-  }
-  ASAN_ONLY(context->asan_stop_ = true);
-  context->suspend();
+  smx_ctx_wrapper(context);
 }
 
-void BoostContext::swap_into(SwappedContext* to_)
+void BoostContext::swap_into_for_real(SwappedContext* to_)
 {
   BoostContext* to = static_cast<BoostContext*>(to_);
-#if BOOST_VERSION < 105600
-  boost::context::jump_fcontext(this->fc_, to->fc_, reinterpret_cast<intptr_t>(to));
-#elif BOOST_VERSION < 106100
+#if BOOST_VERSION < 106100
   boost::context::jump_fcontext(&this->fc_, to->fc_, reinterpret_cast<intptr_t>(to));
 #else
   BoostContext* ctx[2] = {this, to};
-  ASAN_ONLY(void* fake_stack = nullptr);
-  ASAN_ONLY(to->asan_ctx_ = this);
-  ASAN_START_SWITCH(this->asan_stop_ ? nullptr : &fake_stack, to->asan_stack_, to->asan_stack_size_);
   boost::context::detail::transfer_t arg = boost::context::detail::jump_fcontext(to->fc_, ctx);
-  ASAN_ONLY(xbt_assert(this->asan_ctx_ == static_cast<BoostContext**>(arg.data)[0]));
-  ASAN_FINISH_SWITCH(fake_stack, &this->asan_ctx_->asan_stack_, &this->asan_ctx_->asan_stack_size_);
+  this->verify_previous_context(static_cast<BoostContext**>(arg.data)[0]);
   static_cast<BoostContext**>(arg.data)[0]->fc_ = arg.fctx;
 #endif
 }
index dafcedd..8284fc9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -33,15 +33,9 @@ namespace context {
 class BoostContext : public SwappedContext {
 public:
   BoostContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory);
-  ~BoostContext() override;
-
-  void swap_into(SwappedContext* to) override;
 
 private:
-#if BOOST_VERSION < 105600
-  boost::context::fcontext_t* fc_ = nullptr;
-  typedef intptr_t arg_type;
-#elif BOOST_VERSION < 106100
+#if BOOST_VERSION < 106100
   boost::context::fcontext_t fc_;
   typedef intptr_t arg_type;
 #else
@@ -49,7 +43,9 @@ private:
   typedef boost::context::detail::transfer_t arg_type;
 #endif
 
-  static void wrapper(arg_type arg);
+  XBT_ATTRIB_NORETURN static void wrapper(arg_type arg);
+
+  void swap_into_for_real(SwappedContext* to) override;
 };
 
 class BoostContextFactory : public SwappedContextFactory {
index d493cae..47fe3f0 100644 (file)
@@ -1,10 +1,9 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "ContextRaw.hpp"
-#include "context_private.hpp"
 #include "mc/mc.h"
 #include "simgrid/Exception.hpp"
 #include "src/simix/smx_private.hpp"
@@ -13,11 +12,11 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_context);
 
 // Raw context routines
 
-typedef void (*rawctx_entry_point_t)(simgrid::kernel::context::RawContext*);
+typedef void (*rawctx_entry_point_t)(simgrid::kernel::context::SwappedContext*);
 
 typedef void* raw_stack_t;
 extern "C" raw_stack_t raw_makecontext(void* malloced_stack, int stack_size, rawctx_entry_point_t entry_point,
-                                       simgrid::kernel::context::RawContext* arg);
+                                       simgrid::kernel::context::SwappedContext* arg);
 extern "C" void raw_swapcontext(raw_stack_t* old, raw_stack_t new_context);
 
 // TODO, we should handle FP, MMX and the x87 control-word (for x86 and x86_64)
@@ -168,7 +167,7 @@ __asm__ (
    update the definition of HAVE_RAW_CONTEXTS in tools/cmake/CompleteInFiles.cmake */
 
 raw_stack_t raw_makecontext(void* malloced_stack, int stack_size, rawctx_entry_point_t entry_point,
-                            simgrid::kernel::context::RawContext* arg)
+                            simgrid::kernel::context::SwappedContext* arg)
 {
   THROW_UNIMPLEMENTED;
 }
@@ -199,37 +198,17 @@ RawContext::RawContext(std::function<void()>&& code, actor::ActorImpl* actor, Sw
     : SwappedContext(std::move(code), actor, factory)
 {
    if (has_code()) {
-     this->stack_top_ = raw_makecontext(get_stack(), smx_context_stack_size, RawContext::wrapper, this);
+     this->stack_top_ = raw_makecontext(get_stack(), smx_context_stack_size, smx_ctx_wrapper, this);
    } else {
      if (MC_is_active())
        MC_ignore_heap(&stack_top_, sizeof(stack_top_));
    }
 }
 
-void RawContext::wrapper(RawContext* context)
+void RawContext::swap_into_for_real(SwappedContext* to_)
 {
-  ASAN_FINISH_SWITCH(nullptr, &context->asan_ctx_->asan_stack_, &context->asan_ctx_->asan_stack_size_);
-  try {
-    (*context)();
-    context->Context::stop();
-  } catch (ForcefulKillException const&) {
-    XBT_DEBUG("Caught a ForcefulKillException");
-  } catch (simgrid::Exception const& e) {
-    XBT_INFO("Actor killed by an uncaught exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
-    throw;
-  }
-  ASAN_ONLY(context->asan_stop_ = true);
-  context->suspend();
-}
-
-void RawContext::swap_into(SwappedContext* to_)
-{
-  RawContext* to = static_cast<RawContext*>(to_);
-  ASAN_ONLY(void* fake_stack = nullptr);
-  ASAN_ONLY(to->asan_ctx_ = this);
-  ASAN_START_SWITCH(this->asan_stop_ ? nullptr : &fake_stack, to->asan_stack_, to->asan_stack_size_);
+  const RawContext* to = static_cast<RawContext*>(to_);
   raw_swapcontext(&this->stack_top_, to->stack_top_);
-  ASAN_FINISH_SWITCH(fake_stack, &this->asan_ctx_->asan_stack_, &this->asan_ctx_->asan_stack_size_);
 }
 
 ContextFactory* raw_factory()
index af36f10..f9b30e0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -28,13 +28,11 @@ class RawContext : public SwappedContext {
 public:
   RawContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory);
 
-  void swap_into(SwappedContext* to) override;
-
 private:
   /** pointer to top the stack stack */
   void* stack_top_ = nullptr;
 
-  static void wrapper(RawContext* context);
+  void swap_into_for_real(SwappedContext* to) override;
 };
 
 class RawContextFactory : public SwappedContextFactory {
index fbecf2b..afbaa91 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -7,7 +7,6 @@
 #include "simgrid/modelchecker.h"
 #include "src/internal_config.h"
 #include "src/kernel/actor/ActorImpl.hpp"
-#include "src/kernel/context/context_private.hpp"
 #include "src/simix/smx_private.hpp"
 #include "xbt/parmap.hpp"
 
 #if HAVE_VALGRIND_H
 #include <valgrind/valgrind.h>
 #endif
+#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
+#include <sanitizer/asan_interface.h>
+#endif
+#if HAVE_SANITIZER_THREAD_FIBER_SUPPORT
+#include <sanitizer/tsan_interface.h>
+#endif
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_context);
 
+// The name of this function is currently hardcoded in MC (as string).
+// Do not change it without fixing those references as well.
+void smx_ctx_wrapper(simgrid::kernel::context::SwappedContext* context)
+{
+#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
+  __sanitizer_finish_switch_fiber(nullptr, &context->asan_ctx_->asan_stack_, &context->asan_ctx_->asan_stack_size_);
+#endif
+  try {
+    (*context)();
+    context->Context::stop();
+  } catch (simgrid::ForcefulKillException const&) {
+    XBT_DEBUG("Caught a ForcefulKillException");
+  } catch (simgrid::Exception const& e) {
+    XBT_INFO("Actor killed by an uncaught exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
+    throw;
+  }
+#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
+  context->asan_stop_ = true;
+#endif
+  context->suspend();
+  THROW_IMPOSSIBLE;
+}
+
 namespace simgrid {
 namespace kernel {
 namespace context {
@@ -38,23 +66,17 @@ namespace context {
 /* thread-specific storage for the worker's context */
 thread_local SwappedContext* SwappedContext::worker_context_ = nullptr;
 
-SwappedContextFactory::SwappedContextFactory() : ContextFactory(), parallel_(SIMIX_context_is_parallel())
-{
-  parmap_ = nullptr; // will be created lazily with the right parameters if needed (ie, in parallel)
-}
-
 SwappedContext::SwappedContext(std::function<void()>&& code, smx_actor_t actor, SwappedContextFactory* factory)
-    : Context(std::move(code), actor), factory_(factory)
+    : Context(std::move(code), actor), factory_(*factory)
 {
   // Save maestro (=context created first) in preparation for run_all
-  if (not factory->parallel_ && factory->maestro_context_ == nullptr)
-    factory->maestro_context_ = this;
+  if (not SIMIX_context_is_parallel() && factory_.maestro_context_ == nullptr)
+    factory_.maestro_context_ = this;
 
   if (has_code()) {
     xbt_assert((smx_context_stack_size & 0xf) == 0, "smx_context_stack_size should be multiple of 16");
     if (smx_context_guard_size > 0 && not MC_is_active()) {
-
-#if !defined(PTH_STACKGROWTH) || (PTH_STACKGROWTH != -1)
+#if PTH_STACKGROWTH != -1
       xbt_die(
           "Stack overflow protection is known to be broken on your system: you stacks grow upwards (or detection is "
           "broken). "
@@ -97,14 +119,20 @@ SwappedContext::SwappedContext(std::function<void()>&& code, smx_actor_t actor,
       this->stack_ = static_cast<unsigned char*>(xbt_malloc0(smx_context_stack_size));
     }
 
-#if PTH_STACKGROWTH == -1
-    ASAN_ONLY(this->asan_stack_ = this->stack_ + smx_context_stack_size);
-#else
-    ASAN_ONLY(this->asan_stack_ = this->stack_);
-#endif
 #if HAVE_VALGRIND_H
     if (RUNNING_ON_VALGRIND)
       this->valgrind_stack_id_ = VALGRIND_STACK_REGISTER(this->stack_, this->stack_ + smx_context_stack_size);
+#endif
+#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
+    this->asan_stack_ = get_stack_bottom();
+#endif
+#if HAVE_SANITIZER_THREAD_FIBER_SUPPORT
+    this->tsan_fiber_ = __tsan_create_fiber(0);
+#endif
+  } else {
+    // not has_code(): in maestro context
+#if HAVE_SANITIZER_THREAD_FIBER_SUPPORT
+    this->tsan_fiber_ = __tsan_get_current_fiber();
 #endif
   }
 }
@@ -114,6 +142,9 @@ SwappedContext::~SwappedContext()
   if (stack_ == nullptr) // maestro has no extra stack
     return;
 
+#if HAVE_SANITIZER_THREAD_FIBER_SUPPORT
+  __tsan_destroy_fiber(tsan_fiber_);
+#endif
 #if HAVE_VALGRIND_H
   if (RUNNING_ON_VALGRIND)
     VALGRIND_STACK_DEREGISTER(valgrind_stack_id_);
@@ -136,11 +167,6 @@ SwappedContext::~SwappedContext()
   xbt_free(stack_);
 }
 
-unsigned char* SwappedContext::get_stack()
-{
-  return stack_;
-}
-
 void SwappedContext::stop()
 {
   Context::stop();
@@ -148,6 +174,24 @@ void SwappedContext::stop()
   throw ForcefulKillException();
 }
 
+void SwappedContext::swap_into(SwappedContext* to)
+{
+#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
+  void* fake_stack = nullptr;
+  to->asan_ctx_    = this;
+  __sanitizer_start_switch_fiber(this->asan_stop_ ? nullptr : &fake_stack, to->asan_stack_, to->asan_stack_size_);
+#endif
+#if HAVE_SANITIZER_THREAD_FIBER_SUPPORT
+  __tsan_switch_to_fiber(to->tsan_fiber_, 0);
+#endif
+
+  swap_into_for_real(to);
+
+#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
+  __sanitizer_finish_switch_fiber(fake_stack, &this->asan_ctx_->asan_stack_, &this->asan_ctx_->asan_stack_size_);
+#endif
+}
+
 /** Maestro wants to run all ready actors */
 void SwappedContextFactory::run_all()
 {
@@ -155,7 +199,7 @@ void SwappedContextFactory::run_all()
    * stuff It is much easier to understand what happens if you see the working threads as bodies that swap their soul
    * for the ones of the simulated processes that must run.
    */
-  if (parallel_) {
+  if (SIMIX_context_is_parallel()) {
     // We lazily create the parmap so that all options are actually processed when doing so.
     if (parmap_ == nullptr)
       parmap_.reset(
@@ -168,7 +212,7 @@ void SwappedContextFactory::run_all()
     //     It only yields back to worker_context when the work array is exhausted.
     //   - So, resume() is only launched from the parmap for the first job of each minion.
     parmap_->apply(
-        [](smx_actor_t process) {
+        [](const actor::ActorImpl* process) {
           SwappedContext* context = static_cast<SwappedContext*>(process->context_.get());
           context->resume();
         },
@@ -178,7 +222,7 @@ void SwappedContextFactory::run_all()
       return;
 
     /* maestro is already saved in the first slot of workers_context_ */
-    smx_actor_t first_actor = simix_global->actors_to_run.front();
+    const actor::ActorImpl* first_actor = simix_global->actors_to_run.front();
     process_index_          = 1;
     /* execute the first actor; it will chain to the others when using suspend() */
     static_cast<SwappedContext*>(first_actor->context_.get())->resume();
@@ -193,35 +237,32 @@ void SwappedContextFactory::run_all()
  */
 void SwappedContext::resume()
 {
-  if (factory_->parallel_) {
+  SwappedContext* old = static_cast<SwappedContext*>(self());
+  if (SIMIX_context_is_parallel()) {
     // Save my current soul (either maestro, or one of the minions) in a thread-specific area
-    worker_context_ = static_cast<SwappedContext*>(self());
-    // Switch my soul and the actor's one
-    Context::set_current(this);
-    worker_context_->swap_into(this);
-    // No body runs that soul anymore at this point, but it is stored in a safe place.
-    // When the executed actor will do a blocking action, ActorImpl::yield() will call suspend(), below.
-  } else { // sequential execution
-    SwappedContext* old = static_cast<SwappedContext*>(self());
-    Context::set_current(this);
-    old->swap_into(this);
+    worker_context_ = old;
   }
+  // Switch my soul and the actor's one
+  Context::set_current(this);
+  old->swap_into(this);
+  // No body runs that soul anymore at this point, but it is stored in a safe place.
+  // When the executed actor will do a blocking action, ActorImpl::yield() will call suspend(), below.
 }
 
 /** The actor wants to yield back to maestro, because it is blocked in a simcall (i.e., in ActorImpl::yield())
  *
  * Actually, it does not really yield back to maestro, but directly into the next executable actor.
  *
- * This makes the parmap::apply awkward (see ParallelUContext::run_all()) because it only apply regularly
+ * This makes the parmap::apply awkward (see SwappedContextFactory::run_all()) because it only apply regularly
  * on the few first elements of the array, but it saves a lot of context switches back to maestro,
  * and directly forth to the next executable actor.
  */
 void SwappedContext::suspend()
 {
-  if (factory_->parallel_) {
+  SwappedContext* next_context;
+  if (SIMIX_context_is_parallel()) {
     // Get some more work to directly swap into the next executable actor instead of yielding back to the parmap
-    boost::optional<smx_actor_t> next_work = factory_->parmap_->next();
-    SwappedContext* next_context;
+    boost::optional<smx_actor_t> next_work = factory_.parmap_->next();
     if (next_work) {
       // There is a next soul to embody (ie, another executable actor)
       XBT_DEBUG("Run next process");
@@ -233,16 +274,10 @@ void SwappedContext::suspend()
       next_context = worker_context_;
       // When given that soul, the body will wait for the next scheduling round
     }
-
-    // Get the next soul to run, either from another actor or the initial minion's one
-    Context::set_current(next_context);
-    this->swap_into(next_context);
-
   } else { // sequential execution
     /* determine the next context */
-    SwappedContext* next_context;
-    unsigned long int i = factory_->process_index_;
-    factory_->process_index_++;
+    unsigned long int i = factory_.process_index_;
+    factory_.process_index_++;
 
     if (i < simix_global->actors_to_run.size()) {
       /* Actually swap into the next actor directly without transiting to maestro */
@@ -251,11 +286,11 @@ void SwappedContext::suspend()
     } else {
       /* all processes were run, actually return to maestro */
       XBT_DEBUG("No more actors to run");
-      next_context = factory_->maestro_context_;
+      next_context = factory_.maestro_context_;
     }
-    Context::set_current(next_context);
-    this->swap_into(next_context);
   }
+  Context::set_current(next_context);
+  this->swap_into(next_context);
 }
 
 } // namespace context
index 25f22c2..1b815aa 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -6,6 +6,7 @@
 #ifndef SIMGRID_KERNEL_CONTEXT_SWAPPED_CONTEXT_HPP
 #define SIMGRID_KERNEL_CONTEXT_SWAPPED_CONTEXT_HPP
 
+#include "src/internal_config.h" // HAVE_SANITIZER_*
 #include "src/kernel/context/Context.hpp"
 
 #include <memory>
@@ -14,27 +15,37 @@ namespace simgrid {
 namespace kernel {
 namespace context {
 class SwappedContext;
+} // namespace context
+} // namespace kernel
+} // namespace simgrid
+
+/* Use extern "C" to make sure that this symbol is easy to recognize by name, even on exotic platforms */
+extern "C" XBT_ATTRIB_NORETURN void smx_ctx_wrapper(simgrid::kernel::context::SwappedContext* context);
+
+namespace simgrid {
+namespace kernel {
+namespace context {
 
 class SwappedContextFactory : public ContextFactory {
   friend SwappedContext; // Reads whether we are in parallel mode
 public:
-  SwappedContextFactory();
+  SwappedContextFactory()                             = default;
   SwappedContextFactory(const SwappedContextFactory&) = delete;
   SwappedContextFactory& operator=(const SwappedContextFactory&) = delete;
   void run_all() override;
 
 private:
-  bool parallel_;
-
   /* For the sequential execution */
   unsigned long process_index_     = 0;       // next actor to execute
   SwappedContext* maestro_context_ = nullptr; // save maestro's context
 
-  /* For the parallel execution */
-  std::unique_ptr<simgrid::xbt::Parmap<smx_actor_t>> parmap_;
+  /* For the parallel execution, will be created lazily with the right parameters if needed (ie, in parallel) */
+  std::unique_ptr<simgrid::xbt::Parmap<smx_actor_t>> parmap_{nullptr};
 };
 
 class SwappedContext : public Context {
+  friend void ::smx_ctx_wrapper(simgrid::kernel::context::SwappedContext*);
+
 public:
   SwappedContext(std::function<void()>&& code, smx_actor_t get_actor, SwappedContextFactory* factory);
   SwappedContext(const SwappedContext&) = delete;
@@ -43,29 +54,47 @@ public:
 
   void suspend() override;
   virtual void resume();
-  void stop() override;
+  XBT_ATTRIB_NORETURN void stop() override;
+
+  void swap_into(SwappedContext* to);
 
-  virtual void swap_into(SwappedContext* to) = 0; // Defined in Raw, Boost and UContext subclasses
+  unsigned char* get_stack() const { return stack_; }
+  // Return the address for the bottom of the stack.  Depending on the stack direction it may be the lower or higher
+  // address
+  unsigned char* get_stack_bottom() const { return PTH_STACKGROWTH == -1 ? stack_ + smx_context_stack_size : stack_; }
 
-  unsigned char* get_stack();
+protected:
+  // With ASan, after a context switch, check that the originating context is the expected one (see BoostContext)
+  void verify_previous_context(const SwappedContext* context) const;
 
+private:
   static thread_local SwappedContext* worker_context_;
 
+  unsigned char* stack_ = nullptr; // the thread stack
+  SwappedContextFactory& factory_; // for sequential and parallel run_all()
+
+#if HAVE_VALGRIND_H
+  unsigned int valgrind_stack_id_;
+#endif
 #if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
   const void* asan_stack_   = nullptr;
   size_t asan_stack_size_   = 0;
   SwappedContext* asan_ctx_ = nullptr;
   bool asan_stop_           = false;
 #endif
+#if HAVE_SANITIZER_THREAD_FIBER_SUPPORT
+  void* tsan_fiber_;
+#endif
 
-private:
-  unsigned char* stack_ = nullptr;       /* the thread stack */
-  SwappedContextFactory* const factory_; // for sequential and parallel run_all()
+  virtual void swap_into_for_real(SwappedContext* to) = 0; // Defined in Raw, Boost and UContext subclasses
+};
 
-#if HAVE_VALGRIND_H
-  unsigned int valgrind_stack_id_;
+inline void SwappedContext::verify_previous_context(XBT_ATTRIB_UNUSED const SwappedContext* context) const
+{
+#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
+  xbt_assert(this->asan_ctx_ == context);
 #endif
-};
+}
 
 } // namespace context
 } // namespace kernel
index 5f1f159..798b050 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -22,21 +22,21 @@ namespace context {
 
 // ThreadContextFactory
 
-ThreadContextFactory::ThreadContextFactory() : ContextFactory(), parallel_(SIMIX_context_is_parallel())
+ThreadContextFactory::ThreadContextFactory() : ContextFactory()
 {
-  if (parallel_)
+  if (SIMIX_context_is_parallel())
     ParallelThreadContext::initialize();
 }
 
 ThreadContextFactory::~ThreadContextFactory()
 {
-  if (parallel_)
+  if (SIMIX_context_is_parallel())
     ParallelThreadContext::finalize();
 }
 
 ThreadContext* ThreadContextFactory::create_context(std::function<void()>&& code, actor::ActorImpl* actor, bool maestro)
 {
-  if (parallel_)
+  if (SIMIX_context_is_parallel())
     return this->new_context<ParallelThreadContext>(std::move(code), actor, maestro);
   else
     return this->new_context<SerialThreadContext>(std::move(code), actor, maestro);
@@ -44,7 +44,7 @@ ThreadContext* ThreadContextFactory::create_context(std::function<void()>&& code
 
 void ThreadContextFactory::run_all()
 {
-  if (parallel_) {
+  if (SIMIX_context_is_parallel()) {
     // Parallel execution
     ParallelThreadContext::run_all();
   } else {
index 259aef0..a5e74f5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -24,7 +24,7 @@ public:
   ThreadContext(const ThreadContext&) = delete;
   ThreadContext& operator=(const ThreadContext&) = delete;
   ~ThreadContext() override;
-  void stop() override;
+  XBT_ATTRIB_NORETURN void stop() override;
   void suspend() override;
   void attach_start() override;
   void attach_stop() override;
@@ -103,8 +103,6 @@ public:
   }
 
 private:
-  bool parallel_;
-
   ThreadContext* create_context(std::function<void()>&& code, actor::ActorImpl* actor, bool maestro);
 };
 } // namespace context
index fba49bf..0b6f7a8 100644 (file)
@@ -1,12 +1,10 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* \file UContext.cpp Context switching with ucontexts from System V        */
 
-#include "context_private.hpp"
-
 #include "mc/mc.h"
 #include "simgrid/Exception.hpp"
 #include "src/kernel/actor/ActorImpl.hpp"
@@ -23,32 +21,16 @@ constexpr int CTX_ADDR_LEN = 2;
 static_assert(sizeof(simgrid::kernel::context::UContext*) <= CTX_ADDR_LEN * sizeof(int),
               "Ucontexts are not supported on this arch yet. Please increase CTX_ADDR_LEN.");
 
-/* Make sure that this symbol is easy to recognize by name, even on exotic platforms */
+// This function is called by makecontext(3): use extern "C" to have C language linkage for its type
 extern "C" {
-static void smx_ctx_wrapper(int i1, int i2);
-}
-
-// The name of this function is currently hardcoded in MC (as string).
-// Do not change it without fixing those references as well.
-static void smx_ctx_wrapper(int i1, int i2)
+XBT_ATTRIB_NORETURN static void sysv_ctx_wrapper(int i1, int i2)
 {
   // Rebuild the Context* pointer from the integers:
   int ctx_addr[CTX_ADDR_LEN] = {i1, i2};
   simgrid::kernel::context::UContext* context;
   memcpy(&context, ctx_addr, sizeof context);
-
-  ASAN_FINISH_SWITCH(nullptr, &context->asan_ctx_->asan_stack_, &context->asan_ctx_->asan_stack_size_);
-  try {
-    (*context)();
-    context->Context::stop();
-  } catch (simgrid::ForcefulKillException const&) {
-    XBT_DEBUG("Caught a ForcefulKillException");
-  } catch (simgrid::Exception const& e) {
-    XBT_INFO("Actor killed by an uncaught exception %s", simgrid::xbt::demangle(typeid(e).name()).get());
-    throw;
-  }
-  ASAN_ONLY(context->asan_stop_ = true);
-  context->suspend();
+  smx_ctx_wrapper(context);
+}
 }
 
 namespace simgrid {
@@ -79,7 +61,7 @@ UContext::UContext(std::function<void()>&& code, actor::ActorImpl* actor, Swappe
     int ctx_addr[CTX_ADDR_LEN]{};
     UContext* arg = this;
     memcpy(ctx_addr, &arg, sizeof this);
-    makecontext(&this->uc_, (void (*)())smx_ctx_wrapper, 2, ctx_addr[0], ctx_addr[1]);
+    makecontext(&this->uc_, (void (*)())sysv_ctx_wrapper, 2, ctx_addr[0], ctx_addr[1]);
 
 #if SIMGRID_HAVE_MC
     if (MC_is_active()) {
@@ -89,14 +71,10 @@ UContext::UContext(std::function<void()>&& code, actor::ActorImpl* actor, Swappe
   }
 }
 
-void UContext::swap_into(SwappedContext* to_)
+void UContext::swap_into_for_real(SwappedContext* to_)
 {
-  UContext* to = static_cast<UContext*>(to_);
-  ASAN_ONLY(void* fake_stack = nullptr);
-  ASAN_ONLY(to->asan_ctx_ = this);
-  ASAN_START_SWITCH(this->asan_stop_ ? nullptr : &fake_stack, to->asan_stack_, to->asan_stack_size_);
+  const UContext* to = static_cast<UContext*>(to_);
   swapcontext(&this->uc_, &to->uc_);
-  ASAN_FINISH_SWITCH(fake_stack, &this->asan_ctx_->asan_stack_, &this->asan_ctx_->asan_stack_size_);
 }
 
 
index d6db05b..c8a9ad2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -27,10 +27,10 @@ class UContext : public SwappedContext {
 public:
   UContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory);
 
-  void swap_into(SwappedContext* to) override;
-
 private:
   ucontext_t uc_;         /* the ucontext that executes the code */
+
+  void swap_into_for_real(SwappedContext* to) override;
 };
 
 class UContextFactory : public SwappedContextFactory {
diff --git a/src/kernel/context/context_private.hpp b/src/kernel/context/context_private.hpp
deleted file mode 100644 (file)
index 8a47f56..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#ifndef SIMGRID_KERNEL_CONTEXT_PRIVATE_HPP
-#define SIMGRID_KERNEL_CONTEXT_PRIVATE_HPP
-
-#include "src/internal_config.h"
-
-#if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
-#include <sanitizer/asan_interface.h>
-#define ASAN_ONLY(expr) expr
-#define ASAN_START_SWITCH(fake_stack_save, bottom, size) __sanitizer_start_switch_fiber(fake_stack_save, bottom, size)
-#define ASAN_FINISH_SWITCH(fake_stack_save, bottom_old, size_old)                                                      \
-  __sanitizer_finish_switch_fiber(fake_stack_save, bottom_old, size_old)
-#else
-#define ASAN_ONLY(expr) (void)0
-#define ASAN_START_SWITCH(fake_stack_save, bottom, size) (void)0
-#define ASAN_FINISH_SWITCH(fake_stack_save, bottom_old, size_old) (void)0
-#endif
-
-#endif
index 9681f07..53ce0bd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team.
+/* Copyright (c) 2016-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 1db0704..a95a011 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -67,7 +67,7 @@ void simgrid::kernel::lmm::FairBottleneck::bottleneck_solve()
       int nb = 0;
       XBT_DEBUG("Processing cnst %p ", &cnst);
       cnst.usage_ = 0.0;
-      for (Element& elem : cnst.enabled_element_set_) {
+      for (const Element& elem : cnst.enabled_element_set_) {
         xbt_assert(elem.variable->sharing_penalty_ > 0);
         if (elem.consumption_weight > 0 && elem.variable->saturated_variable_set_hook_.is_linked())
           nb++;
@@ -108,14 +108,14 @@ void simgrid::kernel::lmm::FairBottleneck::bottleneck_solve()
       Constraint& cnst = *iter;
       XBT_DEBUG("Updating cnst %p ", &cnst);
       if (cnst.sharing_policy_ != s4u::Link::SharingPolicy::FATPIPE) {
-        for (Element& elem : cnst.enabled_element_set_) {
+        for (const Element& elem : cnst.enabled_element_set_) {
           xbt_assert(elem.variable->sharing_penalty_ > 0);
           XBT_DEBUG("\tUpdate constraint %p (%g) with variable %p by %g", &cnst, cnst.remaining_, elem.variable,
                     elem.variable->mu_);
           double_update(&cnst.remaining_, elem.consumption_weight * elem.variable->mu_, sg_maxmin_precision);
         }
       } else {
-        for (Element& elem : cnst.enabled_element_set_) {
+        for (const Element& elem : cnst.enabled_element_set_) {
           xbt_assert(elem.variable->sharing_penalty_ > 0);
           XBT_DEBUG("\tNon-Shared variable. Update constraint usage of %p (%g) with variable %p by %g", &cnst,
                     cnst.usage_, elem.variable, elem.variable->mu_);
@@ -130,7 +130,7 @@ void simgrid::kernel::lmm::FairBottleneck::bottleneck_solve()
         XBT_DEBUG("\tGet rid of constraint %p", &cnst);
 
         iter = cnst_list.erase(iter);
-        for (Element& elem : cnst.enabled_element_set_) {
+        for (const Element& elem : cnst.enabled_element_set_) {
           if (elem.variable->sharing_penalty_ <= 0)
             break;
           if (elem.consumption_weight > 0 && elem.variable->saturated_variable_set_hook_.is_linked()) {
index 96cc184..f36f3ca 100644 (file)
@@ -1,10 +1,9 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/kernel/lmm/maxmin.hpp"
-#include "src/surf/surf_interface.hpp"
 #include "xbt/backtrace.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_maxmin, surf, "Logging specific to SURF (maxmin)");
@@ -88,9 +87,9 @@ void System::check_concurrency() const
       continue;
 
     const Element& elem    = var.cnsts_[0];
-    int belong_to_enabled  = elem.enabled_element_set_hook.is_linked();
-    int belong_to_disabled = elem.disabled_element_set_hook.is_linked();
-    int belong_to_active   = elem.active_element_set_hook.is_linked();
+    bool belong_to_enabled  = elem.enabled_element_set_hook.is_linked();
+    bool belong_to_disabled = elem.disabled_element_set_hook.is_linked();
+    bool belong_to_active   = elem.active_element_set_hook.is_linked();
 
     for (Element const& elem2 : var.cnsts_) {
       xbt_assert(belong_to_enabled == elem2.enabled_element_set_hook.is_linked(),
@@ -172,17 +171,6 @@ void System::cnst_free(Constraint* cnst)
 Constraint::Constraint(resource::Resource* id_value, double bound_value) : bound_(bound_value), id_(id_value)
 {
   rank_ = next_rank_++;
-
-  remaining_           = 0.0;
-  usage_               = 0.0;
-  concurrency_limit_   = sg_concurrency_limit;
-  concurrency_current_ = 0;
-  concurrency_maximum_ = 0;
-  sharing_policy_      = s4u::Link::SharingPolicy::SHARED;
-
-  lambda_     = 0.0;
-  new_lambda_ = 0.0;
-  cnst_light_ = nullptr;
 }
 
 Constraint* System::constraint_new(resource::Resource* id, double bound_value)
@@ -239,7 +227,7 @@ void System::expand(Constraint* cnst, Variable* var, double consumption_weight)
   // If it does, subtract it from the required slack
   int current_share = 0;
   if (var->concurrency_share_ > 1) {
-    for (Element& elem : var->cnsts_) {
+    for (const Element& elem : var->cnsts_) {
       if (elem.constraint == cnst && elem.enabled_element_set_hook.is_linked())
         current_share += elem.get_concurrency();
     }
@@ -408,13 +396,13 @@ static inline void saturated_constraints_update(double usage, int cnst_light_num
   }
 }
 
-static inline void saturated_variable_set_update(ConstraintLight* cnst_light_tab,
+static inline void saturated_variable_set_update(const ConstraintLight* cnst_light_tab,
                                                  const dyn_light_t& saturated_constraints, System* sys)
 {
   /* Add active variables (i.e. variables that need to be set) from the set of constraints to saturate
    * (cnst_light_tab)*/
   for (int const& saturated_cnst : saturated_constraints) {
-    ConstraintLight& cnst = cnst_light_tab[saturated_cnst];
+    const ConstraintLight& cnst = cnst_light_tab[saturated_cnst];
     for (Element const& elem : cnst.cnst->active_element_set_) {
       xbt_assert(elem.variable->sharing_penalty_ > 0); // All elements of active_element_set should be active
       if (elem.consumption_weight > 0 && not elem.variable->saturated_variable_set_hook_.is_linked())
@@ -619,7 +607,7 @@ template <class CnstList> void System::lmm_solve(CnstList& cnst_list)
           // Remember: non-shared constraints only require that max(elem.value * var.value) < cnst->bound
           cnst->usage_ = 0.0;
           elem.make_inactive();
-          for (Element& elem2 : cnst->enabled_element_set_) {
+          for (const Element& elem2 : cnst->enabled_element_set_) {
             xbt_assert(elem2.variable->sharing_penalty_ > 0);
             if (elem2.variable->value_ > 0)
               continue;
@@ -839,8 +827,8 @@ void System::update_variable_penalty(Variable* var, double penalty)
   if (penalty == var->sharing_penalty_)
     return;
 
-  int enabling_var  = (penalty > 0 && var->sharing_penalty_ <= 0);
-  int disabling_var = (penalty <= 0 && var->sharing_penalty_ > 0);
+  bool enabling_var  = (penalty > 0 && var->sharing_penalty_ <= 0);
+  bool disabling_var = (penalty <= 0 && var->sharing_penalty_ > 0);
 
   XBT_IN("(sys=%p, var=%p, penalty=%f)", this, var, penalty);
 
@@ -884,7 +872,7 @@ void System::update_constraint_bound(Constraint* cnst, double bound)
  *  A recursive algorithm to optimize the system recalculation selecting only constraints that have changed. Each
  *  constraint change is propagated to the list of constraints for each variable.
  */
-void System::update_modified_set_rec(Constraint* cnst)
+void System::update_modified_set_rec(const Constraint* cnst)
 {
   for (Element const& elem : cnst->enabled_element_set_) {
     Variable* var = elem.variable;
index 08627d5..d7de61e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -8,6 +8,7 @@
 
 #include "simgrid/kernel/resource/Action.hpp"
 #include "simgrid/s4u/Link.hpp"
+#include "src/surf/surf_interface.hpp"
 #include "xbt/asserts.h"
 #include "xbt/mallocator.h"
 
@@ -260,24 +261,24 @@ public:
   boost::intrusive::list<Element, boost::intrusive::member_hook<Element, boost::intrusive::list_member_hook<>,
                                                                 &Element::active_element_set_hook>>
       active_element_set_;
-  double remaining_;
-  double usage_;
+  double remaining_ = 0.0;
+  double usage_     = 0.0;
   double bound_;
   // TODO MARTIN Check maximum value across resources at the end of simulation and give a warning is more than e.g. 500
-  int concurrency_current_; /* The current concurrency */
-  int concurrency_maximum_; /* The maximum number of (enabled and disabled) variables associated to the constraint at
-                             * any given time (essentially for tracing)*/
+  int concurrency_current_ = 0; /* The current concurrency */
+  int concurrency_maximum_ = 0; /* The maximum number of (enabled and disabled) variables associated to the constraint
+                                 * at any given time (essentially for tracing)*/
 
-  s4u::Link::SharingPolicy sharing_policy_;
+  s4u::Link::SharingPolicy sharing_policy_ = s4u::Link::SharingPolicy::SHARED;
   int rank_; // Only used in debug messages to identify the constraint
-  double lambda_;
-  double new_lambda_;
-  ConstraintLight* cnst_light_;
+  double lambda_               = 0.0;
+  double new_lambda_           = 0.0;
+  ConstraintLight* cnst_light_ = nullptr;
 
 private:
   static int next_rank_;  // To give a separate rank_ to each constraint
-  int concurrency_limit_; /* The maximum number of variables that may be enabled at any time (stage variables if
-                           * necessary) */
+  int concurrency_limit_ = sg_concurrency_limit; /* The maximum number of variables that may be enabled at any time
+                                                  * (stage variables if necessary) */
   resource::Resource* id_;
 };
 
@@ -336,7 +337,7 @@ public:
   /** @brief Check if a variable can be enabled
    * Make sure to set staged_penalty before, if your intent is only to check concurrency
    */
-  int can_enable() const { return staged_penalty_ > 0 && get_min_concurrency_slack() >= concurrency_share_; }
+  bool can_enable() const { return staged_penalty_ > 0 && get_min_concurrency_slack() >= concurrency_share_; }
 
   /* hookup to system */
   boost::intrusive::list_member_hook<> variable_set_hook_;
@@ -438,7 +439,7 @@ public:
   /** @brief Update a constraint bound */
   void update_constraint_bound(Constraint * cnst, double bound);
 
-  int constraint_used(Constraint* cnst) { return cnst->active_constraint_set_hook_.is_linked(); }
+  int constraint_used(const Constraint* cnst) const { return cnst->active_constraint_set_hook_.is_linked(); }
 
   /** @brief Print the lmm system */
   void print() const;
@@ -504,8 +505,8 @@ private:
    */
   void update(Constraint * cnst, Variable * var, double value);
 
-  void update_modified_set(Constraint * cnst);
-  void update_modified_set_rec(Constraint * cnst);
+  void update_modified_set(Constraint* cnst);
+  void update_modified_set_rec(const Constraint* cnst);
 
   /** @brief Remove all constraints of the modified_constraint_set. */
   void remove_all_modified_set();
@@ -531,7 +532,6 @@ public:
   resource::Action::ModifiedSet* modified_set_ = nullptr;
 
 private:
-
   typedef std::vector<int> dyn_light_t;
   
   //Data used in lmm::solve
index 79fc3c0..bc26a8e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.               */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.               */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -71,7 +71,6 @@ TEST_CASE("kernel::lmm Single constraint shared systems", "[kernel-lmm-shared-si
 
   SECTION("Consumption weight + variable penalty")
   {
-
     /*
      * Resource proportionality between variable is kept while
      * varying consumption weight
@@ -101,7 +100,6 @@ TEST_CASE("kernel::lmm Single constraint shared systems", "[kernel-lmm-shared-si
 
   SECTION("Multiple constraints systems")
   {
-
     /*
      * Multiple constraint systems can be solved with shared variables
      *
@@ -151,7 +149,6 @@ TEST_CASE("kernel::lmm Single constraint unshared systems", "[kernel-lmm-unshare
 
   SECTION("Variable penalty")
   {
-
     /*
      * A variable with a penalty of two get half of the max_share
      *
@@ -181,7 +178,6 @@ TEST_CASE("kernel::lmm Single constraint unshared systems", "[kernel-lmm-unshare
 
   SECTION("Consumption weight")
   {
-
     /*
      * In a given constraint with all variable penalty to 1,
      * the max_share is affected only by the maximum consumption weight
@@ -212,7 +208,6 @@ TEST_CASE("kernel::lmm Single constraint unshared systems", "[kernel-lmm-unshare
 
   SECTION("Consumption weight + variable penalty")
   {
-
     /*
      * Resource proportionality between variable is kept but
      * constraint bound can be violated
@@ -243,7 +238,6 @@ TEST_CASE("kernel::lmm Single constraint unshared systems", "[kernel-lmm-unshare
 
   SECTION("Multiple constraints systems")
   {
-
     /*
      * Multiple constraint systems can be solved with shared variables
      * on unshared constraints.
index a74efb5..2111104 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -24,9 +24,9 @@ Action::Action(simgrid::kernel::resource::Model* model, double cost, bool failed
     : remains_(cost), start_time_(surf_get_clock()), cost_(cost), model_(model), variable_(var)
 {
   if (failed)
-    state_set_ = get_model()->get_failed_action_set();
+    state_set_ = model_->get_failed_action_set();
   else
-    state_set_ = get_model()->get_started_action_set();
+    state_set_ = model_->get_started_action_set();
 
   state_set_->push_back(*this);
 }
@@ -36,12 +36,12 @@ Action::~Action()
   if (state_set_hook_.is_linked())
     simgrid::xbt::intrusive_erase(*state_set_, *this);
   if (get_variable())
-    get_model()->get_maxmin_system()->variable_free(get_variable());
+    model_->get_maxmin_system()->variable_free(get_variable());
 
   /* remove from heap on need (ie, if selective update) */
-  get_model()->get_action_heap().remove(this);
+  model_->get_action_heap().remove(this);
   if (modified_set_hook_.is_linked())
-    simgrid::xbt::intrusive_erase(*get_model()->get_modified_set(), *this);
+    simgrid::xbt::intrusive_erase(*model_->get_modified_set(), *this);
 }
 
 void Action::finish(Action::State state)
@@ -102,10 +102,10 @@ void Action::set_bound(double bound)
 {
   XBT_IN("(%p,%g)", this, bound);
   if (variable_)
-    get_model()->get_maxmin_system()->update_variable_bound(variable_, bound);
+    model_->get_maxmin_system()->update_variable_bound(variable_, bound);
 
-  if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY && get_last_update() != surf_get_clock())
-    get_model()->get_action_heap().remove(this);
+  if (model_->is_update_lazy() && get_last_update() != surf_get_clock())
+    model_->get_action_heap().remove(this);
   XBT_OUT();
 }
 
@@ -117,28 +117,28 @@ void Action::ref()
 void Action::set_max_duration(double duration)
 {
   max_duration_ = duration;
-  if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) // remove action from the heap
-    get_model()->get_action_heap().remove(this);
+  if (model_->is_update_lazy()) // remove action from the heap
+    model_->get_action_heap().remove(this);
 }
 
 void Action::set_sharing_penalty(double sharing_penalty)
 {
   XBT_IN("(%p,%g)", this, sharing_penalty);
   sharing_penalty_ = sharing_penalty;
-  get_model()->get_maxmin_system()->update_variable_penalty(get_variable(), sharing_penalty);
+  model_->get_maxmin_system()->update_variable_penalty(get_variable(), sharing_penalty);
 
-  if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY)
-    get_model()->get_action_heap().remove(this);
+  if (model_->is_update_lazy())
+    model_->get_action_heap().remove(this);
   XBT_OUT();
 }
 
 void Action::cancel()
 {
   set_state(Action::State::FAILED);
-  if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) {
+  if (model_->is_update_lazy()) {
     if (modified_set_hook_.is_linked())
-      simgrid::xbt::intrusive_erase(*get_model()->get_modified_set(), *this);
-    get_model()->get_action_heap().remove(this);
+      xbt::intrusive_erase(*model_->get_modified_set(), *this);
+    model_->get_action_heap().remove(this);
   }
 }
 
@@ -156,10 +156,10 @@ void Action::suspend()
 {
   XBT_IN("(%p)", this);
   if (suspended_ != SuspendStates::SLEEPING) {
-    get_model()->get_maxmin_system()->update_variable_penalty(get_variable(), 0.0);
-    if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) {
-      get_model()->get_action_heap().remove(this);
-      if (state_set_ == get_model()->get_started_action_set() && sharing_penalty_ > 0) {
+    model_->get_maxmin_system()->update_variable_penalty(get_variable(), 0.0);
+    if (model_->is_update_lazy()) {
+      model_->get_action_heap().remove(this);
+      if (state_set_ == model_->get_started_action_set() && sharing_penalty_ > 0) {
         // If we have a lazy model, we need to update the remaining value accordingly
         update_remains_lazy(surf_get_clock());
       }
@@ -173,10 +173,10 @@ void Action::resume()
 {
   XBT_IN("(%p)", this);
   if (suspended_ != SuspendStates::SLEEPING) {
-    get_model()->get_maxmin_system()->update_variable_penalty(get_variable(), get_sharing_penalty());
+    model_->get_maxmin_system()->update_variable_penalty(get_variable(), get_sharing_penalty());
     suspended_ = SuspendStates::RUNNING;
-    if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY)
-      get_model()->get_action_heap().remove(this);
+    if (model_->is_update_lazy())
+      model_->get_action_heap().remove(this);
   }
   XBT_OUT();
 }
@@ -185,7 +185,7 @@ double Action::get_remains()
 {
   XBT_IN("(%p)", this);
   /* update remains before returning it */
-  if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) /* update remains before return it */
+  if (model_->is_update_lazy()) /* update remains before return it */
     update_remains_lazy(surf_get_clock());
   XBT_OUT();
   return remains_;
@@ -196,6 +196,7 @@ void Action::update_max_duration(double delta)
   if (max_duration_ != NO_MAX_DURATION)
     double_update(&max_duration_, delta, sg_surf_precision);
 }
+
 void Action::update_remains(double delta)
 {
   double_update(&remains_, delta, sg_maxmin_precision * sg_surf_precision);
@@ -210,11 +211,13 @@ double ActionHeap::top_date() const
 {
   return top().first;
 }
+
 void ActionHeap::insert(Action* action, double date, ActionHeap::Type type)
 {
   action->type_      = type;
   action->heap_hook_ = emplace(std::make_pair(date, action));
 }
+
 void ActionHeap::remove(Action* action)
 {
   action->type_ = ActionHeap::Type::unset;
@@ -223,6 +226,7 @@ void ActionHeap::remove(Action* action)
     action->heap_hook_ = boost::none;
   }
 }
+
 void ActionHeap::update(Action* action, double date, ActionHeap::Type type)
 {
   action->type_ = type;
@@ -232,6 +236,7 @@ void ActionHeap::update(Action* action, double date, ActionHeap::Type type)
     action->heap_hook_ = emplace(std::make_pair(date, action));
   }
 }
+
 Action* ActionHeap::pop()
 {
   Action* action = top().second;
index 18c7035..58efc3e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 9ce6640..d536e0e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -34,7 +34,7 @@ class DiskAction;
 /*********
  * Model *
  *********/
-class DiskModel : public kernel::resource::Model {
+class DiskModel : public Model {
 public:
   DiskModel();
   DiskModel(const DiskModel&) = delete;
@@ -74,7 +74,7 @@ public:
   void turn_on() override;
   void turn_off() override;
 
-  s4u::Host* get_host() { return host_; }
+  s4u::Host* get_host() const { return host_; }
   void set_host(s4u::Host* host) { host_ = host; }
 
   void destroy(); // Must be called instead of the destructor
index 4357714..640df1e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -13,7 +13,7 @@ namespace kernel {
 namespace resource {
 
 Model::Model(Model::UpdateAlgo algo) : update_algorithm_(algo) {}
-Model::~Model() = default;
+Model::~Model() = default; // Don't move this declaration to the header, or it will break external projects such as SimGrid-FMI
 
 Action::ModifiedSet* Model::get_modified_set() const
 {
@@ -46,7 +46,7 @@ double Model::next_occurring_event_lazy(double now)
   while (not maxmin_system_->modified_set_->empty()) {
     Action* action = &(maxmin_system_->modified_set_->front());
     maxmin_system_->modified_set_->pop_front();
-    bool max_duration_flag = false;
+    ActionHeap::Type action_type = ActionHeap::Type::normal;
 
     if (action->get_state_set() != &started_action_set_)
       continue;
@@ -74,7 +74,7 @@ double Model::next_occurring_event_lazy(double now)
         (min <= -1 || action->get_start_time() + action->get_max_duration() < min)) {
       // when the task will complete anyway because of the deadline if any
       min          = action->get_start_time() + action->get_max_duration();
-      max_duration_flag = true;
+      action_type  = ActionHeap::Type::max_duration;
     }
 
     XBT_DEBUG("Action(%p) corresponds to variable %d", action, action->get_variable()->rank_);
@@ -83,7 +83,7 @@ double Model::next_occurring_event_lazy(double now)
               action->get_start_time(), min, share, action->get_max_duration());
 
     if (min > -1) {
-      action_heap_.update(action, min, max_duration_flag ? ActionHeap::Type::max_duration : ActionHeap::Type::normal);
+      action_heap_.update(action, min, action_type);
       XBT_DEBUG("Insert at heap action(%p) min %f now %f", action, min, now);
     } else
       DIE_IMPOSSIBLE;
@@ -143,7 +143,7 @@ Action* Model::extract_action(Action::StateSet* list)
 {
   if (list->empty())
     return nullptr;
-  simgrid::kernel::resource::Action* res = &list->front();
+  Action* res = &list->front();
   list->pop_front();
   return res;
 }
index a8e7f5d..2264d3b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -13,8 +13,6 @@ namespace simgrid {
 namespace kernel {
 namespace resource {
 
-Resource::~Resource() = default;
-
 double Resource::get_load() const
 {
   return constraint_->get_usage();
index 62cb065..88fac59 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 23f10f0..6e5d32c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 576e92e..b948657 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 19937f4..f12265b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index a324d57..9137c32 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 482ee82..b6bdcfd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -117,7 +117,7 @@ Profile* Profile::from_file(const std::string& path)
   xbt_assert(not path.empty(), "Cannot parse a trace from an empty filename");
   xbt_assert(trace_list.find(path) == trace_list.end(), "Refusing to define trace %s twice", path.c_str());
 
-  std::ifstream* f = surf_ifsopen(path);
+  const std::ifstream* f = surf_ifsopen(path);
   xbt_assert(not f->fail(), "Cannot open file '%s' (path=%s)", path.c_str(), (boost::join(surf_path, ":")).c_str());
 
   std::stringstream buffer;
index 3c173db..5aa6058 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index c995ef8..c60517a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.               */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.               */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 96345af..860786e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -77,7 +77,7 @@ void ClusterZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg
   }
 }
 
-void ClusterZone::get_graph(xbt_graph_t graph, std::map<std::string, xbt_node_t>* nodes,
+void ClusterZone::get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t>* nodes,
                             std::map<std::string, xbt_edge_t>* edges)
 {
   xbt_assert(router_,
@@ -134,8 +134,8 @@ void ClusterZone::create_links_for_node(ClusterCreationArgs* cluster, int id, in
   link.policy    = cluster->sharing_policy;
   sg_platf_new_link(&link);
 
-  s4u::Link* linkUp;
-  s4u::Link* linkDown;
+  const s4u::Link* linkUp;
+  const s4u::Link* linkDown;
   if (link.policy == simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX) {
     linkUp   = s4u::Link::by_name(link_id + "_UP");
     linkDown = s4u::Link::by_name(link_id + "_DOWN");
index 1b6902f..b9d79f8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -32,19 +32,10 @@ DijkstraZone::DijkstraZone(NetZoneImpl* father, const std::string& name, resourc
 {
 }
 
-static void graph_node_data_free(void* n)
+void DijkstraZone::route_graph_delete(xbt_graph_t g)
 {
-  delete static_cast<simgrid::kernel::routing::GraphNodeData*>(n);
-}
-
-static void graph_edge_data_free(void* e)
-{
-  delete static_cast<simgrid::kernel::routing::RouteCreationArgs*>(e);
-}
-
-DijkstraZone::~DijkstraZone()
-{
-  xbt_graph_free_graph(route_graph_, &graph_node_data_free, &graph_edge_data_free, nullptr);
+  xbt_graph_free_graph(g, [](void* n) { delete static_cast<simgrid::kernel::routing::GraphNodeData*>(n); },
+                       [](void* e) { delete static_cast<simgrid::kernel::routing::RouteCreationArgs*>(e); }, nullptr);
 }
 
 void DijkstraZone::seal()
@@ -52,13 +43,9 @@ void DijkstraZone::seal()
   unsigned int cursor;
   xbt_node_t node = nullptr;
 
-  if (not route_graph_)
-    route_graph_ = xbt_graph_new_graph(1, nullptr);
-
   /* Add the loopback if needed */
   if (network_model_->loopback_ && hierarchy_ == RoutingMode::base) {
-
-    xbt_dynar_foreach (xbt_graph_get_nodes(route_graph_), cursor, node) {
+    xbt_dynar_foreach (xbt_graph_get_nodes(route_graph_.get()), cursor, node) {
       bool found = false;
       xbt_edge_t edge = nullptr;
       unsigned int cursor2;
@@ -72,13 +59,13 @@ void DijkstraZone::seal()
       if (not found) {
         RouteCreationArgs* route = new simgrid::kernel::routing::RouteCreationArgs();
         route->link_list.push_back(network_model_->loopback_);
-        xbt_graph_new_edge(route_graph_, node, node, route);
+        xbt_graph_new_edge(route_graph_.get(), node, node, route);
       }
     }
   }
 
   /* initialize graph indexes in nodes after graph has been built */
-  xbt_dynar_t nodes = xbt_graph_get_nodes(route_graph_);
+  const_xbt_dynar_t nodes = xbt_graph_get_nodes(route_graph_.get());
 
   xbt_dynar_foreach (nodes, cursor, node) {
     GraphNodeData* data = static_cast<GraphNodeData*>(xbt_graph_node_get_data(node));
@@ -88,7 +75,7 @@ void DijkstraZone::seal()
 
 xbt_node_t DijkstraZone::route_graph_new_node(int id)
 {
-  xbt_node_t node = xbt_graph_new_node(route_graph_, new GraphNodeData(id));
+  xbt_node_t node = xbt_graph_new_node(route_graph_.get(), new GraphNodeData(id));
   graph_node_map_.emplace(id, node);
 
   return node;
@@ -108,26 +95,25 @@ void DijkstraZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationAr
   int src_id = src->id();
   int dst_id = dst->id();
 
-  xbt_dynar_t nodes = xbt_graph_get_nodes(route_graph_);
+  const_xbt_dynar_t nodes = xbt_graph_get_nodes(route_graph_.get());
 
   /* Use the graph_node id mapping set to quickly find the nodes */
-  xbt_node_t src_elm = node_map_search(src_id);
-  xbt_node_t dst_elm = node_map_search(dst_id);
+  const s_xbt_node_t* src_elm = node_map_search(src_id);
+  const s_xbt_node_t* dst_elm = node_map_search(dst_id);
 
   int src_node_id = static_cast<GraphNodeData*>(xbt_graph_node_get_data(src_elm))->graph_id_;
   int dst_node_id = static_cast<GraphNodeData*>(xbt_graph_node_get_data(dst_elm))->graph_id_;
 
   /* if the src and dst are the same */
   if (src_node_id == dst_node_id) {
-
-    xbt_node_t node_s_v = xbt_dynar_get_as(nodes, src_node_id, xbt_node_t);
-    xbt_node_t node_e_v = xbt_dynar_get_as(nodes, dst_node_id, xbt_node_t);
-    xbt_edge_t edge     = xbt_graph_get_edge(route_graph_, node_s_v, node_e_v);
+    const s_xbt_node_t* node_s_v = xbt_dynar_get_as(nodes, src_node_id, xbt_node_t);
+    const s_xbt_node_t* node_e_v = xbt_dynar_get_as(nodes, dst_node_id, xbt_node_t);
+    const s_xbt_edge_t* edge     = xbt_graph_get_edge(route_graph_.get(), node_s_v, node_e_v);
 
     if (edge == nullptr)
       throw std::invalid_argument(xbt::string_printf("No route from '%s' to '%s'", src->get_cname(), dst->get_cname()));
 
-    RouteCreationArgs* e_route = static_cast<RouteCreationArgs*>(xbt_graph_edge_get_data(edge));
+    const RouteCreationArgs* e_route = static_cast<RouteCreationArgs*>(xbt_graph_edge_get_data(edge));
 
     for (auto const& link : e_route->link_list) {
       route->link_list.insert(route->link_list.begin(), link);
@@ -164,15 +150,15 @@ void DijkstraZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationAr
     while (not pqueue.empty()) {
       int v_id = pqueue.top().second;
       pqueue.pop();
-      xbt_node_t v_node = xbt_dynar_get_as(nodes, v_id, xbt_node_t);
+      const s_xbt_node_t* v_node = xbt_dynar_get_as(nodes, v_id, xbt_node_t);
       xbt_edge_t edge   = nullptr;
       unsigned int cursor;
 
       xbt_dynar_foreach (xbt_graph_node_get_outedges(v_node), cursor, edge) {
-        xbt_node_t u_node                  = xbt_graph_edge_get_target(edge);
-        GraphNodeData* data                = static_cast<GraphNodeData*>(xbt_graph_node_get_data(u_node));
+        const s_xbt_node_t* u_node           = xbt_graph_edge_get_target(edge);
+        const GraphNodeData* data            = static_cast<GraphNodeData*>(xbt_graph_node_get_data(u_node));
         int u_id                           = data->graph_id_;
-        RouteCreationArgs* tmp_e_route     = static_cast<RouteCreationArgs*>(xbt_graph_edge_get_data(edge));
+        const RouteCreationArgs* tmp_e_route = static_cast<RouteCreationArgs*>(xbt_graph_edge_get_data(edge));
         int cost_v_u                       = tmp_e_route->link_list.size(); /* count of links, old model assume 1 */
 
         if (cost_v_u + cost_arr[v_id] < cost_arr[u_id]) {
@@ -189,16 +175,16 @@ void DijkstraZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationAr
   NetPoint* first_gw = nullptr;
 
   for (int v = dst_node_id; v != src_node_id; v = pred_arr[v]) {
-    xbt_node_t node_pred_v = xbt_dynar_get_as(nodes, pred_arr[v], xbt_node_t);
-    xbt_node_t node_v      = xbt_dynar_get_as(nodes, v, xbt_node_t);
-    xbt_edge_t edge        = xbt_graph_get_edge(route_graph_, node_pred_v, node_v);
+    const s_xbt_node_t* node_pred_v = xbt_dynar_get_as(nodes, pred_arr[v], xbt_node_t);
+    const s_xbt_node_t* node_v      = xbt_dynar_get_as(nodes, v, xbt_node_t);
+    const s_xbt_edge_t* edge        = xbt_graph_get_edge(route_graph_.get(), node_pred_v, node_v);
 
     if (edge == nullptr)
       throw std::invalid_argument(xbt::string_printf("No route from '%s' to '%s'", src->get_cname(), dst->get_cname()));
 
-    RouteCreationArgs* e_route = static_cast<RouteCreationArgs*>(xbt_graph_edge_get_data(edge));
+    const RouteCreationArgs* e_route = static_cast<RouteCreationArgs*>(xbt_graph_edge_get_data(edge));
 
-    NetPoint* prev_gw_src = gw_src;
+    const NetPoint* prev_gw_src = gw_src;
     gw_src                = e_route->gw_src;
     NetPoint* gw_dst      = e_route->gw_dst;
 
@@ -241,16 +227,13 @@ void DijkstraZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, Net
 {
   add_route_check_params(src, dst, gw_src, gw_dst, link_list, symmetrical);
 
-  if (not route_graph_)
-    route_graph_ = xbt_graph_new_graph(1, nullptr);
-
   new_edge(src->id(), dst->id(), new_extended_route(hierarchy_, src, dst, gw_src, gw_dst, link_list, symmetrical, 1));
 
   if (symmetrical == true)
     new_edge(dst->id(), src->id(), new_extended_route(hierarchy_, dst, src, gw_dst, gw_src, link_list, symmetrical, 0));
 }
 
-void DijkstraZone::new_edge(int src_id, int dst_id, simgrid::kernel::routing::RouteCreationArgs* route)
+void DijkstraZone::new_edge(int src_id, int dst_id, RouteCreationArgs* route)
 {
   XBT_DEBUG("Create Route from '%d' to '%d'", src_id, dst_id);
 
@@ -264,7 +247,7 @@ void DijkstraZone::new_edge(int src_id, int dst_id, simgrid::kernel::routing::Ro
     dst = route_graph_new_node(dst_id);
 
   // Make sure that this graph edge was not already added to the graph
-  if (xbt_graph_get_edge(route_graph_, src, dst) != nullptr) {
+  if (xbt_graph_get_edge(route_graph_.get(), src, dst) != nullptr) {
     if (route->gw_dst == nullptr || route->gw_src == nullptr)
       throw std::invalid_argument(
           xbt::string_printf("Route from %s to %s already exists", route->src->get_cname(), route->dst->get_cname()));
@@ -275,8 +258,8 @@ void DijkstraZone::new_edge(int src_id, int dst_id, simgrid::kernel::routing::Ro
   }
 
   // Finally add it
-  xbt_graph_new_edge(route_graph_, src, dst, route);
-}
-}
+  xbt_graph_new_edge(route_graph_.get(), src, dst, route);
 }
-} // namespace
+} // namespace routing
+} // namespace kernel
+} // namespace simgrid
index d390e51..01d1da3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -280,7 +280,6 @@ void DragonflyZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationA
   }
 
   if (targetRouter != myRouter) {
-
     // are we on a different group ?
     if (targetRouter->group_ != currentRouter->group_) {
       // go to the router of our group connected to this one.
index 0c4407a..4cd4d11 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -22,7 +22,7 @@ EmptyZone::EmptyZone(NetZoneImpl* father, const std::string& name, resource::Net
 
 EmptyZone::~EmptyZone() = default;
 
-void EmptyZone::get_graph(xbt_graph_t /*graph*/, std::map<std::string, xbt_node_t>* /*nodes*/,
+void EmptyZone::get_graph(const s_xbt_graph_t* /*graph*/, std::map<std::string, xbt_node_t>* /*nodes*/,
                           std::map<std::string, xbt_edge_t>* /*edges*/)
 {
   XBT_ERROR("No routing no graph");
index 8a551ea..46d7449 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -61,7 +61,6 @@ bool FatTreeZone::is_in_sub_tree(FatTreeNode* root, FatTreeNode* node)
 
 void FatTreeZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency)
 {
-
   if (dst->is_router() || src->is_router())
     return;
 
@@ -439,7 +438,7 @@ void FatTreeZone::generate_dot_file(const std::string& filename) const
   file.close();
 }
 
-FatTreeNode::FatTreeNode(ClusterCreationArgs* cluster, int id, int level, int position)
+FatTreeNode::FatTreeNode(const ClusterCreationArgs* cluster, int id, int level, int position)
     : id(id), level(level), position(position)
 {
   LinkCreationArgs linkTemplate;
@@ -461,7 +460,7 @@ FatTreeNode::FatTreeNode(ClusterCreationArgs* cluster, int id, int level, int po
   }
 }
 
-FatTreeLink::FatTreeLink(ClusterCreationArgs* cluster, FatTreeNode* downNode, FatTreeNode* upNode)
+FatTreeLink::FatTreeLink(const ClusterCreationArgs* cluster, FatTreeNode* downNode, FatTreeNode* upNode)
     : up_node_(upNode), down_node_(downNode)
 {
   static int uniqueId = 0;
index c7bb065..bdae1de 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -26,9 +26,6 @@ namespace routing {
 FloydZone::FloydZone(NetZoneImpl* father, const std::string& name, resource::NetworkModel* netmodel)
     : RoutedZone(father, name, netmodel)
 {
-  predecessor_table_ = nullptr;
-  cost_table_        = nullptr;
-  link_table_        = nullptr;
 }
 
 FloydZone::~FloydZone()
@@ -70,7 +67,7 @@ void FloydZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs*
 
   NetPoint* prev_dst_gw = nullptr;
   while (not route_stack.empty()) {
-    RouteCreationArgs* e_route = route_stack.back();
+    const RouteCreationArgs* e_route = route_stack.back();
     route_stack.pop_back();
     if (hierarchy_ == RoutingMode::recursive && prev_dst_gw != nullptr &&
         prev_dst_gw->get_cname() != e_route->gw_src->get_cname()) {
index 779c949..7948547 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -59,7 +59,7 @@ void FullZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs*
   XBT_DEBUG("full getLocalRoute from %s[%u] to %s[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
 
   unsigned int table_size        = get_table_size();
-  RouteCreationArgs* e_route     = TO_ROUTE_FULL(src->id(), dst->id());
+  const RouteCreationArgs* e_route = TO_ROUTE_FULL(src->id(), dst->id());
 
   if (e_route != nullptr) {
     res->gw_src = e_route->gw_src;
index 434f943..6ff888d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -10,6 +10,9 @@
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route, surf, "Routing part of surf");
 
 namespace simgrid {
+
+template class xbt::Extendable<kernel::routing::NetPoint>;
+
 namespace kernel {
 namespace routing {
 
index 1fa9475..81a6383 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -18,18 +18,10 @@ namespace simgrid {
 namespace kernel {
 namespace routing {
 
-class BypassRoute {
-public:
-  explicit BypassRoute(NetPoint* gwSrc, NetPoint* gwDst) : gw_src(gwSrc), gw_dst(gwDst) {}
-  NetPoint* gw_src;
-  NetPoint* gw_dst;
-  std::vector<resource::LinkImpl*> links;
-};
-
 NetZoneImpl::NetZoneImpl(NetZoneImpl* father, const std::string& name, resource::NetworkModel* network_model)
-    : network_model_(network_model), piface_(this), father_(father), name_(name)
+    : piface_(this), father_(father), name_(name), network_model_(network_model)
 {
-  xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(get_name()),
+  xbt_assert(nullptr == s4u::Engine::get_instance()->netpoint_by_name_or_null(get_name()),
              "Refusing to create a second NetZone called '%s'.", get_cname());
 
   netpoint_ = new NetPoint(name_, NetPoint::Type::NetZone, father);
@@ -44,28 +36,9 @@ NetZoneImpl::~NetZoneImpl()
   for (auto const& kv : bypass_routes_)
     delete kv.second;
 
-  simgrid::s4u::Engine::get_instance()->netpoint_unregister(netpoint_);
-}
-const char* NetZoneImpl::get_cname() const
-{
-  return name_.c_str();
-}
-NetZoneImpl* NetZoneImpl::get_father()
-{
-  return father_;
-}
-void NetZoneImpl::seal()
-{
-  sealed_ = true;
-}
-/** @brief Returns the list of direct children (no grand-children)
- *
- * This returns the internal data, no copy. Don't mess with it.
- */
-std::vector<NetZoneImpl*>* NetZoneImpl::get_children()
-{
-  return &children_;
+  s4u::Engine::get_instance()->netpoint_unregister(netpoint_);
 }
+
 /** @brief Returns the list of the hosts found in this NetZone (not recursively)
  *
  * Only the hosts that are directly contained in this NetZone are retrieved,
@@ -75,7 +48,7 @@ std::vector<s4u::Host*> NetZoneImpl::get_all_hosts()
 {
   std::vector<s4u::Host*> res;
   for (auto const& card : get_vertices()) {
-    s4u::Host* host = simgrid::s4u::Host::by_name_or_null(card->get_name());
+    s4u::Host* host = s4u::Host::by_name_or_null(card->get_name());
     if (host != nullptr)
       res.push_back(host);
   }
@@ -85,17 +58,17 @@ int NetZoneImpl::get_host_count()
 {
   int count = 0;
   for (auto const& card : get_vertices()) {
-    s4u::Host* host = simgrid::s4u::Host::by_name_or_null(card->get_name());
+    const s4u::Host* host = s4u::Host::by_name_or_null(card->get_name());
     if (host != nullptr)
       count++;
   }
   return count;
 }
 
-simgrid::s4u::Host* NetZoneImpl::create_host(const std::string& name, const std::vector<double>& speed_per_pstate,
-                                             int coreAmount, const std::map<std::string, std::string>* props)
+s4u::Host* NetZoneImpl::create_host(const std::string& name, const std::vector<double>& speed_per_pstate,
+                                    int coreAmount, const std::map<std::string, std::string>* props)
 {
-  simgrid::s4u::Host* res = new simgrid::s4u::Host(name);
+  s4u::Host* res = new s4u::Host(name);
 
   if (hierarchy_ == RoutingMode::unset)
     hierarchy_ = RoutingMode::base;
@@ -107,19 +80,19 @@ simgrid::s4u::Host* NetZoneImpl::create_host(const std::string& name, const std:
   if (props != nullptr)
     res->set_properties(*props);
 
-  simgrid::s4u::Host::on_creation(*res); // notify the signal
+  s4u::Host::on_creation(*res); // notify the signal
 
   return res;
 }
 
-int NetZoneImpl::add_component(kernel::routing::NetPoint* elm)
+int NetZoneImpl::add_component(NetPoint* elm)
 {
   vertices_.push_back(elm);
   return vertices_.size() - 1; // The rank of the newly created object
 }
-void NetZoneImpl::add_route(kernel::routing::NetPoint* /*src*/, kernel::routing::NetPoint* /*dst*/,
-                            kernel::routing::NetPoint* /*gw_src*/, kernel::routing::NetPoint* /*gw_dst*/,
-                            std::vector<kernel::resource::LinkImpl*>& /*link_list*/, bool /*symmetrical*/)
+
+void NetZoneImpl::add_route(NetPoint* /*src*/, NetPoint* /*dst*/, NetPoint* /*gw_src*/, NetPoint* /*gw_dst*/,
+                            std::vector<resource::LinkImpl*>& /*link_list*/, bool /*symmetrical*/)
 {
   xbt_die("NetZone '%s' does not accept new routes (wrong class).", get_cname());
 }
@@ -145,7 +118,7 @@ void NetZoneImpl::add_bypass_route(NetPoint* src, NetPoint* dst, NetPoint* gw_sr
   }
 
   /* Build a copy that will be stored in the dict */
-  kernel::routing::BypassRoute* newRoute = new kernel::routing::BypassRoute(gw_src, gw_dst);
+  BypassRoute* newRoute = new BypassRoute(gw_src, gw_dst);
   for (auto const& link : link_list)
     newRoute->links.push_back(link);
 
@@ -218,8 +191,8 @@ static void find_common_ancestors(NetPoint* src, NetPoint* dst,
   /* engage the full recursive search */
 
   /* (1) find the path to root of src and dst*/
-  NetZoneImpl* src_as = src->get_englobing_zone();
-  NetZoneImpl* dst_as = dst->get_englobing_zone();
+  const NetZoneImpl* src_as = src->get_englobing_zone();
+  const NetZoneImpl* dst_as = dst->get_englobing_zone();
 
   xbt_assert(src_as, "Host %s must be in a netzone", src->get_cname());
   xbt_assert(dst_as, "Host %s must be in a netzone", dst->get_cname());
@@ -263,7 +236,7 @@ static void find_common_ancestors(NetPoint* src, NetPoint* dst,
 }
 
 /* PRECONDITION: this is the common ancestor of src and dst */
-bool NetZoneImpl::get_bypass_route(routing::NetPoint* src, routing::NetPoint* dst,
+bool NetZoneImpl::get_bypass_route(NetPoint* src, NetPoint* dst,
                                    /* OUT */ std::vector<resource::LinkImpl*>& links, double* latency)
 {
   // If never set a bypass route return nullptr without any further computations
@@ -273,7 +246,7 @@ bool NetZoneImpl::get_bypass_route(routing::NetPoint* src, routing::NetPoint* ds
   /* Base case, no recursion is needed */
   if (dst->get_englobing_zone() == this && src->get_englobing_zone() == this) {
     if (bypass_routes_.find({src, dst}) != bypass_routes_.end()) {
-      BypassRoute* bypassedRoute = bypass_routes_.at({src, dst});
+      const BypassRoute* bypassedRoute = bypass_routes_.at({src, dst});
       for (resource::LinkImpl* const& link : bypassedRoute->links) {
         links.push_back(link);
         if (latency)
@@ -316,7 +289,7 @@ bool NetZoneImpl::get_bypass_route(routing::NetPoint* src, routing::NetPoint* ds
   int max_index = std::max(max_index_src, max_index_dst);
 
   /* (3) Search for a bypass making the path up to the ancestor useless */
-  BypassRoute* bypassedRoute = nullptr;
+  const BypassRoute* bypassedRoute = nullptr;
   std::pair<kernel::routing::NetPoint*, kernel::routing::NetPoint*> key;
   for (int max = 0; max <= max_index; max++) {
     for (int i = 0; i < max; i++) {
@@ -414,6 +387,6 @@ void NetZoneImpl::get_global_route(NetPoint* src, NetPoint* dst,
   if (route.gw_dst != dst)
     get_global_route(route.gw_dst, dst, links, latency);
 }
-}
-}
-} // namespace
+} // namespace routing
+} // namespace kernel
+} // namespace simgrid
index 090085d..60fbeb0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -17,15 +17,14 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_routing_generic, surf_route, "Generic imple
 /* ***************************************************************** */
 /* *********************** GENERIC METHODS ************************* */
 
-static const char* instr_node_name(xbt_node_t node)
+static const char* instr_node_name(const s_xbt_node_t* node)
 {
-  void* data = xbt_graph_node_get_data(node);
+  const void* data = xbt_graph_node_get_data(node);
   return static_cast<const char*>(data);
 }
 
-xbt_node_t new_xbt_graph_node(xbt_graph_t graph, const char* name, std::map<std::string, xbt_node_t>* nodes)
+xbt_node_t new_xbt_graph_node(const s_xbt_graph_t* graph, const char* name, std::map<std::string, xbt_node_t>* nodes)
 {
-
   auto elm = nodes->find(name);
   if (elm == nodes->end()) {
     xbt_node_t ret = xbt_graph_new_node(graph, xbt_strdup(name));
@@ -35,7 +34,8 @@ xbt_node_t new_xbt_graph_node(xbt_graph_t graph, const char* name, std::map<std:
     return elm->second;
 }
 
-xbt_edge_t new_xbt_graph_edge(xbt_graph_t graph, xbt_node_t s, xbt_node_t d, std::map<std::string, xbt_edge_t>* edges)
+xbt_edge_t new_xbt_graph_edge(const s_xbt_graph_t* graph, xbt_node_t s, xbt_node_t d,
+                              std::map<std::string, xbt_edge_t>* edges)
 {
   const char* sn = instr_node_name(s);
   const char* dn = instr_node_name(d);
@@ -64,10 +64,10 @@ RoutedZone::RoutedZone(NetZoneImpl* father, const std::string& name, resource::N
 {
 }
 
-void RoutedZone::get_graph(xbt_graph_t graph, std::map<std::string, xbt_node_t>* nodes,
+void RoutedZone::get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t>* nodes,
                            std::map<std::string, xbt_edge_t>* edges)
 {
-  std::vector<kernel::routing::NetPoint*> vertices = get_vertices();
+  std::vector<NetPoint*> vertices = get_vertices();
 
   for (auto const& my_src : vertices) {
     for (auto const& my_dst : vertices) {
@@ -154,8 +154,8 @@ void RoutedZone::get_route_check_params(NetPoint* src, NetPoint* dst)
   xbt_assert(src, "Cannot find a route from nullptr to %s", dst->get_cname());
   xbt_assert(dst, "Cannot find a route from %s to nullptr", src->get_cname());
 
-  NetZoneImpl* src_as = src->get_englobing_zone();
-  NetZoneImpl* dst_as = dst->get_englobing_zone();
+  const NetZoneImpl* src_as = src->get_englobing_zone();
+  const NetZoneImpl* dst_as = dst->get_englobing_zone();
 
   xbt_assert(src_as == dst_as,
              "Internal error: %s@%s and %s@%s are not in the same netzone as expected. Please report that bug.",
@@ -167,7 +167,7 @@ void RoutedZone::get_route_check_params(NetPoint* src, NetPoint* dst)
              src->get_cname(), dst->get_cname(), src_as->get_cname(), dst_as->get_cname(), get_cname());
 }
 void RoutedZone::add_route_check_params(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
-                                        std::vector<resource::LinkImpl*>& link_list, bool symmetrical)
+                                        const std::vector<resource::LinkImpl*>& link_list, bool symmetrical)
 {
   const char* srcName = src->get_cname();
   const char* dstName = dst->get_cname();
@@ -203,8 +203,8 @@ void RoutedZone::add_route_check_params(NetPoint* src, NetPoint* dst, NetPoint*
                dstName, gw_dst->get_cname());
   }
 
-  simgrid::s4u::NetZone::on_route_creation(symmetrical, src, dst, gw_src, gw_dst, link_list);
-}
-}
-}
+  s4u::NetZone::on_route_creation(symmetrical, src, dst, gw_src, gw_dst, link_list);
 }
+} // namespace routing
+} // namespace kernel
+} // namespace simgrid
index 971fd4c..bca85bd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -83,7 +83,6 @@ void TorusZone::parse_specific_arguments(ClusterCreationArgs* cluster)
 
 void TorusZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat)
 {
-
   XBT_VERB("torus getLocalRoute from '%s'[%u] to '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
 
   if (dst->is_router() || src->is_router())
@@ -134,7 +133,6 @@ void TorusZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs*
       const unsigned cur_dim = dimensions_[j];
       // current_node/dim_product = position in current dimension
       if ((current_node / dim_product) % cur_dim != (dst->id() / dim_product) % cur_dim) {
-
         if ((targetCoords[j] > myCoords[j] &&
              targetCoords[j] <= myCoords[j] + cur_dim / 2) // Is the target node on the right, without the wrap-around?
             || (myCoords[j] > cur_dim / 2 &&
@@ -190,6 +188,6 @@ void TorusZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs*
   delete[] myCoords;
   delete[] targetCoords;
 }
-}
-}
-} // namespace
+} // namespace routing
+} // namespace kernel
+} // namespace simgrid
index 8b03725..be055b4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -18,8 +18,10 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_vivaldi, surf, "Routing part of surf"
 namespace simgrid {
 namespace kernel {
 namespace routing {
+
 namespace vivaldi {
-simgrid::xbt::Extension<NetPoint, Coords> Coords::EXTENSION_ID;
+
+xbt::Extension<NetPoint, Coords> Coords::EXTENSION_ID;
 
 Coords::Coords(NetPoint* netpoint, const std::string& coordStr)
 {
@@ -53,7 +55,7 @@ static inline double euclidean_dist_comp(int index, std::vector<double>* src, st
 
 static std::vector<double>* netpoint_get_coords(NetPoint* np)
 {
-  simgrid::kernel::routing::vivaldi::Coords* coords = np->extension<simgrid::kernel::routing::vivaldi::Coords>();
+  vivaldi::Coords* coords = np->extension<vivaldi::Coords>();
   xbt_assert(coords, "Please specify the Vivaldi coordinates of %s %s (%p)",
              (np->is_netzone() ? "Netzone" : (np->is_host() ? "Host" : "Router")), np->get_cname(), np);
   return &coords->coords;
@@ -69,7 +71,7 @@ void VivaldiZone::set_peer_link(NetPoint* netpoint, double bw_in, double bw_out,
   xbt_assert(netpoint->get_englobing_zone() == this,
              "Cannot add a peer link to a netpoint that is not in this netzone");
 
-  new simgrid::kernel::routing::vivaldi::Coords(netpoint, coord);
+  new vivaldi::Coords(netpoint, coord);
 
   std::string link_up      = "link_" + netpoint->get_name() + "_UP";
   std::string link_down    = "link_" + netpoint->get_name() + "_DOWN";
@@ -87,8 +89,8 @@ void VivaldiZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg
   if (src->is_netzone()) {
     std::string srcName = "router_" + src->get_name();
     std::string dstName = "router_" + dst->get_name();
-    route->gw_src       = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(srcName);
-    route->gw_dst       = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(dstName);
+    route->gw_src       = s4u::Engine::get_instance()->netpoint_by_name_or_null(srcName);
+    route->gw_dst       = s4u::Engine::get_instance()->netpoint_by_name_or_null(dstName);
   }
 
   /* Retrieve the private links */
@@ -129,6 +131,6 @@ void VivaldiZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg
     *lat += euclidean_dist / 1000.0; // From .ms to .s
   }
 }
-}
-}
-}
+} // namespace routing
+} // namespace kernel
+} // namespace simgrid
index d14040e..8701fa2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -19,10 +19,10 @@ namespace mc {
  *  integers are not allowed.
  */
 class ReadOptions {
-  std::uint32_t value_;
+  std::uint32_t value_ = 0;
   constexpr explicit ReadOptions(std::uint32_t value) : value_(value) {}
 public:
-  constexpr ReadOptions() : value_(0) {}
+  constexpr ReadOptions() {}
 
   explicit constexpr operator bool() const { return value_ != 0; }
   constexpr bool operator!() const { return value_ == 0; }
index eb12028..709aa72 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -32,17 +32,10 @@ using simgrid::mc::remote;
 namespace simgrid {
 namespace mc {
 
-ModelChecker::ModelChecker(std::unique_ptr<RemoteClient> process)
-    : base_(nullptr)
-    , socket_event_(nullptr)
-    , signal_event_(nullptr)
-    , page_store_(500)
-    , process_(std::move(process))
-{
-
-}
+ModelChecker::ModelChecker(std::unique_ptr<RemoteClient> process) : process_(std::move(process)) {}
 
-ModelChecker::~ModelChecker() {
+ModelChecker::~ModelChecker()
+{
   if (socket_event_ != nullptr)
     event_free(socket_event_);
   if (signal_event_ != nullptr)
@@ -116,7 +109,7 @@ void ModelChecker::shutdown()
 {
   XBT_DEBUG("Shuting down model-checker");
 
-  simgrid::mc::RemoteClient* process = &this->process();
+  RemoteClient* process = &this->process();
   if (process->running()) {
     XBT_DEBUG("Killing process");
     kill(process->pid(), SIGKILL);
@@ -124,11 +117,11 @@ void ModelChecker::shutdown()
   }
 }
 
-void ModelChecker::resume(simgrid::mc::RemoteClient& process)
+void ModelChecker::resume(RemoteClient& process)
 {
   int res = process.get_channel().send(MC_MESSAGE_CONTINUE);
   if (res)
-    throw simgrid::xbt::errno_error();
+    throw xbt::errno_error();
   process.clear_cache();
 }
 
@@ -146,8 +139,8 @@ static void MC_report_crash(int status)
   XBT_INFO("Counter-example execution trace:");
   for (auto const& s : mc_model_checker->getChecker()->get_textual_trace())
     XBT_INFO("  %s", s.c_str());
-  simgrid::mc::dumpRecordPath();
-  simgrid::mc::session->log_state();
+  dumpRecordPath();
+  session->log_state();
   if (xbt_log_no_loc) {
     XBT_INFO("Stack trace not displayed because you passed --log=no_loc");
   } else {
@@ -164,18 +157,17 @@ static void MC_report_assertion_error()
   XBT_INFO("Counter-example execution trace:");
   for (auto const& s : mc_model_checker->getChecker()->get_textual_trace())
     XBT_INFO("  %s", s.c_str());
-  simgrid::mc::dumpRecordPath();
-  simgrid::mc::session->log_state();
+  dumpRecordPath();
+  session->log_state();
 }
 
-bool ModelChecker::handle_message(char* buffer, ssize_t size)
+bool ModelChecker::handle_message(const char* buffer, ssize_t size)
 {
   s_mc_message_t base_message;
   xbt_assert(size >= (ssize_t)sizeof(base_message), "Broken message");
   memcpy(&base_message, buffer, sizeof(base_message));
 
   switch(base_message.type) {
-
   case MC_MESSAGE_IGNORE_HEAP:
     {
     s_mc_message_ignore_heap_t message;
@@ -226,13 +218,12 @@ bool ModelChecker::handle_message(char* buffer, ssize_t size)
     xbt_assert(not message.callback, "Support for client-side function proposition is not implemented.");
     XBT_DEBUG("Received symbol: %s", message.name);
 
-    if (simgrid::mc::property_automaton == nullptr)
-      simgrid::mc::property_automaton = xbt_automaton_new();
+    if (property_automaton == nullptr)
+      property_automaton = xbt_automaton_new();
 
-    simgrid::mc::RemoteClient* process  = &this->process();
-    simgrid::mc::RemotePtr<int> address = simgrid::mc::remote((int*)message.data);
-    simgrid::xbt::add_proposition(simgrid::mc::property_automaton, message.name,
-                                  [process, address]() { return process->read(address); });
+    RemoteClient* process  = &this->process();
+    RemotePtr<int> address = remote((int*)message.data);
+    xbt::add_proposition(property_automaton, message.name, [process, address]() { return process->read(address); });
 
     break;
     }
@@ -246,7 +237,6 @@ bool ModelChecker::handle_message(char* buffer, ssize_t size)
 
   default:
     xbt_die("Unexpected message from model-checked application");
-
   }
   return true;
 }
@@ -303,7 +293,6 @@ void ModelChecker::handle_waitpid()
     }
 
     if (pid == this->process().pid()) {
-
       // From PTRACE_O_TRACEEXIT:
 #ifdef __linux__
       if (status>>8 == (SIGTRAP | (PTRACE_EVENT_EXIT<<8))) {
@@ -379,5 +368,5 @@ bool ModelChecker::checkDeadlock()
   return message.value != 0;
 }
 
-}
-}
+} // namespace mc
+} // namespace simgrid
index d5016d3..50af859 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -21,14 +21,14 @@ namespace mc {
 /** State of the model-checker (global variables for the model checker)
  */
 class ModelChecker {
-  struct event_base *base_;
-  struct event* socket_event_;
-  struct event* signal_event_;
+  struct event_base* base_    = nullptr;
+  struct event* socket_event_ = nullptr;
+  struct event* signal_event_ = nullptr;
   /** String pool for host names */
   // TODO, use std::set with heterogeneous comparison lookup (C++14)?
   std::set<std::string> hostnames_;
   // This is the parent snapshot of the current state:
-  PageStore page_store_;
+  PageStore page_store_{500};
   std::unique_ptr<RemoteClient> process_;
   Checker* checker_ = nullptr;
 public:
@@ -65,7 +65,7 @@ public:
 
 private:
   void setup_ignore();
-  bool handle_message(char* buffer, ssize_t size);
+  bool handle_message(const char* buffer, ssize_t size);
   void handle_waitpid();
   void on_signal(int signo);
 
index 6d923e2..7a51253 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index ab21a05..06f12de 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index a0a2813..7c2e93f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team.
+/* Copyright (c) 2015-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 24e3c5c..e491e7c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2011-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -27,17 +27,15 @@ VisitedState::VisitedState(unsigned long state_number) : num(state_number)
   this->actors_count = mc_model_checker->process().actors().size();
 
   this->system_state = std::make_shared<simgrid::mc::Snapshot>(state_number);
-  this->original_num = -1;
 }
 
 void VisitedStates::prune()
 {
   while (states_.size() > (std::size_t)_sg_mc_max_visited_states) {
     XBT_DEBUG("Try to remove visited state (maximum number of stored states reached)");
-    auto min_element = boost::range::min_element(states_,
-      [](std::unique_ptr<simgrid::mc::VisitedState>& a, std::unique_ptr<simgrid::mc::VisitedState>& b) {
-        return a->num < b->num;
-      });
+    auto min_element = boost::range::min_element(
+        states_, [](const std::unique_ptr<simgrid::mc::VisitedState>& a,
+                    const std::unique_ptr<simgrid::mc::VisitedState>& b) { return a->num < b->num; });
     xbt_assert(min_element != states_.end());
     // and drop it:
     states_.erase(min_element);
@@ -51,7 +49,7 @@ VisitedStates::addVisitedState(unsigned long state_number, simgrid::mc::State* g
 {
   std::unique_ptr<simgrid::mc::VisitedState> new_state =
     std::unique_ptr<simgrid::mc::VisitedState>(new VisitedState(state_number));
-  graph_state->system_state = new_state->system_state;
+  graph_state->system_state_ = new_state->system_state;
   XBT_DEBUG("Snapshot %p of visited state %d (exploration stack state %d)", new_state->system_state.get(),
             new_state->num, graph_state->num_);
 
index ea116d9..f2eae0c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -21,7 +21,7 @@ public:
   std::size_t heap_bytes_used = 0;
   int actors_count            = 0;
   int num          = 0; // unique id of that state in the storage of all stored IDs
-  int original_num = 0; // num field of the VisitedState to which I was declared equal to (used for dot_output)
+  int original_num = -1; // num field of the VisitedState to which I was declared equal to (used for dot_output)
 
   explicit VisitedState(unsigned long state_number);
   ~VisitedState() = default;
index b34fbce..e03f5f2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team.
+/* Copyright (c) 2016-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -18,5 +18,5 @@ Checker::Checker(Session& s) : session_(&s)
   mc_model_checker->setChecker(this);
 }
 
-}
-}
+} // namespace mc
+} // namespace simgrid
index c71f17e..8527b76 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team.
+/* Copyright (c) 2016-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index bc2e642..070192e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -29,8 +29,8 @@ std::vector<std::vector<simgrid::mc::PatternCommunication*>> incomplete_communic
 
 /********** Static functions ***********/
 
-static e_mc_comm_pattern_difference_t compare_comm_pattern(simgrid::mc::PatternCommunication* comm1,
-                                                           simgrid::mc::PatternCommunication* comm2)
+static e_mc_comm_pattern_difference_t compare_comm_pattern(const simgrid::mc::PatternCommunication* comm1,
+                                                           const simgrid::mc::PatternCommunication* comm2)
 {
   if(comm1->type != comm2->type)
     return TYPE_DIFF;
@@ -50,7 +50,7 @@ static e_mc_comm_pattern_difference_t compare_comm_pattern(simgrid::mc::PatternC
 }
 
 static char* print_determinism_result(e_mc_comm_pattern_difference_t diff, int process,
-                                      simgrid::mc::PatternCommunication* comm, unsigned int cursor)
+                                      const simgrid::mc::PatternCommunication* comm, unsigned int cursor)
 {
   char* type;
   char* res;
@@ -96,7 +96,7 @@ static void update_comm_pattern(simgrid::mc::PatternCommunication* comm_pattern,
   // HACK, type punning
   simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
   mc_model_checker->process().read(temp_comm, comm_addr);
-  simgrid::kernel::activity::CommImpl* comm = temp_comm.get_buffer();
+  const simgrid::kernel::activity::CommImpl* comm = temp_comm.get_buffer();
 
   smx_actor_t src_proc   = mc_model_checker->process().resolve_actor(simgrid::mc::remote(comm->src_actor_.get()));
   smx_actor_t dst_proc   = mc_model_checker->process().resolve_actor(simgrid::mc::remote(comm->dst_actor_.get()));
@@ -116,15 +116,15 @@ static void update_comm_pattern(simgrid::mc::PatternCommunication* comm_pattern,
 namespace simgrid {
 namespace mc {
 
-void CommunicationDeterminismChecker::deterministic_comm_pattern(int process, simgrid::mc::PatternCommunication* comm,
+void CommunicationDeterminismChecker::deterministic_comm_pattern(int process, const PatternCommunication* comm,
                                                                  int backtracking)
 {
   if (not backtracking) {
-    simgrid::mc::PatternCommunicationList& list = initial_communications_pattern[process];
+    PatternCommunicationList& list      = initial_communications_pattern[process];
     e_mc_comm_pattern_difference_t diff = compare_comm_pattern(list.list[list.index_comm].get(), comm);
 
     if (diff != NONE_DIFF) {
-      if (comm->type == simgrid::mc::PatternCommunicationType::send) {
+      if (comm->type == PatternCommunicationType::send) {
         this->send_deterministic = 0;
         if (this->send_diff != nullptr)
           xbt_free(this->send_diff);
@@ -142,7 +142,7 @@ void CommunicationDeterminismChecker::deterministic_comm_pattern(int process, si
         XBT_INFO("%s", this->send_diff);
         xbt_free(this->send_diff);
         this->send_diff = nullptr;
-        simgrid::mc::session->log_state();
+        mc::session->log_state();
         mc_model_checker->exit(SIMGRID_MC_EXIT_NON_DETERMINISM);
       } else if (_sg_mc_comms_determinism && (not this->send_deterministic && not this->recv_deterministic)) {
         XBT_INFO("****************************************************");
@@ -158,7 +158,7 @@ void CommunicationDeterminismChecker::deterministic_comm_pattern(int process, si
           xbt_free(this->recv_diff);
           this->recv_diff = nullptr;
         }
-        simgrid::mc::session->log_state();
+        mc::session->log_state();
         mc_model_checker->exit(SIMGRID_MC_EXIT_NON_DETERMINISM);
       }
     }
@@ -171,35 +171,32 @@ void CommunicationDeterminismChecker::get_comm_pattern(smx_simcall_t request, e_
                                                        int backtracking)
 {
   const smx_actor_t issuer = MC_smx_simcall_get_issuer(request);
-  const simgrid::mc::PatternCommunicationList& initial_pattern = initial_communications_pattern[issuer->get_pid()];
-  const std::vector<simgrid::mc::PatternCommunication*>& incomplete_pattern =
-      incomplete_communications_pattern[issuer->get_pid()];
+  const mc::PatternCommunicationList& initial_pattern          = initial_communications_pattern[issuer->get_pid()];
+  const std::vector<PatternCommunication*>& incomplete_pattern = incomplete_communications_pattern[issuer->get_pid()];
 
-  std::unique_ptr<simgrid::mc::PatternCommunication> pattern(new simgrid::mc::PatternCommunication());
+  std::unique_ptr<PatternCommunication> pattern(new PatternCommunication());
   pattern->index = initial_pattern.index_comm + incomplete_pattern.size();
 
   if (call_type == MC_CALL_TYPE_SEND) {
     /* Create comm pattern */
-    pattern->type = simgrid::mc::PatternCommunicationType::send;
-    pattern->comm_addr = static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_isend__getraw__result(request));
+    pattern->type      = PatternCommunicationType::send;
+    pattern->comm_addr = static_cast<kernel::activity::CommImpl*>(simcall_comm_isend__getraw__result(request));
 
-    simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_synchro;
+    Remote<kernel::activity::CommImpl> temp_synchro;
     mc_model_checker->process().read(temp_synchro,
-                                     remote(static_cast<simgrid::kernel::activity::CommImpl*>(pattern->comm_addr)));
-    simgrid::kernel::activity::CommImpl* synchro =
-        static_cast<simgrid::kernel::activity::CommImpl*>(temp_synchro.get_buffer());
+                                     remote(static_cast<kernel::activity::CommImpl*>(pattern->comm_addr)));
+    const kernel::activity::CommImpl* synchro = static_cast<kernel::activity::CommImpl*>(temp_synchro.get_buffer());
 
     char* remote_name = mc_model_checker->process().read<char*>(RemotePtr<char*>(
         (uint64_t)(synchro->get_mailbox() ? &synchro->get_mailbox()->name_ : &synchro->mbox_cpy->name_)));
     pattern->rdv      = mc_model_checker->process().read_string(RemotePtr<char>(remote_name));
-    pattern->src_proc =
-        mc_model_checker->process().resolve_actor(simgrid::mc::remote(synchro->src_actor_.get()))->get_pid();
+    pattern->src_proc = mc_model_checker->process().resolve_actor(mc::remote(synchro->src_actor_.get()))->get_pid();
     pattern->src_host = MC_smx_actor_get_host_name(issuer);
 
 #if HAVE_SMPI
     simgrid::smpi::Request mpi_request;
-    mc_model_checker->process().read(
-        &mpi_request, remote(static_cast<simgrid::smpi::Request*>(simcall_comm_isend__get__data(request))));
+    mc_model_checker->process().read(&mpi_request,
+                                     remote(static_cast<smpi::Request*>(simcall_comm_isend__get__data(request))));
     pattern->tag = mpi_request.tag();
 #endif
 
@@ -221,29 +218,26 @@ void CommunicationDeterminismChecker::get_comm_pattern(smx_simcall_t request, e_
     }
 #endif
   } else if (call_type == MC_CALL_TYPE_RECV) {
-    pattern->type = simgrid::mc::PatternCommunicationType::receive;
-    pattern->comm_addr = static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_irecv__getraw__result(request));
+    pattern->type      = PatternCommunicationType::receive;
+    pattern->comm_addr = static_cast<kernel::activity::CommImpl*>(simcall_comm_irecv__getraw__result(request));
 
 #if HAVE_SMPI
-    simgrid::smpi::Request mpi_request;
-    mc_model_checker->process().read(
-        &mpi_request, remote(static_cast<simgrid::smpi::Request*>(simcall_comm_irecv__get__data(request))));
+    smpi::Request mpi_request;
+    mc_model_checker->process().read(&mpi_request,
+                                     remote(static_cast<smpi::Request*>(simcall_comm_irecv__get__data(request))));
     pattern->tag = mpi_request.tag();
 #endif
 
-    simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
-    mc_model_checker->process().read(temp_comm,
-                                     remote(static_cast<simgrid::kernel::activity::CommImpl*>(pattern->comm_addr)));
-    simgrid::kernel::activity::CommImpl* comm = temp_comm.get_buffer();
+    Remote<kernel::activity::CommImpl> temp_comm;
+    mc_model_checker->process().read(temp_comm, remote(static_cast<kernel::activity::CommImpl*>(pattern->comm_addr)));
+    const kernel::activity::CommImpl* comm = temp_comm.get_buffer();
 
     char* remote_name;
-    mc_model_checker->process().read(&remote_name,
-                                     remote(comm->get_mailbox()
-                                                ? &simgrid::xbt::string::to_string_data(comm->get_mailbox()->name_).data
-                                                : &simgrid::xbt::string::to_string_data(comm->mbox_cpy->name_).data));
+    mc_model_checker->process().read(
+        &remote_name, remote(comm->get_mailbox() ? &xbt::string::to_string_data(comm->get_mailbox()->name_).data
+                                                 : &xbt::string::to_string_data(comm->mbox_cpy->name_).data));
     pattern->rdv      = mc_model_checker->process().read_string(RemotePtr<char>(remote_name));
-    pattern->dst_proc =
-        mc_model_checker->process().resolve_actor(simgrid::mc::remote(comm->dst_actor_.get()))->get_pid();
+    pattern->dst_proc = mc_model_checker->process().resolve_actor(mc::remote(comm->dst_actor_.get()))->get_pid();
     pattern->dst_host = MC_smx_actor_get_host_name(issuer);
   } else
     xbt_die("Unexpected call_type %i", (int) call_type);
@@ -252,19 +246,19 @@ void CommunicationDeterminismChecker::get_comm_pattern(smx_simcall_t request, e_
   incomplete_communications_pattern[issuer->get_pid()].push_back(pattern.release());
 }
 
-void CommunicationDeterminismChecker::complete_comm_pattern(
-    simgrid::mc::RemotePtr<simgrid::kernel::activity::CommImpl> comm_addr, unsigned int issuer, int backtracking)
+void CommunicationDeterminismChecker::complete_comm_pattern(RemotePtr<kernel::activity::CommImpl> comm_addr,
+                                                            unsigned int issuer, int backtracking)
 {
   /* Complete comm pattern */
-  std::vector<simgrid::mc::PatternCommunication*>& incomplete_pattern = incomplete_communications_pattern[issuer];
-  auto current_comm_pattern = std::find_if(
-      begin(incomplete_pattern), end(incomplete_pattern),
-      [&comm_addr](simgrid::mc::PatternCommunication* comm) { return remote(comm->comm_addr) == comm_addr; });
+  std::vector<PatternCommunication*>& incomplete_pattern = incomplete_communications_pattern[issuer];
+  auto current_comm_pattern =
+      std::find_if(begin(incomplete_pattern), end(incomplete_pattern),
+                   [&comm_addr](const PatternCommunication* comm) { return remote(comm->comm_addr) == comm_addr; });
   if (current_comm_pattern == std::end(incomplete_pattern))
     xbt_die("Corresponding communication not found!");
 
   update_comm_pattern(*current_comm_pattern, comm_addr);
-  std::unique_ptr<simgrid::mc::PatternCommunication> comm_pattern(*current_comm_pattern);
+  std::unique_ptr<PatternCommunication> comm_pattern(*current_comm_pattern);
   XBT_DEBUG("Remove incomplete comm pattern for process %u at cursor %zd", issuer,
             std::distance(begin(incomplete_pattern), current_comm_pattern));
   incomplete_pattern.erase(current_comm_pattern);
@@ -299,8 +293,7 @@ std::vector<std::string> CommunicationDeterminismChecker::get_textual_trace() //
   for (auto const& state : stack_) {
     smx_simcall_t req = &state->executed_req_;
     if (req)
-      trace.push_back(
-          simgrid::mc::request_to_string(req, state->transition_.argument_, simgrid::mc::RequestType::executed));
+      trace.push_back(request_to_string(req, state->transition_.argument_, RequestType::executed));
   }
   return trace;
 }
@@ -336,13 +329,13 @@ void CommunicationDeterminismChecker::prepare()
   initial_communications_pattern.resize(maxpid);
   incomplete_communications_pattern.resize(maxpid);
 
-  std::unique_ptr<simgrid::mc::State> initial_state(new simgrid::mc::State(++expanded_states_count_));
+  std::unique_ptr<State> initial_state(new State(++expanded_states_count_));
 
   XBT_DEBUG("********* Start communication determinism verification *********");
 
   /* Get an enabled actor and insert it in the interleave set of the initial state */
   for (auto& actor : mc_model_checker->process().actors())
-    if (simgrid::mc::actor_is_enabled(actor.copy.get_buffer()))
+    if (mc::actor_is_enabled(actor.copy.get_buffer()))
       initial_state->add_interleaving_set(actor.copy.get_buffer());
 
   stack_.push_back(std::move(initial_state));
@@ -362,15 +355,15 @@ static inline bool all_communications_are_finished()
 void CommunicationDeterminismChecker::restoreState()
 {
   /* Intermediate backtracking */
-  simgrid::mc::State* last_state = stack_.back().get();
-  if (last_state->system_state) {
-    last_state->system_state->restore(&mc_model_checker->process());
+  State* last_state = stack_.back().get();
+  if (last_state->system_state_) {
+    last_state->system_state_->restore(&mc_model_checker->process());
     MC_restore_communications_pattern(last_state);
     return;
   }
 
   /* Restore the initial state */
-  simgrid::mc::session->restore_initial_state();
+  mc::session->restore_initial_state();
 
   unsigned n = MC_smx_get_maxpid();
   assert(n == incomplete_communications_pattern.size());
@@ -386,7 +379,7 @@ void CommunicationDeterminismChecker::restoreState()
       break;
 
     int req_num             = state->transition_.argument_;
-    smx_simcall_t saved_req = &state->executed_req_;
+    const s_smx_simcall* saved_req = &state->executed_req_;
     xbt_assert(saved_req);
 
     /* because we got a copy of the executed request, we have to fetch the
@@ -409,12 +402,12 @@ void CommunicationDeterminismChecker::restoreState()
 
 void CommunicationDeterminismChecker::real_run()
 {
-  std::unique_ptr<simgrid::mc::VisitedState> visited_state = nullptr;
+  std::unique_ptr<VisitedState> visited_state = nullptr;
   smx_simcall_t req = nullptr;
 
   while (not stack_.empty()) {
     /* Get current state */
-    simgrid::mc::State* cur_state = stack_.back().get();
+    State* cur_state = stack_.back().get();
 
     XBT_DEBUG("**************************************************");
     XBT_DEBUG("Exploration depth = %zu (state = %d, interleaved processes = %zu)", stack_.size(), cur_state->num_,
@@ -429,14 +422,13 @@ void CommunicationDeterminismChecker::real_run()
       req = nullptr;
 
     if (req != nullptr && visited_state == nullptr) {
-
       int req_num = cur_state->transition_.argument_;
 
-      XBT_DEBUG("Execute: %s", simgrid::mc::request_to_string(req, req_num, simgrid::mc::RequestType::simix).c_str());
+      XBT_DEBUG("Execute: %s", request_to_string(req, req_num, RequestType::simix).c_str());
 
       std::string req_str;
       if (dot_output != nullptr)
-        req_str = simgrid::mc::request_get_dot_output(req, req_num);
+        req_str = request_get_dot_output(req, req_num);
 
       mc_model_checker->executed_transitions++;
 
@@ -455,7 +447,7 @@ void CommunicationDeterminismChecker::real_run()
       mc_model_checker->wait_for_requests();
 
       /* Create the new expanded state */
-      std::unique_ptr<simgrid::mc::State> next_state(new simgrid::mc::State(++expanded_states_count_));
+      std::unique_ptr<State> next_state(new State(++expanded_states_count_));
 
       /* If comm determinism verification, we cannot stop the exploration if some communications are not finished (at
        * least, data are transferred). These communications  are incomplete and they cannot be analyzed and compared
@@ -468,7 +460,6 @@ void CommunicationDeterminismChecker::real_run()
         visited_state = nullptr;
 
       if (visited_state == nullptr) {
-
         /* Get enabled actors and insert them in the interleave set of the next state */
         for (auto& actor : mc_model_checker->process().actors())
           if (simgrid::mc::actor_is_enabled(actor.copy.get_buffer()))
@@ -482,9 +473,7 @@ void CommunicationDeterminismChecker::real_run()
                 visited_state->original_num == -1 ? visited_state->num : visited_state->original_num, req_str.c_str());
 
       stack_.push_back(std::move(next_state));
-
     } else {
-
       if (stack_.size() > (std::size_t) _sg_mc_max_depth)
         XBT_WARN("/!\\ Max depth reached! /!\\ ");
       else if (visited_state != nullptr)
@@ -508,7 +497,7 @@ void CommunicationDeterminismChecker::real_run()
       }
 
       while (not stack_.empty()) {
-        std::unique_ptr<simgrid::mc::State> state(std::move(stack_.back()));
+        std::unique_ptr<State> state(std::move(stack_.back()));
         stack_.pop_back();
         if (state->interleave_size() && stack_.size() < (std::size_t)_sg_mc_max_depth) {
           /* We found a back-tracking point, let's loop */
@@ -527,13 +516,13 @@ void CommunicationDeterminismChecker::real_run()
     }
   }
 
-  simgrid::mc::session->log_state();
+  mc::session->log_state();
 }
 
 void CommunicationDeterminismChecker::run()
 {
   XBT_INFO("Check communication determinism");
-  simgrid::mc::session->initialize();
+  mc::session->initialize();
 
   this->prepare();
 
@@ -545,5 +534,5 @@ Checker* createCommunicationDeterminismChecker(Session& s)
   return new CommunicationDeterminismChecker(s);
 }
 
-}
-}
+} // namespace mc
+} // namespace simgrid
index c10d60f..a9d50e6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -28,7 +28,7 @@ private:
   void prepare();
   void real_run();
   void log_state() override;
-  void deterministic_comm_pattern(int process, simgrid::mc::PatternCommunication* comm, int backtracking);
+  void deterministic_comm_pattern(int process, const simgrid::mc::PatternCommunication* comm, int backtracking);
   void restoreState();
 public:
   // These are used by functions which should be moved in CommunicationDeterminismChecker:
index bbced3a..6a439c0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2011-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -23,14 +23,14 @@ namespace mc {
 
 VisitedPair::VisitedPair(int pair_num, xbt_automaton_state_t automaton_state,
                          std::shared_ptr<const std::vector<int>> atomic_propositions,
-                         std::shared_ptr<simgrid::mc::State> graph_state)
+                         std::shared_ptr<State> graph_state)
     : num(pair_num), automaton_state(automaton_state)
 {
-  simgrid::mc::RemoteClient* process = &(mc_model_checker->process());
+  RemoteClient* process = &(mc_model_checker->process());
 
   this->graph_state = std::move(graph_state);
-  if(this->graph_state->system_state == nullptr)
-    this->graph_state->system_state = std::make_shared<simgrid::mc::Snapshot>(pair_num);
+  if (this->graph_state->system_state_ == nullptr)
+    this->graph_state->system_state_ = std::make_shared<Snapshot>(pair_num);
   this->heap_bytes_used = mmalloc_get_bytes_used_remote(process->get_heap()->heaplimit, process->get_malloc_info());
 
   this->actors_count = mc_model_checker->process().actors().size();
@@ -39,7 +39,7 @@ VisitedPair::VisitedPair(int pair_num, xbt_automaton_state_t automaton_state,
   this->atomic_propositions = std::move(atomic_propositions);
 }
 
-static bool evaluate_label(xbt_automaton_exp_label_t l, std::vector<int> const& values)
+static bool evaluate_label(const xbt_automaton_exp_label* l, std::vector<int> const& values)
 {
   switch (l->type) {
   case xbt_automaton_exp_label::AUT_OR:
@@ -75,7 +75,7 @@ std::shared_ptr<const std::vector<int>> LivenessChecker::get_proposition_values(
   std::vector<int> values;
   unsigned int cursor = 0;
   xbt_automaton_propositional_symbol_t ps = nullptr;
-  xbt_dynar_foreach(simgrid::mc::property_automaton->propositional_symbols, cursor, ps)
+  xbt_dynar_foreach (mc::property_automaton->propositional_symbols, cursor, ps)
     values.push_back(xbt_automaton_propositional_symbol_evaluate(ps));
   return std::make_shared<const std::vector<int>>(std::move(values));
 }
@@ -86,14 +86,13 @@ std::shared_ptr<VisitedPair> LivenessChecker::insert_acceptance_pair(simgrid::mc
     pair->num, pair->automaton_state, pair->atomic_propositions,
     pair->graph_state);
 
-  auto res = boost::range::equal_range(acceptance_pairs_, new_pair.get(),
-                                       simgrid::mc::DerefAndCompareByActorsCountAndUsedHeap());
+  auto res = boost::range::equal_range(acceptance_pairs_, new_pair.get(), DerefAndCompareByActorsCountAndUsedHeap());
 
   if (pair->search_cycle) for (auto i = res.first; i != res.second; ++i) {
     std::shared_ptr<simgrid::mc::VisitedPair> const& pair_test = *i;
     if (xbt_automaton_state_compare(pair_test->automaton_state, new_pair->automaton_state) != 0 ||
         *(pair_test->atomic_propositions) != *(new_pair->atomic_propositions) ||
-        not snapshot_equal(pair_test->graph_state->system_state.get(), new_pair->graph_state->system_state.get()))
+        not snapshot_equal(pair_test->graph_state->system_state_.get(), new_pair->graph_state->system_state_.get()))
       continue;
     XBT_INFO("Pair %d already reached (equal to pair %d) !", new_pair->num, pair_test->num);
     exploration_stack_.pop_back();
@@ -122,15 +121,15 @@ void LivenessChecker::replay()
 
   /* Intermediate backtracking */
   if(_sg_mc_checkpoint > 0) {
-    simgrid::mc::Pair* pair = exploration_stack_.back().get();
-    if(pair->graph_state->system_state){
-      pair->graph_state->system_state->restore(&mc_model_checker->process());
+    const Pair* pair = exploration_stack_.back().get();
+    if (pair->graph_state->system_state_) {
+      pair->graph_state->system_state_->restore(&mc_model_checker->process());
       return;
     }
   }
 
   /* Restore the initial state */
-  simgrid::mc::session->restore_initial_state();
+  mc::session->restore_initial_state();
 
   /* Traverse the stack from the initial state and re-execute the transitions */
   int depth = 1;
@@ -141,9 +140,8 @@ void LivenessChecker::replay()
     std::shared_ptr<State> state = pair->graph_state;
 
     if (pair->exploration_started) {
-
       int req_num             = state->transition_.argument_;
-      smx_simcall_t saved_req = &state->executed_req_;
+      const s_smx_simcall* saved_req = &state->executed_req_;
 
       smx_simcall_t req = nullptr;
 
@@ -154,11 +152,8 @@ void LivenessChecker::replay()
         req = &issuer->simcall;
 
         /* Debug information */
-        XBT_DEBUG("Replay (depth = %d) : %s (%p)",
-          depth,
-          simgrid::mc::request_to_string(
-            req, req_num, simgrid::mc::RequestType::simix).c_str(),
-          state.get());
+        XBT_DEBUG("Replay (depth = %d) : %s (%p)", depth,
+                  request_to_string(req, req_num, simgrid::mc::RequestType::simix).c_str(), state.get());
       }
 
       this->get_session().execute(state->transition_);
@@ -169,9 +164,7 @@ void LivenessChecker::replay()
     mc_model_checker->executed_transitions++;
 
     depth++;
-
   }
-
   XBT_DEBUG("**** End Replay ****");
 }
 
@@ -187,14 +180,13 @@ int LivenessChecker::insert_visited_pair(std::shared_ptr<VisitedPair> visited_pa
     visited_pair =
         std::make_shared<VisitedPair>(pair->num, pair->automaton_state, pair->atomic_propositions, pair->graph_state);
 
-  auto range = boost::range::equal_range(visited_pairs_, visited_pair.get(),
-                                         simgrid::mc::DerefAndCompareByActorsCountAndUsedHeap());
+  auto range = boost::range::equal_range(visited_pairs_, visited_pair.get(), DerefAndCompareByActorsCountAndUsedHeap());
 
   for (auto i = range.first; i != range.second; ++i) {
-    VisitedPair* pair_test = i->get();
+    const VisitedPair* pair_test = i->get();
     if (xbt_automaton_state_compare(pair_test->automaton_state, visited_pair->automaton_state) != 0 ||
         *(pair_test->atomic_propositions) != *(visited_pair->atomic_propositions) ||
-        not snapshot_equal(pair_test->graph_state->system_state.get(), visited_pair->graph_state->system_state.get()))
+        not snapshot_equal(pair_test->graph_state->system_state_.get(), visited_pair->graph_state->system_state_.get()))
       continue;
     if (pair_test->other_num == -1)
       visited_pair->other_num = pair_test->num;
@@ -251,8 +243,8 @@ void LivenessChecker::show_acceptance_cycle(std::size_t depth)
   XBT_INFO("Counter-example that violates formula:");
   for (auto const& s : this->get_textual_trace())
     XBT_INFO("  %s", s.c_str());
-  simgrid::mc::dumpRecordPath();
-  simgrid::mc::session->log_state();
+  mc::dumpRecordPath();
+  mc::session->log_state();
   XBT_INFO("Counter-example depth: %zu", depth);
 }
 
@@ -263,19 +255,18 @@ std::vector<std::string> LivenessChecker::get_textual_trace() // override
     int req_num       = pair->graph_state->transition_.argument_;
     smx_simcall_t req = &pair->graph_state->executed_req_;
     if (req && req->call_ != SIMCALL_NONE)
-      trace.push_back(simgrid::mc::request_to_string(
-        req, req_num, simgrid::mc::RequestType::executed));
+      trace.push_back(request_to_string(req, req_num, RequestType::executed));
   }
   return trace;
 }
 
-std::shared_ptr<Pair> LivenessChecker::create_pair(Pair* current_pair, xbt_automaton_state_t state,
+std::shared_ptr<Pair> LivenessChecker::create_pair(const Pair* current_pair, xbt_automaton_state_t state,
                                                    std::shared_ptr<const std::vector<int>> propositions)
 {
   expanded_pairs_count_++;
   std::shared_ptr<Pair> next_pair = std::make_shared<Pair>(expanded_pairs_count_);
   next_pair->automaton_state      = state;
-  next_pair->graph_state = std::shared_ptr<simgrid::mc::State>(new simgrid::mc::State(++expanded_states_count_));
+  next_pair->graph_state          = std::shared_ptr<State>(new State(++expanded_states_count_));
   next_pair->atomic_propositions  = std::move(propositions);
   if (current_pair)
     next_pair->depth = current_pair->depth + 1;
@@ -283,7 +274,7 @@ std::shared_ptr<Pair> LivenessChecker::create_pair(Pair* current_pair, xbt_autom
     next_pair->depth = 1;
   /* Get enabled actors and insert them in the interleave set of the next graph_state */
   for (auto& actor : mc_model_checker->process().actors())
-    if (simgrid::mc::actor_is_enabled(actor.copy.get_buffer()))
+    if (mc::actor_is_enabled(actor.copy.get_buffer()))
       next_pair->graph_state->add_interleaving_set(actor.copy.get_buffer());
   next_pair->requests = next_pair->graph_state->interleave_size();
   /* FIXME : get search_cycle value for each accepting state */
@@ -322,7 +313,7 @@ void LivenessChecker::run()
   MC_automaton_load(_sg_mc_property_file.get().c_str());
 
   XBT_DEBUG("Starting the liveness algorithm");
-  simgrid::mc::session->initialize();
+  mc::session->initialize();
 
   /* Initialize */
   this->previous_pair_ = 0;
@@ -333,7 +324,7 @@ void LivenessChecker::run()
   // (application_state, automaton_state) pair to the exploration stack:
   unsigned int cursor = 0;
   xbt_automaton_state_t automaton_state;
-  xbt_dynar_foreach (simgrid::mc::property_automaton->states, cursor, automaton_state)
+  xbt_dynar_foreach (mc::property_automaton->states, cursor, automaton_state)
     if (automaton_state->type == -1)
       exploration_stack_.push_back(this->create_pair(nullptr, automaton_state, propos));
 
@@ -342,7 +333,7 @@ void LivenessChecker::run()
     std::shared_ptr<Pair> current_pair = exploration_stack_.back();
 
     /* Update current state in buchi automaton */
-    simgrid::mc::property_automaton->current_state = current_pair->automaton_state;
+    mc::property_automaton->current_state = current_pair->automaton_state;
 
     XBT_DEBUG(
         "********************* ( Depth = %d, search_cycle = %d, interleave size = %zu, pair_num = %d, requests = %d)",
@@ -359,7 +350,7 @@ void LivenessChecker::run()
       reached_pair = this->insert_acceptance_pair(current_pair.get());
       if (reached_pair == nullptr) {
         this->show_acceptance_cycle(current_pair->depth);
-        throw simgrid::mc::LivenessError();
+        throw LivenessError();
       }
     }
 
@@ -389,15 +380,13 @@ void LivenessChecker::run()
         this->previous_request_.clear();
       }
       this->previous_pair_    = current_pair->num;
-      this->previous_request_ = simgrid::mc::request_get_dot_output(req, req_num);
+      this->previous_request_ = request_get_dot_output(req, req_num);
       if (current_pair->search_cycle)
         fprintf(dot_output, "%d [shape=doublecircle];\n", current_pair->num);
       fflush(dot_output);
     }
 
-    XBT_DEBUG("Execute: %s",
-      simgrid::mc::request_to_string(
-        req, req_num, simgrid::mc::RequestType::simix).c_str());
+    XBT_DEBUG("Execute: %s", request_to_string(req, req_num, RequestType::simix).c_str());
 
     /* Update stats */
     mc_model_checker->executed_transitions++;
@@ -419,16 +408,15 @@ void LivenessChecker::run()
     // For each enabled transition in the property automaton, push a
     // (application_state, automaton_state) pair to the exploration stack:
     for (int i = xbt_dynar_length(current_pair->automaton_state->out) - 1; i >= 0; i--) {
-      xbt_automaton_transition_t transition_succ = (xbt_automaton_transition_t)xbt_dynar_get_as(
+      const xbt_automaton_transition* transition_succ = (xbt_automaton_transition_t)xbt_dynar_get_as(
           current_pair->automaton_state->out, i, xbt_automaton_transition_t);
       if (evaluate_label(transition_succ->label, *prop_values))
         exploration_stack_.push_back(this->create_pair(current_pair.get(), transition_succ->dst, prop_values));
      }
-
   }
 
   XBT_INFO("No property violation found.");
-  simgrid::mc::session->log_state();
+  mc::session->log_state();
 }
 
 Checker* createLivenessChecker(Session& s)
@@ -436,5 +424,5 @@ Checker* createLivenessChecker(Session& s)
   return new LivenessChecker(s);
 }
 
-}
-}
+} // namespace mc
+} // namespace simgrid
index 3867a9e..678e0ee 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -71,7 +71,7 @@ private:
   void remove_acceptance_pair(int pair_num);
   void purge_visited_pairs();
   void backtrack();
-  std::shared_ptr<Pair> create_pair(Pair* pair, xbt_automaton_state_t state,
+  std::shared_ptr<Pair> create_pair(const Pair* pair, xbt_automaton_state_t state,
                                     std::shared_ptr<const std::vector<int>> propositions);
 
   // A stack of (application_state, automaton_state) pairs for DFS exploration:
index c08ecaa..70cf398 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/xbt/mmalloc/mmprivate.h"
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_safety, mc,
-                                "Logging specific to MC safety verification ");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_safety, mc, "Logging specific to MC safety verification ");
+
 namespace simgrid {
 namespace mc {
 
-void SafetyChecker::check_non_termination(simgrid::mc::State* current_state)
+void SafetyChecker::check_non_termination(const State* current_state)
 {
   for (auto state = stack_.rbegin(); state != stack_.rend(); ++state)
-    if (snapshot_equal((*state)->system_state.get(), current_state->system_state.get())) {
+    if (snapshot_equal((*state)->system_state_.get(), current_state->system_state_.get())) {
       XBT_INFO("Non-progressive cycle: state %d -> state %d", (*state)->num_, current_state->num_);
       XBT_INFO("******************************************");
       XBT_INFO("*** NON-PROGRESSIVE CYCLE DETECTED ***");
@@ -42,10 +42,10 @@ void SafetyChecker::check_non_termination(simgrid::mc::State* current_state)
       XBT_INFO("Counter-example execution trace:");
       for (auto const& s : mc_model_checker->getChecker()->get_textual_trace())
         XBT_INFO("  %s", s.c_str());
-      simgrid::mc::dumpRecordPath();
-      simgrid::mc::session->log_state();
+      dumpRecordPath();
+      session->log_state();
 
-      throw simgrid::mc::TerminationError();
+      throw TerminationError();
     }
 }
 
@@ -64,8 +64,7 @@ std::vector<std::string> SafetyChecker::get_textual_trace() // override
     int value         = state->transition_.argument_;
     smx_simcall_t req = &state->executed_req_;
     if (req)
-      trace.push_back(simgrid::mc::request_to_string(
-        req, value, simgrid::mc::RequestType::executed));
+      trace.push_back(request_to_string(req, value, RequestType::executed));
   }
   return trace;
 }
@@ -84,9 +83,8 @@ void SafetyChecker::run()
    * This allows one to explore the call stack at will. */
 
   while (not stack_.empty()) {
-
     /* Get current state */
-    simgrid::mc::State* state = stack_.back().get();
+    State* state = stack_.back().get();
 
     XBT_DEBUG("**************************************************");
     XBT_VERB("Exploration depth=%zu (state=%p, num %d)(%zu interleave)", stack_.size(), state, state->num_,
@@ -125,13 +123,11 @@ void SafetyChecker::run()
 
     // If there are processes to interleave and the maximum depth has not been
     // reached then perform one step of the exploration algorithm.
-    XBT_DEBUG(
-        "Execute: %s",
-        simgrid::mc::request_to_string(req, state->transition_.argument_, simgrid::mc::RequestType::simix).c_str());
+    XBT_DEBUG("Execute: %s", request_to_string(req, state->transition_.argument_, RequestType::simix).c_str());
 
     std::string req_str;
     if (dot_output != nullptr)
-      req_str = simgrid::mc::request_get_dot_output(req, state->transition_.argument_);
+      req_str = request_get_dot_output(req, state->transition_.argument_);
 
     mc_model_checker->executed_transitions++;
 
@@ -139,8 +135,7 @@ void SafetyChecker::run()
     this->get_session().execute(state->transition_);
 
     /* Create the new expanded state (copy the state of MCed into our MCer data) */
-    std::unique_ptr<simgrid::mc::State> next_state =
-        std::unique_ptr<simgrid::mc::State>(new simgrid::mc::State(++expanded_states_count_));
+    std::unique_ptr<State> next_state = std::unique_ptr<State>(new State(++expanded_states_count_));
 
     if (_sg_mc_termination)
       this->check_non_termination(next_state.get());
@@ -151,13 +146,12 @@ void SafetyChecker::run()
 
     /* If this is a new state (or if we don't care about state-equality reduction) */
     if (visited_state_ == nullptr) {
-
       /* Get an enabled process and insert it in the interleave set of the next state */
       for (auto& remoteActor : mc_model_checker->process().actors()) {
         auto actor = remoteActor.copy.get_buffer();
-        if (simgrid::mc::actor_is_enabled(actor)) {
+        if (actor_is_enabled(actor)) {
           next_state->add_interleaving_set(actor);
-          if (reductionMode_ == simgrid::mc::ReductionMode::dpor)
+          if (reductionMode_ == ReductionMode::dpor)
             break; // With DPOR, we take the first enabled transition
         }
       }
@@ -174,7 +168,7 @@ void SafetyChecker::run()
   }
 
   XBT_INFO("No property violation found.");
-  simgrid::mc::session->log_state();
+  session->log_state();
 }
 
 void SafetyChecker::backtrack()
@@ -184,39 +178,35 @@ void SafetyChecker::backtrack()
   /* Check for deadlocks */
   if (mc_model_checker->checkDeadlock()) {
     MC_show_deadlock();
-    throw simgrid::mc::DeadlockError();
+    throw DeadlockError();
   }
 
-  /* Traverse the stack backwards until a state with a non empty interleave
-     set is found, deleting all the states that have it empty in the way.
-     For each deleted state, check if the request that has generated it
-     (from it's predecessor state), depends on any other previous request
-     executed before it. If it does then add it to the interleave set of the
-     state that executed that previous request. */
+  /* Traverse the stack backwards until a state with a non empty interleave set is found, deleting all the states that
+   *  have it empty in the way. For each deleted state, check if the request that has generated it (from its
+   *  predecessor state), depends on any other previous request executed before it. If it does then add it to the
+   *  interleave set of the state that executed that previous request. */
 
   while (not stack_.empty()) {
-    std::unique_ptr<simgrid::mc::State> state = std::move(stack_.back());
+    std::unique_ptr<State> state = std::move(stack_.back());
     stack_.pop_back();
-    if (reductionMode_ == simgrid::mc::ReductionMode::dpor) {
-      smx_simcall_t req = &state->internal_req;
+    if (reductionMode_ == ReductionMode::dpor) {
+      smx_simcall_t req = &state->internal_req_;
       if (req->call_ == SIMCALL_MUTEX_LOCK || req->call_ == SIMCALL_MUTEX_TRYLOCK)
         xbt_die("Mutex is currently not supported with DPOR,  use --cfg=model-check/reduction:none");
 
-      const smx_actor_t issuer = MC_smx_simcall_get_issuer(req);
+      const kernel::actor::ActorImpl* issuer = MC_smx_simcall_get_issuer(req);
       for (auto i = stack_.rbegin(); i != stack_.rend(); ++i) {
-        simgrid::mc::State* prev_state = i->get();
-        if (simgrid::mc::request_depend(req, &prev_state->internal_req)) {
+        State* prev_state = i->get();
+        if (request_depend(req, &prev_state->internal_req_)) {
           if (XBT_LOG_ISENABLED(mc_safety, xbt_log_priority_debug)) {
             XBT_DEBUG("Dependent Transitions:");
             int value              = prev_state->transition_.argument_;
             smx_simcall_t prev_req = &prev_state->executed_req_;
-            XBT_DEBUG("%s (state=%d)",
-                      simgrid::mc::request_to_string(prev_req, value, simgrid::mc::RequestType::internal).c_str(),
+            XBT_DEBUG("%s (state=%d)", simgrid::mc::request_to_string(prev_req, value, RequestType::internal).c_str(),
                       prev_state->num_);
             value    = state->transition_.argument_;
             prev_req = &state->executed_req_;
-            XBT_DEBUG("%s (state=%d)",
-                      simgrid::mc::request_to_string(prev_req, value, simgrid::mc::RequestType::executed).c_str(),
+            XBT_DEBUG("%s (state=%d)", simgrid::mc::request_to_string(prev_req, value, RequestType::executed).c_str(),
                       state->num_);
           }
 
@@ -224,21 +214,16 @@ void SafetyChecker::backtrack()
             prev_state->add_interleaving_set(issuer);
           else
             XBT_DEBUG("Process %p is in done set", req->issuer_);
-
           break;
-
-        } else if (req->issuer_ == prev_state->internal_req.issuer_) {
-
+        } else if (req->issuer_ == prev_state->internal_req_.issuer_) {
           XBT_DEBUG("Simcall %s and %s with same issuer", SIMIX_simcall_name(req->call_),
-                    SIMIX_simcall_name(prev_state->internal_req.call_));
+                    SIMIX_simcall_name(prev_state->internal_req_.call_));
           break;
-
         } else {
-
-          const smx_actor_t previous_issuer = MC_smx_simcall_get_issuer(&prev_state->internal_req);
+          const kernel::actor::ActorImpl* previous_issuer = MC_smx_simcall_get_issuer(&prev_state->internal_req_);
           XBT_DEBUG("Simcall %s, process %ld (state %d) and simcall %s, process %ld (state %d) are independent",
                     SIMIX_simcall_name(req->call_), issuer->get_pid(), state->num_,
-                    SIMIX_simcall_name(prev_state->internal_req.call_), previous_issuer->get_pid(), prev_state->num_);
+                    SIMIX_simcall_name(prev_state->internal_req_.call_), previous_issuer->get_pid(), prev_state->num_);
         }
       }
     }
@@ -259,17 +244,17 @@ void SafetyChecker::backtrack()
 void SafetyChecker::restore_state()
 {
   /* Intermediate backtracking */
-  simgrid::mc::State* last_state = stack_.back().get();
-  if (last_state->system_state) {
-    last_state->system_state->restore(&mc_model_checker->process());
+  const State* last_state = stack_.back().get();
+  if (last_state->system_state_) {
+    last_state->system_state_->restore(&mc_model_checker->process());
     return;
   }
 
   /* Restore the initial state */
-  simgrid::mc::session->restore_initial_state();
+  session->restore_initial_state();
 
   /* Traverse the stack from the state at position start and re-execute the transitions */
-  for (std::unique_ptr<simgrid::mc::State> const& state : stack_) {
+  for (std::unique_ptr<State> const& state : stack_) {
     if (state == stack_.back())
       break;
     session->execute(state->transition_);
@@ -281,33 +266,32 @@ void SafetyChecker::restore_state()
 
 SafetyChecker::SafetyChecker(Session& s) : Checker(s)
 {
-  reductionMode_ = simgrid::mc::reduction_mode;
+  reductionMode_ = reduction_mode;
   if (_sg_mc_termination)
-    reductionMode_ = simgrid::mc::ReductionMode::none;
-  else if (reductionMode_ == simgrid::mc::ReductionMode::unset)
-    reductionMode_ = simgrid::mc::ReductionMode::dpor;
+    reductionMode_ = ReductionMode::none;
+  else if (reductionMode_ == ReductionMode::unset)
+    reductionMode_ = ReductionMode::dpor;
 
   if (_sg_mc_termination)
     XBT_INFO("Check non progressive cycles");
   else
     XBT_INFO("Check a safety property. Reduction is: %s.",
-        (reductionMode_ == simgrid::mc::ReductionMode::none ? "none":
-            (reductionMode_ == simgrid::mc::ReductionMode::dpor ? "dpor": "unknown")));
-  simgrid::mc::session->initialize();
+             (reductionMode_ == ReductionMode::none ? "none"
+                                                    : (reductionMode_ == ReductionMode::dpor ? "dpor" : "unknown")));
+  session->initialize();
 
   XBT_DEBUG("Starting the safety algorithm");
 
-  std::unique_ptr<simgrid::mc::State> initial_state =
-      std::unique_ptr<simgrid::mc::State>(new simgrid::mc::State(++expanded_states_count_));
+  std::unique_ptr<State> initial_state = std::unique_ptr<State>(new State(++expanded_states_count_));
 
   XBT_DEBUG("**************************************************");
   XBT_DEBUG("Initial state");
 
   /* Get an enabled actor and insert it in the interleave set of the initial state */
   for (auto& actor : mc_model_checker->process().actors())
-    if (simgrid::mc::actor_is_enabled(actor.copy.get_buffer())) {
+    if (actor_is_enabled(actor.copy.get_buffer())) {
       initial_state->add_interleaving_set(actor.copy.get_buffer());
-      if (reductionMode_ != simgrid::mc::ReductionMode::none)
+      if (reductionMode_ != ReductionMode::none)
         break;
     }
 
@@ -319,5 +303,5 @@ Checker* createSafetyChecker(Session& s)
   return new SafetyChecker(s);
 }
 
-}
-}
+} // namespace mc
+} // namespace simgrid
index 1377934..ec6ba66 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team.
+/* Copyright (c) 2008-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@ public:
   void log_state() override;
 
 private:
-  void check_non_termination(simgrid::mc::State* current_state);
+  void check_non_termination(const State* current_state);
   void backtrack();
   void restore_state();
 
index f193ef1..35287d4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 228ceff..e94d23a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team.
+/* Copyright (c) 2015-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 4bf2cb2..c9a2579 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -55,12 +55,12 @@ public:
 
 class ProcessComparisonState {
 public:
-  const std::vector<simgrid::mc::IgnoredHeapRegion>* to_ignore = nullptr;
+  const std::vector<IgnoredHeapRegion>* to_ignore = nullptr;
   std::vector<HeapArea> equals_to;
-  std::vector<simgrid::mc::Type*> types;
+  std::vector<Type*> types;
   std::size_t heapsize = 0;
 
-  void initHeapInformation(xbt_mheap_t heap, const std::vector<simgrid::mc::IgnoredHeapRegion>& i);
+  void initHeapInformation(const s_xbt_mheap_t* heap, const std::vector<IgnoredHeapRegion>& i);
 };
 
 class StateComparator {
@@ -77,8 +77,8 @@ public:
     compared_pointers.clear();
   }
 
-  int initHeapInformation(xbt_mheap_t heap1, xbt_mheap_t heap2, const std::vector<simgrid::mc::IgnoredHeapRegion>& i1,
-                          const std::vector<simgrid::mc::IgnoredHeapRegion>& i2);
+  int initHeapInformation(const s_xbt_mheap_t* heap1, const s_xbt_mheap_t* heap2,
+                          const std::vector<IgnoredHeapRegion>& i1, const std::vector<IgnoredHeapRegion>& i2);
 
   template <int rank> HeapArea& equals_to_(std::size_t i, std::size_t j)
   {
@@ -123,11 +123,11 @@ public:
            this->equals_to_<2>(b2, f2).block_ == b1 && this->equals_to_<2>(b2, f2).fragment_ == f1;
   }
 
-  void match_equals(HeapLocationPairs* list);
+  void match_equals(const HeapLocationPairs* list);
 };
 
-}
-}
+} // namespace mc
+} // namespace simgrid
 
 /************************************************************************************/
 
@@ -171,20 +171,20 @@ static bool is_block_stack(int block)
 namespace simgrid {
 namespace mc {
 
-void StateComparator::match_equals(HeapLocationPairs* list)
+void StateComparator::match_equals(const HeapLocationPairs* list)
 {
   for (auto const& pair : *list) {
     if (pair[0].fragment_ != -1) {
-      this->equals_to_<1>(pair[0].block_, pair[0].fragment_) = simgrid::mc::HeapArea(pair[1].block_, pair[1].fragment_);
-      this->equals_to_<2>(pair[1].block_, pair[1].fragment_) = simgrid::mc::HeapArea(pair[0].block_, pair[0].fragment_);
+      this->equals_to_<1>(pair[0].block_, pair[0].fragment_) = HeapArea(pair[1].block_, pair[1].fragment_);
+      this->equals_to_<2>(pair[1].block_, pair[1].fragment_) = HeapArea(pair[0].block_, pair[0].fragment_);
     } else {
-      this->equals_to_<1>(pair[0].block_, 0) = simgrid::mc::HeapArea(pair[1].block_, pair[1].fragment_);
-      this->equals_to_<2>(pair[1].block_, 0) = simgrid::mc::HeapArea(pair[0].block_, pair[0].fragment_);
+      this->equals_to_<1>(pair[0].block_, 0) = HeapArea(pair[1].block_, pair[1].fragment_);
+      this->equals_to_<2>(pair[1].block_, 0) = HeapArea(pair[0].block_, pair[0].fragment_);
     }
   }
 }
 
-void ProcessComparisonState::initHeapInformation(xbt_mheap_t heap, const std::vector<simgrid::mc::IgnoredHeapRegion>& i)
+void ProcessComparisonState::initHeapInformation(const s_xbt_mheap_t* heap, const std::vector<IgnoredHeapRegion>& i)
 {
   auto heaplimit  = heap->heaplimit;
   this->heapsize  = heap->heapsize;
@@ -193,9 +193,9 @@ void ProcessComparisonState::initHeapInformation(xbt_mheap_t heap, const std::ve
   this->types.assign(heaplimit * MAX_FRAGMENT_PER_BLOCK, nullptr);
 }
 
-int StateComparator::initHeapInformation(xbt_mheap_t heap1, xbt_mheap_t heap2,
-                                         const std::vector<simgrid::mc::IgnoredHeapRegion>& i1,
-                                         const std::vector<simgrid::mc::IgnoredHeapRegion>& i2)
+int StateComparator::initHeapInformation(const s_xbt_mheap_t* heap1, const s_xbt_mheap_t* heap2,
+                                         const std::vector<IgnoredHeapRegion>& i1,
+                                         const std::vector<IgnoredHeapRegion>& i2)
 {
   if ((heap1->heaplimit != heap2->heaplimit) || (heap1->heapsize != heap2->heapsize))
     return -1;
@@ -210,7 +210,7 @@ int StateComparator::initHeapInformation(xbt_mheap_t heap1, xbt_mheap_t heap2,
 static inline Region* MC_get_heap_region(const Snapshot& snapshot)
 {
   for (auto const& region : snapshot.snapshot_regions_)
-    if (region->region_type() == simgrid::mc::RegionType::Heap)
+    if (region->region_type() == RegionType::Heap)
       return region.get();
   xbt_die("No heap region");
 }
@@ -218,10 +218,9 @@ static inline Region* MC_get_heap_region(const Snapshot& snapshot)
 static bool heap_area_differ(StateComparator& state, const void* area1, const void* area2, const Snapshot& snapshot1,
                              const Snapshot& snapshot2, HeapLocationPairs* previous, Type* type, int pointer_level);
 
-static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgrid::mc::Snapshot& snapshot1,
-                                const simgrid::mc::Snapshot& snapshot2)
+static bool mmalloc_heap_differ(StateComparator& state, const Snapshot& snapshot1, const Snapshot& snapshot2)
 {
-  const simgrid::mc::RemoteClient& process = mc_model_checker->process();
+  const RemoteClient& process = mc_model_checker->process();
 
   /* Check busy blocks */
   size_t i1 = 1;
@@ -230,8 +229,8 @@ static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgr
   malloc_info heapinfo_temp2;
   malloc_info heapinfo_temp2b;
 
-  simgrid::mc::Region* heap_region1 = MC_get_heap_region(snapshot1);
-  simgrid::mc::Region* heap_region2 = MC_get_heap_region(snapshot2);
+  const Region* heap_region1 = MC_get_heap_region(snapshot1);
+  const Region* heap_region2 = MC_get_heap_region(snapshot2);
 
   // This is the address of std_heap->heapinfo in the application process:
   void* heapinfo_address = &((xbt_mheap_t)process.heap_address)->heapinfo;
@@ -277,7 +276,7 @@ static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgr
 
       /* Try first to associate to same block in the other heap */
       if (heapinfo2->type == heapinfo1->type && state.equals_to_<2>(i1, 0).valid_ == 0) {
-        void* addr_block2 = (ADDR2UINT(i1) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
+        const void* addr_block2 = (ADDR2UINT(i1) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
         if (not heap_area_differ(state, addr_block1, addr_block2, snapshot1, snapshot2, nullptr, nullptr, 0)) {
           for (size_t k = 1; k < heapinfo2->busy_block.size; k++)
             state.equals_to_<2>(i1 + k, 0) = HeapArea(i1, -1);
@@ -289,7 +288,7 @@ static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgr
       }
 
       while (i2 < state.heaplimit && not equal) {
-        void* addr_block2 = (ADDR2UINT(i2) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
+        const void* addr_block2 = (ADDR2UINT(i2) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
 
         if (i2 == i1) {
           i2++;
@@ -317,7 +316,6 @@ static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgr
           equal = true;
           i1 += heapinfo1->busy_block.size;
         }
-
         i2++;
       }
 
@@ -325,11 +323,8 @@ static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgr
         XBT_DEBUG("Block %zu not found (size_used = %zu, addr = %p)", i1, heapinfo1->busy_block.busy_size, addr_block1);
         return true;
       }
-
-    } else {                    /* Fragmented block */
-
+    } else { /* Fragmented block */
       for (size_t j1 = 0; j1 < (size_t)(BLOCKSIZE >> heapinfo1->type); j1++) {
-
         if (heapinfo1->busy_frag.frag_size[j1] == -1) /* Free fragment_ */
           continue;
 
@@ -343,8 +338,8 @@ static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgr
 
         /* Try first to associate to same fragment_ in the other heap */
         if (heapinfo2->type == heapinfo1->type && not state.equals_to_<2>(i1, j1).valid_) {
-          void* addr_block2 = (ADDR2UINT(i1) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
-          void* addr_frag2  = (void*)((char*)addr_block2 + (j1 << heapinfo2->type));
+          const void* addr_block2 = (ADDR2UINT(i1) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
+          const void* addr_frag2  = (const char*)addr_block2 + (j1 << heapinfo2->type);
           if (not heap_area_differ(state, addr_frag1, addr_frag2, snapshot1, snapshot2, nullptr, nullptr, 0))
             equal = true;
         }
@@ -373,15 +368,14 @@ static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgr
             if (state.equals_to_<2>(i2, j2).valid_)
               continue;
 
-            void* addr_block2 = (ADDR2UINT(i2) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
-            void* addr_frag2  = (void*)((char*)addr_block2 + (j2 << heapinfo2b->type));
+            const void* addr_block2 = (ADDR2UINT(i2) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
+            const void* addr_frag2  = (const char*)addr_block2 + (j2 << heapinfo2b->type);
 
             if (not heap_area_differ(state, addr_frag1, addr_frag2, snapshot1, snapshot2, nullptr, nullptr, 0)) {
               equal = true;
               break;
             }
           }
-
           i2++;
         }
 
@@ -391,7 +385,6 @@ static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgr
           return true;
         }
       }
-
       i1++;
     }
   }
@@ -436,7 +429,6 @@ static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgr
         return true;
       }
   }
-
   return false;
 }
 
@@ -452,14 +444,13 @@ static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgr
  * @param check_ignore
  * @return true when different, false otherwise (same or unknown)
  */
-static bool heap_area_differ_without_type(simgrid::mc::StateComparator& state, const void* real_area1,
-                                          const void* real_area2, const simgrid::mc::Snapshot& snapshot1,
-                                          const simgrid::mc::Snapshot& snapshot2, HeapLocationPairs* previous, int size,
-                                          int check_ignore)
+static bool heap_area_differ_without_type(StateComparator& state, const void* real_area1, const void* real_area2,
+                                          const Snapshot& snapshot1, const Snapshot& snapshot2,
+                                          HeapLocationPairs* previous, int size, int check_ignore)
 {
-  const simgrid::mc::RemoteClient& process = mc_model_checker->process();
-  simgrid::mc::Region* heap_region1  = MC_get_heap_region(snapshot1);
-  simgrid::mc::Region* heap_region2  = MC_get_heap_region(snapshot2);
+  const RemoteClient& process = mc_model_checker->process();
+  const Region* heap_region1  = MC_get_heap_region(snapshot1);
+  const Region* heap_region2  = MC_get_heap_region(snapshot2);
 
   for (int i = 0; i < size; ) {
     if (check_ignore > 0) {
@@ -496,13 +487,10 @@ static bool heap_area_differ_without_type(simgrid::mc::StateComparator& state, c
         i = pointer_align + sizeof(void *);
         continue;
       }
-
       return true;
     }
-
     i++;
   }
-
   return false;
 }
 
@@ -520,10 +508,10 @@ static bool heap_area_differ_without_type(simgrid::mc::StateComparator& state, c
  * @param pointer_level
  * @return               true when different, false otherwise (same or unknown)
  */
-static bool heap_area_differ_with_type(simgrid::mc::StateComparator& state, const void* real_area1,
-                                       const void* real_area2, const simgrid::mc::Snapshot& snapshot1,
-                                       const simgrid::mc::Snapshot& snapshot2, HeapLocationPairs* previous,
-                                       simgrid::mc::Type* type, int area_size, int check_ignore, int pointer_level)
+static bool heap_area_differ_with_type(StateComparator& state, const void* real_area1, const void* real_area2,
+                                       const Snapshot& snapshot1, const Snapshot& snapshot2,
+                                       HeapLocationPairs* previous, const Type* type, int area_size, int check_ignore,
+                                       int pointer_level)
 {
   // HACK: This should not happen but in practice, there are some
   // DW_TAG_typedef without an associated DW_AT_type:
@@ -543,14 +531,14 @@ static bool heap_area_differ_with_type(simgrid::mc::StateComparator& state, cons
       return false;
   }
 
-  simgrid::mc::Type* subtype;
-  simgrid::mc::Type* subsubtype;
+  const Type* subtype;
+  const Type* subsubtype;
   int elm_size;
   const void* addr_pointed1;
   const void* addr_pointed2;
 
-  simgrid::mc::Region* heap_region1 = MC_get_heap_region(snapshot1);
-  simgrid::mc::Region* heap_region2 = MC_get_heap_region(snapshot2);
+  const Region* heap_region1 = MC_get_heap_region(snapshot1);
+  const Region* heap_region2 = MC_get_heap_region(snapshot2);
 
   switch (type->type) {
     case DW_TAG_unspecified_type:
@@ -665,10 +653,10 @@ static bool heap_area_differ_with_type(simgrid::mc::StateComparator& state, cons
             return true;
         }
         } else {
-          for (simgrid::mc::Member& member : type->members) {
+          for (const simgrid::mc::Member& member : type->members) {
             // TODO, optimize this? (for the offset case)
-            void* real_member1 = simgrid::dwarf::resolve_member(real_area1, type, &member, &snapshot1);
-            void* real_member2 = simgrid::dwarf::resolve_member(real_area2, type, &member, &snapshot2);
+            const void* real_member1 = dwarf::resolve_member(real_area1, type, &member, &snapshot1);
+            const void* real_member2 = dwarf::resolve_member(real_area2, type, &member, &snapshot2);
             if (heap_area_differ_with_type(state, real_member1, real_member2, snapshot1, snapshot2, previous,
                                            member.type, -1, check_ignore, 0))
               return true;
@@ -695,8 +683,7 @@ static bool heap_area_differ_with_type(simgrid::mc::StateComparator& state, cons
  * @param  area_size
  * @return                    DWARF type ID for given offset
  */
-static simgrid::mc::Type* get_offset_type(void* real_base_address, simgrid::mc::Type* type, int offset, int area_size,
-                                          const simgrid::mc::Snapshot& snapshot)
+static Type* get_offset_type(void* real_base_address, Type* type, int offset, int area_size, const Snapshot& snapshot)
 {
   // Beginning of the block, the inferred variable type if the type of the block:
   if (offset == 0)
@@ -714,13 +701,13 @@ static simgrid::mc::Type* get_offset_type(void* real_base_address, simgrid::mc::
         return nullptr;
     }
 
-    for (simgrid::mc::Member& member : type->members) {
+    for (const simgrid::mc::Member& member : type->members) {
       if (member.has_offset_location()) {
         // We have the offset, use it directly (shortcut):
         if (member.offset() == offset)
           return member.type;
       } else {
-        void* real_member = simgrid::dwarf::resolve_member(real_base_address, type, &member, &snapshot);
+        void* real_member = dwarf::resolve_member(real_base_address, type, &member, &snapshot);
         if ((char*)real_member - (char*)real_base_address == offset)
           return member.type;
       }
@@ -744,9 +731,8 @@ static simgrid::mc::Type* get_offset_type(void* real_base_address, simgrid::mc::
  * @param pointer_level
  * @return true when different, false otherwise (same or unknown)
  */
-static bool heap_area_differ(simgrid::mc::StateComparator& state, const void* area1, const void* area2,
-                             const simgrid::mc::Snapshot& snapshot1, const simgrid::mc::Snapshot& snapshot2,
-                             HeapLocationPairs* previous, simgrid::mc::Type* type, int pointer_level)
+static bool heap_area_differ(StateComparator& state, const void* area1, const void* area2, const Snapshot& snapshot1,
+                             const Snapshot& snapshot2, HeapLocationPairs* previous, Type* type, int pointer_level)
 {
   const simgrid::mc::RemoteClient& process = mc_model_checker->process();
 
@@ -761,8 +747,8 @@ static bool heap_area_differ(simgrid::mc::StateComparator& state, const void* ar
   int new_size1 = -1;
   int new_size2 = -1;
 
-  simgrid::mc::Type* new_type1 = nullptr;
-  simgrid::mc::Type* new_type2 = nullptr;
+  Type* new_type1 = nullptr;
+  Type* new_type2 = nullptr;
 
   bool match_pairs = false;
 
@@ -782,8 +768,8 @@ static bool heap_area_differ(simgrid::mc::StateComparator& state, const void* ar
   }
 
   // Get block number:
-  block1 = ((char*)area1 - (char*)state.std_heap_copy.heapbase) / BLOCKSIZE + 1;
-  block2 = ((char*)area2 - (char*)state.std_heap_copy.heapbase) / BLOCKSIZE + 1;
+  block1 = ((const char*)area1 - (const char*)state.std_heap_copy.heapbase) / BLOCKSIZE + 1;
+  block2 = ((const char*)area2 - (const char*)state.std_heap_copy.heapbase) / BLOCKSIZE + 1;
 
   // If either block is a stack block:
   if (is_block_stack((int) block1) && is_block_stack((int) block2)) {
@@ -794,8 +780,9 @@ static bool heap_area_differ(simgrid::mc::StateComparator& state, const void* ar
   }
 
   // If either block is not in the expected area of memory:
-  if (((char*)area1 < (char*)state.std_heap_copy.heapbase) || (block1 > (ssize_t)state.processStates[0].heapsize) ||
-      (block1 < 1) || ((char*)area2 < (char*)state.std_heap_copy.heapbase) ||
+  if (((const char*)area1 < (const char*)state.std_heap_copy.heapbase) ||
+      (block1 > (ssize_t)state.processStates[0].heapsize) || (block1 < 1) ||
+      ((const char*)area2 < (const char*)state.std_heap_copy.heapbase) ||
       (block2 > (ssize_t)state.processStates[1].heapsize) || (block2 < 1)) {
     return true;
   }
@@ -820,8 +807,8 @@ static bool heap_area_differ(simgrid::mc::StateComparator& state, const void* ar
       type_size = type->byte_size;
   }
 
-  simgrid::mc::Region* heap_region1 = MC_get_heap_region(snapshot1);
-  simgrid::mc::Region* heap_region2 = MC_get_heap_region(snapshot2);
+  const Region* heap_region1 = MC_get_heap_region(snapshot1);
+  const Region* heap_region2 = MC_get_heap_region(snapshot2);
 
   const malloc_info* heapinfo1 =
       (const malloc_info*)heap_region1->read(&heapinfo_temp1, &heapinfos1[block1], sizeof(malloc_info));
@@ -881,8 +868,7 @@ static bool heap_area_differ(simgrid::mc::StateComparator& state, const void* ar
       return false;
     }
 
-    if (heapinfo1->busy_block.ignore > 0
-        && heapinfo2->busy_block.ignore == heapinfo1->busy_block.ignore)
+    if (heapinfo1->busy_block.ignore > 0 && heapinfo2->busy_block.ignore == heapinfo1->busy_block.ignore)
       check_ignore = heapinfo1->busy_block.ignore;
 
   } else if ((heapinfo1->type > 0) && (heapinfo2->type > 0)) {      /* Fragmented block */
@@ -943,8 +929,8 @@ static bool heap_area_differ(simgrid::mc::StateComparator& state, const void* ar
     }
     // Type inference from the block type.
     else if (state.types_<1>(block1, frag1) != nullptr || state.types_<2>(block2, frag2) != nullptr) {
-      offset1 = (char*)area1 - (char*)real_addr_frag1;
-      offset2 = (char*)area2 - (char*)real_addr_frag2;
+      offset1 = (const char*)area1 - (const char*)real_addr_frag1;
+      offset2 = (const char*)area2 - (const char*)real_addr_frag2;
 
       if (state.types_<1>(block1, frag1) != nullptr && state.types_<2>(block2, frag2) != nullptr) {
         new_type1 = get_offset_type(real_addr_frag1, state.types_<1>(block1, frag1), offset1, size, snapshot1);
@@ -962,7 +948,6 @@ static bool heap_area_differ(simgrid::mc::StateComparator& state, const void* ar
       }
 
       if (new_type1 != nullptr && new_type2 != nullptr && new_type1 != new_type2) {
-
         type = new_type1;
         while (type->byte_size == 0 && type->subtype != nullptr)
           type = type->subtype;
@@ -1001,7 +986,6 @@ static bool heap_area_differ(simgrid::mc::StateComparator& state, const void* ar
     if ((heapinfo1->busy_frag.ignore[frag1] > 0) &&
         (heapinfo2->busy_frag.ignore[frag2] == heapinfo1->busy_frag.ignore[frag1]))
       check_ignore = heapinfo1->busy_frag.ignore[frag1];
-
   } else
     return true;
 
@@ -1017,9 +1001,8 @@ static bool heap_area_differ(simgrid::mc::StateComparator& state, const void* ar
     state.match_equals(previous);
   return false;
 }
-
-}
-}
+} // namespace mc
+} // namespace simgrid
 
 /************************** Snapshot comparison *******************************/
 /******************************************************************************/
@@ -1027,10 +1010,10 @@ static bool heap_area_differ(simgrid::mc::StateComparator& state, const void* ar
 static bool areas_differ_with_type(simgrid::mc::StateComparator& state, const void* real_area1,
                                    const simgrid::mc::Snapshot& snapshot1, simgrid::mc::Region* region1,
                                    const void* real_area2, const simgrid::mc::Snapshot& snapshot2,
-                                   simgrid::mc::Region* region2, simgrid::mc::Type* type, int pointer_level)
+                                   simgrid::mc::Region* region2, const simgrid::mc::Type* type, int pointer_level)
 {
-  simgrid::mc::Type* subtype;
-  simgrid::mc::Type* subsubtype;
+  const simgrid::mc::Type* subtype;
+  const simgrid::mc::Type* subsubtype;
   int elm_size;
   int i;
 
@@ -1131,9 +1114,9 @@ static bool areas_differ_with_type(simgrid::mc::StateComparator& state, const vo
     }
     case DW_TAG_structure_type:
     case DW_TAG_class_type:
-      for (simgrid::mc::Member& member : type->members) {
-        void* member1                   = simgrid::dwarf::resolve_member(real_area1, type, &member, &snapshot1);
-        void* member2                   = simgrid::dwarf::resolve_member(real_area2, type, &member, &snapshot2);
+      for (const simgrid::mc::Member& member : type->members) {
+        const void* member1             = simgrid::dwarf::resolve_member(real_area1, type, &member, &snapshot1);
+        const void* member2             = simgrid::dwarf::resolve_member(real_area2, type, &member, &snapshot2);
         simgrid::mc::Region* subregion1 = snapshot1.get_region(member1, region1); // region1 is hinted
         simgrid::mc::Region* subregion2 = snapshot2.get_region(member2, region2); // region2 is hinted
         if (areas_differ_with_type(state, member1, snapshot1, subregion1, member2, snapshot2, subregion2, member.type,
@@ -1151,9 +1134,10 @@ static bool areas_differ_with_type(simgrid::mc::StateComparator& state, const vo
   return false;
 }
 
-static bool global_variables_differ(simgrid::mc::StateComparator& state, simgrid::mc::ObjectInformation* object_info,
-                                    simgrid::mc::Region* r1, simgrid::mc::Region* r2,
-                                    const simgrid::mc::Snapshot& snapshot1, const simgrid::mc::Snapshot& snapshot2)
+static bool global_variables_differ(simgrid::mc::StateComparator& state,
+                                    const simgrid::mc::ObjectInformation* object_info, simgrid::mc::Region* r1,
+                                    simgrid::mc::Region* r2, const simgrid::mc::Snapshot& snapshot1,
+                                    const simgrid::mc::Snapshot& snapshot2)
 {
   xbt_assert(r1 && r2, "Missing region.");
 
@@ -1167,7 +1151,7 @@ static bool global_variables_differ(simgrid::mc::StateComparator& state, simgrid
         || (char *) current_var.address > (char *) object_info->end_rw)
       continue;
 
-    simgrid::mc::Type* bvariable_type = current_var.type;
+    const simgrid::mc::Type* bvariable_type = current_var.type;
     if (areas_differ_with_type(state, current_var.address, snapshot1, r1, current_var.address, snapshot2, r2,
                                bvariable_type, 0)) {
       XBT_VERB("Global variable %s (%p) is different between snapshots", current_var.name.c_str(), current_var.address);
@@ -1245,12 +1229,10 @@ bool snapshot_equal(const Snapshot* s1, const Snapshot* s2)
   }
 
   /* Init heap information used in heap comparison algorithm */
-  xbt_mheap_t heap1 =
-      static_cast<xbt_mheap_t>(s1->read_bytes(alloca(sizeof(struct mdesc)), sizeof(struct mdesc),
-                                              remote(process.heap_address), simgrid::mc::ReadOptions::lazy()));
-  xbt_mheap_t heap2 =
-      static_cast<xbt_mheap_t>(s2->read_bytes(alloca(sizeof(struct mdesc)), sizeof(struct mdesc),
-                                              remote(process.heap_address), simgrid::mc::ReadOptions::lazy()));
+  const s_xbt_mheap_t* heap1 = static_cast<xbt_mheap_t>(s1->read_bytes(
+      alloca(sizeof(s_xbt_mheap_t)), sizeof(s_xbt_mheap_t), remote(process.heap_address), ReadOptions::lazy()));
+  const s_xbt_mheap_t* heap2 = static_cast<xbt_mheap_t>(s2->read_bytes(
+      alloca(sizeof(s_xbt_mheap_t)), sizeof(s_xbt_mheap_t), remote(process.heap_address), ReadOptions::lazy()));
   if (state_comparator.initHeapInformation(heap1, heap2, s1->to_ignore_, s2->to_ignore_) == -1) {
     XBT_VERB("(%d - %d) Different heap information", s1->num_state_, s2->num_state_);
     return false;
@@ -1301,6 +1283,5 @@ bool snapshot_equal(const Snapshot* s1, const Snapshot* s2)
 
   return true;
 }
-
-}
-}
+} // namespace mc
+} // namespace simgrid
index c0c6a3e..c8e01de 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -28,9 +28,7 @@ void execute(const Dwarf_Op* ops, std::size_t n, const ExpressionContext& contex
     intptr_t second;
 
     switch (atom) {
-
         // Registers:
-
       case DW_OP_breg0:
       case DW_OP_breg1:
       case DW_OP_breg2:
index efb089e..811bbb0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -42,21 +42,12 @@ typedef std::vector<Dwarf_Op> DwarfExpression;
  *  the process memory, etc. All those informations are gathered in
  *  the evaluation context.
  */
-class ExpressionContext {
-public:
-  ExpressionContext()
-      : cursor(nullptr)
-      , frame_base(nullptr)
-      , address_space(nullptr)
-      , object_info(nullptr)
-  {
-  }
+struct ExpressionContext {
   /** CPU state (registers) */
-  unw_cursor_t* cursor;
-  void* frame_base;
-  /** Address space used to read memory */
-  const simgrid::mc::AddressSpace* address_space;
-  simgrid::mc::ObjectInformation* object_info;
+  unw_cursor_t* cursor                           = nullptr;
+  void* frame_base                               = nullptr;
+  const simgrid::mc::AddressSpace* address_space = nullptr; /** Address space used to read memory */
+  simgrid::mc::ObjectInformation* object_info    = nullptr;
 };
 
 /** When an error happens in the execution of a DWARF expression */
@@ -77,11 +68,9 @@ public:
 private:
   // Values of the stack (the top is stack_[size_ - 1]):
   uintptr_t stack_[max_size]{0};
-  size_t size_;
+  size_t size_ = 0;
 
 public:
-  ExpressionStack() : size_(0) {}
-
   // Access:
   std::size_t size() const { return size_; }
   bool empty() const { return size_ == 0; }
index 25b3bc2..869665a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 0d653ed..ee825a7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -23,8 +23,6 @@ namespace mc {
 /** Debug information about a given function or scope within a function */
 class Frame {
 public:
-  Frame();
-
   /** Kind of scope (DW_TAG_subprogram, DW_TAG_inlined_subroutine, etc.) */
   int tag = DW_TAG_invalid;
 
@@ -32,7 +30,7 @@ public:
   std::string name;
 
   /** Range of instruction addresses for which this scope is valid */
-  simgrid::xbt::Range<std::uint64_t> range;
+  simgrid::xbt::Range<std::uint64_t> range{0, 0};
 
   simgrid::dwarf::LocationList frame_base_location;
 
@@ -58,16 +56,6 @@ public:
   void* frame_base(unw_cursor_t& unw_cursor) const;
   void remove_variable(char* name);
 };
-
-inline Frame::Frame()
-{
-  this->tag                = 0;
-  this->range              = {0, 0};
-  this->id                 = 0;
-  this->abstract_origin_id = 0;
-  this->object_info        = nullptr;
-}
-
 } // namespace mc
 } // namespace simgrid
 
index cc70196..276ce89 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -20,7 +20,7 @@ namespace dwarf {
 
 /** Resolve a location expression */
 Location resolve(simgrid::dwarf::DwarfExpression const& expression, simgrid::mc::ObjectInformation* object_info,
-                 unw_cursor_t* c, void* frame_pointer_address, simgrid::mc::AddressSpace* address_space)
+                 unw_cursor_t* c, void* frame_pointer_address, const simgrid::mc::AddressSpace* address_space)
 {
   simgrid::dwarf::ExpressionContext context;
   context.frame_base    = frame_pointer_address;
@@ -50,7 +50,7 @@ static simgrid::dwarf::DwarfExpression const* find_expression(simgrid::dwarf::Lo
 }
 
 Location resolve(simgrid::dwarf::LocationList const& locations, simgrid::mc::ObjectInformation* object_info,
-                 unw_cursor_t* c, void* frame_pointer_address, simgrid::mc::AddressSpace* address_space)
+                 unw_cursor_t* c, void* frame_pointer_address, const simgrid::mc::AddressSpace* address_space)
 {
   unw_word_t ip = 0;
   if (c && unw_get_reg(c, UNW_REG_IP, &ip))
@@ -61,7 +61,7 @@ Location resolve(simgrid::dwarf::LocationList const& locations, simgrid::mc::Obj
   return simgrid::dwarf::resolve(*expression, object_info, c, frame_pointer_address, address_space);
 }
 
-LocationList location_list(simgrid::mc::ObjectInformation& info, Dwarf_Attribute& attr)
+LocationList location_list(const simgrid::mc::ObjectInformation& info, Dwarf_Attribute& attr)
 {
   LocationList locations;
   std::ptrdiff_t offset = 0;
index 07dcb7c..ea30d90 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -49,12 +49,12 @@ typedef std::vector<LocationListEntry> LocationList;
  */
 class Location {
 private:
-  void* memory_;
+  void* memory_    = nullptr;
   int register_id_ = 0;
 
 public:
   explicit Location(void* x) : memory_(x) {}
-  explicit Location(int register_id) : memory_(nullptr), register_id_(register_id) {}
+  explicit Location(int register_id) : register_id_(register_id) {}
   // Type of location:
   bool in_register() const { return memory_ == nullptr; }
   bool in_memory() const { return memory_ != nullptr; }
@@ -66,13 +66,13 @@ public:
 
 XBT_PRIVATE
 Location resolve(simgrid::dwarf::DwarfExpression const& expression, simgrid::mc::ObjectInformation* object_info,
-                 unw_cursor_t* c, void* frame_pointer_address, simgrid::mc::AddressSpace* address_space);
+                 unw_cursor_t* c, void* frame_pointer_address, const simgrid::mc::AddressSpace* address_space);
 
 Location resolve(simgrid::dwarf::LocationList const& locations, simgrid::mc::ObjectInformation* object_info,
-                 unw_cursor_t* c, void* frame_pointer_address, simgrid::mc::AddressSpace* address_space);
+                 unw_cursor_t* c, void* frame_pointer_address, const simgrid::mc::AddressSpace* address_space);
 
 XBT_PRIVATE
-simgrid::dwarf::LocationList location_list(simgrid::mc::ObjectInformation& info, Dwarf_Attribute& attr);
+simgrid::dwarf::LocationList location_list(const simgrid::mc::ObjectInformation& info, Dwarf_Attribute& attr);
 
 } // namespace dwarf
 } // namespace simgrid
index ed52d5a..08412d8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 namespace simgrid {
 namespace mc {
 
-/* For an executable object, addresses are virtual address
- * (there is no offset) i.e.
- * \f$\text{virtual address} = \{dwarf address}\f$
+/* For an executable object, addresses are virtual address (there is no offset) i.e.
+ *  \f$\text{virtual address} = \{dwarf address}\f$
  *
- * For a shared object, the addresses are offset from the beginning
- * of the shared object (the base address of the mapped shared
- * object must be used as offset
+ * For a shared object, the addresses are offset from the beginning of the shared object (the base address of the
+ * mapped shared object must be used as offset
  * i.e. \f$\text{virtual address} = \text{shared object base address}
  *             + \text{dwarf address}\f$.
  */
@@ -32,8 +30,7 @@ void* ObjectInformation::base_address() const
   if (this->executable())
     return nullptr;
 
-  // For an a shared-object (ET_DYN, including position-independent executables)
-  // the base address is its lowest address:
+  // For an a shared-object (ET_DYN, including position-independent executables) the base address is its lowest address:
   void* result = this->start_exec;
   if (this->start_rw != nullptr && result > (void*)this->start_rw)
     result = this->start_rw;
@@ -42,7 +39,7 @@ void* ObjectInformation::base_address() const
   return result;
 }
 
-simgrid::mc::Frame* ObjectInformation::find_function(const void* ip) const
+Frame* ObjectInformation::find_function(const void* ip) const
 {
   /* This is implemented by binary search on a sorted array.
    *
@@ -56,9 +53,9 @@ simgrid::mc::Frame* ObjectInformation::find_function(const void* ip) const
    * We could use std::binary_search by including the high_pc inside
    * the FunctionIndexEntry.
    */
-  const simgrid::mc::FunctionIndexEntry* base = this->functions_index.data();
-  int i                                       = 0;
-  int j                                       = this->functions_index.size() - 1;
+  const FunctionIndexEntry* base = this->functions_index.data();
+  int i                          = 0;
+  int j                          = this->functions_index.size() - 1;
   while (j >= i) {
     int k = i + ((j - i) / 2);
 
@@ -81,9 +78,9 @@ simgrid::mc::Frame* ObjectInformation::find_function(const void* ip) const
   return nullptr;
 }
 
-const simgrid::mc::Variable* ObjectInformation::find_variable(const char* name) const
+const Variable* ObjectInformation::find_variable(const char* name) const
 {
-  for (simgrid::mc::Variable const& variable : this->global_variables) {
+  for (Variable const& variable : this->global_variables) {
     if (variable.name == name)
       return &variable;
   }
@@ -103,11 +100,10 @@ void ObjectInformation::remove_global_variable(const char* name)
 
   while (first <= last) {
     size_type cursor                   = first + (last - first) / 2;
-    simgrid::mc::Variable& current_var = this->global_variables[cursor];
+    const Variable& current_var        = this->global_variables[cursor];
     int cmp                            = current_var.name.compare(name);
 
     if (cmp == 0) {
-
       // Find the whole range:
       first = cursor;
       while (first != 0 && this->global_variables[first - 1].name == name)
@@ -132,8 +128,7 @@ void ObjectInformation::remove_global_variable(const char* name)
 
 /** Ignore a local variable in a scope
  *
- *  Ignore all instances of variables with a given name in
- *  any (possibly inlined) subprogram with a given namespaced
+ *  Ignore all instances of variables with a given name in any (possibly inlined) subprogram with a given namespaced
  *  name.
  *
  *  @param var_name        Name of the local variable to ignore
@@ -141,15 +136,14 @@ void ObjectInformation::remove_global_variable(const char* name)
  *  @param subprogram      (possibly inlined) Subprogram of the scope current scope
  *  @param scope           Current scope
  */
-static void remove_local_variable(simgrid::mc::Frame& scope, const char* var_name, const char* subprogram_name,
-                                  simgrid::mc::Frame const& subprogram)
+static void remove_local_variable(Frame& scope, const char* var_name, const char* subprogram_name,
+                                  Frame const& subprogram)
 {
   typedef std::vector<Variable>::size_type size_type;
 
   // If the current subprogram matches the given name:
   if ((subprogram_name == nullptr || (not subprogram.name.empty() && subprogram.name == subprogram_name)) &&
       not scope.variables.empty()) {
-
     // Try to find the variable and remove it:
     size_type start = 0;
     size_type end   = scope.variables.size() - 1;
@@ -157,7 +151,7 @@ static void remove_local_variable(simgrid::mc::Frame& scope, const char* var_nam
     // Binary search:
     while (start <= end) {
       size_type cursor                   = start + (end - start) / 2;
-      simgrid::mc::Variable& current_var = scope.variables[cursor];
+      const Variable& current_var        = scope.variables[cursor];
       int compare                        = current_var.name.compare(var_name);
       if (compare == 0) {
         // Variable found, remove it:
@@ -173,11 +167,10 @@ static void remove_local_variable(simgrid::mc::Frame& scope, const char* var_nam
   }
 
   // And recursive processing in nested scopes:
-  for (simgrid::mc::Frame& nested_scope : scope.scopes) {
+  for (Frame& nested_scope : scope.scopes) {
     // The new scope may be an inlined subroutine, in this case we want to use its
     // namespaced name in recursive calls:
-    simgrid::mc::Frame const& nested_subprogram =
-        nested_scope.tag == DW_TAG_inlined_subroutine ? nested_scope : subprogram;
+    Frame const& nested_subprogram = nested_scope.tag == DW_TAG_inlined_subroutine ? nested_scope : subprogram;
     remove_local_variable(nested_scope, var_name, subprogram_name, nested_subprogram);
   }
 }
@@ -185,17 +178,17 @@ static void remove_local_variable(simgrid::mc::Frame& scope, const char* var_nam
 void ObjectInformation::remove_local_variable(const char* var_name, const char* subprogram_name)
 {
   for (auto& entry : this->subprograms)
-    simgrid::mc::remove_local_variable(entry.second, var_name, subprogram_name, entry.second);
+    mc::remove_local_variable(entry.second, var_name, subprogram_name, entry.second);
 }
 
 /** @brief Fills the position of the segments (executable, read-only, read/write) */
 // TODO, use the ELF segment information for more robustness
-void find_object_address(std::vector<simgrid::xbt::VmMap> const& maps, simgrid::mc::ObjectInformation* result)
+void find_object_address(std::vector<xbt::VmMap> const& maps, ObjectInformation* result)
 {
   const int PROT_RW = PROT_READ | PROT_WRITE;
   const int PROT_RX = PROT_READ | PROT_EXEC;
 
-  std::string name = simgrid::xbt::Path(result->file_name).get_base_name();
+  std::string name = xbt::Path(result->file_name).get_base_name();
 
   for (size_t i = 0; i < maps.size(); ++i) {
     simgrid::xbt::VmMap const& reg = maps[i];
@@ -236,7 +229,7 @@ void find_object_address(std::vector<simgrid::xbt::VmMap> const& maps, simgrid::
     else if (reg.prot == PROT_READ) {
       xbt_assert(not result->start_ro,
                  "Multiple read-only segments for %s, not supported. Compiling with the following may help: "
-                "-Wl,-znorelro -Wl,-znoseparate-code",
+                 "-Wl,-znorelro -Wl,-znoseparate-code",
                  maps[i].pathname.c_str());
       result->start_ro = (char*)reg.start_addr;
       result->end_ro   = (char*)reg.end_addr;
index 0e3a394..7f4ea9f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -157,7 +157,8 @@ XBT_PRIVATE std::shared_ptr<ObjectInformation> createObjectInformation(std::vect
                                                                        const char* name);
 
 /** Augment the current module with informations about the other ones */
-XBT_PRIVATE void postProcessObjectInformation(simgrid::mc::RemoteClient* process, simgrid::mc::ObjectInformation* info);
+XBT_PRIVATE void postProcessObjectInformation(const simgrid::mc::RemoteClient* process,
+                                              simgrid::mc::ObjectInformation* info);
 } // namespace mc
 } // namespace simgrid
 
index ff9642f..e7d4cac 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 8c4f6c2..5b4dd2a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index e3a6d25..eb5f346 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -89,7 +89,7 @@ static void MC_dwarf_handle_children(simgrid::mc::ObjectInformation* info, Dwarf
  *  @param unit the DIE of the compile unit of the current DIE
  *  @param frame containing frame if any
  */
-static void MC_dwarf_handle_variable_die(simgrid::mc::ObjectInformation* info, Dwarf_Die* die, Dwarf_Die* unit,
+static void MC_dwarf_handle_variable_die(simgrid::mc::ObjectInformation* info, Dwarf_Die* die, const Dwarf_Die* unit,
                                          simgrid::mc::Frame* frame, const char* ns);
 
 /** @brief Get the DW_TAG_type of the DIE
@@ -123,7 +123,6 @@ enum class FormClass {
 static TagClass classify_tag(int tag)
 {
   switch (tag) {
-
     case DW_TAG_array_type:
     case DW_TAG_class_type:
     case DW_TAG_enumeration_type:
@@ -224,7 +223,7 @@ static FormClass classify_form(int form)
  */
 inline XBT_PRIVATE const char* tagname(Dwarf_Die* die)
 {
-  return simgrid::dwarf::tagname(dwarf_tag(die));
+  return tagname(dwarf_tag(die));
 }
 
 } // namespace dwarf
@@ -432,7 +431,7 @@ static bool MC_compare_variable(simgrid::mc::Variable const& a, simgrid::mc::Var
  *  @param  member the member of the type
  *  @param  child  DIE of the member (DW_TAG_member)
  */
-static void MC_dwarf_fill_member_location(simgrid::mc::Type* type, simgrid::mc::Member* member, Dwarf_Die* child)
+static void MC_dwarf_fill_member_location(const simgrid::mc::Type* type, simgrid::mc::Member* member, Dwarf_Die* child)
 {
   xbt_assert(not dwarf_hasattr(child, DW_AT_data_bit_offset), "Can't groke DW_AT_data_bit_offset.");
 
@@ -485,8 +484,8 @@ static void MC_dwarf_fill_member_location(simgrid::mc::Type* type, simgrid::mc::
  *  @param unit DIE of the compilation unit containing the type DIE
  *  @param type the type
  */
-static void MC_dwarf_add_members(simgrid::mc::ObjectInformation* /*info*/, Dwarf_Die* die, Dwarf_Die* /*unit*/,
-                                 simgrid::mc::Type* type)
+static void MC_dwarf_add_members(const simgrid::mc::ObjectInformation* /*info*/, Dwarf_Die* die,
+                                 const Dwarf_Die* /*unit*/, simgrid::mc::Type* type)
 {
   int res;
   Dwarf_Die child;
@@ -645,8 +644,8 @@ static void MC_dwarf_handle_type_die(simgrid::mc::ObjectInformation* info, Dwarf
 static int mc_anonymous_variable_index = 0;
 
 static std::unique_ptr<simgrid::mc::Variable> MC_die_to_variable(simgrid::mc::ObjectInformation* info, Dwarf_Die* die,
-                                                                 Dwarf_Die* /*unit*/, simgrid::mc::Frame* frame,
-                                                                 const char* ns)
+                                                                 const Dwarf_Die* /*unit*/,
+                                                                 const simgrid::mc::Frame* frame, const char* ns)
 {
   // Skip declarations:
   if (MC_dwarf_attr_flag(die, DW_AT_declaration, false))
@@ -740,7 +739,7 @@ static std::unique_ptr<simgrid::mc::Variable> MC_die_to_variable(simgrid::mc::Ob
   return variable;
 }
 
-static void MC_dwarf_handle_variable_die(simgrid::mc::ObjectInformation* info, Dwarf_Die* die, Dwarf_Die* unit,
+static void MC_dwarf_handle_variable_die(simgrid::mc::ObjectInformation* info, Dwarf_Die* die, const Dwarf_Die* unit,
                                          simgrid::mc::Frame* frame, const char* ns)
 {
   std::unique_ptr<simgrid::mc::Variable> variable = MC_die_to_variable(info, die, unit, frame, ns);
@@ -892,10 +891,10 @@ static void MC_dwarf_handle_die(simgrid::mc::ObjectInformation* info, Dwarf_Die*
 
 static Elf64_Half get_type(Elf* elf)
 {
-  Elf64_Ehdr* ehdr64 = elf64_getehdr(elf);
+  const Elf64_Ehdr* ehdr64 = elf64_getehdr(elf);
   if (ehdr64)
     return ehdr64->e_type;
-  Elf32_Ehdr* ehdr32 = elf32_getehdr(elf);
+  const Elf32_Ehdr* ehdr32 = elf32_getehdr(elf);
   if (ehdr32)
     return ehdr32->e_type;
   xbt_die("Could not get ELF heeader");
@@ -936,7 +935,7 @@ static std::vector<char> get_build_id(Elf* elf)
   // Iterate over the program headers and find the PT_NOTE ones:
   for (size_t i = 0; i < phnum; ++i) {
     GElf_Phdr phdr_temp;
-    GElf_Phdr* phdr = gelf_getphdr(elf, i, &phdr_temp);
+    const GElf_Phdr* phdr = gelf_getphdr(elf, i, &phdr_temp);
     if (phdr->p_type != PT_NOTE)
       continue;
 
@@ -1192,11 +1191,10 @@ namespace simgrid {
 namespace mc {
 
 /** @brief Finds informations about a given shared object/executable */
-std::shared_ptr<simgrid::mc::ObjectInformation> createObjectInformation(std::vector<simgrid::xbt::VmMap> const& maps,
-                                                                        const char* name)
+std::shared_ptr<ObjectInformation> createObjectInformation(std::vector<xbt::VmMap> const& maps, const char* name)
 {
-  std::shared_ptr<simgrid::mc::ObjectInformation> result = std::make_shared<simgrid::mc::ObjectInformation>();
-  result->file_name                                      = name;
+  std::shared_ptr<ObjectInformation> result = std::make_shared<ObjectInformation>();
+  result->file_name                         = name;
   simgrid::mc::find_object_address(maps, result.get());
   MC_load_dwarf(result.get());
   MC_post_process_variables(result.get());
@@ -1209,11 +1207,11 @@ std::shared_ptr<simgrid::mc::ObjectInformation> createObjectInformation(std::vec
 
 /*************************************************************************/
 
-void postProcessObjectInformation(simgrid::mc::RemoteClient* process, simgrid::mc::ObjectInformation* info)
+void postProcessObjectInformation(const RemoteClient* process, ObjectInformation* info)
 {
   for (auto& t : info->types) {
-    simgrid::mc::Type* type    = &(t.second);
-    simgrid::mc::Type* subtype = type;
+    Type* type    = &(t.second);
+    Type* subtype = type;
     while (subtype->type == DW_TAG_typedef || subtype->type == DW_TAG_volatile_type ||
            subtype->type == DW_TAG_const_type)
       if (subtype->subtype)
index d24ebe9..392fe30 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -16,7 +16,7 @@ namespace dwarf {
 XBT_PRIVATE const char* attrname(int attr);
 XBT_PRIVATE const char* tagname(int tag);
 
-XBT_PRIVATE void* resolve_member(const void* base, simgrid::mc::Type* type, simgrid::mc::Member* member,
+XBT_PRIVATE void* resolve_member(const void* base, const simgrid::mc::Type* type, const simgrid::mc::Member* member,
                                  const simgrid::mc::AddressSpace* snapshot);
 
 XBT_PRIVATE
index cbbc5b2..6bfa193 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 3cf69dd..95af21f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 1bd5ad4..77fb82a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -18,7 +18,7 @@ namespace dwarf {
  * @param snapshot Snapshot (or nullptr)
  * @return Process address of the given member of the 'object' struct/class
  */
-void* resolve_member(const void* base, simgrid::mc::Type* /*type*/, simgrid::mc::Member* member,
+void* resolve_member(const void* base, const simgrid::mc::Type* /*type*/, const simgrid::mc::Member* member,
                      const simgrid::mc::AddressSpace* address_space)
 {
   ExpressionContext state;
index 82efd56..a51a8fb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -39,7 +39,7 @@ namespace mc {
 int UnwindContext::find_proc_info(unw_addr_space_t /*as*/, unw_word_t ip, unw_proc_info_t* pip, int need_unwind_info,
                                   void* arg) noexcept
 {
-  simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
+  const simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
   return unw_get_accessors(context->process_->unw_underlying_addr_space)
       ->find_proc_info(context->process_->unw_underlying_addr_space, ip, pip, need_unwind_info,
                        context->process_->unw_underlying_context);
@@ -51,7 +51,7 @@ int UnwindContext::find_proc_info(unw_addr_space_t /*as*/, unw_word_t ip, unw_pr
  */
 void UnwindContext::put_unwind_info(unw_addr_space_t /*as*/, unw_proc_info_t* pip, void* arg) noexcept
 {
-  simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
+  const simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
   return unw_get_accessors(context->process_->unw_underlying_addr_space)
       ->put_unwind_info(context->process_->unw_underlying_addr_space, pip, context->process_->unw_underlying_context);
 }
@@ -62,7 +62,7 @@ void UnwindContext::put_unwind_info(unw_addr_space_t /*as*/, unw_proc_info_t* pi
  */
 int UnwindContext::get_dyn_info_list_addr(unw_addr_space_t /*as*/, unw_word_t* dilap, void* arg) noexcept
 {
-  simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
+  const simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
   return unw_get_accessors(context->process_->unw_underlying_addr_space)
       ->get_dyn_info_list_addr(context->process_->unw_underlying_addr_space, dilap,
                                context->process_->unw_underlying_context);
@@ -74,7 +74,7 @@ int UnwindContext::get_dyn_info_list_addr(unw_addr_space_t /*as*/, unw_word_t* d
  */
 int UnwindContext::access_mem(unw_addr_space_t /*as*/, unw_word_t addr, unw_word_t* valp, int write, void* arg) noexcept
 {
-  simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
+  const simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
   if (write)
     return -UNW_EREADONLYREG;
   context->address_space_->read_bytes(valp, sizeof(unw_word_t), remote(addr));
@@ -176,7 +176,7 @@ int UnwindContext::access_reg(unw_addr_space_t /*as*/, unw_regnum_t regnum, unw_
   unw_context_t* context                 = &as_context->unwind_context_;
   if (write)
     return -UNW_EREADONLYREG;
-  greg_t* preg = (greg_t*)get_reg(context, regnum);
+  const greg_t* preg = (greg_t*)get_reg(context, regnum);
   if (not preg)
     return -UNW_EBADREG;
   *valp = *preg;
@@ -188,8 +188,8 @@ int UnwindContext::access_reg(unw_addr_space_t /*as*/, unw_regnum_t regnum, unw_
 int UnwindContext::get_proc_name(unw_addr_space_t /*as*/, unw_word_t addr, char* bufp, size_t buf_len, unw_word_t* offp,
                                  void* arg) noexcept
 {
-  simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
-  simgrid::mc::Frame* frame           = context->process_->find_function(remote(addr));
+  const simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
+  const simgrid::mc::Frame* frame           = context->process_->find_function(remote(addr));
   if (not frame)
     return -UNW_ENOINFO;
   *offp = (unw_word_t)frame->range.begin() - addr;
index 628cbba..beb19d6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -68,8 +68,7 @@ public:
   static unw_addr_space_t createUnwindAddressSpace();
 };
 
-void dumpStack(FILE* file, unw_cursor_t&& cursor);
-void dumpStack(FILE* file, pid_t pid);
+void dumpStack(FILE* file, unw_cursor_t* cursor);
 } // namespace mc
 } // namespace simgrid
 
index d75ec4d..9601c0e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -32,7 +32,7 @@ struct _UPT_info {
  */
 static inline pid_t _UPT_getpid(void* arg)
 {
-  _UPT_info* info = static_cast<_UPT_info*>(arg);
+  const _UPT_info* info = static_cast<_UPT_info*>(arg);
   return info->pid;
 }
 
index c75d927..b76dc7c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -42,14 +42,14 @@ void wait_for_requests()
   while (not simix_global->actors_to_run.empty()) {
     simix_global->run_all_actors();
     for (smx_actor_t const& process : simix_global->actors_that_ran) {
-      smx_simcall_t req = &process->simcall;
+      const s_smx_simcall* req = &process->simcall;
       if (req->call_ != SIMCALL_NONE && not simgrid::mc::request_is_visible(req))
         process->simcall_handle(0);
     }
   }
 #if SIMGRID_HAVE_MC
   xbt_dynar_reset(simix_global->actors_vector);
-  for (std::pair<aid_t, smx_actor_t> const& kv : simix_global->process_list) {
+  for (std::pair<const aid_t, smx_actor_t> const& kv : simix_global->process_list) {
     xbt_dynar_push_as(simix_global->actors_vector, smx_actor_t, kv.second);
   }
 #endif
@@ -88,8 +88,8 @@ bool actor_is_enabled(smx_actor_t actor)
 
     case SIMCALL_COMM_WAIT: {
       /* FIXME: check also that src and dst processes are not suspended */
-      simgrid::kernel::activity::CommImpl* act =
-          static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_wait__getraw__comm(req));
+      const kernel::activity::CommImpl* act =
+          static_cast<kernel::activity::CommImpl*>(simcall_comm_wait__getraw__comm(req));
 
       if (act->src_timeout_ || act->dst_timeout_) {
         /* If it has a timeout it will be always be enabled (regardless of who declared the timeout),
@@ -108,7 +108,7 @@ bool actor_is_enabled(smx_actor_t actor)
       simgrid::kernel::activity::CommImpl** comms = simcall_comm_waitany__get__comms(req);
       size_t count                                = simcall_comm_waitany__get__count(req);
       for (unsigned int index = 0; index < count; ++index) {
-        auto* comm = comms[index];
+        auto const* comm = comms[index];
         if (comm->src_actor_ && comm->dst_actor_)
           return true;
       }
@@ -116,11 +116,11 @@ bool actor_is_enabled(smx_actor_t actor)
     }
 
     case SIMCALL_MUTEX_LOCK: {
-      smx_mutex_t mutex = simcall_mutex_lock__get__mutex(req);
+      const kernel::activity::MutexImpl* mutex = simcall_mutex_lock__get__mutex(req);
 
-      if (mutex->owner_ == nullptr)
+      if (mutex->get_owner() == nullptr)
         return true;
-      return mutex->owner_->get_pid() == req->issuer_->get_pid();
+      return mutex->get_owner()->get_pid() == req->issuer_->get_pid();
     }
 
     case SIMCALL_SEM_ACQUIRE: {
@@ -148,7 +148,7 @@ bool actor_is_enabled(smx_actor_t actor)
 /* This is the list of requests that are visible from the checker algorithm.
  * Any other requests are handled right away on the application side.
  */
-bool request_is_visible(smx_simcall_t req)
+bool request_is_visible(const s_smx_simcall* req)
 {
 #if SIMGRID_HAVE_MC
   xbt_assert(mc_model_checker == nullptr, "This should be called from the client side");
index a1160d0..44347c0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -40,8 +40,7 @@ XBT_PRIVATE void handle_simcall(smx_simcall_t req, int req_num);
 XBT_PRIVATE bool actor_is_enabled(smx_actor_t process);
 
 /** Check if the given simcall is visible */
-XBT_PRIVATE bool request_is_visible(smx_simcall_t req);
-
+XBT_PRIVATE bool request_is_visible(const s_smx_simcall* req);
 }
 }
 
index ac87f79..97a6f85 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team.
+/* Copyright (c) 2008-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 7700754..db46857 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 9d55a88..68a42e5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -43,7 +43,7 @@ enum e_mc_comm_pattern_difference_t {
   DATA_DIFF,
 };
 
-static inline e_mc_call_type_t MC_get_call_type(smx_simcall_t req)
+static inline e_mc_call_type_t MC_get_call_type(const s_smx_simcall* req)
 {
   switch (req->call_) {
     case SIMCALL_COMM_ISEND:
index e6b4fb4..fbb7f7c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 391d789..6114c08 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 6494e19..152b049 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 8a72ae6..9264a37 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 975d079..2bfdb0c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -106,22 +106,22 @@ void MC_automaton_load(const char *file)
 namespace simgrid {
 namespace mc {
 
-void dumpStack(FILE* file, unw_cursor_t&& cursor)
+void dumpStack(FILE* file, unw_cursor_t* cursor)
 {
   int nframe = 0;
   char buffer[100];
 
   unw_word_t off;
   do {
-    const char* name = not unw_get_proc_name(&cursor, buffer, 100, &off) ? buffer : "?";
+    const char* name = not unw_get_proc_name(cursor, buffer, 100, &off) ? buffer : "?";
     // Unmangle C++ names:
     auto realname = simgrid::xbt::demangle(name);
 
 #if defined(__x86_64__)
     unw_word_t rip = 0;
     unw_word_t rsp = 0;
-    unw_get_reg(&cursor, UNW_X86_64_RIP, &rip);
-    unw_get_reg(&cursor, UNW_X86_64_RSP, &rsp);
+    unw_get_reg(cursor, UNW_X86_64_RIP, &rip);
+    unw_get_reg(cursor, UNW_X86_64_RSP, &rsp);
     fprintf(file, "  %i: %s (RIP=0x%" PRIx64 " RSP=0x%" PRIx64 ")\n", nframe, realname.get(), (std::uint64_t)rip,
             (std::uint64_t)rsp);
 #else
@@ -129,14 +129,14 @@ void dumpStack(FILE* file, unw_cursor_t&& cursor)
 #endif
 
     ++nframe;
-  } while(unw_step(&cursor));
+  } while (unw_step(cursor));
 }
 
 }
 }
 #endif
 
-double MC_process_clock_get(smx_actor_t process)
+double MC_process_clock_get(const simgrid::kernel::actor::ActorImpl* process)
 {
   if (simgrid::mc::processes_time.empty())
     return 0;
@@ -145,7 +145,7 @@ double MC_process_clock_get(smx_actor_t process)
   return -1;
 }
 
-void MC_process_clock_add(smx_actor_t process, double amount)
+void MC_process_clock_add(const simgrid::kernel::actor::ActorImpl* process, double amount)
 {
   simgrid::mc::processes_time[process->get_pid()] += amount;
 }
index d23fe69..7ae53cb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 8b1bf39..7e4e97d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index c25b45b..262add9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index ff6bbb2..de7d62d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team.
+/* Copyright (c) 2008-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 21975e6..51da19c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index a23fb13..3feeed9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 4c7f441..bdd03aa 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -34,7 +34,7 @@ void replay(RecordTrace const& trace)
     smx_actor_t process = SIMIX_process_from_PID(transition.pid_);
     if (not process)
       xbt_die("Unexpected process (pid:%d).", transition.pid_);
-    smx_simcall_t simcall = &(process->simcall);
+    const s_smx_simcall* simcall = &(process->simcall);
     if (simcall == nullptr || simcall->call_ == SIMCALL_NONE)
       xbt_die("No simcall for process %d.", transition.pid_);
     if (not simgrid::mc::request_is_visible(simcall) || not simgrid::mc::actor_is_enabled(process))
index 85bf484..1cc96be 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index aa82045..93c9f3e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 9fc50cb..3c663e4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -57,11 +57,11 @@ bool request_depend_asymmetric(smx_simcall_t r1, smx_simcall_t r2)
     return false;
 
   // Those are internal requests, we do not need indirection because those objects are copies:
-  kernel::activity::CommImpl* synchro1 = MC_get_comm(r1);
-  kernel::activity::CommImpl* synchro2 = MC_get_comm(r2);
+  const kernel::activity::CommImpl* synchro1 = MC_get_comm(r1);
+  const kernel::activity::CommImpl* synchro2 = MC_get_comm(r2);
 
   if ((r1->call_ == SIMCALL_COMM_ISEND || r1->call_ == SIMCALL_COMM_IRECV) && r2->call_ == SIMCALL_COMM_WAIT) {
-    smx_mailbox_t mbox = MC_get_mbox(r1);
+    const kernel::activity::MailboxImpl* mbox = MC_get_mbox(r1);
 
     if (mbox != synchro2->mbox_cpy
         && simcall_comm_wait__get__timeout(r2) <= 0)
@@ -124,8 +124,8 @@ bool request_depend(smx_simcall_t req1, smx_simcall_t req2)
     return request_depend_asymmetric(req1, req2) && request_depend_asymmetric(req2, req1);
 
   // Those are internal requests, we do not need indirection because those objects are copies:
-  kernel::activity::CommImpl* synchro1 = MC_get_comm(req1);
-  kernel::activity::CommImpl* synchro2 = MC_get_comm(req2);
+  const kernel::activity::CommImpl* synchro1 = MC_get_comm(req1);
+  const kernel::activity::CommImpl* synchro2 = MC_get_comm(req2);
 
   switch (req1->call_) {
     case SIMCALL_COMM_ISEND:
@@ -237,7 +237,7 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
         p    = pointer_to_string(remote_act);
 
         simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_synchro;
-        simgrid::kernel::activity::CommImpl* act;
+        const simgrid::kernel::activity::CommImpl* act;
         if (use_remote_comm) {
           mc_model_checker->process().read(temp_synchro,
                                            remote(static_cast<simgrid::kernel::activity::CommImpl*>(remote_act)));
@@ -261,7 +261,7 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
       simgrid::kernel::activity::CommImpl* remote_act =
           static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_test__getraw__comm(req));
       simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_synchro;
-      simgrid::kernel::activity::CommImpl* act;
+      const simgrid::kernel::activity::CommImpl* act;
       if (use_remote_comm) {
         mc_model_checker->process().read(temp_synchro,
                                          remote(static_cast<simgrid::kernel::activity::CommImpl*>(remote_act)));
@@ -325,9 +325,9 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
                                                         ? simcall_mutex_lock__get__mutex(req)
                                                         : simcall_mutex_trylock__get__mutex(req)));
       args = bprintf("locked = %d, owner = %d, sleeping = n/a", mutex.get_buffer()->is_locked(),
-                     mutex.get_buffer()->owner_ != nullptr
+                     mutex.get_buffer()->get_owner() != nullptr
                          ? (int)mc_model_checker->process()
-                               .resolve_actor(simgrid::mc::remote(mutex.get_buffer()->owner_))
+                               .resolve_actor(simgrid::mc::remote(mutex.get_buffer()->get_owner()))
                                ->get_pid()
                          : -1);
       break;
@@ -381,7 +381,7 @@ bool request_is_enabled_by_idx(smx_simcall_t req, unsigned int idx)
 
   Remote<kernel::activity::CommImpl> temp_comm;
   mc_model_checker->process().read(temp_comm, remote(remote_act));
-  kernel::activity::CommImpl* comm = temp_comm.get_buffer();
+  const kernel::activity::CommImpl* comm = temp_comm.get_buffer();
   return comm->src_actor_.get() && comm->dst_actor_.get();
 }
 
@@ -431,10 +431,12 @@ std::string request_get_dot_output(smx_simcall_t req, int value)
         kernel::activity::ActivityImpl* remote_act = simcall_comm_wait__getraw__comm(req);
         Remote<kernel::activity::CommImpl> temp_comm;
         mc_model_checker->process().read(temp_comm, remote(static_cast<kernel::activity::CommImpl*>(remote_act)));
-        kernel::activity::CommImpl* comm = temp_comm.get_buffer();
+        const kernel::activity::CommImpl* comm = temp_comm.get_buffer();
 
-        smx_actor_t src_proc = mc_model_checker->process().resolve_actor(mc::remote(comm->src_actor_.get()));
-        smx_actor_t dst_proc = mc_model_checker->process().resolve_actor(mc::remote(comm->dst_actor_.get()));
+        const kernel::actor::ActorImpl* src_proc =
+            mc_model_checker->process().resolve_actor(mc::remote(comm->src_actor_.get()));
+        const kernel::actor::ActorImpl* dst_proc =
+            mc_model_checker->process().resolve_actor(mc::remote(comm->dst_actor_.get()));
         if (issuer->get_host())
           label =
               xbt::string_printf("[(%ld)%s] Wait [(%ld)->(%ld)]", issuer->get_pid(), MC_smx_actor_get_host_name(issuer),
@@ -449,7 +451,7 @@ std::string request_get_dot_output(smx_simcall_t req, int value)
       kernel::activity::ActivityImpl* remote_act = simcall_comm_test__getraw__comm(req);
       Remote<simgrid::kernel::activity::CommImpl> temp_comm;
       mc_model_checker->process().read(temp_comm, remote(static_cast<kernel::activity::CommImpl*>(remote_act)));
-      kernel::activity::CommImpl* comm = temp_comm.get_buffer();
+      const kernel::activity::CommImpl* comm = temp_comm.get_buffer();
       if (comm->src_actor_.get() == nullptr || comm->dst_actor_.get() == nullptr) {
         if (issuer->get_host())
           label = xbt::string_printf("[(%ld)%s] Test FALSE", issuer->get_pid(), MC_smx_actor_get_host_name(issuer));
index ac850fe..d33c0af 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 1e3450e..4993a2b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 3570f8e..af66ee9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -31,7 +31,7 @@ static inline simgrid::mc::ActorInformation* actor_info_cast(smx_actor_t actor)
  *  @param target       Local vector (to be filled with copies of `s_smx_actor_t`)
  *  @param remote_dynar Address of the process dynar in the remote list
  */
-static void MC_process_refresh_simix_actor_dynar(simgrid::mc::RemoteClient* process,
+static void MC_process_refresh_simix_actor_dynar(const simgrid::mc::RemoteClient* process,
                                                  std::vector<simgrid::mc::ActorInformation>& target,
                                                  simgrid::mc::RemotePtr<s_xbt_dynar_t> remote_dynar)
 {
@@ -119,11 +119,12 @@ const char* MC_smx_actor_get_host_name(smx_actor_t actor)
   if (mc_model_checker == nullptr)
     return actor->get_host()->get_cname();
 
-  simgrid::mc::RemoteClient* process = &mc_model_checker->process();
+  const simgrid::mc::RemoteClient* process = &mc_model_checker->process();
 
   // Read the simgrid::xbt::string in the MCed process:
   simgrid::mc::ActorInformation* info     = actor_info_cast(actor);
-  auto remote_string_address              = remote((simgrid::xbt::string_data*)&actor->get_host()->get_name());
+  auto remote_string_address =
+      remote(reinterpret_cast<const simgrid::xbt::string_data*>(&actor->get_host()->get_name()));
   simgrid::xbt::string_data remote_string = process->read(remote_string_address);
   char hostname[remote_string.len];
   process->read_bytes(hostname, remote_string.len + 1, remote(remote_string.data));
@@ -133,7 +134,7 @@ const char* MC_smx_actor_get_host_name(smx_actor_t actor)
 
 const char* MC_smx_actor_get_name(smx_actor_t actor)
 {
-  simgrid::mc::RemoteClient* process = &mc_model_checker->process();
+  const simgrid::mc::RemoteClient* process = &mc_model_checker->process();
   if (mc_model_checker == nullptr)
     return actor->get_cname();
 
index e46a1ee..69049df 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index b811c1d..6f5e47b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -18,14 +18,12 @@ namespace mc {
 
 State::State(unsigned long state_number) : num_(state_number)
 {
-  this->internal_comm.clear();
-  this->internal_req  = s_smx_simcall();
-  this->executed_req_ = s_smx_simcall();
+  this->internal_comm_.clear();
 
   actor_states_.resize(MC_smx_get_maxpid());
   /* Stateful model checking */
   if ((_sg_mc_checkpoint > 0 && (state_number % _sg_mc_checkpoint == 0)) || _sg_mc_termination) {
-    system_state = std::make_shared<simgrid::mc::Snapshot>(num_);
+    system_state_ = std::make_shared<simgrid::mc::Snapshot>(num_);
     if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
       MC_state_copy_incomplete_communications_pattern(this);
       MC_state_copy_index_communications_pattern(this);
@@ -114,7 +112,7 @@ static inline smx_simcall_t MC_state_choose_request_for_process(simgrid::mc::Sta
           remote(static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_wait__getraw__comm(&actor->simcall)));
       simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_act;
       mc_model_checker->process().read(temp_act, remote_act);
-      simgrid::kernel::activity::CommImpl* act = temp_act.get_buffer();
+      const simgrid::kernel::activity::CommImpl* act = temp_act.get_buffer();
       if (act->src_actor_.get() && act->dst_actor_.get())
         state->transition_.argument_ = 0; // OK
       else if (act->src_actor_.get() == nullptr && act->type_ == simgrid::kernel::activity::CommImpl::Type::READY &&
@@ -149,47 +147,47 @@ static inline smx_simcall_t MC_state_choose_request_for_process(simgrid::mc::Sta
   state->transition_.pid_ = actor->get_pid();
   state->executed_req_    = *req;
   // Fetch the data of the request and translate it:
-  state->internal_req = *req;
+  state->internal_req_ = *req;
 
   /* The waitany and testany request are transformed into a wait or test request over the corresponding communication
    * action so it can be treated later by the dependence function. */
   switch (req->call_) {
     case SIMCALL_COMM_WAITANY: {
-      state->internal_req.call_ = SIMCALL_COMM_WAIT;
+      state->internal_req_.call_ = SIMCALL_COMM_WAIT;
       simgrid::kernel::activity::CommImpl* remote_comm;
       remote_comm = mc_model_checker->process().read(
           remote(simcall_comm_waitany__get__comms(req) + state->transition_.argument_));
-      mc_model_checker->process().read(state->internal_comm, remote(remote_comm));
-      simcall_comm_wait__set__comm(&state->internal_req, state->internal_comm.get_buffer());
-      simcall_comm_wait__set__timeout(&state->internal_req, 0);
+      mc_model_checker->process().read(state->internal_comm_, remote(remote_comm));
+      simcall_comm_wait__set__comm(&state->internal_req_, state->internal_comm_.get_buffer());
+      simcall_comm_wait__set__timeout(&state->internal_req_, 0);
       break;
     }
 
     case SIMCALL_COMM_TESTANY:
-      state->internal_req.call_ = SIMCALL_COMM_TEST;
+      state->internal_req_.call_ = SIMCALL_COMM_TEST;
 
       if (state->transition_.argument_ > 0) {
         simgrid::kernel::activity::CommImpl* remote_comm = mc_model_checker->process().read(
             remote(simcall_comm_testany__get__comms(req) + state->transition_.argument_));
-        mc_model_checker->process().read(state->internal_comm, remote(remote_comm));
+        mc_model_checker->process().read(state->internal_comm_, remote(remote_comm));
       }
 
-      simcall_comm_test__set__comm(&state->internal_req, state->internal_comm.get_buffer());
-      simcall_comm_test__set__result(&state->internal_req, state->transition_.argument_);
+      simcall_comm_test__set__comm(&state->internal_req_, state->internal_comm_.get_buffer());
+      simcall_comm_test__set__result(&state->internal_req_, state->transition_.argument_);
       break;
 
     case SIMCALL_COMM_WAIT:
-      mc_model_checker->process().read_bytes(&state->internal_comm, sizeof(state->internal_comm),
+      mc_model_checker->process().read_bytes(&state->internal_comm_, sizeof(state->internal_comm_),
                                              remote(simcall_comm_wait__getraw__comm(req)));
-      simcall_comm_wait__set__comm(&state->executed_req_, state->internal_comm.get_buffer());
-      simcall_comm_wait__set__comm(&state->internal_req, state->internal_comm.get_buffer());
+      simcall_comm_wait__set__comm(&state->executed_req_, state->internal_comm_.get_buffer());
+      simcall_comm_wait__set__comm(&state->internal_req_, state->internal_comm_.get_buffer());
       break;
 
     case SIMCALL_COMM_TEST:
-      mc_model_checker->process().read_bytes(&state->internal_comm, sizeof(state->internal_comm),
+      mc_model_checker->process().read_bytes(&state->internal_comm_, sizeof(state->internal_comm_),
                                              remote(simcall_comm_test__getraw__comm(req)));
-      simcall_comm_test__set__comm(&state->executed_req_, state->internal_comm.get_buffer());
-      simcall_comm_test__set__comm(&state->internal_req, state->internal_comm.get_buffer());
+      simcall_comm_test__set__comm(&state->executed_req_, state->internal_comm_.get_buffer());
+      simcall_comm_test__set__comm(&state->internal_req_, state->internal_comm_.get_buffer());
       break;
 
     default:
index 4123468..c99c211 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -109,13 +109,13 @@ public:
    * SIMCALL_COMM_TESTANY is translated to a SIMCALL_COMM_TEST
    * and SIMCALL_COMM_WAITANY to a SIMCALL_COMM_WAIT.
    */
-  s_smx_simcall internal_req;
+  s_smx_simcall internal_req_;
 
   /* Can be used as a copy of the remote synchro object */
-  simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> internal_comm;
+  simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> internal_comm_;
 
   /** Snapshot of system state (if needed) */
-  std::shared_ptr<simgrid::mc::Snapshot> system_state;
+  std::shared_ptr<simgrid::mc::Snapshot> system_state_;
 
   // For CommunicationDeterminismChecker
   std::vector<std::vector<simgrid::mc::PatternCommunication>> incomplete_comm_pattern_;
@@ -124,7 +124,10 @@ public:
   explicit State(unsigned long state_number);
 
   std::size_t interleave_size() const;
-  void add_interleaving_set(smx_actor_t actor) { this->actor_states_[actor->get_pid()].consider(); }
+  void add_interleaving_set(const simgrid::kernel::actor::ActorImpl* actor)
+  {
+    this->actor_states_[actor->get_pid()].consider();
+  }
   Transition get_transition() const;
 };
 }
index 6eaf30d..782a563 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team.
+/* Copyright (c) 2015-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index a3e2344..5494f33 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -26,7 +26,6 @@ class Channel {
   }
 
 public:
-  Channel() = default;
   explicit Channel(int sock) : socket_(sock) {}
   ~Channel();
 
@@ -34,15 +33,6 @@ public:
   Channel(Channel const&) = delete;
   Channel& operator=(Channel const&) = delete;
 
-  // Move:
-  Channel(Channel&& that) : socket_(that.socket_) { that.socket_ = -1; }
-  Channel& operator=(Channel&& that)
-  {
-    this->socket_ = that.socket_;
-    that.socket_  = -1;
-    return *this;
-  }
-
   // Send
   int send(const void* message, size_t size) const;
   int send(e_mc_message_type type) const
index 06916a4..61e5591 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -38,7 +38,7 @@ Client* Client::initialize()
   _sg_do_model_check = 1;
 
   // Fetch socket from MC_ENV_SOCKET_FD:
-  char* fd_env = std::getenv(MC_ENV_SOCKET_FD);
+  const char* fd_env = std::getenv(MC_ENV_SOCKET_FD);
   if (not fd_env)
     xbt_die("No MC socket passed in the environment");
   int fd =
@@ -72,7 +72,7 @@ Client* Client::initialize()
   return instance_.get();
 }
 
-void Client::handle_deadlock_check(s_mc_message_t*)
+void Client::handle_deadlock_check(const s_mc_message_t*)
 {
   bool deadlock = false;
   if (not simix_global->process_list.empty()) {
@@ -88,11 +88,11 @@ void Client::handle_deadlock_check(s_mc_message_t*)
   s_mc_message_int_t answer{MC_MESSAGE_DEADLOCK_CHECK_REPLY, deadlock};
   xbt_assert(channel_.send(answer) == 0, "Could not send response");
 }
-void Client::handle_continue(s_mc_message_t*)
+void Client::handle_continue(const s_mc_message_t*)
 {
   /* Nothing to do */
 }
-void Client::handle_simcall(s_mc_message_simcall_handle_t* message)
+void Client::handle_simcall(const s_mc_message_simcall_handle_t* message)
 {
   smx_actor_t process = SIMIX_process_from_PID(message->pid);
   if (not process)
@@ -102,7 +102,7 @@ void Client::handle_simcall(s_mc_message_simcall_handle_t* message)
     xbt_die("Could not send MESSAGE_WAITING to model-checker");
 }
 
-void Client::handle_actor_enabled(s_mc_message_actor_enabled_t* msg)
+void Client::handle_actor_enabled(const s_mc_message_actor_enabled_t* msg)
 {
   bool res = simgrid::mc::actor_is_enabled(SIMIX_process_from_PID(msg->aid));
   s_mc_message_int_t answer{MC_MESSAGE_ACTOR_ENABLED_REPLY, res};
@@ -120,9 +120,8 @@ void Client::handle_messages()
     if (received_size < 0)
       xbt_die("Could not receive commands from the model-checker");
 
-    s_mc_message_t* message = (s_mc_message_t*)message_buffer;
+    const s_mc_message_t* message = (s_mc_message_t*)message_buffer;
     switch (message->type) {
-
       case MC_MESSAGE_DEADLOCK_CHECK:
         xbt_assert(received_size == sizeof(s_mc_message_t), "Unexpected size for DEADLOCK_CHECK (%zd != %zu)",
                    received_size, sizeof(s_mc_message_t));
@@ -184,7 +183,7 @@ void Client::ignore_memory(void* addr, std::size_t size)
 
 void Client::ignore_heap(void* address, std::size_t size)
 {
-  xbt_mheap_t heap = mmalloc_get_current_heap();
+  const s_xbt_mheap_t* heap = mmalloc_get_current_heap();
 
   s_mc_message_ignore_heap_t message;
   message.type    = MC_MESSAGE_IGNORE_HEAP;
@@ -228,7 +227,7 @@ void Client::declare_symbol(const char* name, int* value)
 
 void Client::declare_stack(void* stack, size_t size, ucontext_t* context)
 {
-  xbt_mheap_t heap = mmalloc_get_current_heap();
+  const s_xbt_mheap_t* heap = mmalloc_get_current_heap();
 
   s_stack_region_t region;
   memset(&region, 0, sizeof(region));
@@ -243,5 +242,5 @@ void Client::declare_stack(void* stack, size_t size, ucontext_t* context)
   if (channel_.send(message))
     xbt_die("Could not send STACK_REGION to model-checker");
 }
-}
-}
+} // namespace mc
+} // namespace simgrid
index b26207e..d6b7fd6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -28,10 +28,10 @@ public:
   void handle_messages();
 
 private:
-  void handle_deadlock_check(s_mc_message_t* msg);
-  void handle_continue(s_mc_message_t* msg);
-  void handle_simcall(s_mc_message_simcall_handle_t* message);
-  void handle_actor_enabled(s_mc_message_actor_enabled_t* msg);
+  void handle_deadlock_check(const s_mc_message_t* msg);
+  void handle_continue(const s_mc_message_t* msg);
+  void handle_simcall(const s_mc_message_simcall_handle_t* message);
+  void handle_actor_enabled(const s_mc_message_actor_enabled_t* msg);
 
 public:
   Channel const& get_channel() const { return channel_; }
index 940d9f9..fae0571 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -435,7 +435,7 @@ std::string RemoteClient::read_string(RemotePtr<char> address) const
       continue;
     xbt_assert(c > 0, "Could not read string from remote process");
 
-    void* p = memchr(res.data() + off, '\0', c);
+    const void* p = memchr(res.data() + off, '\0', c);
     if (p)
       return std::string(res.data());
 
@@ -487,7 +487,7 @@ void RemoteClient::ignore_region(std::uint64_t addr, std::size_t size)
   }
 
   unsigned int cursor           = 0;
-  IgnoredRegion* current_region = nullptr;
+  const IgnoredRegion* current_region = nullptr;
 
   int start = 0;
   int end   = ignored_regions_.size() - 1;
@@ -536,7 +536,7 @@ void RemoteClient::ignore_heap(IgnoredHeapRegion const& region)
   size_type cursor;
   while (start <= end) {
     cursor               = start + (end - start) / 2;
-    auto& current_region = ignored_heap_[cursor];
+    auto const& current_region = ignored_heap_[cursor];
     if (current_region.address == region.address)
       return;
     else if (current_region.address < region.address)
@@ -565,7 +565,7 @@ void RemoteClient::unignore_heap(void* address, size_t size)
   size_type cursor;
   while (start <= end) {
     cursor       = (start + end) / 2;
-    auto& region = ignored_heap_[cursor];
+    auto const& region = ignored_heap_[cursor];
     if (region.address < address)
       start = cursor + 1;
     else if ((char*)region.address <= ((char*)address + size)) {
@@ -622,7 +622,7 @@ void RemoteClient::dump_stack()
     return;
   }
 
-  simgrid::mc::dumpStack(stderr, std::move(cursor));
+  simgrid::mc::dumpStack(stderr, &cursor);
 
   _UPT_destroy(context);
   unw_destroy_addr_space(as);
index b5cfdc9..6f0a1bd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 5da8005..e3f0371 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -59,11 +59,11 @@ public:
  *  as a `uint64_t`.
  */
 template <class T> class RemotePtr {
-  std::uint64_t address_;
+  std::uint64_t address_ = 0;
 
 public:
-  RemotePtr() : address_(0) {}
-  explicit RemotePtr(std::nullptr_t) : address_(0) {}
+  RemotePtr() = default;
+  explicit RemotePtr(std::nullptr_t) {}
   explicit RemotePtr(std::uint64_t address) : address_(address) {}
   explicit RemotePtr(T* address) : address_((std::uintptr_t)address) {}
   explicit RemotePtr(Remote<T*> p) : address_((std::uintptr_t)*p.get_buffer()) {}
index f014ece..690f910 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team.
+/* Copyright (c) 2015-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 3bf8823..39b5aa7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 808fc60..ef35495 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -15,9 +15,9 @@ namespace mc {
  *  @param page_count      Number of pages of the region
  *  @return                Snapshot page numbers of this new snapshot
  */
-ChunkedData::ChunkedData(PageStore& store, AddressSpace& as, RemotePtr<void> addr, std::size_t page_count)
+ChunkedData::ChunkedData(PageStore& store, const AddressSpace& as, RemotePtr<void> addr, std::size_t page_count)
+    : store_(&store)
 {
-  store_ = &store;
   this->pagenos_.resize(page_count);
   std::vector<char> buffer(xbt_pagesize);
 
index ac4e24a..352214c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -46,9 +46,9 @@ public:
     for (std::size_t const& pageno : pagenos_)
       store_->ref_page(pageno);
   }
-  ChunkedData(ChunkedData&& that) : store_(that.store_), pagenos_(std::move(that.pagenos_))
+  ChunkedData(ChunkedData&& that) : pagenos_(std::move(that.pagenos_))
   {
-    that.store_ = nullptr;
+    std::swap(store_, that.store_);
     that.pagenos_.clear();
   }
   ChunkedData& operator=(ChunkedData const& that)
@@ -82,9 +82,9 @@ public:
   const std::size_t* pagenos() const { return pagenos_.data(); }
 
   /** Get a a pointer to a chunk */
-  const void* page(std::size_t i) const { return store_->get_page(pagenos_[i]); }
+  void* page(std::size_t i) const { return store_->get_page(pagenos_[i]); }
 
-  ChunkedData(PageStore& store, AddressSpace& as, RemotePtr<void> addr, std::size_t page_count);
+  ChunkedData(PageStore& store, const AddressSpace& as, RemotePtr<void> addr, std::size_t page_count);
 };
 
 } // namespace mc
index e11d653..ef1568c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -26,8 +26,8 @@ namespace mc {
 
 /** @brief Compute a hash for the given memory page
  *
- *  The page is used before inserting the page in the page store
- *  in order to find duplicate of this page in the page store.
+ *  The page is used before inserting the page in the page store in order to find duplicate of this page in the page
+ *  store.
  *
  *  @param data Memory page
  *  @return hash off the page
@@ -50,7 +50,7 @@ static XBT_ALWAYS_INLINE PageStore::hash_type mc_hash_page(const void* data)
 
 // ***** snapshot_page_manager
 
-PageStore::PageStore(std::size_t size) : memory_(nullptr), capacity_(size), top_index_(0)
+PageStore::PageStore(std::size_t size) : capacity_(size)
 {
   // Using mmap in order to be able to expand the region by relocating it somewhere else in the virtual memory space:
   void* memory =
@@ -118,7 +118,6 @@ void PageStore::resize(std::size_t size)
 std::size_t PageStore::alloc_page()
 {
   if (this->free_pages_.empty()) {
-
     // Expand the region:
     if (this->top_index_ == this->capacity_)
       // All the pages are allocated, we need add more pages:
@@ -126,9 +125,7 @@ std::size_t PageStore::alloc_page()
 
     // Use a page from the top:
     return this->top_index_++;
-
   } else {
-
     // Use a page from free_pages_ (inside of the region):
     size_t res = this->free_pages_[this->free_pages_.size() - 1];
     this->free_pages_.pop_back();
@@ -145,7 +142,7 @@ void PageStore::remove_page(std::size_t pageno)
 }
 
 /** Store a page in memory */
-std::size_t PageStore::store_page(void* page)
+std::size_t PageStore::store_page(const void* page)
 {
   xbt_assert(top_index_ <= this->capacity_, "top_index is not consistent");
 
@@ -160,7 +157,6 @@ std::size_t PageStore::store_page(void* page)
   for (size_t const& pageno : page_set) {
     const void* snapshot_page = this->get_page(pageno);
     if (memcmp(page, snapshot_page, xbt_pagesize) == 0) {
-
       // If a page with the same content is already in the page store it's reused and its refcount is incremented.
       page_counts_[pageno]++;
       return pageno;
@@ -170,7 +166,7 @@ std::size_t PageStore::store_page(void* page)
   // Otherwise, a new page is allocated in the page store and the content of the page is `memcpy()`-ed to this new page.
   std::size_t pageno = alloc_page();
   xbt_assert(this->page_counts_[pageno] == 0, "Allocated page is already used");
-  void* snapshot_page = (void*)this->get_page(pageno);
+  void* snapshot_page = this->get_page(pageno);
   memcpy(snapshot_page, page, xbt_pagesize);
   page_set.insert(pageno);
   page_counts_[pageno]++;
index c78f575..f5511fe 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -134,14 +134,14 @@ public:
   void ref_page(size_t pageno);
 
   /** @brief Store a page in the page store */
-  std::size_t store_page(void* page);
+  std::size_t store_page(const void* page);
 
   /** @brief Get a page from its page number
    *
    *  @param pageno Number of the memory page in the store
    *  @return Start of the page
    */
-  const void* get_page(std::size_t pageno) const;
+  void* get_page(std::size_t pageno) const;
 
   // Debug/test methods
 
@@ -169,7 +169,7 @@ XBT_ALWAYS_INLINE void PageStore::ref_page(size_t pageno)
   ++this->page_counts_[pageno];
 }
 
-XBT_ALWAYS_INLINE const void* PageStore::get_page(std::size_t pageno) const
+XBT_ALWAYS_INLINE void* PageStore::get_page(std::size_t pageno) const
 {
   return (void*)simgrid::mc::mmu::join(pageno, (std::uintptr_t)this->memory_);
 }
index c9fbe6f..4888385 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 3208437..dd9541e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -44,21 +44,21 @@ void Region::restore()
   }
 }
 
-static XBT_ALWAYS_INLINE void* mc_translate_address_region(uintptr_t addr, simgrid::mc::Region* region)
+static XBT_ALWAYS_INLINE void* mc_translate_address_region(uintptr_t addr, const simgrid::mc::Region* region)
 {
   auto split                = simgrid::mc::mmu::split(addr - region->start().address());
   auto pageno               = split.first;
   auto offset               = split.second;
-  const void* snapshot_page = region->get_chunks().page(pageno);
+  void* snapshot_page       = region->get_chunks().page(pageno);
   return (char*)snapshot_page + offset;
 }
 
-void* Region::read(void* target, const void* addr, std::size_t size)
+void* Region::read(void* target, const void* addr, std::size_t size) const
 {
   xbt_assert(contain(simgrid::mc::remote(addr)), "Trying to read out of the region boundary.");
 
   // Last byte of the region:
-  void* end = (char*)addr + size - 1;
+  const void* end = (const char*)addr + size - 1;
   if (simgrid::mc::mmu::same_chunk((std::uintptr_t)addr, (std::uintptr_t)end)) {
     // The memory is contained in a single page:
     return mc_translate_address_region((uintptr_t)addr, this);
@@ -76,17 +76,17 @@ void* Region::read(void* target, const void* addr, std::size_t size)
 
   // Read each page:
   while (simgrid::mc::mmu::split((std::uintptr_t)addr).first != page_end) {
-    void* snapshot_addr = mc_translate_address_region((uintptr_t)addr, this);
+    const void* snapshot_addr = mc_translate_address_region((uintptr_t)addr, this);
     void* next_page     = (void*)simgrid::mc::mmu::join(simgrid::mc::mmu::split((std::uintptr_t)addr).first + 1, 0);
-    size_t readable     = (char*)next_page - (char*)addr;
+    size_t readable     = (char*)next_page - (const char*)addr;
     memcpy(dest, snapshot_addr, readable);
-    addr = (char*)addr + readable;
+    addr = (const char*)addr + readable;
     dest = (char*)dest + readable;
     size -= readable;
   }
 
   // Read the end:
-  void* snapshot_addr = mc_translate_address_region((uintptr_t)addr, this);
+  const void* snapshot_addr = mc_translate_address_region((uintptr_t)addr, this);
   memcpy(dest, snapshot_addr, size);
 
   return target;
@@ -103,8 +103,8 @@ void* Region::read(void* target, const void* addr, std::size_t size)
  * @param region2 Region of the address in the second snapshot
  * @return same semantic as memcmp
  */
-int MC_snapshot_region_memcmp(const void* addr1, simgrid::mc::Region* region1, const void* addr2,
-                              simgrid::mc::Region* region2, size_t size)
+int MC_snapshot_region_memcmp(const void* addr1, const simgrid::mc::Region* region1, const void* addr2,
+                              const simgrid::mc::Region* region2, size_t size)
 {
   // Using alloca() for large allocations may trigger stack overflow:
   // use malloc if the buffer is too big.
index 4985c61..0131713 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -69,16 +69,16 @@ public:
    *  @param size    Size of the data to read in bytes
    *  @return Pointer where the data is located (either target buffer or original location)
    */
-  void* read(void* target, const void* addr, std::size_t size);
+  void* read(void* target, const void* addr, std::size_t size) const;
 };
 
 } // namespace mc
 } // namespace simgrid
 
-int MC_snapshot_region_memcmp(const void* addr1, simgrid::mc::Region* region1, const void* addr2,
-                              simgrid::mc::Region* region2, std::size_t size);
+int MC_snapshot_region_memcmp(const void* addr1, const simgrid::mc::Region* region1, const void* addr2,
+                              const simgrid::mc::Region* region2, std::size_t size);
 
-static XBT_ALWAYS_INLINE void* MC_region_read_pointer(simgrid::mc::Region* region, const void* addr)
+static XBT_ALWAYS_INLINE void* MC_region_read_pointer(const simgrid::mc::Region* region, const void* addr)
 {
   void* res;
   return *(void**)region->read(&res, addr, sizeof(void*));
index 2f50339..4cad251 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -16,19 +16,18 @@ namespace mc {
 /************************************* Take Snapshot ************************************/
 /****************************************************************************************/
 
-void simgrid::mc::Snapshot::snapshot_regions(simgrid::mc::RemoteClient* process)
+void Snapshot::snapshot_regions(RemoteClient* process)
 {
   snapshot_regions_.clear();
 
   for (auto const& object_info : process->object_infos)
-    add_region(simgrid::mc::RegionType::Data, object_info.get(), object_info->start_rw,
-               object_info->end_rw - object_info->start_rw);
+    add_region(RegionType::Data, object_info.get(), object_info->start_rw, object_info->end_rw - object_info->start_rw);
 
-  xbt_mheap_t heap = process->get_heap();
+  const s_xbt_mheap_t* heap = process->get_heap();
   void* start_heap = heap->base;
   void* end_heap   = heap->breakval;
 
-  add_region(simgrid::mc::RegionType::Heap, nullptr, start_heap, (char*)end_heap - (char*)start_heap);
+  add_region(RegionType::Heap, nullptr, start_heap, (char*)end_heap - (char*)start_heap);
   heap_bytes_used_ = mmalloc_get_bytes_used_remote(heap->heaplimit, process->get_malloc_info());
 }
 
@@ -41,7 +40,7 @@ void simgrid::mc::Snapshot::snapshot_regions(simgrid::mc::RemoteClient* process)
  *  @param ip    Instruction pointer
  *  @return      true if the variable is valid
  * */
-static bool valid_variable(simgrid::mc::Variable* var, simgrid::mc::Frame* scope, const void* ip)
+static bool valid_variable(const simgrid::mc::Variable* var, simgrid::mc::Frame* scope, const void* ip)
 {
   // The variable is not yet valid:
   if (scope->range.begin() + var->start_scope > (std::uint64_t)ip)
@@ -50,14 +49,13 @@ static bool valid_variable(simgrid::mc::Variable* var, simgrid::mc::Frame* scope
     return true;
 }
 
-static void fill_local_variables_values(mc_stack_frame_t stack_frame, simgrid::mc::Frame* scope,
+static void fill_local_variables_values(mc_stack_frame_t stack_frame, Frame* scope,
                                         std::vector<s_local_variable_t>& result)
 {
   if (not scope || not scope->range.contain(stack_frame->ip))
     return;
 
-  for (simgrid::mc::Variable& current_variable : scope->variables) {
-
+  for (const Variable& current_variable : scope->variables) {
     if (not valid_variable(&current_variable, scope, (void*)stack_frame->ip))
       continue;
 
@@ -71,14 +69,13 @@ static void fill_local_variables_values(mc_stack_frame_t stack_frame, simgrid::m
     if (current_variable.address != nullptr)
       new_var.address = current_variable.address;
     else if (not current_variable.location_list.empty()) {
-      simgrid::dwarf::Location location = simgrid::dwarf::resolve(
-          current_variable.location_list, current_variable.object_info, &(stack_frame->unw_cursor),
-          (void*)stack_frame->frame_base, &mc_model_checker->process());
+      dwarf::Location location = simgrid::dwarf::resolve(current_variable.location_list, current_variable.object_info,
+                                                         &(stack_frame->unw_cursor), (void*)stack_frame->frame_base,
+                                                         &mc_model_checker->process());
 
       if (not location.in_memory())
         xbt_die("Cannot handle non-address variable");
       new_var.address = location.address();
-
     } else
       xbt_die("No address");
 
@@ -86,7 +83,7 @@ static void fill_local_variables_values(mc_stack_frame_t stack_frame, simgrid::m
   }
 
   // Recursive processing of nested scopes:
-  for (simgrid::mc::Frame& nested_scope : scope->scopes)
+  for (Frame& nested_scope : scope->scopes)
     fill_local_variables_values(stack_frame, &nested_scope, result);
 }
 
@@ -98,9 +95,9 @@ static std::vector<s_local_variable_t> get_local_variables_values(std::vector<s_
   return variables;
 }
 
-static std::vector<s_mc_stack_frame_t> unwind_stack_frames(simgrid::mc::UnwindContext* stack_context)
+static std::vector<s_mc_stack_frame_t> unwind_stack_frames(UnwindContext* stack_context)
 {
-  simgrid::mc::RemoteClient* process = &mc_model_checker->process();
+  const RemoteClient* process = &mc_model_checker->process();
   std::vector<s_mc_stack_frame_t> result;
 
   unw_cursor_t c = stack_context->cursor();
@@ -108,7 +105,6 @@ static std::vector<s_mc_stack_frame_t> unwind_stack_frames(simgrid::mc::UnwindCo
   // TODO, check condition check (unw_init_local==0 means end of frame)
 
   while (1) {
-
     s_mc_stack_frame_t stack_frame;
 
     stack_frame.unw_cursor = c;
@@ -124,7 +120,7 @@ static std::vector<s_mc_stack_frame_t> unwind_stack_frames(simgrid::mc::UnwindCo
 
     // TODO, use real addresses in frame_t instead of fixing it here
 
-    simgrid::mc::Frame* frame = process->find_function(remote(ip));
+    Frame* frame              = process->find_function(remote(ip));
     stack_frame.frame         = frame;
 
     if (frame) {
@@ -153,7 +149,7 @@ static std::vector<s_mc_stack_frame_t> unwind_stack_frames(simgrid::mc::UnwindCo
   return result;
 }
 
-void simgrid::mc::Snapshot::snapshot_stacks(simgrid::mc::RemoteClient* process)
+void Snapshot::snapshot_stacks(RemoteClient* process)
 {
   for (auto const& stack : process->stack_areas()) {
     s_mc_snapshot_stack_t st;
@@ -176,7 +172,7 @@ void simgrid::mc::Snapshot::snapshot_stacks(simgrid::mc::RemoteClient* process)
   }
 }
 
-static void snapshot_handle_ignore(simgrid::mc::Snapshot* snapshot)
+static void snapshot_handle_ignore(Snapshot* snapshot)
 {
   xbt_assert(snapshot->process());
 
@@ -194,14 +190,14 @@ static void snapshot_handle_ignore(simgrid::mc::Snapshot* snapshot)
   for (auto const& region : snapshot->process()->ignored_regions())
     snapshot->process()->clear_bytes(remote(region.addr), region.size);
 }
-static void snapshot_ignore_restore(simgrid::mc::Snapshot* snapshot)
+
+static void snapshot_ignore_restore(const simgrid::mc::Snapshot* snapshot)
 {
   for (auto const& ignored_data : snapshot->ignored_data_)
     snapshot->process()->write_bytes(ignored_data.data.data(), ignored_data.data.size(), remote(ignored_data.start));
 }
 
-Snapshot::Snapshot(int num_state, RemoteClient* process)
-    : AddressSpace(process), num_state_(num_state), heap_bytes_used_(0), enabled_processes_(), hash_(0)
+Snapshot::Snapshot(int num_state, RemoteClient* process) : AddressSpace(process), num_state_(num_state)
 {
   XBT_DEBUG("Taking snapshot %i", num_state);
 
@@ -225,19 +221,19 @@ Snapshot::Snapshot(int num_state, RemoteClient* process)
 
 void Snapshot::add_region(RegionType type, ObjectInformation* object_info, void* start_addr, std::size_t size)
 {
-  if (type == simgrid::mc::RegionType::Data)
+  if (type == RegionType::Data)
     xbt_assert(object_info, "Missing object info for object.");
-  else if (type == simgrid::mc::RegionType::Heap)
+  else if (type == RegionType::Heap)
     xbt_assert(not object_info, "Unexpected object info for heap region.");
 
-  simgrid::mc::Region* region = new Region(type, start_addr, size);
+  Region* region = new Region(type, start_addr, size);
   region->object_info(object_info);
-  snapshot_regions_.push_back(std::unique_ptr<simgrid::mc::Region>(std::move(region)));
+  snapshot_regions_.push_back(std::unique_ptr<Region>(std::move(region)));
 }
 
 void* Snapshot::read_bytes(void* buffer, std::size_t size, RemotePtr<void> address, ReadOptions options) const
 {
-  Region* region = this->get_region((void*)address.address());
+  const Region* region = this->get_region((void*)address.address());
   if (region) {
     void* res = region->read(buffer, (void*)address.address(), size);
     if (buffer == res || options & ReadOptions::lazy())
@@ -281,7 +277,7 @@ void Snapshot::restore(RemoteClient* process)
   XBT_DEBUG("Restore snapshot %i", num_state_);
 
   // Restore regions
-  for (std::unique_ptr<simgrid::mc::Region> const& region : snapshot_regions_) {
+  for (std::unique_ptr<Region> const& region : snapshot_regions_) {
     if (region) // privatized variables are not snapshotted
       region.get()->restore();
   }
index f227fe7..5b8bb66 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -66,7 +66,7 @@ public:
   /* Regular use */
   bool on_heap(const void* address) const
   {
-    const xbt_mheap_t heap = process()->get_heap();
+    const s_xbt_mheap_t* heap = process()->get_heap();
     return address >= heap->heapbase && address < heap->breakval;
   }
 
@@ -78,7 +78,7 @@ public:
 
   // To be private
   int num_state_;
-  std::size_t heap_bytes_used_;
+  std::size_t heap_bytes_used_ = 0;
   std::vector<std::unique_ptr<Region>> snapshot_regions_;
   std::set<pid_t> enabled_processes_;
   std::vector<std::size_t> stack_sizes_;
index cadb7bd..942e88f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -93,7 +93,6 @@ snap_test_helper::prologue_return snap_test_helper::prologue(int n)
 void snap_test_helper::read_whole_region()
 {
   for (int n = 1; n != 32; ++n) {
-
     prologue_return ret = prologue(n);
     const void* read    = ret.region->read(ret.dstn, ret.src, ret.size);
     INFO("Mismatch in MC_region_read()");
@@ -109,7 +108,6 @@ void snap_test_helper::read_whole_region()
 void snap_test_helper::read_region_parts()
 {
   for (int n = 1; n != 32; ++n) {
-
     prologue_return ret = prologue(n);
 
     for (int j = 0; j != 100; ++j) {
@@ -145,7 +143,6 @@ void snap_test_helper::compare_whole_region()
 void snap_test_helper::compare_region_parts()
 {
   for (int n = 1; n != 32; ++n) {
-
     prologue_return ret = prologue(n);
 
     for (int j = 0; j != 100; ++j) {
@@ -165,10 +162,9 @@ void snap_test_helper::compare_region_parts()
 
 void snap_test_helper::read_pointer()
 {
-
   prologue_return ret = prologue(1);
   memcpy(ret.src, &mc_model_checker, sizeof(void*));
-  simgrid::mc::Region* region2 = new simgrid::mc::Region(simgrid::mc::RegionType::Data, ret.src, ret.size);
+  const simgrid::mc::Region* region2 = new simgrid::mc::Region(simgrid::mc::RegionType::Data, ret.src, ret.size);
   INFO("Mismtach in MC_region_read_pointer()");
   REQUIRE(MC_region_read_pointer(region2, ret.src) == mc_model_checker);
 
@@ -183,7 +179,6 @@ void snap_test_helper::read_pointer()
 
 TEST_CASE("MC::Snapshot: A copy/snapshot of a given memory region", "MC::Snapshot")
 {
-
   INFO("Sparse snapshot (using pages)");
 
   snap_test_helper::Init();
index 463619d..8490f78 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -82,7 +82,7 @@ int MSG_comm_test(msg_comm_t comm)
  * @return the position of the finished communication if any
  * (but it may have failed, use MSG_comm_get_status() to know its status), or -1 if none is finished
  */
-int MSG_comm_testany(xbt_dynar_t comms)
+int MSG_comm_testany(const_xbt_dynar_t comms)
 {
   int finished_index = -1;
 
@@ -124,7 +124,7 @@ int MSG_comm_testany(xbt_dynar_t comms)
 }
 
 /** @brief Destroys the provided communication. */
-void MSG_comm_destroy(msg_comm_t comm)
+void MSG_comm_destroy(const_msg_comm_t comm)
 {
   delete comm;
 }
@@ -159,7 +159,7 @@ void MSG_comm_waitall(msg_comm_t* comm, int nb_elem, double timeout)
  * @return the position of the first finished communication
  * (but it may have failed, use MSG_comm_get_status() to know its status)
  */
-int MSG_comm_waitany(xbt_dynar_t comms)
+int MSG_comm_waitany(const_xbt_dynar_t comms)
 {
   int finished_index = -1;
 
@@ -205,9 +205,8 @@ int MSG_comm_waitany(xbt_dynar_t comms)
  * @param comm a finished communication
  * @return the status of the communication, or #MSG_OK if no error occurred during the communication
  */
-msg_error_t MSG_comm_get_status(msg_comm_t comm)
+msg_error_t MSG_comm_get_status(const_msg_comm_t comm)
 {
-
   return comm->get_status();
 }
 
@@ -216,7 +215,7 @@ msg_error_t MSG_comm_get_status(msg_comm_t comm)
  * @param comm the communication where to get the task
  * @return the task from the communication
  */
-msg_task_t MSG_comm_get_task(msg_comm_t comm)
+msg_task_t MSG_comm_get_task(const_msg_comm_t comm)
 {
   xbt_assert(comm, "Invalid parameter");
 
index 9608ac7..6d4b18e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 124b077..da208dd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -47,11 +47,11 @@ int MSG_task_listen(const char* alias)
 }
 
 /* ************************** Actors *************************** */
-int MSG_process_get_PID(sg_actor_t actor)
+int MSG_process_get_PID(const_sg_actor_t actor)
 {
   return sg_actor_get_PID(actor);
 }
-int MSG_process_get_PPID(sg_actor_t actor)
+int MSG_process_get_PPID(const_sg_actor_t actor)
 {
   return sg_actor_get_PPID(actor);
 }
@@ -59,19 +59,19 @@ msg_process_t MSG_process_from_PID(int PID)
 {
   return sg_actor_by_PID(PID);
 }
-const char* MSG_process_get_name(sg_actor_t actor)
+const char* MSG_process_get_name(const_sg_actor_t actor)
 {
   return sg_actor_get_name(actor);
 }
-sg_host_t MSG_process_get_host(sg_actor_t actor)
+sg_host_t MSG_process_get_host(const_sg_actor_t actor)
 {
   return sg_actor_get_host(actor);
 }
-xbt_dict_t MSG_process_get_properties(sg_actor_t actor)
+xbt_dict_t MSG_process_get_properties(const_sg_actor_t actor)
 {
   return sg_actor_get_properties(actor);
 }
-const char* MSG_process_get_property_value(sg_actor_t actor, const char* name)
+const char* MSG_process_get_property_value(const_sg_actor_t actor, const char* name)
 {
   return sg_actor_get_property_value(actor, name);
 }
@@ -139,7 +139,7 @@ msg_error_t MSG_process_sleep(double duration)
  *
  * This function checks whether @a process is a valid pointer and returns the user data associated to this process.
  */
-void* MSG_process_get_data(msg_process_t process)
+void* MSG_process_get_data(const_sg_actor_t process)
 {
   xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
 
@@ -197,12 +197,12 @@ msg_process_t MSG_process_self()
 }
 
 /** @brief Take an extra reference on that process to prevent it to be garbage-collected */
-void MSG_process_ref(msg_process_t process)
+void MSG_process_ref(const_sg_actor_t process)
 {
   sg_actor_ref(process);
 }
 /** @brief Release a reference on that process so that it can get be garbage-collected */
-void MSG_process_unref(msg_process_t process)
+void MSG_process_unref(const_sg_actor_t process)
 {
   sg_actor_unref(process);
 }
@@ -216,7 +216,7 @@ sg_netzone_t MSG_zone_get_root()
 {
   return sg_zone_get_root();
 }
-const char* MSG_zone_get_name(sg_netzone_t zone)
+const char* MSG_zone_get_name(const_sg_netzone_t zone)
 {
   return sg_zone_get_name(zone);
 }
@@ -224,25 +224,25 @@ sg_netzone_t MSG_zone_get_by_name(const char* name)
 {
   return sg_zone_get_by_name(name);
 }
-void MSG_zone_get_sons(sg_netzone_t zone, xbt_dict_t whereto)
+void MSG_zone_get_sons(const_sg_netzone_t zone, xbt_dict_t whereto)
 {
   return sg_zone_get_sons(zone, whereto);
 }
-const char* MSG_zone_get_property_value(sg_netzone_t zone, const char* name)
+const char* MSG_zone_get_property_value(const_sg_netzone_t zone, const char* name)
 {
   return sg_zone_get_property_value(zone, name);
 }
-void MSG_zone_set_property_value(sg_netzone_t zone, const char* name, char* value)
+void MSG_zone_set_property_value(sg_netzone_t zone, const char* name, const char* value)
 {
   sg_zone_set_property_value(zone, name, value);
 }
-void MSG_zone_get_hosts(sg_netzone_t zone, xbt_dynar_t whereto)
+void MSG_zone_get_hosts(const_sg_netzone_t zone, xbt_dynar_t whereto)
 {
   sg_zone_get_hosts(zone, whereto);
 }
 
 /* ************************** Storages *************************** */
-const char* MSG_storage_get_name(sg_storage_t storage)
+const char* MSG_storage_get_name(const_sg_storage_t storage)
 {
   return sg_storage_get_name(storage);
 }
@@ -250,7 +250,7 @@ sg_storage_t MSG_storage_get_by_name(const char* name)
 {
   return sg_storage_get_by_name(name);
 }
-xbt_dict_t MSG_storage_get_properties(sg_storage_t storage)
+xbt_dict_t MSG_storage_get_properties(const_sg_storage_t storage)
 {
   return sg_storage_get_properties(storage);
 }
@@ -258,7 +258,7 @@ void MSG_storage_set_property_value(sg_storage_t storage, const char* name, cons
 {
   sg_storage_set_property_value(storage, name, value);
 }
-const char* MSG_storage_get_property_value(sg_storage_t storage, const char* name)
+const char* MSG_storage_get_property_value(const_sg_storage_t storage, const char* name)
 {
   return sg_storage_get_property_value(storage, name);
 }
@@ -270,11 +270,11 @@ void MSG_storage_set_data(sg_storage_t storage, void* data)
 {
   sg_storage_set_data(storage, data);
 }
-void* MSG_storage_get_data(sg_storage_t storage)
+void* MSG_storage_get_data(const_sg_storage_t storage)
 {
   return sg_storage_get_data(storage);
 }
-const char* MSG_storage_get_host(sg_storage_t storage)
+const char* MSG_storage_get_host(const_sg_storage_t storage)
 {
   return sg_storage_get_host(storage);
 }
@@ -304,11 +304,11 @@ sg_host_t MSG_host_by_name(const char* name)
 {
   return sg_host_by_name(name);
 }
-const char* MSG_host_get_name(sg_host_t host)
+const char* MSG_host_get_name(const_sg_host_t host)
 {
   return sg_host_get_name(host);
 }
-void* MSG_host_get_data(sg_host_t host)
+void* MSG_host_get_data(const_sg_host_t host)
 {
   return sg_host_data(host);
 }
@@ -320,27 +320,27 @@ xbt_dict_t MSG_host_get_mounted_storage_list(sg_host_t host)
 {
   return sg_host_get_mounted_storage_list(host);
 }
-xbt_dynar_t MSG_host_get_attached_storage_lists(sg_host_t host)
+xbt_dynar_t MSG_host_get_attached_storage_lists(const_sg_host_t host)
 {
   return sg_host_get_attached_storage_list(host);
 }
-double MSG_host_get_speed(sg_host_t host)
+double MSG_host_get_speed(const_sg_host_t host)
 {
   return sg_host_speed(host);
 }
-double MSG_host_get_power_peak_at(sg_host_t host, int pstate_index)
+double MSG_host_get_power_peak_at(const_sg_host_t host, int pstate_index)
 {
   return sg_host_get_pstate_speed(host, pstate_index);
 }
-int MSG_host_get_core_number(sg_host_t host)
+int MSG_host_get_core_number(const_sg_host_t host)
 {
   return sg_host_core_count(host);
 }
-int MSG_host_get_nb_pstates(sg_host_t host)
+int MSG_host_get_nb_pstates(const_sg_host_t host)
 {
   return sg_host_get_nb_pstates(host);
 }
-int MSG_host_get_pstate(sg_host_t host)
+int MSG_host_get_pstate(const_sg_host_t host)
 {
   return sg_host_get_pstate(host);
 }
@@ -356,15 +356,15 @@ void MSG_host_off(sg_host_t h)
 {
   sg_host_turn_off(h);
 }
-int MSG_host_is_on(sg_host_t h)
+int MSG_host_is_on(const_sg_host_t h)
 {
   return sg_host_is_on(h);
 }
-xbt_dict_t MSG_host_get_properties(sg_host_t host)
+xbt_dict_t MSG_host_get_properties(const_sg_host_t host)
 {
   return sg_host_get_properties(host);
 }
-const char* MSG_host_get_property_value(sg_host_t host, const char* name)
+const char* MSG_host_get_property_value(const_sg_host_t host, const char* name)
 {
   return sg_host_get_property_value(host, name);
 }
@@ -372,7 +372,7 @@ void MSG_host_set_property_value(sg_host_t host, const char* name, const char* v
 {
   sg_host_set_property_value(host, name, value);
 }
-void MSG_host_get_process_list(sg_host_t host, xbt_dynar_t whereto)
+void MSG_host_get_process_list(const_sg_host_t host, xbt_dynar_t whereto)
 {
   sg_host_get_actor_list(host, whereto);
 }
@@ -381,7 +381,7 @@ sg_host_t MSG_host_self()
   return sg_host_self();
 }
 
-double MSG_host_get_load(sg_host_t host)
+double MSG_host_get_load(const_sg_host_t host)
 {
   return sg_host_load(host);
 }
@@ -406,7 +406,7 @@ int MSG_vm_is_suspended(sg_vm_t vm)
 {
   return sg_vm_is_suspended(vm);
 }
-const char* MSG_vm_get_name(sg_vm_t vm)
+const char* MSG_vm_get_name(const_sg_vm_t vm)
 {
   return sg_vm_get_name(vm);
 }
@@ -414,11 +414,11 @@ void MSG_vm_set_ramsize(sg_vm_t vm, size_t size)
 {
   sg_vm_set_ramsize(vm, size);
 }
-size_t MSG_vm_get_ramsize(sg_vm_t vm)
+size_t MSG_vm_get_ramsize(const_sg_vm_t vm)
 {
   return sg_vm_get_ramsize(vm);
 }
-sg_host_t MSG_vm_get_pm(sg_vm_t vm)
+sg_host_t MSG_vm_get_pm(const_sg_vm_t vm)
 {
   return sg_vm_get_pm(vm);
 }
@@ -452,7 +452,7 @@ sg_bar_t MSG_barrier_init(unsigned int count)
   return sg_barrier_init(count);
 }
 
-void MSG_barrier_destroy(sg_bar_t bar)
+void MSG_barrier_destroy(const_sg_bar_t bar)
 {
   sg_barrier_destroy(bar);
 }
@@ -482,7 +482,7 @@ int MSG_sem_get_capacity(sg_sem_t sem)
 {
   return sg_sem_get_capacity(sem);
 }
-void MSG_sem_destroy(sg_sem_t sem)
+void MSG_sem_destroy(const_sg_sem_t sem)
 {
   sg_sem_destroy(sem);
 }
index 505c892..07d9b49 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -16,6 +16,9 @@
 
 /**************** datatypes **********************************/
 namespace simgrid {
+
+extern template class XBT_PUBLIC xbt::Extendable<msg::Task>;
+
 namespace msg {
 class Task : public xbt::Extendable<Task> {
   std::string name_             = "";
@@ -48,30 +51,30 @@ public:
   Task& operator=(const Task&) = delete;
   ~Task()                      = default;
 
-  bool is_used() { return is_used_; }
-  bool is_parallel() { return parallel_; }
+  bool is_used() const { return is_used_; }
+  bool is_parallel() const { return parallel_; }
 
   void set_used();
   void set_not_used() { this->is_used_ = false; }
   const std::string& get_name() const { return name_; }
-  const char* get_cname() { return name_.c_str(); }
+  const char* get_cname() const { return name_.c_str(); }
   void set_name(const char* new_name) { name_ = std::string(new_name); }
-  void set_tracing_category(const char* category) { tracing_category_ = category ? std::string(category) : ""; }
-  const std::string& get_tracing_category() { return tracing_category_; }
+  void set_tracing_category(const char* category) { tracing_category_ = category ? category : ""; }
+  const std::string& get_tracing_category() const { return tracing_category_; }
   bool has_tracing_category() { return not tracing_category_.empty(); }
   XBT_ATTRIB_DEPRECATED_v329("Please use set_data()") void* get_user_data() { return get_data(); }
   XBT_ATTRIB_DEPRECATED_v329("Please use get_data()") void set_user_data(void* data) { set_data(data); }
-  long long int get_id() { return id_; }
-  double get_priority() { return priority_; }
+  long long int get_id() const { return id_; }
+  double get_priority() const { return priority_; }
   void set_priority(double priority);
   void set_bound(double bound) { bound_ = bound; }
-  double get_bound() { return bound_; }
+  double get_bound() const { return bound_; }
   void set_rate(double rate) { rate_ = rate; }
-  double get_rate() { return rate_; }
+  double get_rate() const { return rate_; }
   void set_timeout(double timeout) { timeout_ = timeout; }
 
-  s4u::Actor* get_sender();
-  s4u::Host* get_source();
+  s4u::Actor* get_sender() const;
+  s4u::Host* get_source() const;
 
   s4u::ExecPtr compute = nullptr; /* S4U modeling of computation */
   s4u::CommPtr comm    = nullptr; /* S4U modeling of communication */
@@ -98,7 +101,7 @@ public:
   bool test();
   msg_error_t wait_for(double timeout);
   void set_status(msg_error_t status) { status_ = status; }
-  msg_error_t get_status() { return status_; }
+  msg_error_t get_status() const { return status_; }
 };
 
 } // namespace msg
index 0997ce7..50e133d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -32,7 +32,7 @@ msg_process_t MSG_process_create(const char *name, xbt_main_func_t code, void *d
  * @param name a name for the object. It is for user-level information and can be nullptr.
  * @param code is a function describing the behavior of the process.
  * @param data a pointer to any data one may want to attach to the new object.  It is for user-level information and
- *        can be nullptr. It can be retrieved with the function @ref MSG_process_get_data.
+ *        can be nullptr. It can be retrieved with the function MSG_process_get_data().
  * @param host the location where the new process is executed.
  * @param argc first argument passed to @a code
  * @param argv second argument passed to @a code
@@ -52,7 +52,7 @@ msg_process_t MSG_process_create_with_arguments(const char *name, xbt_main_func_
  * @param name a name for the object. It is for user-level information and can be nullptr.
  * @param code is a function describing the behavior of the process.
  * @param data a pointer to any data one may want to attach to the new object.  It is for user-level information and
- *        can be nullptr. It can be retrieved with the function @ref MSG_process_get_data.
+ *        can be nullptr. It can be retrieved with the function MSG_process_get_data().
  * @param host the location where the new process is executed.
  * @param argc first argument passed to @a code
  * @param argv second argument passed to @a code. WARNING, these strings are freed by the SimGrid kernel when the
index 9343108..139ebc8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -16,6 +16,9 @@
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_task, msg, "Logging specific to MSG (task)");
 
 namespace simgrid {
+
+template class xbt::Extendable<msg::Task>;
+
 namespace msg {
 
 Task::Task(const std::string& name, double flops_amount, double bytes_amount, void* data)
@@ -75,10 +78,9 @@ msg_error_t Task::execute()
 
     compute->set_name(name_)
         ->set_tracing_category(tracing_category_)
-        ->set_timeout(timeout_)
         ->set_priority(1 / priority_)
         ->set_bound(bound_)
-        ->wait();
+        ->wait_for(timeout_);
 
     set_not_used();
     XBT_DEBUG("Execution task '%s' finished", get_cname());
@@ -162,12 +164,12 @@ void Task::set_priority(double priority)
   priority_ = 1.0 / priority;
 }
 
-s4u::Actor* Task::get_sender()
+s4u::Actor* Task::get_sender() const
 {
   return comm ? comm->get_sender() : nullptr;
 }
 
-s4u::Host* Task::get_source()
+s4u::Host* Task::get_source() const
 {
   return comm ? comm->get_sender()->get_host() : nullptr;
 }
@@ -206,12 +208,12 @@ void Task::report_multiple_use() const
  * @param message_size a value of the amount of data (in bytes) needed to transfer this new task. If 0, then it cannot
  * be transferred with MSG_task_send() and MSG_task_recv(). This value has to be >=0.
  * @param data a pointer to any data may want to attach to the new object.  It is for user-level information and can
- * be nullptr. It can be retrieved with the function @ref MSG_task_get_data.
+ * be nullptr. It can be retrieved with the function MSG_task_get_data().
  * @return The new corresponding object.
  */
 msg_task_t MSG_task_create(const char *name, double flop_amount, double message_size, void *data)
 {
-  return simgrid::msg::Task::create(name ? std::string(name) : "", flop_amount, message_size, data);
+  return simgrid::msg::Task::create(name ? name : "", flop_amount, message_size, data);
 }
 
 /** @brief Creates a new parallel task
@@ -231,7 +233,7 @@ msg_task_t MSG_task_create(const char *name, double flop_amount, double message_
  * @param bytes_amount an array of @p host_nb* @p host_nb doubles.
  * @param data a pointer to any data may want to attach to the new object.
  *             It is for user-level information and can be nullptr.
- *             It can be retrieved with the function @ref MSG_task_get_data().
+ *             It can be retrieved with the function MSG_task_get_data().
  */
 msg_task_t MSG_parallel_task_create(const char *name, int host_nb, const msg_host_t * host_list,
                                     double *flops_amount, double *bytes_amount, void *data)
@@ -242,7 +244,7 @@ msg_task_t MSG_parallel_task_create(const char *name, int host_nb, const msg_hos
 }
 
 /** @brief Return the user data of the given task */
-void* MSG_task_get_data(msg_task_t task)
+void* MSG_task_get_data(const_msg_task_t task)
 {
   return task->get_data();
 }
@@ -254,19 +256,19 @@ void MSG_task_set_data(msg_task_t task, void *data)
 }
 
 /** @brief Returns the sender of the given task */
-msg_process_t MSG_task_get_sender(msg_task_t task)
+msg_process_t MSG_task_get_sender(const_msg_task_t task)
 {
   return task->get_sender();
 }
 
 /** @brief Returns the source (the sender's host) of the given task */
-msg_host_t MSG_task_get_source(msg_task_t task)
+msg_host_t MSG_task_get_source(const_msg_task_t task)
 {
   return task->get_source();
 }
 
 /** @brief Returns the name of the given task. */
-const char *MSG_task_get_name(msg_task_t task)
+const char* MSG_task_get_name(const_msg_task_t task)
 {
   return task->get_cname();
 }
@@ -683,7 +685,7 @@ msg_error_t MSG_task_cancel(msg_task_t task)
  *
  * It works for either parallel or sequential tasks.
  */
-double MSG_task_get_remaining_work_ratio(msg_task_t task)
+double MSG_task_get_remaining_work_ratio(const_msg_task_t task)
 {
   xbt_assert((task != nullptr), "Cannot get information from a nullptr task");
   if (task->compute) {
@@ -702,7 +704,8 @@ double MSG_task_get_remaining_work_ratio(msg_task_t task)
  * It works for sequential tasks, but the remaining amount of work is not a scalar value for parallel tasks.
  * So you will get an exception if you call this function on parallel tasks. Just don't do it.
  */
-double MSG_task_get_flops_amount(msg_task_t task) {
+double MSG_task_get_flops_amount(const_msg_task_t task)
+{
   if (task->compute != nullptr) {
     return task->compute->get_remaining();
   } else {
@@ -738,14 +741,14 @@ void MSG_task_set_bytes_amount(msg_task_t task, double data_size)
  *  If the communication does not exist it will return 0.
  *  So, if the communication has FINISHED or FAILED it returns zero.
  */
-double MSG_task_get_remaining_communication(msg_task_t task)
+double MSG_task_get_remaining_communication(const_msg_task_t task)
 {
   XBT_DEBUG("calling simcall_communication_get_remains(%p)", task->comm.get());
   return task->comm->get_remaining();
 }
 
 /** @brief Returns the size of the data attached to the given task. */
-double MSG_task_get_bytes_amount(msg_task_t task)
+double MSG_task_get_bytes_amount(const_msg_task_t task)
 {
   xbt_assert(task != nullptr, "Invalid parameter");
   return task->bytes_amount;
@@ -776,11 +779,13 @@ void MSG_task_set_bound(msg_task_t task, double bound)
  * @brief Sets the tracing category of a task.
  *
  * This function should be called after the creation of a MSG task, to define the category of that task. The
- * first parameter task must contain a task that was  =created with the function #MSG_task_create. The second
+ * first parameter task must contain a task that was =created with the function MSG_task_create(). The second
  * parameter category must contain a category that was previously declared with the function #TRACE_category
  * (or with #TRACE_category_with_color).
  *
- * See @ref outcomes_vizu for details on how to trace the (categorized) resource utilization.
+ * @beginrst
+ * See :ref:`outcomes_vizu` for details on how to trace the (categorized) resource utilization.
+ * @endrst
  *
  * @param task the task that is going to be categorized
  * @param category the name of the category to be associated to the task
@@ -808,7 +813,7 @@ void MSG_task_set_category(msg_task_t task, const char* category)
  * @param task the task to be considered
  * @return Returns the name of the tracing category of the given task, "" otherwise
  */
-const char* MSG_task_get_category(msg_task_t task)
+const char* MSG_task_get_category(const_msg_task_t task)
 {
   return task->get_tracing_category().c_str();
 }
index ebf4968..1cd921a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -76,7 +76,7 @@ static void on_virtual_machine_creation(simgrid::vm::VirtualMachineImpl& vm)
 static void on_exec_creation(simgrid::s4u::Actor const&, simgrid::s4u::Exec const& e)
 {
   auto exec                        = static_cast<simgrid::kernel::activity::ExecImpl*>(e.get_impl());
-  simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(exec->get_host());
+  const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(exec->get_host());
   if (vm == nullptr)
     return;
 
@@ -90,7 +90,7 @@ static void on_exec_creation(simgrid::s4u::Actor const&, simgrid::s4u::Exec cons
 static void on_exec_completion(simgrid::s4u::Actor const&, simgrid::s4u::Exec const& e)
 {
   auto exec                        = static_cast<simgrid::kernel::activity::ExecImpl*>(e.get_impl());
-  simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(exec->get_host());
+  const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(exec->get_host());
   if (vm == nullptr)
     return;
 
@@ -114,52 +114,52 @@ void sg_vm_dirty_page_tracking_init()
   }
 }
 
-void sg_vm_start_dirty_page_tracking(sg_vm_t vm)
+void sg_vm_start_dirty_page_tracking(const_sg_vm_t vm)
 {
   vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->start_tracking();
 }
 
-void sg_vm_stop_dirty_page_tracking(sg_vm_t vm)
+void sg_vm_stop_dirty_page_tracking(const_sg_vm_t vm)
 {
   vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->stop_tracking();
 }
 
-double sg_vm_lookup_computed_flops(sg_vm_t vm)
+double sg_vm_lookup_computed_flops(const_sg_vm_t vm)
 {
   return vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->computed_flops_lookup();
 }
 
-void sg_vm_set_dirty_page_intensity(sg_vm_t vm, double intensity)
+void sg_vm_set_dirty_page_intensity(const_sg_vm_t vm, double intensity)
 {
   vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->set_intensity(intensity);
 }
 
-double sg_vm_get_dirty_page_intensity(sg_vm_t vm)
+double sg_vm_get_dirty_page_intensity(const_sg_vm_t vm)
 {
   return vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->get_intensity();
 }
 
-void sg_vm_set_working_set_memory(sg_vm_t vm, sg_size_t size)
+void sg_vm_set_working_set_memory(const_sg_vm_t vm, sg_size_t size)
 {
   vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->set_working_set_memory(size);
 }
 
-sg_size_t sg_vm_get_working_set_memory(sg_vm_t vm)
+sg_size_t sg_vm_get_working_set_memory(const_sg_vm_t vm)
 {
   return vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->get_working_set_memory();
 }
 
-void sg_vm_set_migration_speed(sg_vm_t vm, double speed)
+void sg_vm_set_migration_speed(const_sg_vm_t vm, double speed)
 {
   vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->set_migration_speed(speed);
 }
 
-double sg_vm_get_migration_speed(sg_vm_t vm)
+double sg_vm_get_migration_speed(const_sg_vm_t vm)
 {
   return vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->get_migration_speed();
 }
 
-double sg_vm_get_max_downtime(sg_vm_t vm)
+double sg_vm_get_max_downtime(const_sg_vm_t vm)
 {
   return vm->get_impl()->extension<simgrid::vm::DirtyPageTrackingExt>()->get_max_downtime();
 }
index 6b63130..350382a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_file, s4u, "S4U files");
 int sg_storage_max_file_descriptors = 1024;
 
+/** @defgroup plugin_filesystem Plugin FileSystem
+ *
+ * This adds the notion of Files on top of the storage notion that provided by the core of SimGrid.
+ * Activate this plugin at will.
+ */
+
 namespace simgrid {
+
+template class xbt::Extendable<s4u::File>;
+
 namespace s4u {
 simgrid::xbt::Extension<Disk, FileSystemDiskExt> FileSystemDiskExt::EXTENSION_ID;
 simgrid::xbt::Extension<Storage, FileSystemStorageExt> FileSystemStorageExt::EXTENSION_ID;
 simgrid::xbt::Extension<Host, FileDescriptorHostExt> FileDescriptorHostExt::EXTENSION_ID;
 
-File::File(const std::string& fullpath, void* userdata) : File(fullpath, Host::current(), userdata){}
-
-File::File(const std::string& fullpath, sg_host_t host, void* userdata) : fullpath_(fullpath)
+Storage* File::find_local_storage_on(Host* host)
 {
-  this->set_data(userdata);
-  // this cannot fail because we get a xbt_die if the mountpoint does not exist
-  if (not host->get_mounted_storages().empty()) {
-    Storage* st                  = nullptr;
-    size_t longest_prefix_length = 0;
-    XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath_.c_str(), host->get_cname());
+  Storage* st                  = nullptr;
+  size_t longest_prefix_length = 0;
+  XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath_.c_str(), host->get_cname());
 
-    for (auto const& mnt : host->get_mounted_storages()) {
-      XBT_DEBUG("See '%s'", mnt.first.c_str());
-      mount_point_ = fullpath_.substr(0, mnt.first.length());
+  for (auto const& mnt : host->get_mounted_storages()) {
+    XBT_DEBUG("See '%s'", mnt.first.c_str());
+    mount_point_ = fullpath_.substr(0, mnt.first.length());
 
-      if (mount_point_ == mnt.first && mnt.first.length() > longest_prefix_length) {
-        /* The current mount name is found in the full path and is bigger than the previous*/
-        longest_prefix_length = mnt.first.length();
-        st                    = mnt.second;
-      }
+    if (mount_point_ == mnt.first && mnt.first.length() > longest_prefix_length) {
+      /* The current mount name is found in the full path and is bigger than the previous*/
+      longest_prefix_length = mnt.first.length();
+      st                    = mnt.second;
+    }
+  }
+  if (longest_prefix_length > 0) { /* Mount point found, split fullpath_ into mount_name and path+filename*/
+    mount_point_ = fullpath_.substr(0, longest_prefix_length);
+    path_        = fullpath_.substr(longest_prefix_length, fullpath_.length());
+  } else
+    xbt_die("Can't find mount point for '%s' on '%s'", fullpath_.c_str(), host->get_cname());
+
+  return st;
+}
+
+Disk* File::find_local_disk_on(const Host* host)
+{
+  Disk* d                      = nullptr;
+  size_t longest_prefix_length = 0;
+  for (auto const& disk : host->get_disks()) {
+    std::string current_mount;
+    if (disk->get_host() != host)
+      current_mount = disk->extension<FileSystemDiskExt>()->get_mount_point(disk->get_host());
+    else
+      current_mount = disk->extension<FileSystemDiskExt>()->get_mount_point();
+    mount_point_ = fullpath_.substr(0, current_mount.length());
+    if (mount_point_ == current_mount && current_mount.length() > longest_prefix_length) {
+      /* The current mount name is found in the full path and is bigger than the previous*/
+      longest_prefix_length = current_mount.length();
+      d                     = disk;
     }
     if (longest_prefix_length > 0) { /* Mount point found, split fullpath_ into mount_name and path+filename*/
       mount_point_ = fullpath_.substr(0, longest_prefix_length);
-      path_        = fullpath_.substr(longest_prefix_length, fullpath_.length());
+      if (mount_point_ == std::string("/"))
+        path_ = fullpath_;
+      else
+        path_ = fullpath_.substr(longest_prefix_length, fullpath_.length());
+      XBT_DEBUG("%s + %s", mount_point_.c_str(), path_.c_str());
     } else
       xbt_die("Can't find mount point for '%s' on '%s'", fullpath_.c_str(), host->get_cname());
+  }
+  return d;
+}
+
+File::File(const std::string& fullpath, void* userdata) : File(fullpath, Host::current(), userdata) {}
 
-    local_storage_ = st;
+File::File(const std::string& fullpath, sg_host_t host, void* userdata) : fullpath_(fullpath)
+{
+  this->set_data(userdata);
+  // this cannot fail because we get a xbt_die if the mountpoint does not exist
+  if (not host->get_mounted_storages().empty()) {
+    local_storage_ = find_local_storage_on(host);
   }
   if (not host->get_disks().empty()) {
-    Disk* d                      = nullptr;
-    size_t longest_prefix_length = 0;
-    for (auto const& disk : host->get_disks()) {
-      std::string current_mount;
-      if (disk->get_host() != host)
-        current_mount = disk->extension<FileSystemDiskExt>()->get_mount_point(disk->get_host());
-      else
-        current_mount = disk->extension<FileSystemDiskExt>()->get_mount_point();
-      mount_point_              = fullpath_.substr(0, current_mount.length());
-      if (mount_point_ == current_mount && current_mount.length() > longest_prefix_length) {
-        /* The current mount name is found in the full path and is bigger than the previous*/
-        longest_prefix_length = current_mount.length();
-        d                     = disk;
-      }
-      if (longest_prefix_length > 0) { /* Mount point found, split fullpath_ into mount_name and path+filename*/
-        mount_point_ = fullpath_.substr(0, longest_prefix_length);
-        if (mount_point_ == std::string("/"))
-          path_ = fullpath_;
-        else
-          path_ = fullpath_.substr(longest_prefix_length, fullpath_.length());
-        XBT_DEBUG("%s + %s", mount_point_.c_str(), path_.c_str());
-      } else
-        xbt_die("Can't find mount point for '%s' on '%s'", fullpath_.c_str(), host->get_cname());
-    }
-    local_disk_ = d;
+    local_disk_ = find_local_disk_on(host);
   }
 
   // assign a file descriptor id to the newly opened File
@@ -176,81 +195,99 @@ sg_size_t File::read(sg_size_t size)
 }
 
 /** @brief Write into a file (local or remote)
+ * @ingroup plugin_filesystem
  *
  * @param size of the file to write
  * @return the number of bytes successfully write or -1 if an error occurred
  */
-sg_size_t File::write(sg_size_t size, int write_inside)
+sg_size_t File::write_on_disk(sg_size_t size, bool write_inside)
 {
-  if (size == 0) /* Nothing to write, return */
-    return 0;
   sg_size_t write_size = 0;
-  Host* host           = nullptr;
-
   /* Find the host where the file is physically located (remote or local)*/
-  if (local_storage_)
-    host = local_storage_->get_host();
-  if (local_disk_)
-    host = local_disk_->get_host();
+  Host* host = local_disk_->get_host();
 
   if (host && host->get_name() != Host::current()->get_name()) {
     /* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
     XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", host->get_cname(), size);
     Host::current()->send_to(host, size);
   }
-
-  if (local_storage_) {
-    XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu' '%llu:%llu'", get_path(), local_storage_->get_cname(), size,
-              size_, sg_storage_get_size_used(local_storage_), sg_storage_get_size(local_storage_));
-    // If the storage is full before even starting to write
-    if (sg_storage_get_size_used(local_storage_) >= sg_storage_get_size(local_storage_))
-      return 0;
-    if (write_inside == 0) {
-      /* Subtract the part of the file that might disappear from the used sized on the storage element */
-      local_storage_->extension<FileSystemStorageExt>()->decr_used_size(size_ - current_position_);
-      write_size = local_storage_->write(size);
-      local_storage_->extension<FileSystemStorageExt>()->incr_used_size(write_size);
-      current_position_ += write_size;
+  XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu' '%llu:%llu'", get_path(), local_disk_->get_cname(), size, size_,
+            sg_disk_get_size_used(local_disk_), sg_disk_get_size(local_disk_));
+  // If the storage is full before even starting to write
+  if (sg_disk_get_size_used(local_disk_) >= sg_disk_get_size(local_disk_))
+    return 0;
+  if (not write_inside) {
+    /* Subtract the part of the file that might disappear from the used sized on the storage element */
+    local_disk_->extension<FileSystemDiskExt>()->decr_used_size(size_ - current_position_);
+    write_size = local_disk_->write(size);
+    local_disk_->extension<FileSystemDiskExt>()->incr_used_size(write_size);
+    current_position_ += write_size;
+    size_ = current_position_;
+  } else {
+    write_size = local_disk_->write(size);
+    current_position_ += write_size;
+    if (current_position_ > size_)
       size_ = current_position_;
-    } else {
-      write_size = local_storage_->write(size);
-      current_position_ += write_size;
-      if (current_position_ > size_)
-        size_ = current_position_;
-    }
-    std::map<std::string, sg_size_t>* content = local_storage_->extension<FileSystemStorageExt>()->get_content();
+  }
+  std::map<std::string, sg_size_t>* content = local_disk_->extension<FileSystemDiskExt>()->get_content();
 
-    content->erase(path_);
-    content->insert({path_, size_});
+  content->erase(path_);
+  content->insert({path_, size_});
+
+  return write_size;
+}
+
+sg_size_t File::write_on_storage(sg_size_t size, bool write_inside)
+{
+  sg_size_t write_size = 0;
+  /* Find the host where the file is physically located (remote or local)*/
+  Host* host = local_storage_->get_host();
+
+  if (host && host->get_name() != Host::current()->get_name()) {
+    /* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
+    XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", host->get_cname(), size);
+    Host::current()->send_to(host, size);
   }
 
-  if (local_disk_) {
-    XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu' '%llu:%llu'", get_path(), local_disk_->get_cname(), size, size_,
-              sg_disk_get_size_used(local_disk_), sg_disk_get_size(local_disk_));
-    // If the storage is full before even starting to write
-    if (sg_disk_get_size_used(local_disk_) >= sg_disk_get_size(local_disk_))
-      return 0;
-    if (write_inside == 0) {
-      /* Subtract the part of the file that might disappear from the used sized on the storage element */
-      local_disk_->extension<FileSystemDiskExt>()->decr_used_size(size_ - current_position_);
-      write_size = local_disk_->write(size);
-      local_disk_->extension<FileSystemDiskExt>()->incr_used_size(write_size);
-      current_position_ += write_size;
+  XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu' '%llu:%llu'", get_path(), local_storage_->get_cname(), size, size_,
+            sg_storage_get_size_used(local_storage_), sg_storage_get_size(local_storage_));
+  // If the storage is full before even starting to write
+  if (sg_storage_get_size_used(local_storage_) >= sg_storage_get_size(local_storage_))
+    return 0;
+  if (not write_inside) {
+    /* Subtract the part of the file that might disappear from the used sized on the storage element */
+    local_storage_->extension<FileSystemStorageExt>()->decr_used_size(size_ - current_position_);
+    write_size = local_storage_->write(size);
+    local_storage_->extension<FileSystemStorageExt>()->incr_used_size(write_size);
+    current_position_ += write_size;
+    size_ = current_position_;
+  } else {
+    write_size = local_storage_->write(size);
+    current_position_ += write_size;
+    if (current_position_ > size_)
       size_ = current_position_;
-    } else {
-      write_size = local_disk_->write(size);
-      current_position_ += write_size;
-      if (current_position_ > size_)
-        size_ = current_position_;
-    }
-    std::map<std::string, sg_size_t>* content = local_disk_->extension<FileSystemDiskExt>()->get_content();
-
-    content->erase(path_);
-    content->insert({path_, size_});
   }
+  std::map<std::string, sg_size_t>* content = local_storage_->extension<FileSystemStorageExt>()->get_content();
+
+  content->erase(path_);
+  content->insert({path_, size_});
+
   return write_size;
 }
 
+sg_size_t File::write(sg_size_t size, bool write_inside)
+{
+  if (size == 0) /* Nothing to write, return */
+    return 0;
+
+  if (local_disk_)
+    return write_on_disk(size, write_inside);
+  if (local_storage_)
+    return write_on_storage(size, write_inside);
+
+  return 0;
+}
+
 sg_size_t File::size()
 {
   return size_;
@@ -367,10 +404,10 @@ int File::remote_copy(sg_host_t host, const char* fullpath)
   current_position_ += read_size;
 
   Host* dst_host = host;
+  size_t longest_prefix_length = 0;
   if (local_storage_) {
     /* Find the host that owns the storage where the file has to be copied */
-    Storage* storage_dest        = nullptr;
-    size_t longest_prefix_length = 0;
+    const Storage* storage_dest = nullptr;
 
     for (auto const& elm : host->get_mounted_storages()) {
       std::string mount_point = std::string(fullpath).substr(0, elm.first.size());
@@ -391,8 +428,7 @@ int File::remote_copy(sg_host_t host, const char* fullpath)
   }
 
   if (local_disk_) {
-    size_t longest_prefix_length = 0;
-    Disk* dst_disk               = nullptr;
+    const Disk* dst_disk = nullptr;
 
     for (auto const& disk : host->get_disks()) {
       std::string current_mount = disk->extension<FileSystemDiskExt>()->get_mount_point();
@@ -436,7 +472,7 @@ int File::remote_move(sg_host_t host, const char* fullpath)
   return res;
 }
 
-FileSystemDiskExt::FileSystemDiskExt(simgrid::s4u::Disk* ptr)
+FileSystemDiskExt::FileSystemDiskExt(const Disk* ptr)
 {
   const char* size_str    = ptr->get_property("size");
   if (size_str)
@@ -453,10 +489,9 @@ FileSystemDiskExt::FileSystemDiskExt(simgrid::s4u::Disk* ptr)
     content_.reset(parse_content(content_str));
 }
 
-FileSystemStorageExt::FileSystemStorageExt(simgrid::s4u::Storage* ptr)
+FileSystemStorageExt::FileSystemStorageExt(const Storage* ptr) : size_(ptr->get_impl()->size_)
 {
   content_.reset(parse_content(ptr->get_impl()->content_name_));
-  size_    = ptr->get_impl()->size_;
 }
 
 std::map<std::string, sg_size_t>* FileSystemDiskExt::parse_content(const std::string& filename)
@@ -579,6 +614,13 @@ static void on_simulation_end()
 }
 
 /* **************************** Public interface *************************** */
+/** @brief Initialize the file system plugin.
+    @ingroup plugin_filesystem
+
+    @beginrst
+    See the examples in :ref:`s4u_ex_disk_io`.
+    @endrst
+ */
 void sg_storage_file_system_init()
 {
   sg_storage_max_file_descriptors = 1024;
@@ -618,17 +660,23 @@ sg_size_t sg_file_write(sg_file_t fd, sg_size_t size)
   return fd->write(size);
 }
 
-void sg_file_close(sg_file_t fd)
+void sg_file_close(const_sg_file_t fd)
 {
   delete fd;
 }
 
+/** Retrieves the path to the file
+ * @ingroup plugin_filesystem
+ */
 const char* sg_file_get_name(sg_file_t fd)
 {
   xbt_assert((fd != nullptr), "Invalid file descriptor");
   return fd->get_path();
 }
 
+/** Retrieves the size of the file
+ * @ingroup plugin_filesystem
+ */
 sg_size_t sg_file_get_size(sg_file_t fd)
 {
   return fd->size();
@@ -639,19 +687,25 @@ void sg_file_dump(sg_file_t fd)
   fd->dump();
 }
 
-void* sg_file_get_data(sg_file_t fd)
+/** Retrieves the user data associated with the file
+ * @ingroup plugin_filesystem
+ */
+void* sg_file_get_data(const_sg_file_t fd)
 {
   return fd->get_data();
 }
 
+/** Changes the user data associated with the file
+ * @ingroup plugin_filesystem
+ */
 void sg_file_set_data(sg_file_t fd, void* data)
 {
   fd->set_data(data);
 }
 
 /**
- * @brief Set the file position indicator in the sg_file_t by adding offset bytes
- * to the position specified by origin (either SEEK_SET, SEEK_CUR, or SEEK_END).
+ * @brief Set the file position indicator in the sg_file_t by adding offset bytes to the position specified by origin (either SEEK_SET, SEEK_CUR, or SEEK_END).
+ * @ingroup plugin_filesystem
  *
  * @param fd : file object that identifies the stream
  * @param offset : number of bytes to offset from origin
@@ -682,6 +736,8 @@ void sg_file_unlink(sg_file_t fd)
 
 /**
  * @brief Copy a file to another location on a remote host.
+ * @ingroup plugin_filesystem
+ *
  * @param file : the file to move
  * @param host : the remote host where the file has to be copied
  * @param fullpath : the complete path destination on the remote host
@@ -694,6 +750,8 @@ int sg_file_rcopy(sg_file_t file, sg_host_t host, const char* fullpath)
 
 /**
  * @brief Move a file to another location on a remote host.
+ * @ingroup plugin_filesystem
+ *
  * @param file : the file to move
  * @param host : the remote host where the file has to be moved
  * @param fullpath : the complete path destination on the remote host
@@ -704,44 +762,45 @@ int sg_file_rmove(sg_file_t file, sg_host_t host, const char* fullpath)
   return file->remote_move(host, fullpath);
 }
 
-sg_size_t sg_disk_get_size_free(sg_disk_t d)
+sg_size_t sg_disk_get_size_free(const_sg_disk_t d)
 {
   return d->extension<FileSystemDiskExt>()->get_size() - d->extension<FileSystemDiskExt>()->get_used_size();
 }
 
-sg_size_t sg_disk_get_size_used(sg_disk_t d)
+sg_size_t sg_disk_get_size_used(const_sg_disk_t d)
 {
   return d->extension<FileSystemDiskExt>()->get_used_size();
 }
 
-sg_size_t sg_disk_get_size(sg_disk_t d)
+sg_size_t sg_disk_get_size(const_sg_disk_t d)
 {
   return d->extension<FileSystemDiskExt>()->get_size();
 }
 
-const char* sg_disk_get_mount_point(sg_disk_t d)
+const char* sg_disk_get_mount_point(const_sg_disk_t d)
 {
   return d->extension<FileSystemDiskExt>()->get_mount_point();
 }
 
-sg_size_t sg_storage_get_size_free(sg_storage_t st)
+sg_size_t sg_storage_get_size_free(const_sg_storage_t st)
 {
   return st->extension<FileSystemStorageExt>()->get_size() - st->extension<FileSystemStorageExt>()->get_used_size();
 }
 
-sg_size_t sg_storage_get_size_used(sg_storage_t st)
+sg_size_t sg_storage_get_size_used(const_sg_storage_t st)
 {
   return st->extension<FileSystemStorageExt>()->get_used_size();
 }
 
-sg_size_t sg_storage_get_size(sg_storage_t st)
+sg_size_t sg_storage_get_size(const_sg_storage_t st)
 {
   return st->extension<FileSystemStorageExt>()->get_size();
 }
 
-xbt_dict_t sg_storage_get_content(sg_storage_t storage)
+xbt_dict_t sg_storage_get_content(const_sg_storage_t storage)
 {
-  std::map<std::string, sg_size_t>* content = storage->extension<simgrid::s4u::FileSystemStorageExt>()->get_content();
+  const std::map<std::string, sg_size_t>* content =
+      storage->extension<simgrid::s4u::FileSystemStorageExt>()->get_content();
   // Note: ::operator delete is ok here (no destructor called) since the dict elements are of POD type sg_size_t.
   xbt_dict_t content_as_dict = xbt_dict_new_homogeneous(::operator delete);
 
index f714b0f..2232332 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -83,19 +83,17 @@ namespace dvfs {
  *  global configuration
  */
 class Governor {
-
-private:
   simgrid::s4u::Host* const host_;
   double sampling_rate_;
-  int min_pstate; //< Never use a pstate less than this one
-  int max_pstate; //< Never use a pstate larger than this one
+  int min_pstate = cfg_min_pstate; //< Never use a pstate less than this one
+  int max_pstate = cfg_max_pstate; //< Never use a pstate larger than this one
 
 public:
   explicit Governor(simgrid::s4u::Host* ptr)
       : host_(ptr)
-      , min_pstate(cfg_min_pstate)
-      , max_pstate(cfg_max_pstate == max_pstate_not_limited ? host_->get_pstate_count() - 1 : cfg_max_pstate)
   {
+    if (cfg_max_pstate == max_pstate_not_limited)
+      max_pstate = host_->get_pstate_count() - 1;
     init();
   }
   virtual ~Governor() = default;
@@ -307,7 +305,7 @@ public:
     // FIXME I think that this fires at the same time for all hosts, so when the src sends something,
     // the dst will be notified even though it didn't even arrive at the recv yet
     simgrid::s4u::Link::on_communicate.connect(
-        [this](kernel::resource::NetworkAction const&, s4u::Host* src, s4u::Host* dst) {
+        [this](const kernel::resource::NetworkAction&, const s4u::Host* src, const s4u::Host* dst) {
           if ((get_host() == src || get_host() == dst) && iteration_running) {
             post_task();
           }
index c7ea340..1f4ba65 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 SIMGRID_REGISTER_PLUGIN(host_energy, "Cpu energy consumption.", &sg_host_energy_plugin_init)
 
-/** @defgroup plugin_host_energy
+/** @defgroup plugin_host_energy plugin_host_energy Plugin Host Energy
 
   @beginrst
+
 This is the energy plugin, enabling to account not only for computation time, but also for the dissipated energy in the
 simulated platform.
-To activate this plugin, first call :cpp:func:`sg_host_energy_plugin_init()` before your :cpp:func:`MSG_init()`, and then use
-:cpp:func:`MSG_host_get_consumed_energy()` to retrieve the consumption of a given host.
+To activate this plugin, first call :cpp:func:`sg_host_energy_plugin_init()` before your loading your platform, and
+then use :cpp:func:`sg_host_get_consumed_energy()` to retrieve the consumption of a given host.
 
 When the host is on, this energy consumption naturally depends on both the current CPU load and the host energy profile.
 According to our measurements, the consumption is somehow linear in the amount of cores at full speed, with an
-abnormality when all the cores are idle. The full details are in `our scientific paper <https://hal.inria.fr/hal-01523608>`_
-on that topic.
+abnormality when all the cores are idle. The full details are in `our scientific paper
+<https://hal.inria.fr/hal-01523608>`_ on that topic.
 
 As a result, our energy model takes 4 parameters:
 
-  - ``Idle`` wattage (i.e., instantaneous consumption in Watt) when your host is up and running, but without anything to do.
+  - ``Idle`` wattage (i.e., instantaneous consumption in Watt) when your host is up and running, but without anything to
+    do.
   - ``Epsilon`` wattage when all cores are at 0 or epsilon%, but not in Idle state.
   - ``AllCores`` wattage when all cores of the host are at 100%.
   - ``Off`` wattage when the host is turned off.
@@ -91,7 +93,8 @@ This encodes the following values:
    </table>
 
 To change the pstate of a given CPU, use the following functions:
-:cpp:func:`MSG_host_get_nb_pstates()`, :cpp:func:`simgrid::s4u::Host::set_pstate()`, :cpp:func:`MSG_host_get_power_peak_at()`.
+:cpp:func:`MSG_host_get_nb_pstates()`, :cpp:func:`simgrid::s4u::Host::set_pstate()`,
+:cpp:func:`MSG_host_get_power_peak_at()`.
 
 .. raw:: html
 
@@ -134,6 +137,9 @@ class HostEnergy {
    */
   int pstate_           = 0;
   const int pstate_off_ = -1;
+  double watts_off_     = 0.0;              /*< Consumption when the machine is turned off (shutdown) */
+  double total_energy_  = 0.0;              /*< Total energy consumed by the host */
+  double last_updated_  = surf_get_clock(); /*< Timestamp of the last energy update event*/
 
   /* Only used to split total energy into unused/used hosts.
    * If you want to get this info for something else, rather use the host_load plugin
@@ -156,11 +162,8 @@ public:
   double get_watt_min_at(int pstate);
   double get_watt_max_at(int pstate);
   double get_power_range_slope_at(int pstate);
+  double get_last_update_time() { return last_updated_; }
   void update();
-
-  double watts_off_    = 0.0; /*< Consumption when the machine is turned off (shutdown) */
-  double total_energy_ = 0.0; /*< Total energy consumed by the host */
-  double last_updated_;       /*< Timestamp of the last energy update event*/
 };
 
 simgrid::xbt::Extension<simgrid::s4u::Host, HostEnergy> HostEnergy::EXTENSION_ID;
@@ -168,7 +171,7 @@ simgrid::xbt::Extension<simgrid::s4u::Host, HostEnergy> HostEnergy::EXTENSION_ID
 /* Computes the consumption so far. Called lazily on need. */
 void HostEnergy::update()
 {
-  double start_time  = this->last_updated_;
+  double start_time  = last_updated_;
   double finish_time = surf_get_clock();
   //
   // We may have start == finish if the past consumption was updated since the simcall was started
@@ -177,7 +180,7 @@ void HostEnergy::update()
   // Even in this case, we need to save the pstate for the next call (after this if),
   // which may have changed since that recent update.
   if (start_time < finish_time) {
-    double previous_energy = this->total_energy_;
+    double previous_energy = total_energy_;
 
     double instantaneous_power_consumption = this->get_current_watts_value();
 
@@ -185,20 +188,20 @@ void HostEnergy::update()
 
     // TODO Trace: Trace energy_this_step from start_time to finish_time in host->getName()
 
-    this->total_energy_ = previous_energy + energy_this_step;
-    this->last_updated_ = finish_time;
+    total_energy_ = previous_energy + energy_this_step;
+    last_updated_ = finish_time;
 
     XBT_DEBUG("[update_energy of %s] period=[%.8f-%.8f]; current speed=%.2E flop/s (pstate %i); total consumption "
               "before: %.8f J -> added now: %.8f J",
-              host_->get_cname(), start_time, finish_time, host_->get_pstate_speed(this->pstate_), this->pstate_,
-              previous_energy, energy_this_step);
+              host_->get_cname(), start_time, finish_time, host_->get_pstate_speed(pstate_), pstate_, previous_energy,
+              energy_this_step);
   }
 
   /* Save data for the upcoming time interval: whether it's on/off and the pstate if it's on */
-  this->pstate_ = host_->is_on() ? host_->get_pstate() : pstate_off_;
+  pstate_ = host_->is_on() ? host_->get_pstate() : pstate_off_;
 }
 
-HostEnergy::HostEnergy(simgrid::s4u::Host* ptr) : host_(ptr), last_updated_(surf_get_clock())
+HostEnergy::HostEnergy(simgrid::s4u::Host* ptr) : host_(ptr)
 {
   init_watts_range_list();
 
@@ -473,14 +476,14 @@ static void on_action_state_change(simgrid::kernel::resource::CpuAction const& a
     simgrid::s4u::Host* host = cpu->get_host();
     if (host != nullptr) {
       // If it's a VM, take the corresponding PM
-      simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
+      const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
       if (vm) // If it's a VM, take the corresponding PM
         host = vm->get_pm();
 
       // Get the host_energy extension for the relevant host
       HostEnergy* host_energy = host->extension<HostEnergy>();
 
-      if (host_energy->last_updated_ < surf_get_clock())
+      if (host_energy->get_last_update_time() < surf_get_clock())
         host_energy->update();
     }
   }
@@ -529,7 +532,7 @@ static void on_simulation_end()
 
 /** @ingroup plugin_host_energy
  * @brief Enable host energy plugin
- * @details Enable energy plugin to get joules consumption of each cpu. Call this function before #MSG_init().
+ * @details Enable energy plugin to get joules consumption of each cpu. Call this function before loading your platform.
  */
 void sg_host_energy_plugin_init()
 {
@@ -553,7 +556,7 @@ void sg_host_energy_plugin_init()
   simgrid::s4u::Exec::on_start.connect([](simgrid::s4u::Actor const&, simgrid::s4u::Exec const& activity) {
     if (activity.get_host_number() == 1) { // We only run on one host
       simgrid::s4u::Host* host         = activity.get_host();
-      simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
+      const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
       if (vm != nullptr)
         host = vm->get_pm();
       xbt_assert(host != nullptr);
@@ -594,7 +597,7 @@ static void ensure_plugin_inited()
  *  The result is that the actor requesting this value will be interrupted,
  *  the value will be updated in kernel mode before returning the control to the requesting actor.
  */
-double sg_host_get_consumed_energy(sg_host_t host)
+double sg_host_get_consumed_energy(const_sg_host_t host)
 {
   ensure_plugin_inited();
   return host->extension<HostEnergy>()->get_consumed_energy();
@@ -603,7 +606,7 @@ double sg_host_get_consumed_energy(sg_host_t host)
 /** @ingroup plugin_host_energy
  *  @brief Get the amount of watt dissipated when the host is idling
  */
-double sg_host_get_idle_consumption(sg_host_t host)
+double sg_host_get_idle_consumption(const_sg_host_t host)
 {
   ensure_plugin_inited();
   return host->extension<HostEnergy>()->get_watt_idle_at(0);
@@ -612,7 +615,7 @@ double sg_host_get_idle_consumption(sg_host_t host)
 /** @ingroup plugin_host_energy
  *  @brief Get the amount of watt dissipated at the given pstate when the host is idling
  */
-double sg_host_get_idle_consumption_at(sg_host_t host, int pstate)
+double sg_host_get_idle_consumption_at(const_sg_host_t host, int pstate)
 {
   ensure_plugin_inited();
   return host->extension<HostEnergy>()->get_watt_idle_at(pstate);
@@ -621,7 +624,7 @@ double sg_host_get_idle_consumption_at(sg_host_t host, int pstate)
 /** @ingroup plugin_host_energy
  *  @brief Get the amount of watt dissipated at the given pstate when the host is at 0 or epsilon% CPU usage.
  */
-double sg_host_get_wattmin_at(sg_host_t host, int pstate)
+double sg_host_get_wattmin_at(const_sg_host_t host, int pstate)
 {
   ensure_plugin_inited();
   return host->extension<HostEnergy>()->get_watt_min_at(pstate);
@@ -629,7 +632,7 @@ double sg_host_get_wattmin_at(sg_host_t host, int pstate)
 /** @ingroup plugin_host_energy
  *  @brief  Returns the amount of watt dissipated at the given pstate when the host burns CPU at 100%
  */
-double sg_host_get_wattmax_at(sg_host_t host, int pstate)
+double sg_host_get_wattmax_at(const_sg_host_t host, int pstate)
 {
   ensure_plugin_inited();
   return host->extension<HostEnergy>()->get_watt_max_at(pstate);
@@ -637,7 +640,7 @@ double sg_host_get_wattmax_at(sg_host_t host, int pstate)
 /** @ingroup plugin_host_energy
  *  @brief  Returns the power slope at the given pstate
  */
-double sg_host_get_power_range_slope_at(sg_host_t host, int pstate)
+double sg_host_get_power_range_slope_at(const_sg_host_t host, int pstate)
 {
   ensure_plugin_inited();
   return host->extension<HostEnergy>()->get_power_range_slope_at(pstate);
@@ -645,7 +648,7 @@ double sg_host_get_power_range_slope_at(sg_host_t host, int pstate)
 /** @ingroup plugin_host_energy
  *  @brief Returns the current consumption of the host
  */
-double sg_host_get_current_consumption(sg_host_t host)
+double sg_host_get_current_consumption(const_sg_host_t host)
 {
   ensure_plugin_inited();
   return host->extension<HostEnergy>()->get_current_watts_value();
index f84ffc0..f881f1d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 // Makes sure that this plugin can be activated from the command line with ``--cfg=plugin:host_load``
 SIMGRID_REGISTER_PLUGIN(host_load, "Cpu load", &sg_host_load_plugin_init)
 
-/** @defgroup plugin_host_load
+/** @defgroup plugin_host_load Simple plugin that monitors the current load for each host.
 
   @beginrst
-
-Simple plugin that monitors the current load for each host.
-
 In addition, this constitutes a good introductory example on how to write a plugin.
 It attaches an extension to each host to store some data, and places callbacks in the following signals:
 
   - :cpp:member:`simgrid::s4u::Host::on_creation`: Attach a new extension to the newly created host.
   - :cpp:member:`simgrid::s4u::Exec::on_start`: Make note that a new execution started, increasing the load.
   - :cpp:member:`simgrid::s4u::Exec::on_completion`: Make note that an execution completed, decreasing the load.
-  - :cpp:member:`simgrid::s4u::Host::on_state_change`: Do what is appropriate when the host gets suspended, turned off or similar.
+  - :cpp:member:`simgrid::s4u::Host::on_state_change`: Do what is appropriate when the host gets suspended, turned off
+    or similar.
   - :cpp:member:`simgrid::s4u::Host::on_speed_change`: Do what is appropriate when the DVFS is modified.
 
   Note that extensions are automatically destroyed when the host gets destroyed.
@@ -63,7 +61,6 @@ public:
       , last_reset_(surf_get_clock())
       , current_speed_(host_->get_speed())
       , current_flops_(host_->get_load())
-      , theor_max_flops_(0)
   {
   }
   ~HostLoad() = default;
@@ -237,7 +234,7 @@ void sg_host_load_plugin_init()
   simgrid::s4u::Exec::on_start.connect([](simgrid::s4u::Actor const&, simgrid::s4u::Exec const& activity) {
     if (activity.get_host_number() == 1) { // We only run on one host
       simgrid::s4u::Host* host         = activity.get_host();
-      simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
+      const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
       if (vm != nullptr)
         host = vm->get_pm();
       xbt_assert(host != nullptr);
@@ -253,7 +250,7 @@ void sg_host_load_plugin_init()
   simgrid::s4u::Exec::on_completion.connect([](simgrid::s4u::Actor const&, simgrid::s4u::Exec const& activity) {
     if (activity.get_host_number() == 1) { // We only run on one host
       simgrid::s4u::Host* host         = activity.get_host();
-      simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
+      const simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
       if (vm != nullptr)
         host = vm->get_pm();
       xbt_assert(host != nullptr);
@@ -270,7 +267,7 @@ void sg_host_load_plugin_init()
 /** @brief Returns the current load of that host, as a ratio = achieved_flops / (core_current_speed * core_amount)
  *  @ingroup plugin_host_load
  */
-double sg_host_get_current_load(sg_host_t host)
+double sg_host_get_current_load(const_sg_host_t host)
 {
   xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin.");
 
@@ -280,7 +277,7 @@ double sg_host_get_current_load(sg_host_t host)
 /** @brief Returns the current load of that host
  *  @ingroup plugin_host_load
  */
-double sg_host_get_avg_load(sg_host_t host)
+double sg_host_get_avg_load(const_sg_host_t host)
 {
   xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin.");
 
@@ -290,7 +287,7 @@ double sg_host_get_avg_load(sg_host_t host)
 /** @brief Returns the time this host was idle since the last reset
  *  @ingroup plugin_host_load
  */
-double sg_host_get_idle_time(sg_host_t host)
+double sg_host_get_idle_time(const_sg_host_t host)
 {
   xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin.");
 
@@ -300,7 +297,7 @@ double sg_host_get_idle_time(sg_host_t host)
 /** @brief Returns the time this host was idle since the beginning of the simulation
  *  @ingroup plugin_host_load
  */
-double sg_host_get_total_idle_time(sg_host_t host)
+double sg_host_get_total_idle_time(const_sg_host_t host)
 {
   xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin.");
 
@@ -310,7 +307,7 @@ double sg_host_get_total_idle_time(sg_host_t host)
 /** @brief Returns the amount of flops computed by that host since the last reset
  *  @ingroup plugin_host_load
  */
-double sg_host_get_computed_flops(sg_host_t host)
+double sg_host_get_computed_flops(const_sg_host_t host)
 {
   xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin.");
 
@@ -320,7 +317,7 @@ double sg_host_get_computed_flops(sg_host_t host)
 /** @brief Resets the idle time and flops amount of that host
  *  @ingroup plugin_host_load
  */
-void sg_host_load_reset(sg_host_t host)
+void sg_host_load_reset(const_sg_host_t host)
 {
   xbt_assert(HostLoad::EXTENSION_ID.valid(), "Please sg_host_load_plugin_init() to initialize this plugin.");
 
index 3a81581..682d1dc 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -15,7 +15,7 @@
 
 SIMGRID_REGISTER_PLUGIN(link_energy, "Link energy consumption.", &sg_link_energy_plugin_init)
 
-/** @defgroup plugin_link_energy
+/** @defgroup plugin_link_energy Plugin Link Energy
 
  This is the link energy plugin, accounting for the dissipated energy in the simulated platform.
 
@@ -34,8 +34,7 @@ SIMGRID_REGISTER_PLUGIN(link_energy, "Link energy consumption.", &sg_link_energy
  The second property means that when your host is turned off, it will dissipate only 10 Watts (please note that these
  values are arbitrary).
 
- To simulate the energy-related elements, first call the simgrid#energy#sg_link_energy_plugin_init() before your
- #MSG_init(),
+ To simulate the energy-related elements, first call the sg_link_energy_plugin_init() before loading the platform
  and then use the following function to retrieve the consumption of a given link: sg_link_get_consumed_energy().
  */
 
@@ -58,7 +57,7 @@ public:
 private:
   double get_power();
 
-  simgrid::s4u::Link* link_{};
+  s4u::Link* link_{};
 
   bool inited_{false};
   double idle_{0.0};
@@ -68,7 +67,7 @@ private:
   double last_updated_{0.0}; /*< Timestamp of the last energy update event*/
 };
 
-simgrid::xbt::Extension<simgrid::s4u::Link, LinkEnergy> LinkEnergy::EXTENSION_ID;
+xbt::Extension<s4u::Link, LinkEnergy> LinkEnergy::EXTENSION_ID;
 
 void LinkEnergy::update()
 {
@@ -126,7 +125,6 @@ void LinkEnergy::init_watts_range_list()
 
 double LinkEnergy::get_power()
 {
-
   if (!inited_)
     return 0.0;
 
@@ -141,7 +139,7 @@ double LinkEnergy::get_power()
 double LinkEnergy::get_consumed_energy()
 {
   if (last_updated_ < surf_get_clock()) // We need to simcall this as it modifies the environment
-    simgrid::kernel::actor::simcall(std::bind(&LinkEnergy::update, this));
+    kernel::actor::simcall(std::bind(&LinkEnergy::update, this));
   return this->total_energy_;
 }
 } // namespace plugin
@@ -150,12 +148,11 @@ double LinkEnergy::get_consumed_energy()
 using simgrid::plugin::LinkEnergy;
 
 /* **************************** events  callback *************************** */
-static void on_communicate(simgrid::kernel::resource::NetworkAction const& action, simgrid::s4u::Host*,
-                           simgrid::s4u::Host*)
+static void on_communicate(const simgrid::kernel::resource::NetworkAction& action, const simgrid::s4u::Host*,
+                           const simgrid::s4u::Host*)
 {
   XBT_DEBUG("onCommunicate is called");
   for (simgrid::kernel::resource::LinkImpl* link : action.links()) {
-
     if (link == nullptr)
       continue;
 
@@ -187,7 +184,7 @@ int sg_link_energy_is_inited()
 /** @ingroup plugin_link_energy
  * @brief Enable energy plugin
  * @details Enable energy plugin to get joules consumption of each cpu. You should call this function before
- * #MSG_init().
+ * loading your platform.
  */
 void sg_link_energy_plugin_init()
 {
@@ -227,7 +224,7 @@ void sg_link_energy_plugin_init()
  *  The result is that the actor requesting this value will be interrupted,
  *  the value will be updated in kernel mode before returning the control to the requesting actor.
  */
-double sg_link_get_consumed_energy(sg_link_t link)
+double sg_link_get_consumed_energy(const_sg_link_t link)
 {
   if (not LinkEnergy::EXTENSION_ID.valid())
     throw simgrid::xbt::InitializationError("The Energy plugin is not active. Please call sg_link_energy_plugin_init() "
index b7ccd74..2d79dcb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -20,6 +20,9 @@ void surf_vm_model_init_HL13()
 }
 
 namespace simgrid {
+
+template class xbt::Extendable<vm::VirtualMachineImpl>;
+
 namespace vm {
 /*************
  * Callbacks *
@@ -54,20 +57,20 @@ static void host_state_change(s4u::Host const& host)
 
 static void add_active_exec(s4u::Actor const&, s4u::Exec const& task)
 {
-  s4u::VirtualMachine* vm = dynamic_cast<s4u::VirtualMachine*>(task.get_host());
+  const s4u::VirtualMachine* vm = dynamic_cast<s4u::VirtualMachine*>(task.get_host());
   if (vm != nullptr) {
     VirtualMachineImpl* vm_impl = vm->get_impl();
-    vm_impl->active_tasks_      = vm_impl->active_tasks_ + 1;
+    vm_impl->add_active_exec();
     vm_impl->update_action_weight();
   }
 }
 
 static void remove_active_exec(s4u::Actor const&, s4u::Exec const& task)
 {
-  s4u::VirtualMachine* vm = dynamic_cast<s4u::VirtualMachine*>(task.get_host());
+  const s4u::VirtualMachine* vm = dynamic_cast<s4u::VirtualMachine*>(task.get_host());
   if (vm != nullptr) {
     VirtualMachineImpl* vm_impl = vm->get_impl();
-    vm_impl->active_tasks_      = vm_impl->active_tasks_ - 1;
+    vm_impl->remove_active_exec();
     vm_impl->update_action_weight();
   }
 }
@@ -80,20 +83,20 @@ static s4u::VirtualMachine* get_vm_from_activity(kernel::activity::ActivityImpl
 
 static void add_active_activity(kernel::activity::ActivityImpl const& act)
 {
-  s4u::VirtualMachine* vm = get_vm_from_activity(act);
+  const s4u::VirtualMachine* vm = get_vm_from_activity(act);
   if (vm != nullptr) {
     VirtualMachineImpl *vm_impl = vm->get_impl();
-    vm_impl->active_tasks_ = vm_impl->active_tasks_ + 1;
+    vm_impl->add_active_exec();
     vm_impl->update_action_weight();
   }
 }
 
 static void remove_active_activity(kernel::activity::ActivityImpl const& act)
 {
-  s4u::VirtualMachine* vm = get_vm_from_activity(act);
+  const s4u::VirtualMachine* vm = get_vm_from_activity(act);
   if (vm != nullptr) {
     VirtualMachineImpl *vm_impl = vm->get_impl();
-    vm_impl->active_tasks_ = vm_impl->active_tasks_ - 1;
+    vm_impl->remove_active_exec();
     vm_impl->update_action_weight();
   }
 }
@@ -136,11 +139,10 @@ double VMModel::next_occurring_event(double now)
 
   /* iterate for all virtual machines */
   for (s4u::VirtualMachine* const& ws_vm : VirtualMachineImpl::allVms_) {
-    kernel::resource::Cpu* cpu = ws_vm->pimpl_cpu;
+    const kernel::resource::Cpu* cpu = ws_vm->pimpl_cpu;
 
-    double solved_value =
-        ws_vm->get_impl()->action_->get_variable()->get_value(); // this is X1 in comment above, what
-                                                                 // this VM got in the sharing on the PM
+    // solved_value below is X1 in comment above: what this VM got in the sharing on the PM
+    double solved_value = ws_vm->get_impl()->get_action()->get_variable()->get_value();
     XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value, ws_vm->get_cname(), ws_vm->get_pm()->get_cname());
 
     xbt_assert(cpu->get_model() == surf_cpu_model_vm);
@@ -158,7 +160,7 @@ double VMModel::next_occurring_event(double now)
 
 VirtualMachineImpl::VirtualMachineImpl(simgrid::s4u::VirtualMachine* piface, simgrid::s4u::Host* host_PM,
                                        int core_amount, size_t ramsize)
-    : HostImpl(piface), physical_host_(host_PM), core_amount_(core_amount), user_bound_(std::numeric_limits<double>::max()), ramsize_(ramsize)
+    : HostImpl(piface), physical_host_(host_PM), core_amount_(core_amount), ramsize_(ramsize)
 {
   /* Register this VM to the list of all VMs */
   allVms_.push_back(piface);
@@ -318,9 +320,9 @@ void VirtualMachineImpl::set_bound(double bound)
 
 void VirtualMachineImpl::update_action_weight(){
   /* The impact of the VM over its PM is the min between its vCPU amount and the amount of tasks it contains */
-  int impact = std::min(active_tasks_, get_core_amount());
+  int impact = std::min(active_execs_, get_core_amount());
 
-  XBT_DEBUG("set the weight of the dummy CPU action of VM%p on PM to %d (#tasks: %d)", this, impact, active_tasks_);
+  XBT_DEBUG("set the weight of the dummy CPU action of VM%p on PM to %d (#tasks: %u)", this, impact, active_execs_);
 
   if (impact > 0)
     action_->set_sharing_penalty(1. / impact);
index 8f27c16..a3c5464 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -14,6 +14,9 @@
 #define VM_INTERFACE_HPP_
 
 namespace simgrid {
+
+extern template class XBT_PUBLIC xbt::Extendable<vm::VirtualMachineImpl>;
+
 namespace vm {
 
 /************
@@ -28,14 +31,16 @@ class XBT_PUBLIC VirtualMachineImpl : public surf::HostImpl, public simgrid::xbt
   friend simgrid::s4u::VirtualMachine;
 
 public:
-  explicit VirtualMachineImpl(s4u::VirtualMachine* piface, s4u::Host* host, int core_amount, size_t ramsize);
-  ~VirtualMachineImpl();
-
   /** @brief Callbacks fired after VM creation. Signature: `void(VirtualMachineImpl&)` */
   static xbt::signal<void(simgrid::vm::VirtualMachineImpl&)> on_creation;
   /** @brief Callbacks fired after VM destruction. Signature: `void(VirtualMachineImpl const&)` */
   static xbt::signal<void(simgrid::vm::VirtualMachineImpl const&)> on_destruction;
 
+  static std::deque<s4u::VirtualMachine*> allVms_;
+
+  explicit VirtualMachineImpl(s4u::VirtualMachine* piface, s4u::Host* host, int core_amount, size_t ramsize);
+  ~VirtualMachineImpl();
+
   virtual void suspend(kernel::actor::ActorImpl* issuer);
   virtual void resume();
   virtual void shutdown(kernel::actor::ActorImpl* issuer);
@@ -45,30 +50,35 @@ public:
   /** @brief Get the physical host on which the given VM is running */
   s4u::Host* get_physical_host() { return physical_host_; }
 
-  sg_size_t get_ramsize() { return ramsize_; }
+  sg_size_t get_ramsize() const { return ramsize_; }
   void set_ramsize(sg_size_t ramsize) { ramsize_ = ramsize; }
 
-  s4u::VirtualMachine::state get_state() { return vm_state_; }
+  s4u::VirtualMachine::state get_state() const { return vm_state_; }
   void set_state(s4u::VirtualMachine::state state) { vm_state_ = state; }
 
-  int get_core_amount() { return core_amount_; }
+  unsigned int get_core_amount() { return core_amount_; }
+  kernel::resource::Action* get_action() { return action_; }
 
   virtual void set_bound(double bound);
 
-  /* The vm object of the lower layer */
-  kernel::resource::Action* action_ = nullptr;
-  static std::deque<s4u::VirtualMachine*> allVms_;
-  bool is_migrating_ = false;
-  int active_tasks_ = 0;
-
   void update_action_weight();
 
+  void add_active_exec() { active_execs_++; }
+  void remove_active_exec() { active_execs_--; }
+
+  void start_migration() { is_migrating_ = true; }
+  void end_migration() { is_migrating_ = false; }
+  bool is_migrating() const { return is_migrating_; }
+
 private:
+  kernel::resource::Action* action_ = nullptr;
+  unsigned int active_execs_        = 0;
   s4u::Host* physical_host_;
-  int core_amount_;
-  double user_bound_;
-  size_t ramsize_            = 0;
+  unsigned int core_amount_;
+  double user_bound_                   = std::numeric_limits<double>::max();
+  size_t ramsize_                      = 0;
   s4u::VirtualMachine::state vm_state_ = s4u::VirtualMachine::state::CREATED;
+  bool is_migrating_                   = false;
 };
 
 /*********
index 33e4798..7bb0f60 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 61e27f6..47e56ea 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index a828f8a..43f2629 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -13,12 +13,12 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(vm_live_migration, s4u, "S4U virtual machines li
 
 namespace simgrid {
 namespace vm {
-simgrid::xbt::Extension<s4u::Host, VmMigrationExt> VmMigrationExt::EXTENSION_ID;
+xbt::Extension<s4u::Host, VmMigrationExt> VmMigrationExt::EXTENSION_ID;
 
 void VmMigrationExt::ensureVmMigrationExtInstalled()
 {
   if (not EXTENSION_ID.valid())
-    EXTENSION_ID = simgrid::s4u::Host::extension_create<VmMigrationExt>();
+    EXTENSION_ID = s4u::Host::extension_create<VmMigrationExt>();
 }
 
 void MigrationRx::operator()()
@@ -30,7 +30,7 @@ void MigrationRx::operator()()
       std::string("__mig_stage3:") + vm_->get_cname() + "(" + src_pm_->get_cname() + "-" + dst_pm_->get_cname() + ")";
 
   while (not received_finalize) {
-    std::string* payload = static_cast<std::string*>(mbox->get());
+    const std::string* payload = static_cast<std::string*>(mbox->get());
 
     if (finalize_task_name == *payload)
       received_finalize = true;
@@ -50,7 +50,7 @@ void MigrationRx::operator()()
   vm_->resume();
 
   // Now the VM is running on the new host (the migration is completed) (even if the SRC crash)
-  vm_->get_impl()->is_migrating_ = false;
+  vm_->get_impl()->end_migration();
   XBT_DEBUG("VM(%s) moved from PM(%s) to PM(%s)", vm_->get_cname(), src_pm_->get_cname(), dst_pm_->get_cname());
 
   if (TRACE_vm_is_enabled()) {
@@ -59,18 +59,18 @@ void MigrationRx::operator()()
     counter++;
 
     // start link
-    container_t msg = simgrid::instr::Container::by_name(vm_->get_name());
-    simgrid::instr::Container::get_root()->get_link("VM_LINK")->start_event(msg, "M", key);
+    container_t msg = instr::Container::by_name(vm_->get_name());
+    instr::Container::get_root()->get_link("VM_LINK")->start_event(msg, "M", key);
 
     // destroy existing container of this vm
-    simgrid::instr::Container::by_name(vm_->get_name())->remove_from_parent();
+    instr::Container::by_name(vm_->get_name())->remove_from_parent();
 
     // create new container on the new_host location
-    new simgrid::instr::Container(vm_->get_name(), "VM", simgrid::instr::Container::by_name(dst_pm_->get_name()));
+    new instr::Container(vm_->get_name(), "VM", instr::Container::by_name(dst_pm_->get_name()));
 
     // end link
-    msg = simgrid::instr::Container::by_name(vm_->get_name());
-    simgrid::instr::Container::get_root()->get_link("VM_LINK")->end_event(msg, "M", key);
+    msg = instr::Container::by_name(vm_->get_name());
+    instr::Container::get_root()->get_link("VM_LINK")->end_event(msg, "M", key);
   }
   // Inform the SRC that the migration has been correctly performed
   std::string* payload = new std::string("__mig_stage4:");
@@ -181,7 +181,6 @@ void MigrationTx::operator()()
       skip_stage2 = true;
     } else if (sent > ramsize)
       XBT_CRITICAL("bug");
-
   } catch (const Exception&) {
     // hostfailure (if you want to know whether this is the SRC or the DST check directly in send_migration_data code)
     // Stop the dirty page tracking an return (there is no memory space to release)
@@ -203,7 +202,6 @@ void MigrationTx::operator()()
 
   /* Stage2: send update pages iteratively until the size of remaining states becomes smaller than threshold value. */
   if (not skip_stage2) {
-
     int stage2_round = 0;
     /* just after stage1, nothing has been updated. But, we have to send the data updated during stage1 */
     sg_size_t updated_size = get_updated_size(computed_during_stage1, dp_rate, dp_cap);
@@ -213,7 +211,6 @@ void MigrationTx::operator()()
 
     /* When the remaining size is below the threshold value, move to stage 3. */
     while (threshold < remaining_size) {
-
       XBT_DEBUG("mig-stage 2:%d updated_size %llu computed_during_stage1 %f dp_rate %f dp_cap %llu", stage2_round,
                 updated_size, computed_during_stage1, dp_rate, dp_cap);
 
@@ -277,16 +274,16 @@ void MigrationTx::operator()()
   // effectively the VM on the DST node.
   XBT_DEBUG("mig: tx_done");
 }
-}
-}
+} // namespace vm
+} // namespace simgrid
 
 static void onVirtualMachineShutdown(simgrid::s4u::VirtualMachine const& vm)
 {
-  if (vm.get_impl()->is_migrating_) {
+  if (vm.get_impl()->is_migrating()) {
     vm.extension<simgrid::vm::VmMigrationExt>()->rx_->kill();
     vm.extension<simgrid::vm::VmMigrationExt>()->tx_->kill();
     vm.extension<simgrid::vm::VmMigrationExt>()->issuer_->kill();
-    vm.get_impl()->is_migrating_ = false;
+    vm.get_impl()->end_migration();
   }
 }
 
@@ -314,9 +311,9 @@ simgrid::s4u::VirtualMachine* sg_vm_create_migratable(simgrid::s4u::Host* pm, co
   return vm;
 }
 
-int sg_vm_is_migrating(simgrid::s4u::VirtualMachine* vm)
+int sg_vm_is_migrating(const simgrid::s4u::VirtualMachine* vm)
 {
-  return vm->get_impl()->is_migrating_;
+  return vm->get_impl()->is_migrating();
 }
 
 void sg_vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm)
@@ -335,12 +332,12 @@ void sg_vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm)
     throw simgrid::VmFailureException(
         XBT_THROW_POINT,
         simgrid::xbt::string_printf("Cannot migrate VM '%s' that is not running yet.", vm->get_cname()));
-  if (vm->get_impl()->is_migrating_)
+  if (vm->get_impl()->is_migrating())
     throw simgrid::VmFailureException(
         XBT_THROW_POINT,
         simgrid::xbt::string_printf("Cannot migrate VM '%s' that is already migrating.", vm->get_cname()));
 
-  vm->get_impl()->is_migrating_ = true;
+  vm->get_impl()->start_migration();
   simgrid::s4u::VirtualMachine::on_migration_start(*vm);
 
   std::string rx_name =
@@ -363,6 +360,6 @@ void sg_vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm)
   tx->join();
   rx->join();
 
-  vm->get_impl()->is_migrating_ = false;
+  vm->get_impl()->end_migration();
   simgrid::s4u::VirtualMachine::on_migration_end(*vm);
 }
index a981013..13a3fb4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 5917ea2..c689d2d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -122,7 +122,7 @@ void VirtualMachine::destroy()
   Host::destroy();
 }
 
-simgrid::s4u::Host* VirtualMachine::get_pm()
+simgrid::s4u::Host* VirtualMachine::get_pm() const
 {
   return pimpl_vm_->get_physical_host();
 }
@@ -137,7 +137,7 @@ VirtualMachine::state VirtualMachine::get_state()
   return kernel::actor::simcall([this]() { return pimpl_vm_->get_state(); });
 }
 
-size_t VirtualMachine::get_ramsize()
+size_t VirtualMachine::get_ramsize() const
 {
   return pimpl_vm_->get_ramsize();
 }
@@ -197,13 +197,13 @@ sg_vm_t sg_vm_create_multicore(sg_host_t pm, const char* name, int coreAmount)
   return new simgrid::s4u::VirtualMachine(name, pm, coreAmount);
 }
 
-const char* sg_vm_get_name(sg_vm_t vm)
+const char* sg_vm_get_name(const_sg_vm_t vm)
 {
   return vm->get_cname();
 }
 
 /** @brief Get the physical host of a given VM. */
-sg_host_t sg_vm_get_pm(sg_vm_t vm)
+sg_host_t sg_vm_get_pm(const_sg_vm_t vm)
 {
   return vm->get_pm();
 }
@@ -213,7 +213,7 @@ void sg_vm_set_ramsize(sg_vm_t vm, size_t size)
   vm->set_ramsize(size);
 }
 
-size_t sg_vm_get_ramsize(sg_vm_t vm)
+size_t sg_vm_get_ramsize(const_sg_vm_t vm)
 {
   return vm->get_ramsize();
 }
@@ -270,9 +270,14 @@ void sg_vm_resume(sg_vm_t vm)
 }
 
 /** @brief Immediately kills all processes within the given VM.
- * Any memory that they allocated will be leaked, unless you used #MSG_process_on_exit().
  *
- * No extra delay occurs. If you want to simulate this too, you want to use a #MSG_process_sleep().
+ @beginrst
+ The memory allocated by these actors is leaked, unless you used :cpp:func:`simgrid::s4u::Actor::on_exit`.
+  
+ @endrst
+ * 
+ * No extra delay occurs by default. You may let your actor sleep by a specific amount to simulate any extra delay that you want.
  */
 void sg_vm_shutdown(sg_vm_t vm)
 {
index e52b3f2..374eaea 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 0ac6454..9069f5e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -21,6 +21,9 @@
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_actor, s4u, "S4U actors");
 
 namespace simgrid {
+
+template class xbt::Extendable<s4u::Actor>;
+
 namespace s4u {
 
 xbt::signal<void(Actor&)> s4u::Actor::on_creation;
@@ -70,15 +73,15 @@ ActorPtr Actor::create(const std::string& name, s4u::Host* host, const std::func
 ActorPtr Actor::create(const std::string& name, s4u::Host* host, const std::string& function,
                        std::vector<std::string> args)
 {
-  simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(function);
+  const simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(function);
   return create(name, host, factory(std::move(args)));
 }
 
-void intrusive_ptr_add_ref(Actor* actor)
+void intrusive_ptr_add_ref(const Actor* actor)
 {
   intrusive_ptr_add_ref(actor->pimpl_);
 }
-void intrusive_ptr_release(Actor* actor)
+void intrusive_ptr_release(const Actor* actor)
 {
   intrusive_ptr_release(actor->pimpl_);
 }
@@ -138,7 +141,7 @@ void Actor::set_host(Host* new_host)
     s4u::Actor::on_migration_start(*this);
   }
 
-  auto* previous_location = get_host();
+  const s4u::Host* previous_location = get_host();
 
   kernel::actor::simcall([this, new_host]() {
     if (pimpl_->waiting_synchro != nullptr) {
@@ -345,11 +348,22 @@ void execute(double flops, double priority)
 void parallel_execute(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
                       const std::vector<double>& bytes_amounts)
 {
-  parallel_execute(hosts, flops_amounts, bytes_amounts, -1);
+  exec_init(hosts, flops_amounts, bytes_amounts)->wait();
 }
 
 void parallel_execute(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
-                      const std::vector<double>& bytes_amounts, double timeout)
+                      const std::vector<double>& bytes_amounts, double timeout) // XBT_ATTRIB_DEPRECATED_v329
+{
+  exec_init(hosts, flops_amounts, bytes_amounts)->wait_for(timeout);
+}
+
+ExecPtr exec_init(double flops_amount)
+{
+  return ExecPtr(new ExecSeq(get_host(), flops_amount));
+}
+
+ExecPtr exec_init(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
+                  const std::vector<double>& bytes_amounts)
 {
   xbt_assert(hosts.size() > 0, "Your parallel executions must span over at least one host.");
   xbt_assert(hosts.size() == flops_amounts.size() || flops_amounts.empty(),
@@ -371,17 +385,6 @@ void parallel_execute(const std::vector<s4u::Host*>& hosts, const std::vector<do
   xbt_assert(std::all_of(bytes_amounts.begin(), bytes_amounts.end(), [](double elm) { return std::isfinite(elm); }),
              "flops_amounts comprises infinite values!");
 
-  exec_init(hosts, flops_amounts, bytes_amounts)->set_timeout(timeout)->wait();
-}
-
-ExecPtr exec_init(double flops_amount)
-{
-  return ExecPtr(new ExecSeq(get_host(), flops_amount));
-}
-
-ExecPtr exec_init(const std::vector<s4u::Host*>& hosts, const std::vector<double>& flops_amounts,
-                  const std::vector<double>& bytes_amounts)
-{
   return ExecPtr(new ExecPar(hosts, flops_amounts, bytes_amounts));
 }
 
@@ -424,13 +427,6 @@ void suspend()
   kernel::actor::simcall_blocking<void>([self] { self->suspend(); });
 }
 
-void resume()
-{
-  kernel::actor::ActorImpl* self = simgrid::kernel::actor::ActorImpl::self();
-  kernel::actor::simcall([self] { self->resume(); });
-  Actor::on_resume(*self->ciface());
-}
-
 void exit()
 {
   kernel::actor::ActorImpl* self = simgrid::kernel::actor::ActorImpl::self();
@@ -479,7 +475,7 @@ void sg_actor_start(sg_actor_t actor, xbt_main_func_t code, int argc, char** arg
  *
  * This function checks whether @a actor is a valid pointer and return its PID (or 0 in case of problem).
  */
-aid_t sg_actor_get_PID(sg_actor_t actor)
+aid_t sg_actor_get_PID(const_sg_actor_t actor)
 {
   /* Do not raise an exception here: this function is called by the logs
    * and the exceptions, so it would be called back again and again */
@@ -494,7 +490,7 @@ aid_t sg_actor_get_PID(sg_actor_t actor)
  * This function checks whether @a actor is a valid pointer and return its parent's PID.
  * Returns -1 if the actor has not been created by any other actor.
  */
-aid_t sg_actor_get_PPID(sg_actor_t actor)
+aid_t sg_actor_get_PPID(const_sg_actor_t actor)
 {
   return actor->get_ppid();
 }
@@ -515,12 +511,12 @@ sg_actor_t sg_actor_by_PID(aid_t pid)
 /** @ingroup m_actor_management
  * @brief Return the name of an actor.
  */
-const char* sg_actor_get_name(sg_actor_t actor)
+const char* sg_actor_get_name(const_sg_actor_t actor)
 {
   return actor->get_cname();
 }
 
-sg_host_t sg_actor_get_host(sg_actor_t actor)
+sg_host_t sg_actor_get_host(const_sg_actor_t actor)
 {
   return actor->get_host();
 }
@@ -532,7 +528,7 @@ sg_host_t sg_actor_get_host(sg_actor_t actor)
  * @param name a property name
  * @return value of a property (or nullptr if the property is not set)
  */
-const char* sg_actor_get_property_value(sg_actor_t actor, const char* name)
+const char* sg_actor_get_property_value(const_sg_actor_t actor, const char* name)
 {
   return actor->get_property(name);
 }
@@ -542,7 +538,7 @@ const char* sg_actor_get_property_value(sg_actor_t actor, const char* name)
  *
  * This function returns all the parameters associated with an actor
  */
-xbt_dict_t sg_actor_get_properties(sg_actor_t actor)
+xbt_dict_t sg_actor_get_properties(const_sg_actor_t actor)
 {
   xbt_assert(actor != nullptr, "Invalid parameter: First argument must not be nullptr");
   xbt_dict_t as_dict                        = xbt_dict_new_homogeneous(xbt_free_f);
@@ -735,12 +731,12 @@ void sg_actor_self_execute(double flops)
 }
 
 /** @brief Take an extra reference on that actor to prevent it to be garbage-collected */
-void sg_actor_ref(sg_actor_t actor)
+void sg_actor_ref(const_sg_actor_t actor)
 {
   intrusive_ptr_add_ref(actor);
 }
 /** @brief Release a reference on that actor so that it can get be garbage-collected */
-void sg_actor_unref(sg_actor_t actor)
+void sg_actor_unref(const_sg_actor_t actor)
 {
   intrusive_ptr_release(actor);
 }
index 7289a6c..d031081 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -17,11 +17,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_barrier, s4u, "S4U barrier");
 namespace simgrid {
 namespace s4u {
 
-Barrier::Barrier(unsigned int expected_processes)
-    : mutex_(Mutex::create()), cond_(ConditionVariable::create()), expected_actors_(expected_processes)
-{
-}
-
 /** @brief Create a new barrier
  *
  * See @ref s4u_raii.
@@ -79,7 +74,7 @@ sg_bar_t sg_barrier_init(unsigned int count)
 }
 
 /** @brief Initializes a barrier, with count elements */
-void sg_barrier_destroy(sg_bar_t bar)
+void sg_barrier_destroy(const_sg_bar_t bar)
 {
   delete bar;
 }
index 9b9ac8b..b9a8811 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -31,7 +31,7 @@ Comm::~Comm()
   }
 }
 
-int Comm::wait_any_for(std::vector<CommPtr>* comms, double timeout)
+int Comm::wait_any_for(const std::vector<CommPtr>* comms, double timeout)
 {
   std::unique_ptr<kernel::activity::CommImpl* []> rcomms(new kernel::activity::CommImpl*[comms->size()]);
   std::transform(begin(*comms), end(*comms), rcomms.get(),
@@ -39,7 +39,7 @@ int Comm::wait_any_for(std::vector<CommPtr>* comms, double timeout)
   return simcall_comm_waitany(rcomms.get(), comms->size(), timeout);
 }
 
-void Comm::wait_all(std::vector<CommPtr>* comms)
+void Comm::wait_all(const std::vector<CommPtr>* comms)
 {
   // TODO: this should be a simcall or something
   // TODO: we are missing a version with timeout
@@ -182,7 +182,7 @@ Comm* Comm::wait_for(double timeout)
   }
   return this;
 }
-int Comm::test_any(std::vector<CommPtr>* comms)
+int Comm::test_any(const std::vector<CommPtr>* comms)
 {
   std::unique_ptr<kernel::activity::CommImpl* []> rcomms(new kernel::activity::CommImpl*[comms->size()]);
   std::transform(begin(*comms), end(*comms), rcomms.get(),
index 0e9683f..c95fc4f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -20,7 +20,7 @@ ConditionVariablePtr ConditionVariable::create()
 {
   kernel::activity::ConditionVariableImpl* cond =
       kernel::actor::simcall([] { return new kernel::activity::ConditionVariableImpl(); });
-  return ConditionVariablePtr(&cond->cond_, false);
+  return ConditionVariablePtr(cond->get_iface(), false);
 }
 
 /**
@@ -31,12 +31,12 @@ void ConditionVariable::wait(MutexPtr lock)
   simcall_cond_wait(cond_, lock->pimpl_);
 }
 
-void ConditionVariable::wait(std::unique_lock<Mutex>& lock)
+void ConditionVariable::wait(const std::unique_lock<Mutex>& lock)
 {
   simcall_cond_wait(cond_, lock.mutex()->pimpl_);
 }
 
-std::cv_status s4u::ConditionVariable::wait_for(std::unique_lock<Mutex>& lock, double timeout)
+std::cv_status s4u::ConditionVariable::wait_for(const std::unique_lock<Mutex>& lock, double timeout)
 {
   // The simcall uses -1 for "any timeout" but we don't want this:
   if (timeout < 0)
@@ -51,7 +51,7 @@ std::cv_status s4u::ConditionVariable::wait_for(std::unique_lock<Mutex>& lock, d
   }
 }
 
-std::cv_status ConditionVariable::wait_until(std::unique_lock<Mutex>& lock, double timeout_time)
+std::cv_status ConditionVariable::wait_until(const std::unique_lock<Mutex>& lock, double timeout_time)
 {
   double now = SIMIX_get_clock();
   double timeout;
@@ -75,12 +75,12 @@ void ConditionVariable::notify_all()
   simgrid::kernel::actor::simcall([this]() { cond_->broadcast(); });
 }
 
-void intrusive_ptr_add_ref(ConditionVariable* cond)
+void intrusive_ptr_add_ref(const ConditionVariable* cond)
 {
   intrusive_ptr_add_ref(cond->cond_);
 }
 
-void intrusive_ptr_release(ConditionVariable* cond)
+void intrusive_ptr_release(const ConditionVariable* cond)
 {
   intrusive_ptr_release(cond->cond_);
 }
@@ -118,7 +118,7 @@ void sg_cond_notify_all(sg_cond_t cond)
   cond->notify_all();
 }
 
-void sg_cond_destroy(sg_cond_t cond)
+void sg_cond_destroy(const_sg_cond_t cond)
 {
   delete cond;
 }
index 153a65c..684cbab 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -10,9 +10,8 @@
 #include "src/kernel/resource/DiskImpl.hpp"
 
 namespace simgrid {
-namespace xbt {
-template class Extendable<s4u::Disk>;
-} // namespace xbt
+
+template class xbt::Extendable<s4u::Disk>;
 
 namespace s4u {
 
@@ -25,12 +24,12 @@ double Disk::get_read_bandwidth() const
   return this->pimpl_->get_read_bandwidth();
 }
 
-double Disk::get_write_bandwidth()
+double Disk::get_write_bandwidth() const
 {
   return pimpl_->get_write_bandwidth();
 }
 
-Host* Disk::get_host()
+Host* Disk::get_host() const
 {
   return pimpl_->get_host();
 }
@@ -67,7 +66,6 @@ sg_size_t Disk::read(sg_size_t size)
 
 IoPtr Disk::write_async(sg_size_t size)
 {
-
   return IoPtr(io_init(size, Io::OpType::WRITE)->start());
 }
 
index 583175b..6b00aa9 100644 (file)
@@ -1,6 +1,6 @@
 /* s4u::Engine Simulation Engine and global functions. */
 
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -194,7 +194,7 @@ Link* Engine::link_by_name_or_null(const std::string& name)
   return link == pimpl->links_.end() ? nullptr : link->second->get_iface();
 }
 
-void Engine::link_register(const std::string& name, Link* link)
+void Engine::link_register(const std::string& name, const Link* link)
 {
   pimpl->links_[name] = link->get_impl();
 }
@@ -238,7 +238,7 @@ Storage* Engine::storage_by_name_or_null(const std::string& name)
   return storage == pimpl->storages_.end() ? nullptr : storage->second->get_iface();
 }
 
-void Engine::storage_register(const std::string& name, Storage* storage)
+void Engine::storage_register(const std::string& name, const Storage* storage)
 {
   pimpl->storages_[name] = storage->get_impl();
 }
@@ -283,7 +283,7 @@ std::vector<ActorPtr> Engine::get_all_actors()
 {
   std::vector<ActorPtr> actor_list;
   actor_list.push_back(simgrid::s4u::Actor::self());
-  for (auto& kv : simix_global->process_list) {
+  for (auto const& kv : simix_global->process_list) {
     actor_list.push_back(kv.second->iface());
   }
   return actor_list;
@@ -292,7 +292,7 @@ std::vector<ActorPtr> Engine::get_all_actors()
 std::vector<ActorPtr> Engine::get_filtered_actors(const std::function<bool(ActorPtr)>& filter)
 {
   std::vector<ActorPtr> actor_list;
-  for (auto& kv : simix_global->process_list) {
+  for (auto const& kv : simix_global->process_list) {
     if (filter(kv.second->iface()))
       actor_list.push_back(kv.second->iface());
   }
@@ -318,7 +318,7 @@ s4u::NetZone* Engine::get_netzone_root()
   return pimpl->netzone_root_->get_iface();
 }
 /** @brief Set the root netzone, containing all others. Once set, it cannot be changed. */
-void Engine::set_netzone_root(s4u::NetZone* netzone)
+void Engine::set_netzone_root(const s4u::NetZone* netzone)
 {
   xbt_assert(pimpl->netzone_root_ == nullptr, "The root NetZone cannot be changed once set");
   pimpl->netzone_root_ = netzone->get_impl();
@@ -362,9 +362,7 @@ std::vector<kernel::routing::NetPoint*> Engine::get_all_netpoints()
 /** @brief Register a new netpoint to the system */
 void Engine::netpoint_register(kernel::routing::NetPoint* point)
 {
-  // simgrid::kernel::actor::simcall([&]{ FIXME: this segfaults in set_thread
-  pimpl->netpoints_[point->get_name()] = point;
-  // });
+  simgrid::kernel::actor::simcall([this, point] { pimpl->netpoints_[point->get_name()] = point; });
 }
 
 /** @brief Unregister a given netpoint */
index cf38325..ba92439 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -40,27 +40,31 @@ bool Exec::test()
 }
 
 Exec* Exec::wait()
+{
+  return this->wait_for(-1);
+}
+
+Exec* Exec::wait_for(double timeout)
 {
   if (state_ == State::INITED)
-    start();
-  simcall_execution_wait(pimpl_);
+    vetoable_start();
+  simcall_execution_wait(pimpl_, timeout);
   state_ = State::FINISHED;
   on_completion(*Actor::self(), *this);
   this->release_dependencies();
   return this;
 }
 
-Exec* Exec::wait_for(double)
-{
-  THROW_UNIMPLEMENTED;
-}
-
 int Exec::wait_any_for(std::vector<ExecPtr>* execs, double timeout)
 {
   std::unique_ptr<kernel::activity::ExecImpl* []> rexecs(new kernel::activity::ExecImpl*[execs->size()]);
   std::transform(begin(*execs), end(*execs), rexecs.get(),
                  [](const ExecPtr& exec) { return static_cast<kernel::activity::ExecImpl*>(exec->pimpl_.get()); });
-  return simcall_execution_waitany_for(rexecs.get(), execs->size(), timeout);
+
+  int changed_pos = simcall_execution_waitany_for(rexecs.get(), execs->size(), timeout);
+  if (changed_pos != -1)
+    execs->at(changed_pos)->release_dependencies();
+  return changed_pos;
 }
 
 Exec* Exec::cancel()
@@ -80,7 +84,7 @@ ExecPtr Exec::set_bound(double bound)
   bound_ = bound;
   return this;
 }
-ExecPtr Exec::set_timeout(double timeout)
+ExecPtr Exec::set_timeout(double timeout) // XBT_ATTRIB_DEPRECATED_v329
 {
   xbt_assert(state_ == State::INITED, "Cannot change the bound of an exec after its start");
   timeout_ = timeout;
index 94d7900..038bb3e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -18,9 +18,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_host, s4u, "Logging specific to the S4U host
 XBT_LOG_EXTERNAL_CATEGORY(surf_route);
 
 namespace simgrid {
-namespace xbt {
-template class Extendable<s4u::Host>;
-} // namespace xbt
+
+template class xbt::Extendable<s4u::Host>;
 
 namespace s4u {
 
@@ -126,13 +125,13 @@ int Host::get_pstate_count() const
  *
  * Daemons and regular actors are all mixed in this list.
  */
-std::vector<ActorPtr> Host::get_all_actors()
+std::vector<ActorPtr> Host::get_all_actors() const
 {
   return pimpl_->get_all_actors();
 }
 
 /** @brief Returns how many actors (daemonized or not) have been launched on this host */
-int Host::get_actor_count()
+int Host::get_actor_count() const
 {
   return pimpl_->get_actor_count();
 }
@@ -149,7 +148,7 @@ int Host::get_actor_count()
  * walk through the routing components tree and find a route between hosts
  * by calling each "get_route" function in each routing component.
  */
-void Host::route_to(Host* dest, std::vector<Link*>& links, double* latency)
+void Host::route_to(const Host* dest, std::vector<Link*>& links, double* latency) const
 {
   std::vector<kernel::resource::LinkImpl*> linkImpls;
   this->route_to(dest, linkImpls, latency);
@@ -158,7 +157,7 @@ void Host::route_to(Host* dest, std::vector<Link*>& links, double* latency)
 }
 
 /** @brief Just like Host::routeTo, but filling an array of link implementations */
-void Host::route_to(Host* dest, std::vector<kernel::resource::LinkImpl*>& links, double* latency)
+void Host::route_to(const Host* dest, std::vector<kernel::resource::LinkImpl*>& links, double* latency) const
 {
   kernel::routing::NetZoneImpl::get_global_route(pimpl_netpoint_, dest->get_netpoint(), links, latency);
   if (XBT_LOG_ISENABLED(surf_route, xbt_log_priority_debug)) {
@@ -308,12 +307,9 @@ std::vector<const char*> Host::get_attached_storages() const
 
 std::unordered_map<std::string, Storage*> const& Host::get_mounted_storages()
 {
-  if (mounts_ == nullptr) {
-    mounts_ = new std::unordered_map<std::string, Storage*>();
-    for (auto const& m : this->pimpl_->storage_) {
-      mounts_->insert({m.first, m.second->get_iface()});
-    }
-  }
+  if (mounts_ == nullptr)
+    mounts_ = pimpl_->get_mounted_storages();
+
   return *mounts_;
 }
 
@@ -361,12 +357,12 @@ sg_host_t* sg_host_list()
   return res;
 }
 
-const char* sg_host_get_name(sg_host_t host)
+const char* sg_host_get_name(const_sg_host_t host)
 {
   return host->get_cname();
 }
 
-void* sg_host_extension_get(sg_host_t host, size_t ext)
+void* sg_host_extension_get(const_sg_host_t host, size_t ext)
 {
   return host->extension(ext);
 }
@@ -399,7 +395,7 @@ xbt_dynar_t sg_hosts_as_dynar()
 // ========= Layering madness ==============*
 
 // ========== User data Layer ==========
-void* sg_host_data(sg_host_t host)
+void* sg_host_data(const_sg_host_t host)
 {
   return host->get_data();
 }
@@ -427,14 +423,14 @@ xbt_dict_t sg_host_get_mounted_storage_list(sg_host_t host)
   xbt_dict_t res = xbt_dict_new_homogeneous(nullptr);
   for (auto const& elm : host->get_mounted_storages()) {
     const char* mount_name = elm.first.c_str();
-    sg_storage_t storage   = elm.second;
+    const simgrid::s4u::Storage* storage = elm.second;
     xbt_dict_set(res, mount_name, (void*)storage->get_cname());
   }
 
   return res;
 }
 
-xbt_dynar_t sg_host_get_attached_storage_list(sg_host_t host)
+xbt_dynar_t sg_host_get_attached_storage_list(const_sg_host_t host)
 {
   xbt_dynar_t storage_dynar               = xbt_dynar_new(sizeof(const char*), nullptr);
   std::vector<const char*> storage_vector = host->get_attached_storages();
@@ -446,7 +442,7 @@ xbt_dynar_t sg_host_get_attached_storage_list(sg_host_t host)
 // =========== user-level functions ===============
 // ================================================
 /** @brief Returns the total speed of a host */
-double sg_host_speed(sg_host_t host)
+double sg_host_speed(const_sg_host_t host)
 {
   return host->get_speed();
 }
@@ -457,7 +453,7 @@ double sg_host_speed(sg_host_t host)
  * @param pstate_index pstate to test
  * @return Returns the processor speed associated with pstate_index
  */
-double sg_host_get_pstate_speed(sg_host_t host, int pstate_index)
+double sg_host_get_pstate_speed(const_sg_host_t host, int pstate_index)
 {
   return host->get_pstate_speed(pstate_index);
 }
@@ -468,12 +464,12 @@ double sg_host_get_pstate_speed(sg_host_t host, int pstate_index)
  * @param host a host
  * @return the number of cores
  */
-int sg_host_core_count(sg_host_t host)
+int sg_host_core_count(const_sg_host_t host)
 {
   return host->get_core_count();
 }
 
-double sg_host_get_available_speed(sg_host_t host)
+double sg_host_get_available_speed(const_sg_host_t host)
 {
   return host->get_available_speed();
 }
@@ -482,7 +478,7 @@ double sg_host_get_available_speed(sg_host_t host)
  *
  *  See also @ref plugin_energy.
  */
-int sg_host_get_nb_pstates(sg_host_t host)
+int sg_host_get_nb_pstates(const_sg_host_t host)
 {
   return host->get_pstate_count();
 }
@@ -491,7 +487,7 @@ int sg_host_get_nb_pstates(sg_host_t host)
  *
  *  See also @ref plugin_energy.
  */
-int sg_host_get_pstate(sg_host_t host)
+int sg_host_get_pstate(const_sg_host_t host)
 {
   return host->get_pstate();
 }
@@ -537,13 +533,13 @@ void sg_host_turn_off(sg_host_t host)
  * @param host host to test
  * @return Returns true if the host is up and running, and false if it's currently down
  */
-int sg_host_is_on(sg_host_t host)
+int sg_host_is_on(const_sg_host_t host)
 {
   return host->is_on();
 }
 
 /** @brief Get the properties of a host */
-xbt_dict_t sg_host_get_properties(sg_host_t host)
+xbt_dict_t sg_host_get_properties(const_sg_host_t host)
 {
   xbt_dict_t as_dict = xbt_dict_new_homogeneous(xbt_free_f);
   const std::unordered_map<std::string, std::string>* props = host->get_properties();
@@ -562,7 +558,7 @@ xbt_dict_t sg_host_get_properties(sg_host_t host)
  * @param name a property name
  * @return value of a property (or nullptr if property not set)
  */
-const char* sg_host_get_property_value(sg_host_t host, const char* name)
+const char* sg_host_get_property_value(const_sg_host_t host, const char* name)
 {
   return host->get_property(name);
 }
@@ -579,7 +575,7 @@ void sg_host_set_property_value(sg_host_t host, const char* name, const char* va
  * @param to where to
  * @param links [OUT] where to store the list of links (must exist, cannot be nullptr).
  */
-void sg_host_route(sg_host_t from, sg_host_t to, xbt_dynar_t links)
+void sg_host_route(const_sg_host_t from, const_sg_host_t to, xbt_dynar_t links)
 {
   std::vector<simgrid::s4u::Link*> vlinks;
   from->route_to(to, vlinks, nullptr);
@@ -592,7 +588,7 @@ void sg_host_route(sg_host_t from, sg_host_t to, xbt_dynar_t links)
  * @param from where from
  * @param to where to
  */
-double sg_host_route_latency(sg_host_t from, sg_host_t to)
+double sg_host_route_latency(const_sg_host_t from, const_sg_host_t to)
 {
   std::vector<simgrid::s4u::Link*> vlinks;
   double res = 0;
@@ -605,7 +601,7 @@ double sg_host_route_latency(sg_host_t from, sg_host_t to)
  * @param from where from
  * @param to where to
  */
-double sg_host_route_bandwidth(sg_host_t from, sg_host_t to)
+double sg_host_route_bandwidth(const_sg_host_t from, const_sg_host_t to)
 {
   double min_bandwidth = -1.0;
 
@@ -625,7 +621,7 @@ void sg_host_send_to(sg_host_t from, sg_host_t to, double byte_amount)
 }
 
 /** @brief Displays debugging information about a host */
-void sg_host_dump(sg_host_t host)
+void sg_host_dump(const_sg_host_t host)
 {
   XBT_INFO("Displaying host %s", host->get_cname());
   XBT_INFO("  - speed: %.0f", host->get_speed());
@@ -645,10 +641,10 @@ void sg_host_dump(sg_host_t host)
  * @param host a host
  * @param whereto a dynar in which we should push actors living on that host
  */
-void sg_host_get_actor_list(sg_host_t host, xbt_dynar_t whereto)
+void sg_host_get_actor_list(const_sg_host_t host, xbt_dynar_t whereto)
 {
-  auto actors = host->get_all_actors();
-  for (auto& actor : actors)
+  auto const actors = host->get_all_actors();
+  for (auto const& actor : actors)
     xbt_dynar_push(whereto, &actor);
 }
 
@@ -660,10 +656,16 @@ sg_host_t sg_host_self()
 /* needs to be public and without simcall for exceptions and logging events */
 const char* sg_host_self_get_name()
 {
-  return SIMIX_is_maestro() ? "" : simgrid::kernel::actor::ActorImpl::self()->get_host()->get_cname();
+  const char* res = "";
+  if (not SIMIX_is_maestro()) {
+    const simgrid::s4u::Host* host = simgrid::kernel::actor::ActorImpl::self()->get_host();
+    if (host != nullptr)
+      res = host->get_cname();
+  }
+  return res;
 }
 
-double sg_host_load(sg_host_t host)
+double sg_host_load(const_sg_host_t host)
 {
   return host->get_load();
 }
index cca68b0..9b363ce 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -56,14 +56,14 @@ Io* Io::cancel()
 
 Io* Io::wait()
 {
-  simcall_io_wait(pimpl_);
-  state_ = State::FINISHED;
-  return this;
+  return this->wait_for(-1);
 }
 
-Io* Io::wait_for(double)
+Io* Io::wait_for(double timeout)
 {
-  THROW_UNIMPLEMENTED;
+  simcall_io_wait(pimpl_, timeout);
+  state_ = State::FINISHED;
+  return this;
 }
 
 bool Io::test()
@@ -76,9 +76,12 @@ bool Io::test()
   if (state_ == State::INITED)
     this->start();
 
-  THROW_UNIMPLEMENTED;
+  if (simcall_io_test(pimpl_)) {
+    state_ = State::FINISHED;
+    return true;
+  }
 
-  // return false
+  return false;
 }
 
 /** @brief Returns the amount of flops that remain to be done */
index 742f062..4942e65 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -14,6 +14,9 @@
 #include "xbt/log.h"
 
 namespace simgrid {
+
+template class xbt::Extendable<s4u::Link>;
+
 namespace s4u {
 
 xbt::signal<void(Link&)> Link::on_creation;
@@ -42,7 +45,7 @@ const char* Link::get_cname() const
 {
   return this->pimpl_->get_cname();
 }
-bool Link::is_used()
+bool Link::is_used() const
 {
   return this->pimpl_->is_used();
 }
@@ -57,12 +60,12 @@ double Link::get_bandwidth() const
   return this->pimpl_->get_bandwidth();
 }
 
-Link::SharingPolicy Link::get_sharing_policy()
+Link::SharingPolicy Link::get_sharing_policy() const
 {
   return this->pimpl_->get_sharing_policy();
 }
 
-double Link::get_usage()
+double Link::get_usage() const
 {
   return this->pimpl_->get_constraint()->get_usage();
 }
@@ -107,7 +110,7 @@ void Link::set_property(const std::string& key, const std::string& value)
 
 /* **************************** Public C interface *************************** */
 
-const char* sg_link_name(sg_link_t link)
+const char* sg_link_name(const_sg_link_t link)
 {
   return link->get_cname();
 }
@@ -116,19 +119,19 @@ sg_link_t sg_link_by_name(const char* name)
   return simgrid::s4u::Link::by_name(name);
 }
 
-int sg_link_is_shared(sg_link_t link)
+int sg_link_is_shared(const_sg_link_t link)
 {
   return (int)link->get_sharing_policy();
 }
-double sg_link_bandwidth(sg_link_t link)
+double sg_link_bandwidth(const_sg_link_t link)
 {
   return link->get_bandwidth();
 }
-double sg_link_latency(sg_link_t link)
+double sg_link_latency(const_sg_link_t link)
 {
   return link->get_latency();
 }
-void* sg_link_data(sg_link_t link)
+void* sg_link_data(const_sg_link_t link)
 {
   return link->get_data();
 }
index 95c0ab0..3fd04ac 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -150,7 +150,7 @@ void* Mailbox::get(double timeout)
   return res;
 }
 
-smx_activity_t Mailbox::iprobe(int type, int (*match_fun)(void*, void*, kernel::activity::CommImpl*), void* data)
+smx_activity_t Mailbox::iprobe(int type, bool (*match_fun)(void*, void*, kernel::activity::CommImpl*), void* data)
 {
   return kernel::actor::simcall([this, type, match_fun, data] { return pimpl_->iprobe(type, match_fun, data); });
 }
index 6494276..ce2b60c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -49,13 +49,13 @@ MutexPtr Mutex::create()
 }
 
 /* refcounting of the intrusive_ptr is delegated to the implementation object */
-void intrusive_ptr_add_ref(Mutex* mutex)
+void intrusive_ptr_add_ref(const Mutex* mutex)
 {
   xbt_assert(mutex);
   if (mutex->pimpl_)
     mutex->pimpl_->ref();
 }
-void intrusive_ptr_release(Mutex* mutex)
+void intrusive_ptr_release(const Mutex* mutex)
 {
   xbt_assert(mutex);
   if (mutex->pimpl_)
@@ -89,7 +89,7 @@ int sg_mutex_try_lock(sg_mutex_t mutex)
   return mutex->try_lock();
 }
 
-void sg_mutex_destroy(sg_mutex_t mutex)
+void sg_mutex_destroy(const_sg_mutex_t mutex)
 {
   delete mutex;
 }
index b5cdbce..2e13264 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -36,7 +36,7 @@ void NetZone::set_property(const std::string& key, const std::string& value)
 }
 
 /** @brief Returns the list of direct children (no grand-children) */
-std::vector<NetZone*> NetZone::get_children()
+std::vector<NetZone*> NetZone::get_children() const
 {
   std::vector<NetZone*> res;
   for (auto child : *(pimpl_->get_children()))
@@ -62,7 +62,7 @@ NetZone* NetZone::get_father()
  * Only the hosts that are directly contained in this NetZone are retrieved,
  * not the ones contained in sub-netzones.
  */
-std::vector<Host*> NetZone::get_all_hosts()
+std::vector<Host*> NetZone::get_all_hosts() const
 {
   return pimpl_->get_all_hosts();
 }
@@ -99,7 +99,7 @@ sg_netzone_t sg_zone_get_root()
   return simgrid::s4u::Engine::get_instance()->get_netzone_root();
 }
 
-const char* sg_zone_get_name(sg_netzone_t netzone)
+const char* sg_zone_get_name(const_sg_netzone_t netzone)
 {
   return netzone->get_cname();
 }
@@ -109,24 +109,24 @@ sg_netzone_t sg_zone_get_by_name(const char* name)
   return simgrid::s4u::Engine::get_instance()->netzone_by_name_or_null(name);
 }
 
-void sg_zone_get_sons(sg_netzone_t netzone, xbt_dict_t whereto)
+void sg_zone_get_sons(const_sg_netzone_t netzone, xbt_dict_t whereto)
 {
   for (auto const& elem : netzone->get_children()) {
     xbt_dict_set(whereto, elem->get_cname(), static_cast<void*>(elem));
   }
 }
 
-const char* sg_zone_get_property_value(sg_netzone_t netzone, const char* name)
+const char* sg_zone_get_property_value(const_sg_netzone_t netzone, const char* name)
 {
   return netzone->get_property(name);
 }
 
-void sg_zone_set_property_value(sg_netzone_t netzone, const char* name, char* value)
+void sg_zone_set_property_value(sg_netzone_t netzone, const char* name, const char* value)
 {
   netzone->set_property(name, value);
 }
 
-void sg_zone_get_hosts(sg_netzone_t netzone, xbt_dynar_t whereto)
+void sg_zone_get_hosts(const_sg_netzone_t netzone, xbt_dynar_t whereto)
 {
   /* converts vector to dynar */
   std::vector<simgrid::s4u::Host*> hosts = netzone->get_all_hosts();
index debf3ec..b4a5ed7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -21,7 +21,7 @@ Semaphore::Semaphore(unsigned int initial_capacity)
 Semaphore::~Semaphore()
 {
   if (sem_ != nullptr) {
-    xbt_assert(sem_->sleeping_.empty(), "Cannot destroy semaphore since someone is still using it");
+    xbt_assert(not sem_->is_used(), "Cannot destroy semaphore since someone is still using it");
     delete sem_;
   }
 }
@@ -104,7 +104,7 @@ int sg_sem_get_capacity(sg_sem_t sem)
   return sem->get_capacity();
 }
 
-void sg_sem_destroy(sg_sem_t sem)
+void sg_sem_destroy(const_sg_sem_t sem)
 {
   delete sem;
 }
index 59667fd..dfd02fd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -11,9 +11,8 @@
 #include "src/surf/StorageImpl.hpp"
 
 namespace simgrid {
-namespace xbt {
-template class Extendable<s4u::Storage>;
-} // namespace xbt
+
+template class xbt::Extendable<s4u::Storage>;
 
 namespace s4u {
 
@@ -36,9 +35,9 @@ Storage* Storage::by_name_or_null(const std::string& name)
   return Engine::get_instance()->storage_by_name_or_null(name);
 }
 
-const char* Storage::get_type()
+const char* Storage::get_type() const
 {
-  return pimpl_->typeId_.c_str();
+  return pimpl_->get_type();
 }
 
 const std::unordered_map<std::string, std::string>* Storage::get_properties() const
@@ -73,7 +72,6 @@ sg_size_t Storage::read(sg_size_t size)
 
 IoPtr Storage::write_async(sg_size_t size)
 {
-
   return IoPtr(io_init(size, Io::OpType::WRITE)->start());
 }
 
@@ -97,13 +95,13 @@ sg_size_t Storage::write(sg_size_t size)
  *
  * This functions checks whether a storage is a valid pointer or not and return its name.
  */
-const char* sg_storage_get_name(sg_storage_t storage)
+const char* sg_storage_get_name(const_sg_storage_t storage)
 {
   xbt_assert((storage != nullptr), "Invalid parameters");
   return storage->get_cname();
 }
 
-const char* sg_storage_get_host(sg_storage_t storage)
+const char* sg_storage_get_host(const_sg_storage_t storage)
 {
   xbt_assert((storage != nullptr), "Invalid parameters");
   return storage->get_host()->get_cname();
@@ -114,7 +112,7 @@ const char* sg_storage_get_host(sg_storage_t storage)
  * @param storage a storage
  * @return a dict containing the properties
  */
-xbt_dict_t sg_storage_get_properties(sg_storage_t storage)
+xbt_dict_t sg_storage_get_properties(const_sg_storage_t storage)
 {
   xbt_assert((storage != nullptr), "Invalid parameters (storage is nullptr)");
   xbt_dict_t as_dict                        = xbt_dict_new_homogeneous(xbt_free_f);
@@ -146,7 +144,7 @@ void sg_storage_set_property_value(sg_storage_t storage, const char* name, const
  * @param name a property name
  * @return value of a property (or nullptr if property not set)
  */
-const char* sg_storage_get_property_value(sg_storage_t storage, const char* name)
+const char* sg_storage_get_property_value(const_sg_storage_t storage, const char* name)
 {
   return storage->get_property(name);
 }
@@ -173,7 +171,7 @@ xbt_dynar_t sg_storages_as_dynar()
   return res;
 }
 
-void* sg_storage_get_data(sg_storage_t storage)
+void* sg_storage_get_data(const_sg_storage_t storage)
 {
   xbt_assert((storage != nullptr), "Invalid parameters");
   return storage->get_data();
index 5872efa..4131660 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -21,8 +21,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_daxparse, sd, "Parsing DAX files");
 /* Ensure that transfer tasks have unique names even though a file is used several times */
 void uniq_transfer_task_name(SD_task_t task)
 {
-  SD_task_t child = *(task->successors->begin());
-  SD_task_t parent = *(task->predecessors->begin());
+  const_SD_task_t child  = *(task->successors->begin());
+  const_SD_task_t parent = *(task->predecessors->begin());
 
   std::string new_name =
       std::string(SD_task_get_name(parent)) + "_" + SD_task_get_name(task) + "_" + SD_task_get_name(child);
@@ -30,20 +30,23 @@ void uniq_transfer_task_name(SD_task_t task)
   SD_task_set_name(task, new_name.c_str());
 }
 
-static bool children_are_marked(SD_task_t task){
+static bool children_are_marked(const_SD_task_t task)
+{
   return std::none_of(task->successors->begin(), task->successors->end(),
                       [](const SD_task_t& elm) { return not elm->marked; }) &&
          std::none_of(task->outputs->begin(), task->outputs->end(),
                       [](const SD_task_t& elm) { return not elm->marked; });
 }
 
-static bool parents_are_marked(SD_task_t task){
+static bool parents_are_marked(const_SD_task_t task)
+{
   return std::none_of(task->predecessors->begin(), task->predecessors->end(),
                       [](const SD_task_t& elm) { return not elm->marked; }) &&
          std::none_of(task->inputs->begin(), task->inputs->end(), [](const SD_task_t& elm) { return not elm->marked; });
 }
 
-bool acyclic_graph_detail(xbt_dynar_t dag){
+bool acyclic_graph_detail(const_xbt_dynar_t dag)
+{
   unsigned int count;
   bool all_marked = true;
   SD_task_t task = nullptr;
index 90d8662..39792bb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -99,11 +99,11 @@ xbt_dynar_t SD_dotload_generic(const char* filename, bool sequential, bool sched
           if (comp != computers.end()) {
             computer = comp->second;
           } else {
-            computer = new std::vector<SD_task_t>;
+            computer = new std::vector<SD_task_t>();
             computers.insert({char_performer, computer});
           }
           if (static_cast<unsigned int>(order) < computer->size()) {
-            SD_task_t task_test = computer->at(order);
+            const s_SD_task_t* task_test = computer->at(order);
             if (task_test && task_test != task) {
               /* the user gave the same order to several tasks */
               schedule_success = false;
@@ -153,8 +153,8 @@ xbt_dynar_t SD_dotload_generic(const char* filename, bool sequential, bool sched
     std::sort(edges.begin(), edges.end(), [](const Agedge_t* a, const Agedge_t* b) { return AGSEQ(a) < AGSEQ(b); });
 
     for (Agedge_t* edge : edges) {
-      char *src_name=agnameof(agtail(edge));
-      char *dst_name=agnameof(aghead(edge));
+      const char* src_name = agnameof(agtail(edge));
+      const char* dst_name = agnameof(aghead(edge));
       double size = atof(agget(edge, (char *) "size"));
 
       SD_task_t src = jobs.at(src_name);
index a862ecc..ee13102 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -33,7 +33,6 @@ std::set<SD_task_t>* simulate(double how_long){
   /* main loop */
   while (elapsed_time >= 0 && (how_long < 0 || 0.00001 < (how_long - total_time)) &&
          not sd_global->watch_point_reached) {
-
     XBT_DEBUG("Total time: %f", total_time);
 
     elapsed_time = surf_solve(how_long > 0 ? surf_get_clock() + how_long - total_time: -1.0);
@@ -43,7 +42,7 @@ std::set<SD_task_t>* simulate(double how_long){
 
     /* let's see which tasks are done */
     for (auto const& model : all_existing_models) {
-      simgrid::kernel::resource::Action* action = model->extract_done_action();
+      const simgrid::kernel::resource::Action* action = model->extract_done_action();
       while (action != nullptr && action->get_data() != nullptr) {
         SD_task_t task = static_cast<SD_task_t>(action->get_data());
         XBT_VERB("Task '%s' done", SD_task_get_name(task));
@@ -214,7 +213,7 @@ void SD_simulate(double how_long)
 
 void SD_simulate_with_update(double how_long, xbt_dynar_t changed_tasks_dynar)
 {
-  std::set<SD_task_t> *changed_tasks = simgrid::sd::simulate(how_long);
+  const std::set<SD_task_t>* changed_tasks = simgrid::sd::simulate(how_long);
   for (auto const& task : *changed_tasks)
     xbt_dynar_push(changed_tasks_dynar, &task);
 }
index 6dcdeaf..4bde0b8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -204,7 +204,7 @@ void SD_task_destroy(SD_task_t task)
  * @return the user data associated with this task (can be @c nullptr)
  * @see SD_task_set_data()
  */
-void *SD_task_get_data(SD_task_t task)
+void* SD_task_get_data(const_SD_task_t task)
 {
   return task->data;
 }
@@ -254,7 +254,7 @@ void SD_task_set_rate(SD_task_t task, double rate)
  * #SD_NOT_SCHEDULED, #SD_SCHEDULED, #SD_RUNNABLE, #SD_RUNNING, #SD_DONE or #SD_FAILED
  * @see e_SD_task_state_t
  */
-e_SD_task_state_t SD_task_get_state(SD_task_t task)
+e_SD_task_state_t SD_task_get_state(const_SD_task_t task)
 {
   return task->state;
 }
@@ -316,7 +316,7 @@ void SD_task_set_state(SD_task_t task, e_SD_task_state_t new_state)
  * @param task a task
  * @return the name of this task (can be @c nullptr)
  */
-const char *SD_task_get_name(SD_task_t task)
+const char* SD_task_get_name(const_SD_task_t task)
 {
   return task->name;
 }
@@ -334,7 +334,7 @@ void SD_task_set_name(SD_task_t task, const char *name)
  * @return a newly allocated dynar comprising the parents of this task
  */
 
-xbt_dynar_t SD_task_get_parents(SD_task_t task)
+xbt_dynar_t SD_task_get_parents(const_SD_task_t task)
 {
   xbt_dynar_t parents = xbt_dynar_new(sizeof(SD_task_t), nullptr);
 
@@ -351,7 +351,7 @@ xbt_dynar_t SD_task_get_parents(SD_task_t task)
  * @param task a task
  * @return a newly allocated dynar comprising the parents of this task
  */
-xbt_dynar_t SD_task_get_children(SD_task_t task)
+xbt_dynar_t SD_task_get_children(const_SD_task_t task)
 {
   xbt_dynar_t children = xbt_dynar_new(sizeof(SD_task_t), nullptr);
 
@@ -369,7 +369,7 @@ xbt_dynar_t SD_task_get_children(SD_task_t task)
  * Only call this on already scheduled tasks!
  * @param task a task
  */
-int SD_task_get_workstation_count(SD_task_t task)
+int SD_task_get_workstation_count(const_SD_task_t task)
 {
   return task->allocation->size();
 }
@@ -380,7 +380,7 @@ int SD_task_get_workstation_count(SD_task_t task)
  * Only call this on already scheduled tasks!
  * @param task a task
  */
-sg_host_t *SD_task_get_workstation_list(SD_task_t task)
+sg_host_t* SD_task_get_workstation_list(const_SD_task_t task)
 {
   return task->allocation->data();
 }
@@ -392,7 +392,7 @@ sg_host_t *SD_task_get_workstation_list(SD_task_t task)
  * @return the total amount of work (computation or data transfer) for this task
  * @see SD_task_get_remaining_amount()
  */
-double SD_task_get_amount(SD_task_t task)
+double SD_task_get_amount(const_SD_task_t task)
 {
   return task->amount;
 }
@@ -420,7 +420,7 @@ void SD_task_set_amount(SD_task_t task, double amount)
  * @param task a parallel task assuming Amdahl's law as speedup model
  * @return the alpha parameter (serial part of a task in percent) for this task
  */
-double SD_task_get_alpha(SD_task_t task)
+double SD_task_get_alpha(const_SD_task_t task)
 {
   xbt_assert(SD_task_get_kind(task) == SD_TASK_COMP_PAR_AMDAHL, "Alpha parameter is not defined for this kind of task");
   return task->alpha;
@@ -433,7 +433,7 @@ double SD_task_get_alpha(SD_task_t task)
  * @return the remaining amount of work (computation or data transfer) of this task
  * @see SD_task_get_amount()
  */
-double SD_task_get_remaining_amount(SD_task_t task)
+double SD_task_get_remaining_amount(const_SD_task_t task)
 {
   if (task->surf_action)
     return task->surf_action->get_remains();
@@ -441,13 +441,13 @@ double SD_task_get_remaining_amount(SD_task_t task)
     return (task->state == SD_DONE) ? 0 : task->amount;
 }
 
-e_SD_task_kind_t SD_task_get_kind(SD_task_t task)
+e_SD_task_kind_t SD_task_get_kind(const_SD_task_t task)
 {
   return task->kind;
 }
 
 /** @brief Displays debugging information about a task */
-void SD_task_dump(SD_task_t task)
+void SD_task_dump(const_SD_task_t task)
 {
   XBT_INFO("Displaying task %s", SD_task_get_name(task));
   if (task->state == SD_RUNNABLE)
@@ -499,7 +499,7 @@ void SD_task_dump(SD_task_t task)
 }
 
 /** @brief Dumps the task in dotty formalism into the FILE* passed as second argument */
-void SD_task_dotty(SD_task_t task, void *out)
+void SD_task_dotty(const_SD_task_t task, void* out)
 {
   FILE *fout = static_cast<FILE*>(out);
   fprintf(fout, "  T%p [label=\"%.20s\"", task, task->name);
@@ -583,7 +583,7 @@ void SD_task_dependency_add(SD_task_t src, SD_task_t dst)
  * If src is nullptr, checks whether dst has any pre-dependency.
  * If dst is nullptr, checks whether src has any post-dependency.
  */
-int SD_task_dependency_exists(SD_task_t src, SD_task_t dst)
+int SD_task_dependency_exists(const_SD_task_t src, SD_task_t dst)
 {
   xbt_assert(src != nullptr || dst != nullptr, "Invalid parameter: both src and dst are nullptr");
 
@@ -676,7 +676,7 @@ void SD_task_unwatch(SD_task_t task, e_SD_task_state_t state)
  * @param bytes_amount communication amount between each pair of hosts (i.e., a matrix of host_count*host_count doubles)
  * @see SD_schedule()
  */
-double SD_task_get_execution_time(SD_task_t /*task*/, int host_count, const sg_host_t* host_list,
+double SD_task_get_execution_time(const_SD_task_t /*task*/, int host_count, const sg_host_t* host_list,
                                   const double* flops_amount, const double* bytes_amount)
 {
   xbt_assert(host_count > 0, "Invalid parameter");
@@ -820,7 +820,7 @@ void SD_task_run(SD_task_t task)
  * @param task: a task
  * @return the start time of this task
  */
-double SD_task_get_start_time(SD_task_t task)
+double SD_task_get_start_time(const_SD_task_t task)
 {
   if (task->surf_action)
     return task->surf_action->get_start_time();
@@ -838,7 +838,7 @@ double SD_task_get_start_time(SD_task_t task)
  * @param task: a task
  * @return the start time of this task
  */
-double SD_task_get_finish_time(SD_task_t task)
+double SD_task_get_finish_time(const_SD_task_t task)
 {
   if (task->surf_action)        /* should never happen as actions are destroyed right after their completion */
     return task->surf_action->get_finish_time();
index e452c3b..734cb6e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -63,7 +63,7 @@ struct s_SD_task_t {
 /* SimDag private functions */
 XBT_PRIVATE void SD_task_set_state(SD_task_t task, e_SD_task_state_t new_state);
 XBT_PRIVATE void SD_task_run(SD_task_t task);
-XBT_PRIVATE bool acyclic_graph_detail(xbt_dynar_t dag);
+XBT_PRIVATE bool acyclic_graph_detail(const_xbt_dynar_t dag);
 XBT_PRIVATE void uniq_transfer_task_name(SD_task_t task);
 XBT_PRIVATE const char *__get_state_name(e_SD_task_state_t state);
 #endif
index ed0a7e9..134eefd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 99640f5..6e09b76 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 748c354..03f3673 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 4526a66..634a6f2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team.
+/* Copyright (c) 2015-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@ typename C::mapped_type const* find_map_ptr(C const& c, K const& k)
     return &i->second;
 }
 
-}
-}
+} // namespace util
+} // namespace simgrid
 
 #endif
index 275c34d..226cd5f 100644 (file)
@@ -5,7 +5,7 @@
 /*                                                                            */
 /* This is somehow the "libc" of SimGrid                                      */
 
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
  *
  * @param execution The execution synchro
  */
-e_smx_state_t simcall_execution_wait(const smx_activity_t& execution)
+e_smx_state_t simcall_execution_wait(const smx_activity_t& execution, double timeout)
 {
-  return (e_smx_state_t)simcall_BODY_execution_wait(static_cast<simgrid::kernel::activity::ExecImpl*>(execution.get()));
+  return (e_smx_state_t)simcall_BODY_execution_wait(static_cast<simgrid::kernel::activity::ExecImpl*>(execution.get()),
+                                                    timeout);
 }
 
 bool simcall_execution_test(const smx_activity_t& execution)
@@ -64,7 +65,7 @@ e_smx_state_t simcall_process_sleep(double duration) // XBT_DEPRECATED_v329
  * @ingroup simix_comm_management
  */
 void simcall_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff,
-                       size_t src_buff_size, int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+                       size_t src_buff_size, bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
                        void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data,
                        double timeout)
 {
@@ -94,7 +95,7 @@ void simcall_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size,
  */
 smx_activity_t simcall_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff,
                                   size_t src_buff_size,
-                                  int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+                                  bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
                                   void (*clean_fun)(void*),
                                   void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
                                   void* data, bool detached)
@@ -113,7 +114,7 @@ smx_activity_t simcall_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double
  * @ingroup simix_comm_management
  */
 void simcall_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size,
-                       int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+                       bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
                        void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data,
                        double timeout, double rate)
 {
@@ -137,7 +138,7 @@ void simcall_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff,
  * @ingroup simix_comm_management
  */
 smx_activity_t simcall_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size,
-                                  int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+                                  bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
                                   void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
                                   void* data, double rate)
 {
@@ -151,7 +152,7 @@ smx_activity_t simcall_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, void
  * @ingroup simix_comm_management
  */
 smx_activity_t simcall_comm_iprobe(smx_mailbox_t mbox, int type,
-                                   int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), void* data)
+                                   bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), void* data)
 {
   xbt_assert(mbox, "No rendez-vous point defined for iprobe");
 
@@ -302,9 +303,14 @@ int simcall_sem_acquire_timeout(smx_sem_t sem, double timeout)
   return simcall_BODY_sem_acquire_timeout(sem, timeout);
 }
 
-e_smx_state_t simcall_io_wait(const smx_activity_t& io)
+e_smx_state_t simcall_io_wait(const smx_activity_t& io, double timeout)
 {
-  return (e_smx_state_t)simcall_BODY_io_wait(static_cast<simgrid::kernel::activity::IoImpl*>(io.get()));
+  return (e_smx_state_t)simcall_BODY_io_wait(static_cast<simgrid::kernel::activity::IoImpl*>(io.get()), timeout);
+}
+
+bool simcall_io_test(const smx_activity_t& io)
+{
+  return simcall_BODY_io_test(static_cast<simgrid::kernel::activity::IoImpl*>(io.get()));
 }
 
 void simcall_run_kernel(std::function<void()> const& code, simgrid::mc::SimcallInspector* t)
index 8babbe6..f1e5ab4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 066b3ed..379db02 100644 (file)
@@ -4,7 +4,7 @@
 /*                    DO NOT EVER CHANGE THIS FILE                    */
 /*                                                                    */
 /* change simcalls specification in src/simix/simcalls.in             */
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.    */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.    */
 /**********************************************************************/
 
 /*
@@ -27,6 +27,18 @@ static inline void simcall_execution_wait__set__execution(smx_simcall_t simcall,
 {
   simgrid::simix::marshal<simgrid::kernel::activity::ExecImpl*>(simcall->args_[0], arg);
 }
+static inline double simcall_execution_wait__get__timeout(smx_simcall_t simcall)
+{
+  return simgrid::simix::unmarshal<double>(simcall->args_[1]);
+}
+static inline double simcall_execution_wait__getraw__timeout(smx_simcall_t simcall)
+{
+  return simgrid::simix::unmarshal_raw<double>(simcall->args_[1]);
+}
+static inline void simcall_execution_wait__set__timeout(smx_simcall_t simcall, double arg)
+{
+  simgrid::simix::marshal<double>(simcall->args_[1], arg);
+}
 static inline int simcall_execution_wait__get__result(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<int>(simcall->result_);
@@ -921,6 +933,18 @@ static inline void simcall_io_wait__set__io(smx_simcall_t simcall, simgrid::kern
 {
   simgrid::simix::marshal<simgrid::kernel::activity::IoImpl*>(simcall->args_[0], arg);
 }
+static inline double simcall_io_wait__get__timeout(smx_simcall_t simcall)
+{
+  return simgrid::simix::unmarshal<double>(simcall->args_[1]);
+}
+static inline double simcall_io_wait__getraw__timeout(smx_simcall_t simcall)
+{
+  return simgrid::simix::unmarshal_raw<double>(simcall->args_[1]);
+}
+static inline void simcall_io_wait__set__timeout(smx_simcall_t simcall, double arg)
+{
+  simgrid::simix::marshal<double>(simcall->args_[1], arg);
+}
 static inline sg_size_t simcall_io_wait__get__result(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<sg_size_t>(simcall->result_);
@@ -934,6 +958,31 @@ static inline void simcall_io_wait__set__result(smx_simcall_t simcall, sg_size_t
   simgrid::simix::marshal<sg_size_t>(simcall->result_, result);
 }
 
+static inline simgrid::kernel::activity::IoImpl* simcall_io_test__get__io(smx_simcall_t simcall)
+{
+  return simgrid::simix::unmarshal<simgrid::kernel::activity::IoImpl*>(simcall->args_[0]);
+}
+static inline simgrid::kernel::activity::IoImpl* simcall_io_test__getraw__io(smx_simcall_t simcall)
+{
+  return simgrid::simix::unmarshal_raw<simgrid::kernel::activity::IoImpl*>(simcall->args_[0]);
+}
+static inline void simcall_io_test__set__io(smx_simcall_t simcall, simgrid::kernel::activity::IoImpl* arg)
+{
+  simgrid::simix::marshal<simgrid::kernel::activity::IoImpl*>(simcall->args_[0], arg);
+}
+static inline bool simcall_io_test__get__result(smx_simcall_t simcall)
+{
+  return simgrid::simix::unmarshal<bool>(simcall->result_);
+}
+static inline bool simcall_io_test__getraw__result(smx_simcall_t simcall)
+{
+  return simgrid::simix::unmarshal_raw<bool>(simcall->result_);
+}
+static inline void simcall_io_test__set__result(smx_simcall_t simcall, bool result)
+{
+  simgrid::simix::marshal<bool>(simcall->result_, result);
+}
+
 static inline int simcall_mc_random__get__min(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<int>(simcall->args_[0]);
@@ -999,7 +1048,7 @@ static inline void simcall_run_blocking__set__code(smx_simcall_t simcall, std::f
 
 /* The prototype of all simcall handlers, automatically generated for you */
 
-XBT_PRIVATE void simcall_HANDLER_execution_wait(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* execution);
+XBT_PRIVATE void simcall_HANDLER_execution_wait(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* execution, double timeout);
 XBT_PRIVATE void simcall_HANDLER_execution_waitany_for(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl** execs, size_t count, double timeout);
 XBT_PRIVATE void simcall_HANDLER_execution_test(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* execution);
 XBT_PRIVATE void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, unsigned char* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout);
@@ -1017,5 +1066,6 @@ XBT_PRIVATE void simcall_HANDLER_cond_wait(smx_simcall_t simcall, smx_cond_t con
 XBT_PRIVATE void simcall_HANDLER_cond_wait_timeout(smx_simcall_t simcall, smx_cond_t cond, smx_mutex_t mutex, double timeout);
 XBT_PRIVATE void simcall_HANDLER_sem_acquire(smx_simcall_t simcall, smx_sem_t sem);
 XBT_PRIVATE void simcall_HANDLER_sem_acquire_timeout(smx_simcall_t simcall, smx_sem_t sem, double timeout);
-XBT_PRIVATE void simcall_HANDLER_io_wait(smx_simcall_t simcall, simgrid::kernel::activity::IoImpl* io);
+XBT_PRIVATE void simcall_HANDLER_io_wait(smx_simcall_t simcall, simgrid::kernel::activity::IoImpl* io, double timeout);
+XBT_PRIVATE void simcall_HANDLER_io_test(smx_simcall_t simcall, simgrid::kernel::activity::IoImpl* io);
 XBT_PRIVATE int simcall_HANDLER_mc_random(smx_simcall_t simcall, int min, int max);
index ba60b6d..da28700 100644 (file)
@@ -4,7 +4,7 @@
 /*                    DO NOT EVER CHANGE THIS FILE                    */
 /*                                                                    */
 /* change simcalls specification in src/simix/simcalls.in             */
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.    */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.    */
 /**********************************************************************/
 
 /*
@@ -39,11 +39,11 @@ inline static R simcall(e_smx_simcall_t call, T const&... t)
   return simgrid::simix::unmarshal<R>(self->simcall.result_);
 }
 
-inline static int simcall_BODY_execution_wait(simgrid::kernel::activity::ExecImpl* execution)
+inline static int simcall_BODY_execution_wait(simgrid::kernel::activity::ExecImpl* execution, double timeout)
 {
   if (0) /* Go to that function to follow the code flow through the simcall barrier */
-    simcall_HANDLER_execution_wait(&SIMIX_process_self()->simcall, execution);
-  return simcall<int, simgrid::kernel::activity::ExecImpl*>(SIMCALL_EXECUTION_WAIT, execution);
+    simcall_HANDLER_execution_wait(&SIMIX_process_self()->simcall, execution, timeout);
+  return simcall<int, simgrid::kernel::activity::ExecImpl*, double>(SIMCALL_EXECUTION_WAIT, execution, timeout);
 }
 
 inline static int simcall_BODY_execution_waitany_for(simgrid::kernel::activity::ExecImpl** execs, size_t count, double timeout)
@@ -165,11 +165,18 @@ inline static int simcall_BODY_sem_acquire_timeout(smx_sem_t sem, double timeout
   return simcall<int, smx_sem_t, double>(SIMCALL_SEM_ACQUIRE_TIMEOUT, sem, timeout);
 }
 
-inline static sg_size_t simcall_BODY_io_wait(simgrid::kernel::activity::IoImpl* io)
+inline static sg_size_t simcall_BODY_io_wait(simgrid::kernel::activity::IoImpl* io, double timeout)
 {
   if (0) /* Go to that function to follow the code flow through the simcall barrier */
-    simcall_HANDLER_io_wait(&SIMIX_process_self()->simcall, io);
-  return simcall<sg_size_t, simgrid::kernel::activity::IoImpl*>(SIMCALL_IO_WAIT, io);
+    simcall_HANDLER_io_wait(&SIMIX_process_self()->simcall, io, timeout);
+  return simcall<sg_size_t, simgrid::kernel::activity::IoImpl*, double>(SIMCALL_IO_WAIT, io, timeout);
+}
+
+inline static bool simcall_BODY_io_test(simgrid::kernel::activity::IoImpl* io)
+{
+  if (0) /* Go to that function to follow the code flow through the simcall barrier */
+    simcall_HANDLER_io_test(&SIMIX_process_self()->simcall, io);
+  return simcall<bool, simgrid::kernel::activity::IoImpl*>(SIMCALL_IO_TEST, io);
 }
 
 inline static int simcall_BODY_mc_random(int min, int max)
index f2182ee..0006e87 100644 (file)
@@ -4,7 +4,7 @@
 /*                    DO NOT EVER CHANGE THIS FILE                    */
 /*                                                                    */
 /* change simcalls specification in src/simix/simcalls.in             */
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.    */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.    */
 /**********************************************************************/
 
 /*
@@ -38,6 +38,7 @@ typedef enum {
   SIMCALL_SEM_ACQUIRE,
   SIMCALL_SEM_ACQUIRE_TIMEOUT,
   SIMCALL_IO_WAIT,
+  SIMCALL_IO_TEST,
   SIMCALL_MC_RANDOM,
   SIMCALL_RUN_KERNEL,
   SIMCALL_RUN_BLOCKING,
index c014307..8d4fd42 100644 (file)
@@ -4,7 +4,7 @@
 /*                    DO NOT EVER CHANGE THIS FILE                    */
 /*                                                                    */
 /* change simcalls specification in src/simix/simcalls.in             */
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.    */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.    */
 /**********************************************************************/
 
 /*
@@ -45,6 +45,7 @@ const char* simcall_names[] = {
     "SIMCALL_SEM_ACQUIRE",
     "SIMCALL_SEM_ACQUIRE_TIMEOUT",
     "SIMCALL_IO_WAIT",
+    "SIMCALL_IO_TEST",
     "SIMCALL_MC_RANDOM",
     "SIMCALL_RUN_KERNEL",
     "SIMCALL_RUN_BLOCKING",
@@ -58,11 +59,11 @@ const char* simcall_names[] = {
 void simgrid::kernel::actor::ActorImpl::simcall_handle(int value) {
   XBT_DEBUG("Handling simcall %p: %s", &simcall, SIMIX_simcall_name(simcall.call_));
   SIMCALL_SET_MC_VALUE(simcall, value);
-  if (context_->iwannadie)
+  if (context_->wannadie())
     return;
   switch (simcall.call_) {
     case SIMCALL_EXECUTION_WAIT:
-      simcall_HANDLER_execution_wait(&simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::ExecImpl*>(simcall.args_[0]));
+      simcall_HANDLER_execution_wait(&simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::ExecImpl*>(simcall.args_[0]), simgrid::simix::unmarshal<double>(simcall.args_[1]));
       break;
 
     case SIMCALL_EXECUTION_WAITANY_FOR:
@@ -138,7 +139,11 @@ void simgrid::kernel::actor::ActorImpl::simcall_handle(int value) {
       break;
 
     case SIMCALL_IO_WAIT:
-      simcall_HANDLER_io_wait(&simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::IoImpl*>(simcall.args_[0]));
+      simcall_HANDLER_io_wait(&simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::IoImpl*>(simcall.args_[0]), simgrid::simix::unmarshal<double>(simcall.args_[1]));
+      break;
+
+    case SIMCALL_IO_TEST:
+      simcall_HANDLER_io_test(&simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::IoImpl*>(simcall.args_[0]));
       break;
 
     case SIMCALL_MC_RANDOM:
index 26a3cbc..ad153fd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -16,7 +16,7 @@
 
 XBT_PUBLIC_DATA const char* simcall_names[]; /* Name of each simcall */
 
-typedef int (*simix_match_func_t)(void*, void*, simgrid::kernel::activity::CommImpl*);
+typedef bool (*simix_match_func_t)(void*, void*, simgrid::kernel::activity::CommImpl*);
 typedef void (*simix_copy_data_func_t)(simgrid::kernel::activity::CommImpl*, void*, size_t);
 typedef void (*simix_clean_func_t)(void*);
 typedef void (*FPtr)(void); // Hide the ugliness
index 05a4c06..270b523 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
@@ -35,7 +35,7 @@
 # Last but not the least, you should declare the new simix call in
 # ./include/simgrid/simix.h (otherwise you will get a warning at compile time)
 
-int           execution_wait(simgrid::kernel::activity::ExecImpl* execution) [[block]];
+int           execution_wait(simgrid::kernel::activity::ExecImpl* execution, double timeout) [[block]];
 int           execution_waitany_for(simgrid::kernel::activity::ExecImpl** execs, size_t count, double timeout) [[block]];
 bool          execution_test(simgrid::kernel::activity::ExecImpl* execution) [[block]];
 
@@ -58,7 +58,8 @@ int        cond_wait_timeout(smx_cond_t cond, smx_mutex_t mutex, double timeout)
 void      sem_acquire(smx_sem_t sem) [[block]];
 int       sem_acquire_timeout(smx_sem_t sem, double timeout) [[block]];
 
-sg_size_t io_wait(simgrid::kernel::activity::IoImpl* io) [[block]];
+sg_size_t io_wait(simgrid::kernel::activity::IoImpl* io, double timeout) [[block]];
+bool      io_test(simgrid::kernel::activity::IoImpl* io) [[block]];
 
 int        mc_random(int min, int max);
 
index 123b4c1..36fa58d 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
@@ -135,7 +135,7 @@ class Simcall(object):
         res.append(indent + 'case SIMCALL_%s:' % (self.name.upper()))
         if self.need_handler:
             call = "simcall_HANDLER_%s(&simcall%s%s)" % (self.name,
-                                                        ", " if len(args) > 0 else "",
+                                                        ", " if args else "",
                                                         ', '.join(args))
         else:
             call = "SIMIX_%s(%s)" % (self.name, ', '.join(args))
@@ -178,8 +178,7 @@ class Simcall(object):
                                                                                     self.name,
                                                                                     ''.join(', %s %s' % (arg.rettype(), arg.name)
                                                                                             for i, arg in enumerate(self.args)))
-        else:
-            return ""
+        return ""
 
 
 def parse(fn):
@@ -243,7 +242,7 @@ def header(name):
     fd.write(
         '/* change simcalls specification in src/simix/simcalls.in             */\n')
     fd.write(
-        '/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.    */\n')
+        '/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.    */\n')
     fd.write(
         '/**********************************************************************/\n\n')
     fd.write('/*\n')
@@ -345,7 +344,7 @@ if __name__ == '__main__':
         '  XBT_DEBUG("Handling simcall %p: %s", &simcall, SIMIX_simcall_name(simcall.call_));\n')
     fd.write('  SIMCALL_SET_MC_VALUE(simcall, value);\n')
     fd.write(
-        '  if (context_->iwannadie)\n')
+        '  if (context_->wannadie())\n')
     fd.write('    return;\n')
     fd.write('  switch (simcall.call_) {\n')
 
index a0034ca..d0343dd 100644 (file)
@@ -1,6 +1,6 @@
 /* a fast and simple context switching library                              */
 
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 1038309..17b354c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -64,7 +64,7 @@ void SIMIX_process_set_function(const char* process_host, const char* process_fu
 {
   simgrid::kernel::routing::ActorCreationArgs actor;
 
-  sg_host_t host = sg_host_by_name(process_host);
+  const simgrid::s4u::Host* host = sg_host_by_name(process_host);
   if (not host)
     throw std::invalid_argument(simgrid::xbt::string_printf("Host '%s' unknown", process_host));
   actor.host = process_host;
@@ -77,7 +77,7 @@ void SIMIX_process_set_function(const char* process_host, const char* process_fu
   }
 
   // Check we know how to handle this function name:
-  simgrid::simix::ActorCodeFactory& parse_code = SIMIX_get_actor_code_factory(process_function);
+  const simgrid::simix::ActorCodeFactory& parse_code = SIMIX_get_actor_code_factory(process_function);
   xbt_assert(parse_code, "Function '%s' unknown", process_function);
 
   actor.function           = process_function;
index 9408952..fa70127 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -305,11 +305,6 @@ void SIMIX_global_init(int *argc, char **argv)
     /* register a function to be called by SURF after the environment creation */
     sg_platf_init();
     simgrid::s4u::Engine::on_platform_created.connect(surf_presolve);
-
-    simgrid::s4u::Storage::on_creation.connect([](simgrid::s4u::Storage const& storage) {
-      sg_storage_t s = simgrid::s4u::Storage::by_name(storage.get_name());
-      xbt_assert(s != nullptr, "Storage not found for name %s", storage.get_cname());
-    });
   }
 
   if (simgrid::config::get_value<bool>("debug/clean-atexit"))
@@ -600,6 +595,6 @@ int SIMIX_is_maestro()
 {
   if (simix_global == nullptr) // SimDag
     return true;
-  simgrid::kernel::actor::ActorImpl* self = SIMIX_process_self();
+  const simgrid::kernel::actor::ActorImpl* self = SIMIX_process_self();
   return self == nullptr || self == simix_global->maestro_;
 }
index 8ffc2ed..81da1ce 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index beea76c..451dfd7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index a738af2..5029643 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index f1df813..aafd435 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 7e128bc..73c99a9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index aefbf60..ceedaab 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -83,13 +83,14 @@ void mpi_type_free_keyval_ (int* keyval, int* ierr) {
  *ierr = MPI_Type_free_keyval( keyval);
 }
 
-void mpi_type_get_extent_ (int* datatype, MPI_Aint * lb, MPI_Aint * extent, int* ierr){
-
- *ierr = MPI_Type_get_extent(simgrid::smpi::Datatype::f2c(*datatype), lb, extent);
+void mpi_type_get_extent_(int* datatype, MPI_Aint* lb, MPI_Aint* extent, int* ierr)
+{
 *ierr = MPI_Type_get_extent(simgrid::smpi::Datatype::f2c(*datatype), lb, extent);
 }
 
-void mpi_type_get_true_extent_ (int* datatype, MPI_Aint * lb, MPI_Aint * extent, int* ierr){
- *ierr = MPI_Type_get_true_extent(simgrid::smpi::Datatype::f2c(*datatype), lb, extent);
+void mpi_type_get_true_extent_(int* datatype, MPI_Aint* lb, MPI_Aint* extent, int* ierr)
+{
+  *ierr = MPI_Type_get_true_extent(simgrid::smpi::Datatype::f2c(*datatype), lb, extent);
 }
 
 void mpi_type_commit_(int* datatype,  int* ierr){
index 7249a49..9f46387 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.           */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.           */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license ,(GNU LGPL) which comes with this package. */
@@ -39,12 +39,15 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_mpi, smpi, "Logging specific to SMPI ,(mpi)
       char error_string[MPI_MAX_ERROR_STRING];                                                                         \
       int error_size;                                                                                                  \
       PMPI_Error_string(ret, error_string, &error_size);                                                               \
-      if ((errhan) == nullptr || (errhan)->errhandler() == MPI_ERRORS_RETURN)                                          \
+      MPI_Errhandler err = (errhan) ? (errhan)->errhandler() : MPI_ERRHANDLER_NULL;                                    \
+      if (err == MPI_ERRHANDLER_NULL || err == MPI_ERRORS_RETURN)                                                      \
         XBT_WARN("%s - returned %.*s instead of MPI_SUCCESS", __func__, error_size, error_string);                     \
-      else if ((errhan)->errhandler() == MPI_ERRORS_ARE_FATAL)                                                         \
+      else if (err == MPI_ERRORS_ARE_FATAL)                                                                            \
         xbt_die("%s - returned %.*s instead of MPI_SUCCESS", __func__, error_size, error_string);                      \
       else                                                                                                             \
-        (errhan)->errhandler()->call((errhan), ret);                                                                   \
+        err->call((errhan), ret);                                                                                      \
+      if (err != MPI_ERRHANDLER_NULL)                                                                                  \
+        simgrid::smpi::Errhandler::unref(err);                                                                         \
       MC_assert(not MC_is_active()); /* Only fail in MC mode */                                                        \
     }                                                                                                                  \
     XBT_VERB("SMPI - Leaving %s", __func__);                                                                           \
index f78f90f..0b484fd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -81,7 +81,7 @@ int PMPI_Get_version (int *version,int *subversion){
 
 int PMPI_Get_library_version (char *version,int *len){
   smpi_bench_end();
-  snprintf(version, MPI_MAX_LIBRARY_VERSION_STRING, "SMPI Version %d.%d. Copyright The Simgrid Team 2007-2019",
+  snprintf(version, MPI_MAX_LIBRARY_VERSION_STRING, "SMPI Version %d.%d. Copyright The SimGrid Team 2007-2020",
            SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR);
   *len = strlen(version) > MPI_MAX_LIBRARY_VERSION_STRING ? MPI_MAX_LIBRARY_VERSION_STRING : strlen(version);
   smpi_bench_begin();
index 0a97fa0..ad92c87 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -176,7 +176,7 @@ int PMPI_Igatherv(const void* sendbuf, int sendcount, MPI_Datatype sendtype, voi
   int rank         = simgrid::s4u::this_actor::get_pid();
   int dt_size_recv = recvtype->is_replayable() ? 1 : recvtype->size();
 
-  std::vector<int>* trace_recvcounts = new std::vector<int>;
+  std::vector<int>* trace_recvcounts = new std::vector<int>();
   if (comm->rank() == root) {
     for (int i = 0; i < comm->size(); i++) // copy data to avoid bad free
       trace_recvcounts->push_back(recvcounts[i] * dt_size_recv);
@@ -275,7 +275,7 @@ int PMPI_Iallgatherv(const void* sendbuf, int sendcount, MPI_Datatype sendtype,
   int rank         = simgrid::s4u::this_actor::get_pid();
   int dt_size_recv = recvtype->is_replayable() ? 1 : recvtype->size();
 
-  std::vector<int>* trace_recvcounts = new std::vector<int>;
+  std::vector<int>* trace_recvcounts = new std::vector<int>();
   for (int i = 0; i < comm->size(); i++) { // copy data to avoid bad free
     trace_recvcounts->push_back(recvcounts[i] * dt_size_recv);
   }
@@ -377,7 +377,7 @@ int PMPI_Iscatterv(const void* sendbuf, const int* sendcounts, const int* displs
   int rank         = simgrid::s4u::this_actor::get_pid();
   int dt_size_send = sendtype->is_replayable() ? 1 : sendtype->size();
 
-  std::vector<int>* trace_sendcounts = new std::vector<int>;
+  std::vector<int>* trace_sendcounts = new std::vector<int>();
   if (comm->rank() == root) {
     for (int i = 0; i < comm->size(); i++) { // copy data to avoid bad free
       trace_sendcounts->push_back(sendcounts[i] * dt_size_send);
@@ -576,7 +576,7 @@ int PMPI_Ireduce_scatter(const void *sendbuf, void *recvbuf, const int *recvcoun
 
   smpi_bench_end();
   int rank                           = simgrid::s4u::this_actor::get_pid();
-  std::vector<int>* trace_recvcounts = new std::vector<int>;
+  std::vector<int>* trace_recvcounts = new std::vector<int>();
   int dt_send_size                   = datatype->is_replayable() ? 1 : datatype->size();
   int totalcount                     = 0;
 
@@ -733,8 +733,8 @@ int PMPI_Ialltoallv(const void* sendbuf, const int* sendcounts, const int* sendd
   smpi_bench_end();
   int send_size                      = 0;
   int recv_size                      = 0;
-  std::vector<int>* trace_sendcounts = new std::vector<int>;
-  std::vector<int>* trace_recvcounts = new std::vector<int>;
+  std::vector<int>* trace_sendcounts = new std::vector<int>();
+  std::vector<int>* trace_recvcounts = new std::vector<int>();
   int dt_size_recv                   = recvtype->size();
 
   const int* real_sendcounts = sendcounts;
@@ -824,8 +824,8 @@ int PMPI_Ialltoallw(const void* sendbuf, const int* sendcounts, const int* sendd
 
   int send_size                      = 0;
   int recv_size                      = 0;
-  std::vector<int>* trace_sendcounts = new std::vector<int>;
-  std::vector<int>* trace_recvcounts = new std::vector<int>;
+  std::vector<int>* trace_sendcounts = new std::vector<int>();
+  std::vector<int>* trace_recvcounts = new std::vector<int>();
 
   const int* real_sendcounts         = sendcounts;
   const int* real_senddispls          = senddispls;
index 9cefd11..85dd53a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -292,7 +292,9 @@ int PMPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler errhandler){
 
 int PMPI_Comm_call_errhandler(MPI_Comm comm,int errorcode){
   CHECK_COMM(1)
-  comm->errhandler()->call(comm, errorcode);
+  MPI_Errhandler err = comm->errhandler();
+  err->call(comm, errorcode);
+  simgrid::smpi::Errhandler::unref(err);
   return MPI_SUCCESS;
 }
 
index e84d07f..aadb595 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -369,6 +369,8 @@ int PMPI_File_call_errhandler(MPI_File file,int errorcode){
   if (file == nullptr) {
     return MPI_ERR_WIN;
   }
-  file->errhandler()->call(file, errorcode);
+  MPI_Errhandler err = file->errhandler();
+  err->call(file, errorcode);
+  simgrid::smpi::Errhandler::unref(err);
   return MPI_SUCCESS;
 }
index 03c5f78..5a7932a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 70dfc80..d96a263 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 414ffc9..5dedee4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 7160946..a5c3141 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -427,8 +427,8 @@ int PMPI_Sendrecv(const void* sendbuf, int sendcount, MPI_Datatype sendtype, int
     int src_traced         = getPid(comm, src);
 
     // FIXME: Hack the way to trace this one
-    std::vector<int>* dst_hack = new std::vector<int>;
-    std::vector<int>* src_hack = new std::vector<int>;
+    std::vector<int>* dst_hack = new std::vector<int>();
+    std::vector<int>* src_hack = new std::vector<int>();
     dst_hack->push_back(dst_traced);
     src_hack->push_back(src_traced);
     TRACE_smpi_comm_in(my_proc_id, __func__,
@@ -460,6 +460,7 @@ int PMPI_Sendrecv_replace(void* buf, int count, MPI_Datatype datatype, int dst,
   CHECK_TYPE(3, datatype)
 
   int size = datatype->get_extent() * count;
+  xbt_assert(size > 0);
   void* recvbuf = xbt_new0(char, size);
   retval = MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count, datatype, src, recvtag, comm, status);
   if(retval==MPI_SUCCESS){
index 8165328..a82845c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -24,7 +24,8 @@ int PMPI_Cart_create(MPI_Comm comm_old, int ndims, const int* dims, const int* p
   CHECK_NEGATIVE(2, MPI_ERR_ARG, ndims)
   for (int i = 0; i < ndims; i++)
     CHECK_NEGATIVE(2, MPI_ERR_ARG, dims[i])
-  simgrid::smpi::Topo_Cart* topo = new simgrid::smpi::Topo_Cart(comm_old, ndims, dims, periodic, reorder, comm_cart);
+  const simgrid::smpi::Topo_Cart* topo =
+      new simgrid::smpi::Topo_Cart(comm_old, ndims, dims, periodic, reorder, comm_cart);
   if (*comm_cart == MPI_COMM_NULL) {
     delete topo;
   } else {
@@ -113,7 +114,7 @@ int PMPI_Cart_sub(MPI_Comm comm, const int* remain_dims, MPI_Comm* comm_new) {
   if (topo==nullptr) {
     return MPI_ERR_ARG;
   }
-  MPIR_Cart_Topology cart = topo->sub(remain_dims, comm_new);
+  const simgrid::smpi::Topo_Cart* cart = topo->sub(remain_dims, comm_new);
   if(*comm_new==MPI_COMM_NULL)
       delete cart;
   if(cart==nullptr)
index 473daa2..8176b32 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index aaff7ad..45b7844 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -703,6 +703,8 @@ int PMPI_Win_set_errhandler(MPI_Win win, MPI_Errhandler errhandler){
 
 int PMPI_Win_call_errhandler(MPI_Win win,int errorcode){
   CHECK_WIN(1, win)
-  win->errhandler()->call(win, errorcode);
+  MPI_Errhandler err = win->errhandler();
+  err->call(win, errorcode);
+  simgrid::smpi::Errhandler::unref(err);
   return MPI_SUCCESS;
 }
index 0a774ad..10f41b5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -53,7 +53,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
  * Function: is_2dmesh
 
- * Return: int
+ * Return: bool
 
  * Inputs:
      num: the number of processors in a communicator
@@ -66,7 +66,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  ****************************************************************************/
 #ifndef TWOD
 #define TWOD
-static int is_2dmesh(int num, int *i, int *j)
+static bool is_2dmesh(int num, int* i, int* j)
 {
   int x, max = num / 2;
   x = sqrt(double(num));
@@ -82,11 +82,11 @@ static int is_2dmesh(int num, int *i, int *j)
         *j = x;
       }
 
-      return 1;
+      return true;
     }
     x++;
   }
-  return 0;
+  return false;
 }
 #endif
 /*****************************************************************************
index 02e5d12..b0a1002 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -50,8 +50,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *****************************************************************************/
 
 /*****************************************************************************
- * Function: is_2dmesh
- * return: int
+ * Function: is_3dmesh
+ * return: bool
  * num: the number of processors in a communicator
  * i: x dimension
  * j: y dimension
@@ -60,7 +60,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  ****************************************************************************/
 #ifndef THREED
 #define THREED
-static int is_3dmesh(int num, int *i, int *j, int *k)
+static bool is_3dmesh(int num, int* i, int* j, int* k)
 {
   int x, max = num / 3;
   x = cbrt(num);
@@ -69,11 +69,11 @@ static int is_3dmesh(int num, int *i, int *j, int *k)
     if ((num % (x * x)) == 0) {
       *i = *j = x;
       *k = num / (x * x);
-      return 1;
+      return true;
     }
     x++;
   }
-  return 0;
+  return false;
 }
 #endif
 /*****************************************************************************
index 63d5f33..aad2d1f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index d1cdb55..77b8723 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index c7a5380..b2ded1c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index afaabc3..f6c91ab 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 0c3706e..fa31811 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 2cbbe65..bf05661 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index c8e0600..c7a2d48 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -100,7 +100,7 @@ int allgather__mvapich2_smp(const void *sendbuf,int sendcnt, MPI_Datatype sendty
     /* Exchange the data between the node leaders*/
     if (local_rank == 0 && (leader_comm_size > 1)) {
         /*When data in each socket is different*/
-        if (comm->is_uniform() != 1) {
+        if (not comm->is_uniform()) {
 
             int *node_sizes = NULL;
             int i = 0;
index ad4f6a2..75bb2f3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 35372f7..d3cbef3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 7c62e75..4dff788 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 3fc59a6..3b9b391 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 9716db3..354d0da 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 8163bfb..b279d4d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 06332d5..4d1972b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 4123cfe..98d2c9a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 0087dd7..f1145b2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 7855b11..e923db5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index dae1b2d..bb2ee44 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index d026ec5..38c47df 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 7bf4271..1c1b490 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 851c6c4..902521a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 1920b14..4d24d5a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index cbfdaa7..bfd8e53 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@ int allreduce__mvapich2_rs(const void *sendbuf,
     int mpi_errno = MPI_SUCCESS;
     int newrank = 0;
     int mask, pof2, i, send_idx, recv_idx, last_idx, send_cnt;
-    int dst, is_commutative, rem, newdst, recv_cnt;
+    int dst, rem, newdst, recv_cnt;
     MPI_Aint true_lb, true_extent, extent;
 
     if (count == 0) {
@@ -47,7 +47,7 @@ int allreduce__mvapich2_rs(const void *sendbuf,
     int comm_size =  comm->size();
     int rank = comm->rank();
 
-    is_commutative = (op==MPI_OP_NULL || op->is_commutative());
+    bool is_commutative = (op == MPI_OP_NULL || op->is_commutative());
 
     /* need to allocate temporary buffer to store incoming data */
     datatype->extent(&true_lb, &true_extent);
index 393dba7..1ab4064 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index dfa142a..c864a07 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 209fbf4..94a342b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index e2808ec..2fad414 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index e1f09dc..33f100c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index e0859ce..19163c0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 4607c6e..9a7d66b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index e772a91..15c1446 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 81e6b9d..8c2c410 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index eb6c76a..489e719 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index caf0808..1bf3f35 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 2b40358..7e3c0c1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index c1316e8..38f89eb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 7da2954..c427d2c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 485d7b1..87a79b0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 799bccc..272ffb9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 0f001cd..93d562b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 0930b20..15dd553 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 26b629d..c3302de 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index a2cdc87..2577c4e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 2daafb4..c80ded7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 6b53837..0f8a190 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index f073888..7a78184 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 9c50d21..830ae6b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 29ef3ca..c477b3e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 43cb7d7..3891cb1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 7068328..e8d7562 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index d625e29..2ed596d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 37008f7..f8bd696 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 655c4b1..b2e7497 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index c209f5b..f5bcf6d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 7bac365..5005e57 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index ff7ed2a..67ff58b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 05d0ada..f01702f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 60e3ebf..196dfd3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index d40bfa1..33b178f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 53969d3..9df1420 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -43,10 +43,10 @@ int alltoallv__ring(const void* send_buff, const int* send_counts, const int* se
   num_procs = comm->size();
   send_chunk = send_type->get_extent();
   recv_chunk = recv_type->get_extent();
-  int pof2 = ((num_procs != 0) && ((num_procs & (~num_procs + 1)) == num_procs));
+  bool pof2  = ((num_procs != 0) && ((num_procs & (~num_procs + 1)) == num_procs));
   for (i = 0; i < num_procs; i++) {
 
-    if (pof2 == 1) {
+    if (pof2) {
       /* use exclusive-or algorithm */
       src = dst = rank ^ i;
     } else {
index a0e3027..03efef5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index e877c7d..073140e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 802481f..f5ac1dc 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index fa5aab1..d30b8b1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 535b208..6883351 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 5931266..1029e93 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 1690c72..2f56a6e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 986bf92..cf341e1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index a423e2d..c91a4a3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 6d331df..eba0963 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index b9a70b5..bd461a6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index bc56af4..080798f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 29d5a65..0ef9081 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 2899d05..48571dd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 5c73a9f..8b367f3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 70239f6..ca2b739 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -250,9 +250,9 @@ int bcast__mvapich2_intra_node(void *buffer,
 {
     int mpi_errno = MPI_SUCCESS;
     int comm_size;
-    int two_level_bcast = 1;
+    bool two_level_bcast = true;
     size_t nbytes = 0;
-    int is_homogeneous, is_contig;
+    bool is_homogeneous, is_contig;
     MPI_Aint type_size;
     unsigned char* tmp_buf = nullptr;
     MPI_Comm shmem_comm;
@@ -275,16 +275,16 @@ int bcast__mvapich2_intra_node(void *buffer,
    // rank = comm->rank();
 /*
     if (HANDLE_GET_KIND(datatype) == HANDLE_KIND_BUILTIN)*/
-        is_contig = 1;
+        is_contig = true;
 /*    else {
         MPID_Datatype_get_ptr(datatype, dtp);
         is_contig = dtp->is_contig;
     }
 */
-    is_homogeneous = 1;
+    is_homogeneous = true;
 #ifdef MPID_HAS_HETERO
     if (comm_ptr->is_hetero)
-        is_homogeneous = 0;
+      is_homogeneous = false;
 #endif
 
     /* MPI_Type_size() might not give the accurate size of the packed
@@ -303,13 +303,13 @@ int bcast__mvapich2_intra_node(void *buffer,
     nbytes = (size_t) (count) * (type_size);
     if (comm_size <= mv2_bcast_two_level_system_size) {
         if (nbytes > mv2_bcast_short_msg && nbytes < mv2_bcast_large_msg) {
-            two_level_bcast = 1;
+          two_level_bcast = true;
         } else {
-            two_level_bcast = 0;
+          two_level_bcast = false;
         }
     }
 
-    if (two_level_bcast == 1
+    if (two_level_bcast
 #if defined(_MCST_SUPPORT_)
             || comm_ptr->ch.is_mcast_ok
 #endif
index 393b714..805a8f6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index b4e7de5..24736d4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 5ac3dc6..7148af8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 9cf489b..85cb981 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2011-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -114,7 +114,8 @@ int bcast__scatter_rdb_allgather(
     int relative_rank, mask;
     int mpi_errno = MPI_SUCCESS;
     int scatter_size, curr_size, recv_size = 0;
-    int j, k, i, tmp_mask, is_contig, is_homogeneous;
+    int j, k, i, tmp_mask;
+    bool is_contig, is_homogeneous;
     MPI_Aint type_size = 0, nbytes = 0;
     int relative_dst, dst_tree_root, my_tree_root, send_offset;
     int recv_offset, tree_root, nprocs_completed, offset;
@@ -130,13 +131,9 @@ int bcast__scatter_rdb_allgather(
     if (comm_size == 1) goto fn_exit;
 
     //if (HANDLE_GET_KIND(datatype) == HANDLE_KIND_BUILTIN)
-    if(datatype->flags() & DT_FLAG_CONTIGUOUS)
-        is_contig = 1;
-    else {
-        is_contig = 0;
-    }
+    is_contig = ((datatype->flags() & DT_FLAG_CONTIGUOUS) != 0);
 
-    is_homogeneous = 1;
+    is_homogeneous = true;
 
     /* MPI_Type_size() might not give the accurate size of the packed
      * datatype for heterogeneous systems (because of padding, encoding,
index 56d09c8..28351a2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index cd65be0..11b879a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 2f0b8ef..856b843 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index db6b2e7..7a977ee 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 127ca1b..7cad39a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -52,9 +52,8 @@ typedef int (*MV2_Gather_function_ptr) (const void *sendbuf,
 extern MV2_Gather_function_ptr MV2_Gather_inter_leader_function;
 extern MV2_Gather_function_ptr MV2_Gather_intra_node_function;
 
-#define TEMP_BUF_HAS_NO_DATA (0)
-#define TEMP_BUF_HAS_DATA (1)
-
+#define TEMP_BUF_HAS_NO_DATA (false)
+#define TEMP_BUF_HAS_DATA (true)
 
 namespace simgrid{
 namespace smpi{
@@ -80,13 +79,9 @@ namespace smpi{
  *                      intra node gather function
  * errflag           - (out) to record errors
  */
-static int MPIR_pt_pt_intra_gather( const void *sendbuf, int sendcnt, MPI_Datatype sendtype,
-                            void *recvbuf, int recvcnt, MPI_Datatype recvtype,
-                            int root, int rank,
-                            void *tmp_buf, int nbytes,
-                            int is_data_avail,
-                            MPI_Comm comm,
-                            MV2_Gather_function_ptr intra_node_fn_ptr)
+static int MPIR_pt_pt_intra_gather(const void* sendbuf, int sendcnt, MPI_Datatype sendtype, void* recvbuf, int recvcnt,
+                                   MPI_Datatype recvtype, int root, int rank, void* tmp_buf, int nbytes,
+                                   bool is_data_avail, MPI_Comm comm, MV2_Gather_function_ptr intra_node_fn_ptr)
 {
     int mpi_errno = MPI_SUCCESS;
     MPI_Aint recvtype_extent = 0;  /* Datatype extent */
index 36fbe6b..3aaaab5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index a3f4e60..3b0e3af 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 63c4245..e2f142b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index a47f49a..065c434 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -29,7 +29,7 @@ int reduce__binomial(const void *sendbuf, void *recvbuf, int count,
   extent = datatype->get_extent();
 
   unsigned char* tmp_buf = smpi_get_tmp_sendbuffer(count * extent);
-  int is_commutative =  (op==MPI_OP_NULL || op->is_commutative());
+  bool is_commutative    = (op == MPI_OP_NULL || op->is_commutative());
   mask = 1;
 
   int lroot;
index 2eaffae..24ceabc 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 866ab8a..d2c91de 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -128,7 +128,7 @@ int reduce__mvapich2_knomial(
         MPI_Comm comm)
 {
     int mpi_errno = MPI_SUCCESS;
-    int rank, is_commutative;
+    int rank;
     int src, k;
     MPI_Request send_request;
     int index=0;
@@ -146,7 +146,7 @@ int reduce__mvapich2_knomial(
     datatype->extent(&true_lb, &true_extent);
     extent = datatype->get_extent();
 
-    is_commutative =  (op==MPI_OP_NULL || op->is_commutative());
+    bool is_commutative = (op == MPI_OP_NULL || op->is_commutative());
 
     if (rank != root) {
         recvbuf = (void*)smpi_get_tmp_recvbuffer(count * std::max(extent, true_extent));
index f3017a8..b52dcb2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -91,7 +91,7 @@ int reduce__mvapich2_two_level( const void *sendbuf,
     const unsigned char* in_buf = nullptr;
     unsigned char *out_buf = nullptr, *tmp_buf = nullptr;
     MPI_Aint true_lb, true_extent, extent;
-    int is_commutative = 0, stride = 0;
+    int stride          = 0;
     int intra_node_root=0;
 
     //if not set (use of the algo directly, without mvapich2 selector)
@@ -115,7 +115,7 @@ int reduce__mvapich2_two_level( const void *sendbuf,
     leader_of_root = comm->group()->rank(leaders_map[root]);
     leader_root = leader_comm->group()->rank(leaders_map[root]);
 
-    is_commutative= (op==MPI_OP_NULL || op->is_commutative());
+    bool is_commutative = (op == MPI_OP_NULL || op->is_commutative());
 
     datatype->extent(&true_lb,
                                        &true_extent);
@@ -124,8 +124,7 @@ int reduce__mvapich2_two_level( const void *sendbuf,
 
     if (local_size == total_size) {
         /* First handle the case where there is only one node */
-        if (stride <= MV2_INTRA_SHMEM_REDUCE_MSG &&
-            is_commutative == 1) {
+        if (stride <= MV2_INTRA_SHMEM_REDUCE_MSG && is_commutative) {
             if (local_rank == 0 ) {
               tmp_buf = smpi_get_tmp_sendbuffer(count * std::max(extent, true_extent));
               tmp_buf = tmp_buf - true_lb;
@@ -215,7 +214,7 @@ int reduce__mvapich2_two_level( const void *sendbuf,
          *this step*/
         if (MV2_Reduce_intra_function == & MPIR_Reduce_shmem_MV2)
         {
-          if (is_commutative == 1 && (count * (std::max(extent, true_extent)) < SHMEM_COLL_BLOCK_SIZE)) {
+          if (is_commutative && (count * (std::max(extent, true_extent)) < SHMEM_COLL_BLOCK_SIZE)) {
             mpi_errno = MV2_Reduce_intra_function(in_buf, out_buf, count, datatype, op, intra_node_root, shmem_comm);
             } else {
                     mpi_errno = MPIR_Reduce_intra_knomial_wrapper_MV2(in_buf, out_buf, count,
index 3f3cdb6..0caa56c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 86bb34a..0605957 100644 (file)
@@ -517,7 +517,8 @@ static void MPI_I_do_op(void* b1, void* b2, void* rslt, int cnt,
 REDUCE_LIMITS
 namespace simgrid{
 namespace smpi{
-static int MPI_I_anyReduce(const void* Sendbuf, void* Recvbuf, int count, MPI_Datatype mpi_datatype, MPI_Op mpi_op, int root, MPI_Comm comm, int is_all)
+static int MPI_I_anyReduce(const void* Sendbuf, void* Recvbuf, int count, MPI_Datatype mpi_datatype, MPI_Op mpi_op,
+                           int root, MPI_Comm comm, bool is_all)
 {
   char *scr1buf, *scr2buf, *scr3buf, *xxx, *sendbuf, *recvbuf;
   int myrank, size, x_base, x_size, computed, idx;
@@ -951,12 +952,12 @@ static int MPI_I_anyReduce(const void* Sendbuf, void* Recvbuf, int count, MPI_Da
 
 int reduce__rab(const void* Sendbuf, void* Recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
 {
-  return( MPI_I_anyReduce(Sendbuf, Recvbuf, count, datatype, op, root, comm, 0) );
+  return MPI_I_anyReduce(Sendbuf, Recvbuf, count, datatype, op, root, comm, false);
 }
 
 int allreduce__rab(const void* Sendbuf, void* Recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
 {
-  return( MPI_I_anyReduce(Sendbuf, Recvbuf, count, datatype, op,   -1, comm, 1) );
+  return MPI_I_anyReduce(Sendbuf, Recvbuf, count, datatype, op, -1, comm, true);
 }
 }
 }
index fa74378..208022e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 2f75f1f..1aa22b3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -32,16 +32,13 @@ int reduce_scatter__mpich_pair(const void *sendbuf, void *recvbuf, const int rec
     unsigned char* tmp_recvbuf;
     int mpi_errno = MPI_SUCCESS;
     int total_count, dst, src;
-    int is_commutative;
     comm_size = comm->size();
     rank = comm->rank();
 
     extent =datatype->get_extent();
     datatype->extent(&true_lb, &true_extent);
 
-    if (op->is_commutative()) {
-        is_commutative = 1;
-    }
+    bool is_commutative = (op == MPI_OP_NULL || op->is_commutative());
 
     int* disps = new int[comm_size];
 
@@ -274,16 +271,14 @@ int reduce_scatter__mpich_rdb(const void *sendbuf, void *recvbuf, const int recv
     int mask, dst_tree_root, my_tree_root, j, k;
     int received;
     MPI_Datatype sendtype, recvtype;
-    int nprocs_completed, tmp_mask, tree_root, is_commutative=0;
+    int nprocs_completed, tmp_mask, tree_root;
     comm_size = comm->size();
     rank = comm->rank();
 
     extent =datatype->get_extent();
     datatype->extent(&true_lb, &true_extent);
 
-    if ((op==MPI_OP_NULL) || op->is_commutative()) {
-        is_commutative = 1;
-    }
+    bool is_commutative = (op == MPI_OP_NULL || op->is_commutative());
 
     int* disps = new int[comm_size];
 
index 79f77d7..fc72566 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 399d94f..a762ce1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 50d24eb..1a13871 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 8e816ca..f33e414 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index b05003d..65ea838 100644 (file)
@@ -1,6 +1,6 @@
 /* smpi_coll.c -- various optimized routing for collectives                 */
 
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 4ca403e..64fdcf7 100644 (file)
@@ -1,6 +1,6 @@
 /* selector with default/naive Simgrid algorithms. These should not be trusted for performance evaluations */
 
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 7d21362..20c1c6f 100644 (file)
@@ -1,6 +1,6 @@
 /* selector for collective algorithms based on openmpi's default coll_tuned_decision_fixed selector */
 
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 3c0f27a..e877a88 100644 (file)
@@ -1,6 +1,6 @@
 /* selector for collective algorithms based on mpich decision logic */
 
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -69,7 +69,7 @@ int allreduce__mpich(const void *sbuf, void *rbuf, int count,
     block_dsize = dsize * count;
 
     /*MPICH uses SMP algorithms for all commutative ops now*/
-    if(!comm->is_smp_comm()){
+    if (not comm->is_smp_comm()) {
       if(comm->get_leaders_comm()==MPI_COMM_NULL){
         comm->init_smp();
       }
@@ -263,7 +263,7 @@ int bcast__mpich(void *buff, int count,
     //int segsize = 0;
     size_t message_size, dsize;
 
-    if(!comm->is_smp_comm()){
+    if (not comm->is_smp_comm()) {
       if(comm->get_leaders_comm()==MPI_COMM_NULL){
         comm->init_smp();
       }
@@ -359,7 +359,7 @@ int reduce__mpich(const void *sendbuf, void *recvbuf,
     int communicator_size=0;
     size_t message_size, dsize;
 
-    if(!comm->is_smp_comm()){
+    if (not comm->is_smp_comm()) {
       if(comm->get_leaders_comm()==MPI_COMM_NULL){
         comm->init_smp();
       }
@@ -457,10 +457,10 @@ int reduce_scatter__mpich(const void *sbuf, void *rbuf,
     if( (op==MPI_OP_NULL || op->is_commutative()) &&  total_message_size > 524288) {
         return reduce_scatter__mpich_pair(sbuf, rbuf, rcounts, dtype, op, comm);
     } else if ((op != MPI_OP_NULL && not op->is_commutative())) {
-      int is_block_regular = 1;
+      bool is_block_regular = true;
       for (i = 0; i < (comm_size - 1); ++i) {
         if (rcounts[i] != rcounts[i + 1]) {
-          is_block_regular = 0;
+          is_block_regular = false;
           break;
         }
       }
index 2128f77..ac8185c 100644 (file)
@@ -1,6 +1,6 @@
 /* selector for collective algorithms based on mvapich decision logic */
 
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -86,10 +86,9 @@ int allgather__mvapich2(const void *sendbuf, int sendcount, MPI_Datatype sendtyp
   int mpi_errno = MPI_SUCCESS;
   long nbytes = 0, comm_size, recvtype_size;
   int range = 0;
-  int partial_sub_ok = 0;
+  bool partial_sub_ok = false;
   int conf_index = 0;
   int range_threshold = 0;
-  int is_two_level = 0;
   MPI_Comm shmem_comm;
   //MPI_Comm *shmem_commptr=NULL;
   /* Get the size of the communicator */
@@ -116,14 +115,14 @@ int allgather__mvapich2(const void *sendbuf, int sendcount, MPI_Datatype sendtyp
     do {
       if (local_size == mv2_allgather_table_ppn_conf[i]) {
         conf_index = i;
-        partial_sub_ok = 1;
+        partial_sub_ok = true;
         break;
       }
       i++;
     } while(i < mv2_allgather_num_ppn_conf);
   }
   conf_check_end:
-  if (partial_sub_ok != 1) {
+  if (not partial_sub_ok) {
     conf_index = 0;
   }
 
@@ -147,11 +146,11 @@ int allgather__mvapich2(const void *sendbuf, int sendcount, MPI_Datatype sendtyp
       mv2_allgather_thresholds_table[conf_index][range].inter_leader[range_threshold].
       MV2_pt_Allgatherction;
 
-  is_two_level =  mv2_allgather_thresholds_table[conf_index][range].two_level[range_threshold];
+  bool is_two_level = mv2_allgather_thresholds_table[conf_index][range].two_level[range_threshold];
 
   /* intracommunicator */
-  if(is_two_level ==1){
-    if(partial_sub_ok ==1){
+  if (is_two_level) {
+    if (partial_sub_ok) {
       if (comm->is_blocked()){
       mpi_errno = MPIR_2lvl_Allgather_MV2(sendbuf, sendcount, sendtype,
                             recvbuf, recvcount, recvtype,
@@ -340,18 +339,17 @@ int allreduce__mvapich2(const void *sendbuf,
 
   MPI_Aint sendtype_size = 0;
   long nbytes = 0;
-  int is_commutative = 0;
   MPI_Aint true_lb, true_extent;
 
   sendtype_size=datatype->size();
   nbytes = count * sendtype_size;
 
   datatype->extent(&true_lb, &true_extent);
-  is_commutative = op->is_commutative();
+  bool is_commutative = op->is_commutative();
 
   {
     int range = 0, range_threshold = 0, range_threshold_intra = 0;
-    int is_two_level = 0;
+    bool is_two_level = false;
 
     /* Search for the corresponding system size inside the tuning table */
     while ((range < (mv2_size_allreduce_tuning_table - 1)) &&
@@ -360,7 +358,7 @@ int allreduce__mvapich2(const void *sendbuf,
     }
     /* Search for corresponding inter-leader function */
     /* skip mcast pointers if mcast is not available */
-    if(mv2_allreduce_thresholds_table[range].mcast_enabled != 1){
+    if (not mv2_allreduce_thresholds_table[range].mcast_enabled) {
         while ((range_threshold < (mv2_allreduce_thresholds_table[range].size_inter_table - 1))
             && ((mv2_allreduce_thresholds_table[range].
                 inter_leader[range_threshold].MV2_pt_Allreducection
@@ -378,8 +376,8 @@ int allreduce__mvapich2(const void *sendbuf,
     && (mv2_allreduce_thresholds_table[range].inter_leader[range_threshold].max != -1)) {
         range_threshold++;
     }
-    if(mv2_allreduce_thresholds_table[range].is_two_level_allreduce[range_threshold] == 1){
-        is_two_level = 1;
+    if (mv2_allreduce_thresholds_table[range].is_two_level_allreduce[range_threshold]) {
+      is_two_level = true;
     }
     /* Search for corresponding intra-node function */
     while ((range_threshold_intra <
@@ -403,23 +401,23 @@ int allreduce__mvapich2(const void *sendbuf,
         {
           MV2_Allreducection = &MPIR_Allreduce_pt2pt_rd_MV2;
         }
-        if(is_two_level != 1) {
+        if (not is_two_level) {
             MV2_Allreducection = &MPIR_Allreduce_pt2pt_rd_MV2;
         }
     }
 
-    if(is_two_level == 1){
-        // check if shm is ready, if not use other algorithm first
-        if (is_commutative) {
+    if (is_two_level) {
+      // check if shm is ready, if not use other algorithm first
+      if (is_commutative) {
           if(comm->get_leaders_comm()==MPI_COMM_NULL){
             comm->init_smp();
           }
           mpi_errno = MPIR_Allreduce_two_level_MV2(sendbuf, recvbuf, count,
                                                      datatype, op, comm);
-                } else {
+      } else {
         mpi_errno = MPIR_Allreduce_pt2pt_rd_MV2(sendbuf, recvbuf, count,
             datatype, op, comm);
-        }
+      }
     } else {
         mpi_errno = MV2_Allreducection(sendbuf, recvbuf, count,
             datatype, op, comm);
@@ -468,12 +466,11 @@ int bcast__mvapich2(void *buffer,
 {
     int mpi_errno = MPI_SUCCESS;
     int comm_size/*, rank*/;
-    int two_level_bcast = 1;
+    bool two_level_bcast      = true;
     long nbytes = 0;
     int range = 0;
     int range_threshold = 0;
     int range_threshold_intra = 0;
-    // int is_homogeneous, is_contig;
     MPI_Aint type_size;
     //, position;
     // unsigned char *tmp_buf = NULL;
@@ -490,15 +487,15 @@ int bcast__mvapich2(void *buffer,
     comm_size = comm->size();
     //rank = comm->rank();
 
-    //is_contig=1;
+    // bool is_contig = true;
 /*    if (HANDLE_GET_KIND(datatype) == HANDLE_KIND_BUILTIN)*/
-/*        is_contig = 1;*/
+/*        is_contig = true;*/
 /*    else {*/
 /*        MPID_Datatype_get_ptr(datatype, dtp);*/
 /*        is_contig = dtp->is_contig;*/
 /*    }*/
 
-    // is_homogeneous = 1;
+    // bool is_homogeneous = true;
 
     /* MPI_Type_size() might not give the accurate size of the packed
      * datatype for heterogeneous systems (because of padding, encoding,
@@ -585,7 +582,7 @@ int bcast__mvapich2(void *buffer,
 #else
         mv2_bcast_thresholds_table[range].is_two_level_bcast[range_threshold];
 #endif
-     if (two_level_bcast == 1) {
+    if (two_level_bcast) {
        // if (not is_contig || not is_homogeneous) {
 //   tmp_buf = smpi_get_tmp_sendbuffer(nbytes);
 
@@ -669,11 +666,11 @@ int reduce__mvapich2(const void *sendbuf,
   int range = 0;
   int range_threshold = 0;
   int range_intra_threshold = 0;
-  int is_commutative, pof2;
+  int pof2;
   int comm_size = 0;
   long nbytes = 0;
   int sendtype_size;
-  int is_two_level = 0;
+  bool is_two_level = false;
 
   comm_size = comm->size();
   sendtype_size=datatype->size();
@@ -682,7 +679,7 @@ int reduce__mvapich2(const void *sendbuf,
   if (count == 0)
     return MPI_SUCCESS;
 
-  is_commutative = (op==MPI_OP_NULL || op->is_commutative());
+  bool is_commutative = (op == MPI_OP_NULL || op->is_commutative());
 
   /* find nearest power-of-two less than or equal to comm_size */
   for( pof2 = 1; pof2 <= comm_size; pof2 <<= 1 );
@@ -729,24 +726,23 @@ int reduce__mvapich2(const void *sendbuf,
     {
       mv2_reduce_inter_knomial_factor = mv2_reduce_thresholds_table[range].inter_k_degree;
     }
-  if(mv2_reduce_thresholds_table[range].is_two_level_reduce[range_threshold] == 1){
-      is_two_level = 1;
+  if (mv2_reduce_thresholds_table[range].is_two_level_reduce[range_threshold]) {
+    is_two_level = true;
   }
   /* We call Reduce function */
-  if(is_two_level == 1)
-    {
-       if (is_commutative == 1) {
+  if (is_two_level) {
+    if (is_commutative) {
          if(comm->get_leaders_comm()==MPI_COMM_NULL){
            comm->init_smp();
          }
          mpi_errno = MPIR_Reduce_two_level_helper_MV2(sendbuf, recvbuf, count,
                                            datatype, op, root, comm);
-        } else {
+    } else {
       mpi_errno = MPIR_Reduce_binomial_MV2(sendbuf, recvbuf, count,
           datatype, op, root, comm);
-      }
+    }
     } else if(MV2_Reduce_function == &MPIR_Reduce_inter_knomial_wrapper_MV2 ){
-        if(is_commutative ==1)
+        if (is_commutative)
           {
             mpi_errno = MV2_Reduce_function(sendbuf, recvbuf, count,
                 datatype, op, root, comm);
@@ -781,13 +777,12 @@ int reduce_scatter__mvapich2(const void *sendbuf, void *recvbuf, const int *recv
   int mpi_errno = MPI_SUCCESS;
   int i = 0, comm_size = comm->size(), total_count = 0, type_size =
       0, nbytes = 0;
-  int is_commutative = 0;
   int* disps          = new int[comm_size];
 
   if(mv2_red_scat_thresholds_table==NULL)
     init_mv2_reduce_scatter_tables_stampede();
 
-  is_commutative=(op==MPI_OP_NULL || op->is_commutative());
+  bool is_commutative = (op == MPI_OP_NULL || op->is_commutative());
   for (i = 0; i < comm_size; i++) {
       disps[i] = total_count;
       total_count += recvcnts[i];
@@ -823,10 +818,10 @@ int reduce_scatter__mvapich2(const void *sendbuf, void *recvbuf, const int *recv
           recvcnts, datatype,
           op, comm);
   } else {
-      int is_block_regular = 1;
+      bool is_block_regular = true;
       for (i = 0; i < (comm_size - 1); ++i) {
           if (recvcnts[i] != recvcnts[i+1]) {
-              is_block_regular = 0;
+              is_block_regular = false;
               break;
           }
       }
@@ -861,7 +856,7 @@ int scatter__mvapich2(const void *sendbuf,
   int mpi_errno = MPI_SUCCESS;
   //   int mpi_errno_ret = MPI_SUCCESS;
   int rank, nbytes, comm_size;
-  int partial_sub_ok = 0;
+  bool partial_sub_ok = false;
   int conf_index = 0;
      MPI_Comm shmem_comm;
   //    MPID_Comm *shmem_commptr=NULL;
@@ -897,7 +892,7 @@ int scatter__mvapich2(const void *sendbuf,
             do {
                 if (local_size == mv2_scatter_table_ppn_conf[i]) {
                     conf_index = i;
-                    partial_sub_ok = 1;
+                    partial_sub_ok = true;
                     break;
                 }
                 i++;
@@ -905,7 +900,7 @@ int scatter__mvapich2(const void *sendbuf,
         }
     }
 
-  if (partial_sub_ok != 1) {
+  if (not partial_sub_ok) {
       conf_index = 0;
   }
 
index e859efc..8b3928c 100644 (file)
@@ -2,7 +2,7 @@
 /* This is the tuning used by MVAPICH for Stampede platform based on (MV2_ARCH_INTEL_XEON_E5_2680_16,
  * MV2_HCA_MLX_CX_FDR) */
 
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -339,7 +339,7 @@ struct mv2_allgather_tuning_element {
 
 struct mv2_allgather_tuning_table {
   int numproc;
-  int two_level[MV2_MAX_NB_THRESHOLDS];
+  bool two_level[MV2_MAX_NB_THRESHOLDS];
   int size_inter_table;
   mv2_allgather_tuning_element inter_leader[MV2_MAX_NB_THRESHOLDS];
 };
@@ -379,7 +379,7 @@ static void init_mv2_allgather_tables_stampede()
   mv2_allgather_tuning_table mv2_tmp_allgather_thresholds_table_1ppn[] = {
       {
           2,
-          {0},
+          {false},
           1,
           {
               {0, -1, &MPIR_Allgather_Ring_MV2},
@@ -387,7 +387,7 @@ static void init_mv2_allgather_tables_stampede()
       },
       {
           4,
-          {0, 0},
+          {false, false},
           2,
           {
               {0, 262144, &MPIR_Allgather_RD_MV2}, {262144, -1, &MPIR_Allgather_Ring_MV2},
@@ -395,7 +395,7 @@ static void init_mv2_allgather_tables_stampede()
       },
       {
           8,
-          {0, 0},
+          {false, false},
           2,
           {
               {0, 131072, &MPIR_Allgather_RD_MV2}, {131072, -1, &MPIR_Allgather_Ring_MV2},
@@ -403,7 +403,7 @@ static void init_mv2_allgather_tables_stampede()
       },
       {
           16,
-          {0, 0},
+          {false, false},
           2,
           {
               {0, 131072, &MPIR_Allgather_RD_MV2}, {131072, -1, &MPIR_Allgather_Ring_MV2},
@@ -411,7 +411,7 @@ static void init_mv2_allgather_tables_stampede()
       },
       {
           32,
-          {0, 0},
+          {false, false},
           2,
           {
               {0, 65536, &MPIR_Allgather_RD_MV2}, {65536, -1, &MPIR_Allgather_Ring_MV2},
@@ -419,7 +419,7 @@ static void init_mv2_allgather_tables_stampede()
       },
       {
           64,
-          {0, 0},
+          {false, false},
           2,
           {
               {0, 32768, &MPIR_Allgather_RD_MV2}, {32768, -1, &MPIR_Allgather_Ring_MV2},
@@ -432,7 +432,7 @@ static void init_mv2_allgather_tables_stampede()
   mv2_allgather_tuning_table mv2_tmp_allgather_thresholds_table_2ppn[] = {
       {
           4,
-          {0, 0},
+          {false, false},
           2,
           {
               {0, 524288, &MPIR_Allgather_RD_MV2}, {524288, -1, &MPIR_Allgather_Ring_MV2},
@@ -440,7 +440,7 @@ static void init_mv2_allgather_tables_stampede()
       },
       {
           8,
-          {0, 1, 0},
+          {false, true, false},
           2,
           {
               {0, 32768, &MPIR_Allgather_RD_MV2},
@@ -450,7 +450,7 @@ static void init_mv2_allgather_tables_stampede()
       },
       {
           16,
-          {0, 1, 0},
+          {false, true, false},
           2,
           {
               {0, 16384, &MPIR_Allgather_RD_MV2},
@@ -460,7 +460,7 @@ static void init_mv2_allgather_tables_stampede()
       },
       {
           32,
-          {1, 1, 0},
+          {true, true, false},
           2,
           {
               {0, 65536, &MPIR_Allgather_RD_MV2},
@@ -470,7 +470,7 @@ static void init_mv2_allgather_tables_stampede()
       },
       {
           64,
-          {1, 1, 0},
+          {true, true, false},
           2,
           {
               {0, 32768, &MPIR_Allgather_RD_MV2},
@@ -480,7 +480,7 @@ static void init_mv2_allgather_tables_stampede()
       },
       {
           128,
-          {1, 1, 0},
+          {true, true, false},
           2,
           {
               {0, 65536, &MPIR_Allgather_RD_MV2},
@@ -495,7 +495,7 @@ static void init_mv2_allgather_tables_stampede()
   mv2_allgather_tuning_table mv2_tmp_allgather_thresholds_table_16ppn[] = {
       {
           16,
-          {0, 0},
+          {false, false},
           2,
           {
               {0, 1024, &MPIR_Allgather_RD_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2},
@@ -503,7 +503,7 @@ static void init_mv2_allgather_tables_stampede()
       },
       {
           32,
-          {0, 0},
+          {false, false},
           2,
           {
               {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2},
@@ -511,7 +511,7 @@ static void init_mv2_allgather_tables_stampede()
       },
       {
           64,
-          {0, 0},
+          {false, false},
           2,
           {
               {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2},
@@ -519,7 +519,7 @@ static void init_mv2_allgather_tables_stampede()
       },
       {
           128,
-          {0, 0},
+          {false, false},
           2,
           {
               {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2},
@@ -527,7 +527,7 @@ static void init_mv2_allgather_tables_stampede()
       },
       {
           256,
-          {0, 0},
+          {false, false},
           2,
           {
               {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2},
@@ -535,7 +535,7 @@ static void init_mv2_allgather_tables_stampede()
       },
       {
           512,
-          {0, 0},
+          {false, false},
           2,
           {
               {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2}, {1024, -1, &MPIR_Allgather_Ring_MV2},
@@ -737,8 +737,8 @@ struct mv2_allreduce_tuning_element {
 
 struct mv2_allreduce_tuning_table {
   int numproc;
-  int mcast_enabled;
-  int is_two_level_allreduce[MV2_MAX_NB_THRESHOLDS];
+  bool mcast_enabled;
+  bool is_two_level_allreduce[MV2_MAX_NB_THRESHOLDS];
   int size_inter_table;
   mv2_allreduce_tuning_element inter_leader[MV2_MAX_NB_THRESHOLDS];
   int size_intra_table;
@@ -793,8 +793,8 @@ static void init_mv2_allreduce_tables_stampede()
   mv2_allreduce_tuning_table mv2_tmp_allreduce_thresholds_table[] = {
       {
           16,
-          0,
-          {1, 0},
+          false,
+          {true, false},
           2,
           {
               {0, 1024, &MPIR_Allreduce_pt2pt_rd_MV2}, {1024, -1, &MPIR_Allreduce_pt2pt_rs_MV2},
@@ -806,8 +806,8 @@ static void init_mv2_allreduce_tables_stampede()
       },
       {
           32,
-          0,
-          {1, 1, 0},
+          false,
+          {true, true, false},
           3,
           {
               {0, 1024, &MPIR_Allreduce_pt2pt_rd_MV2},
@@ -821,8 +821,8 @@ static void init_mv2_allreduce_tables_stampede()
       },
       {
           64,
-          0,
-          {1, 1, 0},
+          false,
+          {true, true, false},
           3,
           {
               {0, 512, &MPIR_Allreduce_pt2pt_rd_MV2},
@@ -836,8 +836,8 @@ static void init_mv2_allreduce_tables_stampede()
       },
       {
           128,
-          0,
-          {1, 1, 0},
+          false,
+          {true, true, false},
           3,
           {
               {0, 512, &MPIR_Allreduce_pt2pt_rd_MV2},
@@ -851,8 +851,8 @@ static void init_mv2_allreduce_tables_stampede()
       },
       {
           256,
-          0,
-          {1, 1, 0},
+          false,
+          {true, true, false},
           3,
           {
               {0, 512, &MPIR_Allreduce_pt2pt_rd_MV2},
@@ -866,8 +866,8 @@ static void init_mv2_allreduce_tables_stampede()
       },
       {
           512,
-          0,
-          {1, 1, 0},
+          false,
+          {true, true, false},
           3,
           {
               {0, 512, &MPIR_Allreduce_pt2pt_rd_MV2},
@@ -881,8 +881,8 @@ static void init_mv2_allreduce_tables_stampede()
       },
       {
           1024,
-          0,
-          {1, 1, 1, 0},
+          false,
+          {true, true, true, false},
           4,
           {
               {0, 512, &MPIR_Allreduce_pt2pt_rd_MV2},
@@ -897,8 +897,8 @@ static void init_mv2_allreduce_tables_stampede()
       },
       {
           2048,
-          0,
-          {1, 1, 1, 0},
+          false,
+          {true, true, true, false},
           4,
           {
               {0, 64, &MPIR_Allreduce_pt2pt_rd_MV2},
@@ -929,7 +929,7 @@ struct mv2_bcast_tuning_table {
   int bcast_segment_size;
   int intra_node_knomial_factor;
   int inter_node_knomial_factor;
-  int is_two_level_bcast[MV2_MAX_NB_THRESHOLDS];
+  bool is_two_level_bcast[MV2_MAX_NB_THRESHOLDS];
   int size_inter_table;
   mv2_bcast_tuning_element inter_leader[MV2_MAX_NB_THRESHOLDS];
   int size_intra_table;
@@ -980,7 +980,7 @@ static void init_mv2_bcast_tables_stampede()
        8192,
        4,
        4,
-       {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
+       {true, true, true, true, true, true, true, true, true, true, true},
        11,
        {{0, 8, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2},
         {8, 16, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
@@ -1009,7 +1009,7 @@ static void init_mv2_bcast_tables_stampede()
        8192,
        4,
        4,
-       {1, 1, 1, 1, 1, 1, 1, 1},
+       {true, true, true, true, true, true, true, true},
        8,
        {{0, 128, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2},
         {128, 256, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
@@ -1032,7 +1032,7 @@ static void init_mv2_bcast_tables_stampede()
        8192,
        4,
        4,
-       {1, 1, 1, 1, 1, 1, 1, 1, 1},
+       {true, true, true, true, true, true, true, true, true},
        9,
        {{0, 2, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
         {2, 4, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8},
@@ -1057,7 +1057,7 @@ static void init_mv2_bcast_tables_stampede()
        8192,
        4,
        4,
-       {1, 1, 1, 0},
+       {true, true, true, false},
        4,
        {{0, 8192, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8},
         {8192, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
@@ -1072,7 +1072,7 @@ static void init_mv2_bcast_tables_stampede()
        8192,
        4,
        4,
-       {1, 1, 1, 1, 1},
+       {true, true, true, true, true},
        5,
        {{0, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
         {16384, 131072, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2},
@@ -1089,7 +1089,7 @@ static void init_mv2_bcast_tables_stampede()
        8192,
        4,
        4,
-       {1, 1, 1, 1, 1},
+       {true, true, true, true, true},
        5,
        {{0, 4096, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8},
         {4096, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
@@ -1106,7 +1106,7 @@ static void init_mv2_bcast_tables_stampede()
        8192,
        4,
        4,
-       {1, 1, 1, 1, 1},
+       {true, true, true, true, true},
        5,
        {{0, 8192, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8},
         {8192, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
@@ -1123,7 +1123,7 @@ static void init_mv2_bcast_tables_stampede()
        8192,
        4,
        4,
-       {1, 1, 1, 1, 1, 1, 1},
+       {true, true, true, true, true, true, true},
        7,
        {{0, 16, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8},
         {16, 32, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
@@ -1157,7 +1157,7 @@ struct mv2_reduce_tuning_table {
   int numproc;
   int inter_k_degree;
   int intra_k_degree;
-  int is_two_level_reduce[MV2_MAX_NB_THRESHOLDS];
+  bool is_two_level_reduce[MV2_MAX_NB_THRESHOLDS];
   int size_inter_table;
   mv2_reduce_tuning_element inter_leader[MV2_MAX_NB_THRESHOLDS];
   int size_intra_table;
@@ -1195,7 +1195,7 @@ static void init_mv2_reduce_tables_stampede()
           16,
           4,
           4,
-          {1, 0, 0},
+          {true, false, false},
           3,
           {
               {0, 262144, &MPIR_Reduce_inter_knomial_wrapper_MV2},
@@ -1211,7 +1211,7 @@ static void init_mv2_reduce_tables_stampede()
           32,
           4,
           4,
-          {1, 1, 1, 1, 0, 0, 0},
+          {true, true, true, true, false, false, false},
           7,
           {
               {0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2},
@@ -1236,7 +1236,7 @@ static void init_mv2_reduce_tables_stampede()
           64,
           4,
           4,
-          {1, 1, 1, 1, 0},
+          {true, true, true, true, false},
           5,
           {
               {0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2},
@@ -1258,7 +1258,7 @@ static void init_mv2_reduce_tables_stampede()
           128,
           4,
           4,
-          {1, 0, 1, 0, 1, 0},
+          {true, false, true, false, true, false},
           6,
           {
               {0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2},
@@ -1281,7 +1281,7 @@ static void init_mv2_reduce_tables_stampede()
           256,
           4,
           4,
-          {1, 1, 1, 0, 1, 1, 0},
+          {true, true, true, false, true, true, false},
           7,
           {
               {0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2},
@@ -1306,7 +1306,7 @@ static void init_mv2_reduce_tables_stampede()
           512,
           4,
           4,
-          {1, 0, 1, 1, 1, 0},
+          {true, false, true, true, true, false},
           6,
           {
               {0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2},
@@ -1329,7 +1329,7 @@ static void init_mv2_reduce_tables_stampede()
           1024,
           4,
           4,
-          {1, 0, 1, 1, 1},
+          {true, false, true, true, true},
           5,
           {
               {0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2},
@@ -1351,7 +1351,7 @@ static void init_mv2_reduce_tables_stampede()
           2048,
           4,
           4,
-          {1, 0, 1, 1, 1, 1},
+          {true, false, true, true, true, true},
           6,
           {
               {0, 2048, &MPIR_Reduce_inter_knomial_wrapper_MV2},
index a56f631..4a174df 100644 (file)
@@ -1,6 +1,6 @@
 /* Asynchronous parts of the basic collective algorithms, meant to be used both for the naive default implementation, but also for non blocking collectives */
 
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 46eca5e..e5f5e92 100644 (file)
@@ -1,6 +1,6 @@
 /* selector for collective algorithms based on openmpi's default coll_tuned_decision_fixed selector */
 
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -100,12 +100,12 @@ int barrier__ompi(MPI_Comm  comm)
 /*     * the use the recursive doubling algorithm, otherwise*/
 /*     * bruck is the one we want.*/
     {
-        int has_one = 0;
+        bool has_one = false;
         for( ; communicator_size > 0; communicator_size >>= 1 ) {
             if( communicator_size & 0x1 ) {
                 if( has_one )
                     return barrier__ompi_bruck(comm);
-                has_one = 1;
+                has_one = true;
             }
         }
     }
index ed2dbce..07c4bfd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index c35535b..bd78da2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index c4f1eb5..7a0006a 100644 (file)
@@ -1,5 +1,5 @@
 /* High level handling of collective algorithms */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index dacb7e3..a9fa971 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -17,30 +17,32 @@ namespace simgrid{
 namespace smpi{
 
 class Comm : public F2C, public Keyval{
+  friend Topo;
   MPI_Group group_;
-  SMPI_Topo_type topoType_;
+  SMPI_Topo_type topoType_ = MPI_INVALID_TOPO;
   MPI_Topology topo_; // to be replaced by an union
-  int refcount_;
-  MPI_Comm leaders_comm_; // inter-node communicator
-  MPI_Comm intra_comm_;   // intra-node communicator . For MPI_COMM_WORLD this can't be used, as var is global.
-  // use an intracomm stored in the process data instead
-  int* leaders_map_; // who is the leader of each process
-  int is_uniform_;
-  int* non_uniform_map_;        // set if smp nodes have a different number of processes allocated
-  int is_blocked_;              // are ranks allocated on the same smp node contiguous ?
-  int is_smp_comm_;             // set to 0 in case this is already an intra-comm or a leader-comm to avoid recursion
+  int refcount_          = 1;
+  MPI_Comm leaders_comm_ = MPI_COMM_NULL; // inter-node communicator
+  MPI_Comm intra_comm_   = MPI_COMM_NULL; // intra-node communicator. For MPI_COMM_WORLD this can't be used, as var is
+                                          // global. Use an intracomm stored in the process data instead
+  int* leaders_map_     = nullptr;        // who is the leader of each process
+  int is_uniform_       = 1;
+  int* non_uniform_map_ = nullptr; // set if smp nodes have a different number of processes allocated
+  int is_blocked_       = 0;       // are ranks allocated on the same smp node contiguous ?
+  bool is_smp_comm_     = false;   // set to false in case this is already an intra-comm or a leader-comm to avoid
+                                   // recursion
   std::list<MPI_Win> rma_wins_; // attached windows for synchronization.
   std::string name_;
-  MPI_Info info_;
+  MPI_Info info_ = MPI_INFO_NULL;
   int id_;
-  MPI_Errhandler errhandler_;
+  MPI_Errhandler errhandler_ = MPI_ERRORS_ARE_FATAL;
 
 public:
   static std::unordered_map<int, smpi_key_elem> keyvals_;
   static int keyval_id_;
 
   Comm() = default;
-  Comm(MPI_Group group, MPI_Topology topo, int smp = 0, int id=MPI_UNDEFINED);
+  Comm(MPI_Group group, MPI_Topology topo, bool smp = false, int id = MPI_UNDEFINED);
   int dup(MPI_Comm* newcomm);
   int dup_with_info(MPI_Info info, MPI_Comm* newcomm);
   MPI_Group group();
@@ -61,9 +63,9 @@ public:
   MPI_Comm get_leaders_comm();
   MPI_Comm get_intra_comm();
   MPI_Comm find_intra_comm(int* leader);
-  int is_uniform();
-  int is_blocked();
-  int is_smp_comm();
+  bool is_uniform();
+  bool is_blocked();
+  bool is_smp_comm();
   MPI_Comm split(int color, int key);
   void cleanup_smp();
   void ref();
@@ -82,7 +84,7 @@ public:
   void add_rma_win(MPI_Win win);
   void remove_rma_win(MPI_Win win);
   void finish_rma_calls();
-  MPI_Comm split_type(int type, int key, MPI_Info info);
+  MPI_Comm split_type(int type, int key, const Info* info);
 };
 
 } // namespace smpi
index ac9bfc0..e934e39 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 09a821b..5b4d4c0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -77,7 +77,7 @@ namespace simgrid{
 namespace smpi{
 
 class Datatype : public F2C, public Keyval{
-  char* name_;
+  char* name_ = nullptr;
   /* The id here is the (unique) datatype id used for this datastructure.
    * It's default value is set to -1 since some code expects this return value
    * when no other id has been assigned
@@ -87,7 +87,7 @@ class Datatype : public F2C, public Keyval{
   MPI_Aint lb_;
   MPI_Aint ub_;
   int flags_;
-  int refcount_;
+  int refcount_ = 1;
 
 public:
   static std::unordered_map<int, smpi_key_elem> keyvals_;
@@ -114,7 +114,7 @@ public:
   void commit();
   bool is_valid();
   bool is_basic();
-  static const char* encode(MPI_Datatype dt) { return dt->id.c_str(); }
+  static const char* encode(const Datatype* dt) { return dt->id.c_str(); }
   static MPI_Datatype decode(const std::string& datatype_id);
   bool is_replayable();
   void addflag(int flag);
@@ -129,8 +129,8 @@ public:
   static int keyval_create(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval,
                            void* extra_state);
   static int keyval_free(int* keyval);
-  int pack(const void* inbuf, int incount, void* outbuf, int outcount, int* position, MPI_Comm comm);
-  int unpack(const void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Comm comm);
+  int pack(const void* inbuf, int incount, void* outbuf, int outcount, int* position, const Comm* comm);
+  int unpack(const void* inbuf, int insize, int* position, void* outbuf, int outcount, const Comm* comm);
 
   static int create_contiguous(int count, MPI_Datatype old_type, MPI_Aint lb, MPI_Datatype* new_type);
   static int create_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type);
index 28b9fa5..fb5922b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index e08e91f..3030901 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 455973c..de22e28 100644 (file)
@@ -1,6 +1,6 @@
 /* Handle Fortan - C conversion for MPI Types*/
 
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@ class F2C {
     // Beware of collisions if id in mpif.h is not unique
     static std::unordered_map<std::string, F2C*>* f2c_lookup_;
     static int f2c_id_;
-    int my_f2c_id_;
+    int my_f2c_id_ = -1;
 
   protected:
     static std::unordered_map<std::string, F2C*>* f2c_lookup();
@@ -36,7 +36,7 @@ class F2C {
     static char* get_key(char* key, int id);
     static void delete_lookup();
     static std::unordered_map<std::string, F2C*>* lookup();
-    F2C() : my_f2c_id_(-1){}
+    F2C() {}
     virtual ~F2C() = default;
 
     //Override these to handle specific values.
index 95e3d99..24e653b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -45,7 +45,7 @@ class File{
   int sync();
   int seek(MPI_Offset offset, int whence);
   int seek_shared(MPI_Offset offset, int whence);
-  int set_view(MPI_Offset disp, MPI_Datatype etype, MPI_Datatype filetype, const char *datarep, MPI_Info info);
+  int set_view(MPI_Offset disp, MPI_Datatype etype, MPI_Datatype filetype, const char* datarep, const Info* info);
   int get_view(MPI_Offset *disp, MPI_Datatype *etype, MPI_Datatype *filetype, char *datarep);
   MPI_Info info();
   void set_info( MPI_Info info);
@@ -57,7 +57,7 @@ class File{
   static int write_ordered(MPI_File fh, const void *buf, int count,MPI_Datatype datatype, MPI_Status *status);
   template <int (*T)(MPI_File, void *, int, MPI_Datatype, MPI_Status *)> int op_all(void *buf, int count,MPI_Datatype datatype, MPI_Status *status);
   static int close(MPI_File *fh);
-  static int del(const char *filename, MPI_Info info);
+  static int del(const char* filename, const Info* info);
   MPI_Errhandler errhandler();
   void set_errhandler( MPI_Errhandler errhandler);
 };
index e82bedc..889dfa6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 8768c01..4c0abca 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 1fb206a..280afa5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -21,7 +21,7 @@ class Info : public F2C{
 
 public:
   Info() = default;
-  explicit Info(Info* orig) : map_(orig->map_) {}
+  explicit Info(const Info* orig) : map_(orig->map_) {}
   ~Info() = default;
   void ref();
   static void unref(MPI_Info info);
index a23be10..71bcae8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -56,7 +56,8 @@ class Keyval{
     template <typename T> int attr_delete(int keyval);
     template <typename T> int attr_get(int keyval, void* attr_value, int* flag);
     template <typename T> int attr_put(int keyval, void* attr_value);
-    template <typename T> static int call_deleter(T* obj, smpi_key_elem elem, int keyval, void * value, int* flag);
+    template <typename T>
+    static int call_deleter(T* obj, const s_smpi_key_elem_t* elem, int keyval, void* value, int* flag);
     template <typename T> void cleanup_attr();
 };
 
@@ -112,7 +113,7 @@ template <typename T> int Keyval::attr_delete(int keyval){
 
 
 template <typename T> int Keyval::attr_get(int keyval, void* attr_value, int* flag){
-  smpi_key_elem elem = T::keyvals_.at(keyval);
+  const s_smpi_key_elem_t* elem = T::keyvals_.at(keyval);
   if(elem==nullptr)
     return MPI_ERR_ARG;
   if(attributes()->empty()){
index bae3055..403b230 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index cc64583..902a892 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -51,6 +51,7 @@ class Request : public F2C {
   smpi_mpi_generalized_request_funcs generalized_funcs;
   MPI_Request* nbc_requests_;
   int nbc_requests_size_;
+  static bool match_common(MPI_Request req, MPI_Request sender, MPI_Request receiver);
 
 public:
   Request() = default;
@@ -111,12 +112,12 @@ public:
   static int waitall(int count, MPI_Request requests[], MPI_Status status[]);
   static int waitsome(int incount, MPI_Request requests[], int* indices, MPI_Status status[]);
 
-  static int match_send(void* a, void* b, kernel::activity::CommImpl* ignored);
-  static int match_recv(void* a, void* b, kernel::activity::CommImpl* ignored);
+  static bool match_send(void* a, void* b, kernel::activity::CommImpl* ignored);
+  static bool match_recv(void* a, void* b, kernel::activity::CommImpl* ignored);
 
   static int grequest_start( MPI_Grequest_query_function *query_fn, MPI_Grequest_free_function *free_fn, MPI_Grequest_cancel_function *cancel_fn, void *extra_state, MPI_Request *request);
   static int grequest_complete( MPI_Request request);
-  static int get_status(MPI_Request req, int* flag, MPI_Status * status);
+  static int get_status(const Request* req, int* flag, MPI_Status* status);
 
   static void free_f(int id);
   static Request* f2c(int);
index b5c6736..31a7a1d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -19,7 +19,7 @@ public:
 static void empty(MPI_Status * status);
 static int cancelled (const MPI_Status * status);
 static void set_cancelled (MPI_Status * status, int flag);
-static void set_elements (MPI_Status * status, MPI_Datatype , int count);
+static void set_elements(MPI_Status* status, const Datatype*, int count);
 static int get_count(const MPI_Status * status, MPI_Datatype datatype);
 };
 
index a0d55ad..507606f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -15,12 +15,12 @@ namespace simgrid{
 namespace smpi{
 
 class Topo {
-  MPI_Comm comm_;
+  MPI_Comm comm_ = MPI_COMM_NULL;
 
 public:
   virtual ~Topo() = default;
   MPI_Comm getComm() const { return comm_; }
-  void setComm(MPI_Comm comm) { comm_ = comm; }
+  void setComm(MPI_Comm comm);
 };
 
 class Topo_Cart: public Topo {
index c308fc4..d4d62ad 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 5486297..f9a1206 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@ class Win : public F2C, public Keyval {
   void* base_;
   MPI_Aint size_;
   int disp_unit_;
-  int assert_;
+  int assert_ = 0;
   MPI_Info info_;
   MPI_Comm comm_;
   std::vector<MPI_Request> *requests_;
@@ -78,9 +78,8 @@ public:
   int get_accumulate(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, void *result_addr,
               int result_count, MPI_Datatype result_datatype, int target_rank, MPI_Aint target_disp, int target_count,
               MPI_Datatype target_datatype, MPI_Op op, MPI_Request* request=nullptr);
-  int compare_and_swap(const void *origin_addr, void *compare_addr,
-        void *result_addr, MPI_Datatype datatype, int target_rank,
-        MPI_Aint target_disp);
+  int compare_and_swap(const void* origin_addr, const void* compare_addr, void* result_addr, MPI_Datatype datatype,
+                       int target_rank, MPI_Aint target_disp);
   static Win* f2c(int id);
 
   int lock(int lock_type, int rank, int assert);
index 30b9bf1..4c27a61 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -136,7 +136,7 @@ static std::string TRACE_smpi_get_key(int src, int dst, int tag, int send)
   return key;
 }
 
-void TRACE_smpi_setup_container(int rank, sg_host_t host)
+void TRACE_smpi_setup_container(int rank, const_sg_host_t host)
 {
   container_t father = simgrid::instr::Container::get_root();
   if (TRACE_smpi_is_grouped()) {
@@ -156,7 +156,7 @@ void TRACE_smpi_init(int rank)
   TRACE_smpi_setup_container(rank, sg_host_self());
   simgrid::s4u::this_actor::on_exit([self](bool) { smpi_container(self->get_pid())->remove_from_parent(); });
 #if HAVE_PAPI
-  container_t container   = smpi_container(rank);
+  const simgrid::instr::Container* container = smpi_container(rank);
   papi_counter_t counters = smpi_process()->papi_counters();
 
   for (auto const& it : counters) {
@@ -252,7 +252,7 @@ void TRACE_smpi_recv(int src, int dst, int tag)
 }
 
 /**************** Functions to trace the migration of tasks. *****************/
-void TRACE_smpi_process_change_host(int rank, sg_host_t new_host)
+void TRACE_smpi_process_change_host(int rank, const_sg_host_t new_host)
 {
   if (not TRACE_smpi_is_enabled()) return;
 
index 0bc5edc..c29d787 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index d32f115..8f0c9b3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -162,9 +162,9 @@ void smpi_bench_end()
 
 #if HAVE_PAPI
   if (not smpi_cfg_papi_events_file().empty() && TRACE_smpi_is_enabled()) {
-    container_t container =
+    const simgrid::instr::Container* container =
         simgrid::instr::Container::by_name(std::string("rank-") + std::to_string(simgrid::s4u::this_actor::get_pid()));
-    papi_counter_t& counter_data = smpi_process()->papi_counters();
+    const papi_counter_t& counter_data = smpi_process()->papi_counters();
 
     for (auto const& pair : counter_data) {
       simgrid::instr::VariableType* variable = static_cast<simgrid::instr::VariableType*>(container->type_->by_name(pair.first));
@@ -376,7 +376,7 @@ int smpi_sample_2(int global, const char *file, int line, int iter_count)
   auto sample = samples.find(loc);
   if (sample == samples.end())
     xbt_die("Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
-  LocalData& data = sample->second;
+  const LocalData& data = sample->second;
 
   if (data.benching) {
     // we need to run a new bench
@@ -446,7 +446,7 @@ int smpi_sample_exit(int global, const char *file, int line, int iter_count){
       xbt_die("Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
   
     if (smpi_process()->sampling()){//end of loop, but still sampling needed
-      LocalData& data = sample->second;
+      const LocalData& data = sample->second;
       smpi_process()->set_sampling(0);
       smpi_execute(data.mean * iter_count);
       smpi_bench_begin();
@@ -474,13 +474,13 @@ void smpi_trace_set_call_location(const char* file, const int line)
 }
 
 /** Required for Fortran bindings */
-void smpi_trace_set_call_location_(const char* file, int* line)
+void smpi_trace_set_call_location_(const char* file, const int* line)
 {
   smpi_trace_set_call_location(file, *line);
 }
 
 /** Required for Fortran if -fsecond-underscore is activated */
-void smpi_trace_set_call_location__(const char* file, int* line)
+void smpi_trace_set_call_location__(const char* file, const int* line)
 {
   smpi_trace_set_call_location(file, *line);
 }
index bdf5327..7bd5640 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 5cf91eb..f82d228 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team.
+/* Copyright (c) 2004-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -67,7 +67,7 @@ void SMPI_app_instance_register(const char *name, xbt_main_func_t code, int num_
 
 void smpi_deployment_register_process(const std::string& instance_id, int rank, simgrid::s4u::Actor* actor)
 {
-  Instance& instance = smpi_instances.at(instance_id);
+  const Instance& instance = smpi_instances.at(instance_id);
   instance.comm_world_->group()->set_mapping(actor, rank);
 }
 
index 4834e84..9a4bd79 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -132,13 +132,14 @@ void smpi_comm_set_copy_data_callback(void (*callback) (smx_activity_t, void*, s
   };
 }
 
-static void memcpy_private(void* dest, const void* src, std::vector<std::pair<size_t, size_t>>& private_blocks)
+static void memcpy_private(void* dest, const void* src, const std::vector<std::pair<size_t, size_t>>& private_blocks)
 {
   for (auto const& block : private_blocks)
     memcpy((uint8_t*)dest+block.first, (uint8_t*)src+block.first, block.second-block.first);
 }
 
-static void check_blocks(std::vector<std::pair<size_t, size_t>> &private_blocks, size_t buff_size) {
+static void check_blocks(const std::vector<std::pair<size_t, size_t>>& private_blocks, size_t buff_size)
+{
   for (auto const& block : private_blocks)
     xbt_assert(block.first <= block.second && block.second <= buff_size, "Oops, bug in shared malloc.");
 }
@@ -383,7 +384,7 @@ static void smpi_copy_file(const std::string& src, const std::string& target, of
     if (got == -1) {
       xbt_assert(errno == EINTR, "Cannot read from %s", src.c_str());
     } else {
-      char* p  = buf;
+      const char* p = buf;
       int todo = got;
       while (int done = write(fdout, p, todo)) {
         if (done == -1) {
@@ -557,7 +558,7 @@ int smpi_main(const char* executable, int argc, char* argv[])
 
   /* This is a ... heavy way to count the MPI ranks */
   int rank_counts = 0;
-  simgrid::s4u::Actor::on_creation.connect([&rank_counts](simgrid::s4u::Actor& actor) {
+  simgrid::s4u::Actor::on_creation.connect([&rank_counts](const simgrid::s4u::Actor& actor) {
     if (not actor.is_daemon())
       rank_counts++;
   });
index 25cadab..efad11a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index a315b6c..a5f00a7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -56,8 +56,9 @@ void smpi_prepare_global_memory_segment()
 static void smpi_get_executable_global_size()
 {
   char buffer[PATH_MAX];
-  char* full_name = realpath(xbt_binary_name, buffer);
-  xbt_assert(full_name != nullptr, "Could not resolve real path of binary file '%s'", xbt_binary_name);
+  const char* full_name = realpath(simgrid::xbt::binary_name.c_str(), buffer);
+  xbt_assert(full_name != nullptr, "Could not resolve real path of binary file '%s'",
+             simgrid::xbt::binary_name.c_str());
 
   std::vector<simgrid::xbt::VmMap> map = simgrid::xbt::get_memory_map(getpid());
   for (auto i = map.begin(); i != map.end() ; ++i) {
@@ -193,7 +194,7 @@ void smpi_switch_data_segment(simgrid::s4u::ActorPtr actor)
   XBT_DEBUG("Switching data frame to the one of process %ld", actor->get_pid());
   simgrid::smpi::ActorExt* process = smpi_process_remote(actor);
   int current                     = process->privatized_region()->file_descriptor;
-  void* tmp = mmap(TOPAGE(smpi_data_exe_start), smpi_data_exe_size, PROT_RW, MAP_FIXED | MAP_SHARED, current, 0);
+  const void* tmp = mmap(TOPAGE(smpi_data_exe_start), smpi_data_exe_size, PROT_RW, MAP_FIXED | MAP_SHARED, current, 0);
   if (tmp != TOPAGE(smpi_data_exe_start))
     xbt_die("Couldn't map the new region (errno %d): %s", errno, strerror(errno));
   smpi_loaded_page = actor->get_pid();
index 5d2619c..1cd1302 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -64,7 +64,7 @@ public:
 typedef std::tuple</*sender*/ int, /* receiver */ int, /* tag */ int> req_key_t;
 typedef std::unordered_map<req_key_t, MPI_Request, hash_tuple::hash<std::tuple<int,int,int>>> req_storage_t;
 
-void log_timed_action(simgrid::xbt::ReplayAction& action, double clock)
+void log_timed_action(const simgrid::xbt::ReplayAction& action, double clock)
 {
   if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){
     std::string s = boost::algorithm::join(action, " ");
@@ -102,7 +102,7 @@ public:
 
     void get_requests(std::vector<MPI_Request>& vec)
     {
-      for (auto& pair : store) {
+      for (auto const& pair : store) {
         auto& req = pair.second;
         auto my_proc_id = simgrid::s4u::this_actor::get_pid();
         if (req != MPI_REQUEST_NULL && (req->src() == my_proc_id || req->dst() == my_proc_id)) {
@@ -411,6 +411,7 @@ void WaitAction::kernel(simgrid::xbt::ReplayAction& action)
 {
   std::string s = boost::algorithm::join(action, " ");
   xbt_assert(req_storage.size(), "action wait not preceded by any irecv or isend: %s", s.c_str());
+  const WaitTestParser& args = get_args();
   MPI_Request request = req_storage.find(args.src, args.dst, args.tag);
   req_storage.remove(request);
 
@@ -425,7 +426,7 @@ void WaitAction::kernel(simgrid::xbt::ReplayAction& action)
   // Must be taken before Request::wait() since the request may be set to
   // MPI_REQUEST_NULL by Request::wait!
   bool is_wait_for_receive = (request->flags() & MPI_REQ_RECV);
-  // TODO: Here we take the rank while we normally take the process id (look for my_proc_id)
+  // TODO: Here we take the rank while we normally take the process id (look for get_pid())
   TRACE_smpi_comm_in(rank, __func__, new simgrid::instr::WaitTIData(args.src, args.dst, args.tag));
 
   MPI_Status status;
@@ -438,57 +439,63 @@ void WaitAction::kernel(simgrid::xbt::ReplayAction& action)
 
 void SendAction::kernel(simgrid::xbt::ReplayAction&)
 {
+  const SendRecvParser& args = get_args();
   int dst_traced = MPI_COMM_WORLD->group()->actor(args.partner)->get_pid();
 
-  TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::Pt2PtTIData(name, args.partner, args.size,
-        args.tag, Datatype::encode(args.datatype1)));
+  TRACE_smpi_comm_in(
+      get_pid(), __func__,
+      new simgrid::instr::Pt2PtTIData(get_name(), args.partner, args.size, args.tag, Datatype::encode(args.datatype1)));
   if (not TRACE_smpi_view_internals())
-    TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, args.tag, args.size * args.datatype1->size());
+    TRACE_smpi_send(get_pid(), get_pid(), dst_traced, args.tag, args.size * args.datatype1->size());
 
-  if (name == "send") {
+  if (get_name() == "send") {
     Request::send(nullptr, args.size, args.datatype1, args.partner, args.tag, MPI_COMM_WORLD);
-  } else if (name == "isend") {
+  } else if (get_name() == "isend") {
     MPI_Request request = Request::isend(nullptr, args.size, args.datatype1, args.partner, args.tag, MPI_COMM_WORLD);
     req_storage.add(request);
   } else {
-    xbt_die("Don't know this action, %s", name.c_str());
+    xbt_die("Don't know this action, %s", get_name().c_str());
   }
 
-  TRACE_smpi_comm_out(my_proc_id);
+  TRACE_smpi_comm_out(get_pid());
 }
 
 void RecvAction::kernel(simgrid::xbt::ReplayAction&)
 {
-  TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::Pt2PtTIData(name, args.partner, args.size,
-        args.tag, Datatype::encode(args.datatype1)));
+  const SendRecvParser& args = get_args();
+  TRACE_smpi_comm_in(
+      get_pid(), __func__,
+      new simgrid::instr::Pt2PtTIData(get_name(), args.partner, args.size, args.tag, Datatype::encode(args.datatype1)));
 
   MPI_Status status;
   // unknown size from the receiver point of view
-  if (args.size <= 0.0) {
+  double arg_size = args.size;
+  if (arg_size <= 0.0) {
     Request::probe(args.partner, args.tag, MPI_COMM_WORLD, &status);
-    args.size = status.count;
+    arg_size = status.count;
   }
 
   bool is_recv = false; // Help analyzers understanding that status is not used unintialized
-  if (name == "recv") {
+  if (get_name() == "recv") {
     is_recv = true;
-    Request::recv(nullptr, args.size, args.datatype1, args.partner, args.tag, MPI_COMM_WORLD, &status);
-  } else if (name == "irecv") {
-    MPI_Request request = Request::irecv(nullptr, args.size, args.datatype1, args.partner, args.tag, MPI_COMM_WORLD);
+    Request::recv(nullptr, arg_size, args.datatype1, args.partner, args.tag, MPI_COMM_WORLD, &status);
+  } else if (get_name() == "irecv") {
+    MPI_Request request = Request::irecv(nullptr, arg_size, args.datatype1, args.partner, args.tag, MPI_COMM_WORLD);
     req_storage.add(request);
   } else {
     THROW_IMPOSSIBLE;
   }
 
-  TRACE_smpi_comm_out(my_proc_id);
+  TRACE_smpi_comm_out(get_pid());
   if (is_recv && not TRACE_smpi_view_internals()) {
     int src_traced = MPI_COMM_WORLD->group()->actor(status.MPI_SOURCE)->get_pid();
-    TRACE_smpi_recv(src_traced, my_proc_id, args.tag);
+    TRACE_smpi_recv(src_traced, get_pid(), args.tag);
   }
 }
 
 void ComputeAction::kernel(simgrid::xbt::ReplayAction&)
 {
+  const ComputeParser& args = get_args();
   if (smpi_cfg_simulate_computation()) {
     smpi_execute_flops(args.flops/smpi_adjust_comp_speed());
   }
@@ -496,6 +503,7 @@ void ComputeAction::kernel(simgrid::xbt::ReplayAction&)
 
 void SleepAction::kernel(simgrid::xbt::ReplayAction&)
 {
+  const SleepParser& args = get_args();
   XBT_DEBUG("Sleep for: %lf secs", args.time);
   int rank = simgrid::s4u::this_actor::get_pid();
   TRACE_smpi_sleeping_in(rank, args.time);
@@ -505,18 +513,20 @@ void SleepAction::kernel(simgrid::xbt::ReplayAction&)
 
 void LocationAction::kernel(simgrid::xbt::ReplayAction&)
 {
+  const LocationParser& args = get_args();
   smpi_trace_set_call_location(args.filename.c_str(), args.line);
 }
 
 void TestAction::kernel(simgrid::xbt::ReplayAction&)
 {
+  const WaitTestParser& args = get_args();
   MPI_Request request = req_storage.find(args.src, args.dst, args.tag);
   req_storage.remove(request);
   // if request is null here, this may mean that a previous test has succeeded
   // Different times in traced application and replayed version may lead to this
   // In this case, ignore the extra calls.
   if (request != MPI_REQUEST_NULL) {
-    TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("test"));
+    TRACE_smpi_comm_in(get_pid(), __func__, new simgrid::instr::NoOpTIData("test"));
 
     MPI_Status status;
     int flag = 0;
@@ -530,7 +540,7 @@ void TestAction::kernel(simgrid::xbt::ReplayAction&)
     else
       req_storage.add(request);
 
-    TRACE_smpi_comm_out(my_proc_id);
+    TRACE_smpi_comm_out(get_pid());
   }
 }
 
@@ -554,11 +564,11 @@ void WaitAllAction::kernel(simgrid::xbt::ReplayAction&)
   const unsigned int count_requests = req_storage.size();
 
   if (count_requests > 0) {
-    TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::Pt2PtTIData("waitall", -1, count_requests, ""));
+    TRACE_smpi_comm_in(get_pid(), __func__, new simgrid::instr::Pt2PtTIData("waitall", -1, count_requests, ""));
     std::vector<std::pair</*sender*/int,/*recv*/int>> sender_receiver;
     std::vector<MPI_Request> reqs;
     req_storage.get_requests(reqs);
-    for (const auto& req : reqs) {
+    for (auto const& req : reqs) {
       if (req && (req->flags() & MPI_REQ_RECV)) {
         sender_receiver.push_back({req->src(), req->dst()});
       }
@@ -566,170 +576,184 @@ void WaitAllAction::kernel(simgrid::xbt::ReplayAction&)
     Request::waitall(count_requests, &(reqs.data())[0], MPI_STATUSES_IGNORE);
     req_storage.get_store().clear();
 
-    for (auto& pair : sender_receiver) {
+    for (auto const& pair : sender_receiver) {
       TRACE_smpi_recv(pair.first, pair.second, 0);
     }
-    TRACE_smpi_comm_out(my_proc_id);
+    TRACE_smpi_comm_out(get_pid());
   }
 }
 
 void BarrierAction::kernel(simgrid::xbt::ReplayAction&)
 {
-  TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("barrier"));
+  TRACE_smpi_comm_in(get_pid(), __func__, new simgrid::instr::NoOpTIData("barrier"));
   colls::barrier(MPI_COMM_WORLD);
-  TRACE_smpi_comm_out(my_proc_id);
+  TRACE_smpi_comm_out(get_pid());
 }
 
 void BcastAction::kernel(simgrid::xbt::ReplayAction&)
 {
-  TRACE_smpi_comm_in(my_proc_id, "action_bcast",
-      new simgrid::instr::CollTIData("bcast", MPI_COMM_WORLD->group()->actor(args.root)->get_pid(),
-        -1.0, args.size, -1, Datatype::encode(args.datatype1), ""));
+  const BcastArgParser& args = get_args();
+  TRACE_smpi_comm_in(get_pid(), "action_bcast",
+                     new simgrid::instr::CollTIData("bcast", MPI_COMM_WORLD->group()->actor(args.root)->get_pid(), -1.0,
+                                                    args.size, -1, Datatype::encode(args.datatype1), ""));
 
   colls::bcast(send_buffer(args.size * args.datatype1->size()), args.size, args.datatype1, args.root, MPI_COMM_WORLD);
 
-  TRACE_smpi_comm_out(my_proc_id);
+  TRACE_smpi_comm_out(get_pid());
 }
 
 void ReduceAction::kernel(simgrid::xbt::ReplayAction&)
 {
-  TRACE_smpi_comm_in(my_proc_id, "action_reduce",
-      new simgrid::instr::CollTIData("reduce", MPI_COMM_WORLD->group()->actor(args.root)->get_pid(),
-        args.comp_size, args.comm_size, -1,
-        Datatype::encode(args.datatype1), ""));
+  const ReduceArgParser& args = get_args();
+  TRACE_smpi_comm_in(get_pid(), "action_reduce",
+                     new simgrid::instr::CollTIData("reduce", MPI_COMM_WORLD->group()->actor(args.root)->get_pid(),
+                                                    args.comp_size, args.comm_size, -1,
+                                                    Datatype::encode(args.datatype1), ""));
 
   colls::reduce(send_buffer(args.comm_size * args.datatype1->size()),
                 recv_buffer(args.comm_size * args.datatype1->size()), args.comm_size, args.datatype1, MPI_OP_NULL,
                 args.root, MPI_COMM_WORLD);
   private_execute_flops(args.comp_size);
 
-  TRACE_smpi_comm_out(my_proc_id);
+  TRACE_smpi_comm_out(get_pid());
 }
 
 void AllReduceAction::kernel(simgrid::xbt::ReplayAction&)
 {
-  TRACE_smpi_comm_in(my_proc_id, "action_allreduce", new simgrid::instr::CollTIData("allreduce", -1, args.comp_size, args.comm_size, -1,
-        Datatype::encode(args.datatype1), ""));
+  const AllReduceArgParser& args = get_args();
+  TRACE_smpi_comm_in(get_pid(), "action_allreduce",
+                     new simgrid::instr::CollTIData("allreduce", -1, args.comp_size, args.comm_size, -1,
+                                                    Datatype::encode(args.datatype1), ""));
 
   colls::allreduce(send_buffer(args.comm_size * args.datatype1->size()),
                    recv_buffer(args.comm_size * args.datatype1->size()), args.comm_size, args.datatype1, MPI_OP_NULL,
                    MPI_COMM_WORLD);
   private_execute_flops(args.comp_size);
 
-  TRACE_smpi_comm_out(my_proc_id);
+  TRACE_smpi_comm_out(get_pid());
 }
 
 void AllToAllAction::kernel(simgrid::xbt::ReplayAction&)
 {
-  TRACE_smpi_comm_in(my_proc_id, "action_alltoall",
-      new simgrid::instr::CollTIData("alltoall", -1, -1.0, args.send_size, args.recv_size,
-        Datatype::encode(args.datatype1),
-        Datatype::encode(args.datatype2)));
+  const AllToAllArgParser& args = get_args();
+  TRACE_smpi_comm_in(get_pid(), "action_alltoall",
+                     new simgrid::instr::CollTIData("alltoall", -1, -1.0, args.send_size, args.recv_size,
+                                                    Datatype::encode(args.datatype1),
+                                                    Datatype::encode(args.datatype2)));
 
   colls::alltoall(send_buffer(args.send_size * args.comm_size * args.datatype1->size()), args.send_size, args.datatype1,
                   recv_buffer(args.recv_size * args.comm_size * args.datatype2->size()), args.recv_size, args.datatype2,
                   MPI_COMM_WORLD);
 
-  TRACE_smpi_comm_out(my_proc_id);
+  TRACE_smpi_comm_out(get_pid());
 }
 
 void GatherAction::kernel(simgrid::xbt::ReplayAction&)
 {
-  TRACE_smpi_comm_in(my_proc_id, name.c_str(), new simgrid::instr::CollTIData(name, (name == "gather") ? args.root : -1, -1.0, args.send_size, args.recv_size,
-        Datatype::encode(args.datatype1), Datatype::encode(args.datatype2)));
+  const GatherArgParser& args = get_args();
+  TRACE_smpi_comm_in(get_pid(), get_name().c_str(),
+                     new simgrid::instr::CollTIData(get_name(), (get_name() == "gather") ? args.root : -1, -1.0,
+                                                    args.send_size, args.recv_size, Datatype::encode(args.datatype1),
+                                                    Datatype::encode(args.datatype2)));
 
-  if (name == "gather") {
+  if (get_name() == "gather") {
     int rank = MPI_COMM_WORLD->rank();
     colls::gather(send_buffer(args.send_size * args.datatype1->size()), args.send_size, args.datatype1,
                   (rank == args.root) ? recv_buffer(args.recv_size * args.comm_size * args.datatype2->size()) : nullptr,
                   args.recv_size, args.datatype2, args.root, MPI_COMM_WORLD);
-  }
-  else
+  } else
     colls::allgather(send_buffer(args.send_size * args.datatype1->size()), args.send_size, args.datatype1,
                      recv_buffer(args.recv_size * args.datatype2->size()), args.recv_size, args.datatype2,
                      MPI_COMM_WORLD);
 
-  TRACE_smpi_comm_out(my_proc_id);
+  TRACE_smpi_comm_out(get_pid());
 }
 
 void GatherVAction::kernel(simgrid::xbt::ReplayAction&)
 {
   int rank = MPI_COMM_WORLD->rank();
+  const GatherVArgParser& args = get_args();
+  TRACE_smpi_comm_in(get_pid(), get_name().c_str(),
+                     new simgrid::instr::VarCollTIData(
+                         get_name(), (get_name() == "gatherv") ? args.root : -1, args.send_size, nullptr, -1,
+                         args.recvcounts, Datatype::encode(args.datatype1), Datatype::encode(args.datatype2)));
 
-  TRACE_smpi_comm_in(my_proc_id, name.c_str(), new simgrid::instr::VarCollTIData(
-        name, (name == "gatherv") ? args.root : -1, args.send_size, nullptr, -1, args.recvcounts,
-        Datatype::encode(args.datatype1), Datatype::encode(args.datatype2)));
-
-  if (name == "gatherv") {
+  if (get_name() == "gatherv") {
     colls::gatherv(send_buffer(args.send_size * args.datatype1->size()), args.send_size, args.datatype1,
                    (rank == args.root) ? recv_buffer(args.recv_size_sum * args.datatype2->size()) : nullptr,
                    args.recvcounts->data(), args.disps.data(), args.datatype2, args.root, MPI_COMM_WORLD);
-  }
-  else {
+  } else {
     colls::allgatherv(send_buffer(args.send_size * args.datatype1->size()), args.send_size, args.datatype1,
                       recv_buffer(args.recv_size_sum * args.datatype2->size()), args.recvcounts->data(),
                       args.disps.data(), args.datatype2, MPI_COMM_WORLD);
   }
 
-  TRACE_smpi_comm_out(my_proc_id);
+  TRACE_smpi_comm_out(get_pid());
 }
 
 void ScatterAction::kernel(simgrid::xbt::ReplayAction&)
 {
   int rank = MPI_COMM_WORLD->rank();
-  TRACE_smpi_comm_in(my_proc_id, "action_scatter", new simgrid::instr::CollTIData(name, args.root, -1.0, args.send_size, args.recv_size,
-        Datatype::encode(args.datatype1),
-        Datatype::encode(args.datatype2)));
+  const ScatterArgParser& args = get_args();
+  TRACE_smpi_comm_in(get_pid(), "action_scatter",
+                     new simgrid::instr::CollTIData(get_name(), args.root, -1.0, args.send_size, args.recv_size,
+                                                    Datatype::encode(args.datatype1),
+                                                    Datatype::encode(args.datatype2)));
 
   colls::scatter(send_buffer(args.send_size * args.datatype1->size()), args.send_size, args.datatype1,
                  (rank == args.root) ? recv_buffer(args.recv_size * args.datatype2->size()) : nullptr, args.recv_size,
                  args.datatype2, args.root, MPI_COMM_WORLD);
 
-  TRACE_smpi_comm_out(my_proc_id);
+  TRACE_smpi_comm_out(get_pid());
 }
 
 void ScatterVAction::kernel(simgrid::xbt::ReplayAction&)
 {
   int rank = MPI_COMM_WORLD->rank();
-  TRACE_smpi_comm_in(my_proc_id, "action_scatterv", new simgrid::instr::VarCollTIData(name, args.root, -1, args.sendcounts, args.recv_size,
-        nullptr, Datatype::encode(args.datatype1),
-        Datatype::encode(args.datatype2)));
+  const ScatterVArgParser& args = get_args();
+  TRACE_smpi_comm_in(get_pid(), "action_scatterv",
+                     new simgrid::instr::VarCollTIData(get_name(), args.root, -1, args.sendcounts, args.recv_size,
+                                                       nullptr, Datatype::encode(args.datatype1),
+                                                       Datatype::encode(args.datatype2)));
 
   colls::scatterv((rank == args.root) ? send_buffer(args.send_size_sum * args.datatype1->size()) : nullptr,
                   args.sendcounts->data(), args.disps.data(), args.datatype1,
                   recv_buffer(args.recv_size * args.datatype2->size()), args.recv_size, args.datatype2, args.root,
                   MPI_COMM_WORLD);
 
-  TRACE_smpi_comm_out(my_proc_id);
+  TRACE_smpi_comm_out(get_pid());
 }
 
 void ReduceScatterAction::kernel(simgrid::xbt::ReplayAction&)
 {
-  TRACE_smpi_comm_in(my_proc_id, "action_reducescatter",
+  const ReduceScatterArgParser& args = get_args();
+  TRACE_smpi_comm_in(
+      get_pid(), "action_reducescatter",
       new simgrid::instr::VarCollTIData("reducescatter", -1, 0, nullptr, -1, args.recvcounts,
-        std::to_string(args.comp_size), /* ugly hack to print comp_size */
-        Datatype::encode(args.datatype1)));
+                                        std::to_string(args.comp_size), /* ugly hack to print comp_size */
+                                        Datatype::encode(args.datatype1)));
 
   colls::reduce_scatter(send_buffer(args.recv_size_sum * args.datatype1->size()),
                         recv_buffer(args.recv_size_sum * args.datatype1->size()), args.recvcounts->data(),
                         args.datatype1, MPI_OP_NULL, MPI_COMM_WORLD);
 
   private_execute_flops(args.comp_size);
-  TRACE_smpi_comm_out(my_proc_id);
+  TRACE_smpi_comm_out(get_pid());
 }
 
 void AllToAllVAction::kernel(simgrid::xbt::ReplayAction&)
 {
-  TRACE_smpi_comm_in(my_proc_id, __func__,
-      new simgrid::instr::VarCollTIData(
-        "alltoallv", -1, args.send_size_sum, args.sendcounts, args.recv_size_sum, args.recvcounts,
-        Datatype::encode(args.datatype1), Datatype::encode(args.datatype2)));
+  const AllToAllVArgParser& args = get_args();
+  TRACE_smpi_comm_in(get_pid(), __func__,
+                     new simgrid::instr::VarCollTIData(
+                         "alltoallv", -1, args.send_size_sum, args.sendcounts, args.recv_size_sum, args.recvcounts,
+                         Datatype::encode(args.datatype1), Datatype::encode(args.datatype2)));
 
   colls::alltoallv(send_buffer(args.send_buf_size * args.datatype1->size()), args.sendcounts->data(),
                    args.senddisps.data(), args.datatype1, recv_buffer(args.recv_buf_size * args.datatype2->size()),
                    args.recvcounts->data(), args.recvdisps.data(), args.datatype2, MPI_COMM_WORLD);
 
-  TRACE_smpi_comm_out(my_proc_id);
+  TRACE_smpi_comm_out(get_pid());
 }
 } // Replay Namespace
 }} // namespace simgrid::smpi
@@ -754,7 +778,7 @@ void smpi_replay_init(const char* instance_id, int rank, double start_delay_flop
   TRACE_smpi_comm_in(my_proc_id, "smpi_replay_run_init", new simgrid::instr::NoOpTIData("init"));
   TRACE_smpi_comm_out(my_proc_id);
   xbt_replay_action_register("init", [](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::InitAction().execute(action); });
-  xbt_replay_action_register("finalize", [](simgrid::xbt::ReplayAction&) { /* nothing to do */ });
+  xbt_replay_action_register("finalize", [](simgrid::xbt::ReplayAction const&) { /* nothing to do */ });
   xbt_replay_action_register("comm_size", [](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::CommunicatorAction().execute(action); });
   xbt_replay_action_register("comm_split",[](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::CommunicatorAction().execute(action); });
   xbt_replay_action_register("comm_dup",  [](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::CommunicatorAction().execute(action); });
index ef02210..c510fc5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -208,7 +208,7 @@ void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int
     smpi_shared_malloc_bogusfile = mkstemp(name);
     XBT_DEBUG("bogusfile         : %s\n", name);
     unlink(name);
-    char* dumb  = new char[smpi_shared_malloc_blocksize](); // zero initialized
+    const char* dumb = new char[smpi_shared_malloc_blocksize](); // zero initialized
     ssize_t err = write(smpi_shared_malloc_bogusfile, dumb, smpi_shared_malloc_blocksize);
     if(err<0)
       xbt_die("Could not write bogus file for shared malloc");
@@ -240,8 +240,7 @@ void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int
     for (size_t offset = start_block_offset; offset < stop_block_offset; offset += smpi_shared_malloc_blocksize) {
       XBT_DEBUG("\t\tglobal shared allocation, mmap block offset %zx", offset);
       void* pos = (void*)((unsigned long)mem + offset);
-      void* res = mmap(pos, smpi_shared_malloc_blocksize, PROT_READ | PROT_WRITE, mmap_flag,
-                       huge_fd, 0);
+      const void* res = mmap(pos, smpi_shared_malloc_blocksize, PROT_READ | PROT_WRITE, mmap_flag, huge_fd, 0);
       xbt_assert(res == pos, "Could not map folded virtual memory (%s). Do you perhaps need to increase the "
                              "size of the mapped file using --cfg=smpi/shared-malloc-blocksize:newvalue (default 1048576) ? "
                              "You can also try using  the sysctl vm.max_map_count. "
@@ -254,8 +253,9 @@ void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int
     if(low_page_start_offset < low_page_stop_offset) {
       XBT_DEBUG("\t\tglobal shared allocation, mmap block start");
       void* pos = (void*)((unsigned long)mem + low_page_start_offset);
-      void* res = mmap(pos, low_page_stop_offset-low_page_start_offset, PROT_READ | PROT_WRITE, mmap_base_flag, // not a full huge page
-                       smpi_shared_malloc_bogusfile, 0);
+      const void* res = mmap(pos, low_page_stop_offset - low_page_start_offset, PROT_READ | PROT_WRITE,
+                             mmap_base_flag, // not a full huge page
+                             smpi_shared_malloc_bogusfile, 0);
       xbt_assert(res == pos, "Could not map folded virtual memory (%s). Do you perhaps need to increase the "
                              "size of the mapped file using --cfg=smpi/shared-malloc-blocksize:newvalue (default 1048576) ?"
                              "You can also try using  the sysctl vm.max_map_count",
@@ -266,8 +266,9 @@ void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int
       size_t high_page_stop_offset = stop_offset == size ? size : ALIGN_DOWN((int64_t)stop_offset, PAGE_SIZE);
       if(high_page_stop_offset > stop_block_offset) {
         void* pos = (void*)((unsigned long)mem + stop_block_offset);
-        void* res = mmap(pos, high_page_stop_offset-stop_block_offset, PROT_READ | PROT_WRITE, mmap_base_flag, // not a full huge page
-                         smpi_shared_malloc_bogusfile, 0);
+        const void* res = mmap(pos, high_page_stop_offset - stop_block_offset, PROT_READ | PROT_WRITE,
+                               mmap_base_flag, // not a full huge page
+                               smpi_shared_malloc_bogusfile, 0);
         xbt_assert(res == pos, "Could not map folded virtual memory (%s). Do you perhaps need to increase the "
                                "size of the mapped file using --cfg=smpi/shared-malloc-blocksize:newvalue (default 1048576) ?"
                                "You can also try using  the sysctl vm.max_map_count",
index 7e029ad..23a1736 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team.
+/* Copyright (c) 2016-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 6c2bacc..7562d23 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -28,18 +28,10 @@ namespace smpi{
 std::unordered_map<int, smpi_key_elem> Comm::keyvals_;
 int Comm::keyval_id_=0;
 
-Comm::Comm(MPI_Group group, MPI_Topology topo, int smp, int in_id) : group_(group), topo_(topo),is_smp_comm_(smp), id_(in_id)
+Comm::Comm(MPI_Group group, MPI_Topology topo, bool smp, int in_id)
+    : group_(group), topo_(topo), is_smp_comm_(smp), id_(in_id)
 {
-  refcount_        = 1;
-  topoType_        = MPI_INVALID_TOPO;
-  intra_comm_      = MPI_COMM_NULL;
-  leaders_comm_    = MPI_COMM_NULL;
-  is_uniform_      = 1;
-  non_uniform_map_ = nullptr;
-  leaders_map_     = nullptr;
-  is_blocked_      = 0;
-  info_            = MPI_INFO_NULL;
-  errhandler_      = MPI_ERRORS_ARE_FATAL;
+  errhandler_->ref();
   //First creation of comm is done before SIMIX_run, so only do comms for others
   if(in_id==MPI_UNDEFINED && smp==0 && this->rank()!=MPI_UNDEFINED ){
     int id;
@@ -61,7 +53,6 @@ void Comm::destroy(Comm* comm)
     Comm::destroy(smpi_process()->comm_world());
     return;
   }
-  delete comm->topo_; // there's no use count on topos
   Comm::unref(comm);
 }
 
@@ -121,6 +112,7 @@ int Comm::dup_with_info(MPI_Info info, MPI_Comm* newcomm){
     (*newcomm)->info_=MPI_INFO_NULL;
   }
   if(info != MPI_INFO_NULL){
+    info->ref();
     (*newcomm)->info_=info;
   }
   return ret;
@@ -211,19 +203,22 @@ MPI_Comm Comm::get_intra_comm(){
   else return intra_comm_;
 }
 
-int Comm::is_uniform(){
+bool Comm::is_uniform()
+{
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process()->comm_world()->is_uniform();
-  return is_uniform_;
+  return is_uniform_ != 0;
 }
 
-int Comm::is_blocked(){
+bool Comm::is_blocked()
+{
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process()->comm_world()->is_blocked();
-  return is_blocked_;
+  return is_blocked_ != 0;
 }
 
-int Comm::is_smp_comm(){
+bool Comm::is_smp_comm()
+{
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process()->comm_world()->is_smp_comm();
   return is_smp_comm_;
@@ -334,6 +329,11 @@ void Comm::unref(Comm* comm){
   if(comm->refcount_==0){
     comm->cleanup_smp();
     comm->cleanup_attr<Comm>();
+    if (comm->info_ != MPI_INFO_NULL)
+      simgrid::smpi::Info::unref(comm->info_);
+    if (comm->errhandler_ != MPI_ERRHANDLER_NULL)
+      simgrid::smpi::Errhandler::unref(comm->errhandler_);
+    delete comm->topo_; // there's no use count on topos
     delete comm;
   }
 }
@@ -418,6 +418,7 @@ void Comm::init_smp(){
       leader_group_size++;
     }
   }
+  xbt_assert(leader_group_size > 0);
   std::sort(leader_list, leader_list + leader_group_size);
 
   MPI_Group leaders_group = new  Group(leader_group_size);
@@ -459,7 +460,7 @@ void Comm::init_smp(){
         break;
       }
     }
-    if(is_uniform==0 && this->is_uniform()!=0){
+    if (is_uniform == 0 && this->is_uniform()) {
       non_uniform_map_ = non_uniform_map;
     }else{
       xbt_free(non_uniform_map);
@@ -537,30 +538,40 @@ void Comm::finish_rma_calls(){
   }
 }
 
-MPI_Info Comm::info(){
-  if(info_== MPI_INFO_NULL)
+MPI_Info Comm::info()
+{
+  if (info_ == MPI_INFO_NULL)
     info_ = new Info();
   info_->ref();
   return info_;
 }
 
-void Comm::set_info(MPI_Info info){
-  if(info_!= MPI_INFO_NULL)
+void Comm::set_info(MPI_Info info)
+{
+  if (info_ != MPI_INFO_NULL)
+    simgrid::smpi::Info::unref(info);
+  info_ = info;
+  if (info_ != MPI_INFO_NULL)
     info->ref();
-  info_=info;
 }
 
-MPI_Errhandler Comm::errhandler(){
+MPI_Errhandler Comm::errhandler()
+{
+  if (errhandler_ != MPI_ERRHANDLER_NULL)
+    errhandler_->ref();
   return errhandler_;
 }
 
-void Comm::set_errhandler(MPI_Errhandler errhandler){
-  errhandler_=errhandler;
-  if(errhandler_!= MPI_ERRHANDLER_NULL)
-    errhandler->ref();
+void Comm::set_errhandler(MPI_Errhandler errhandler)
+{
+  if (errhandler_ != MPI_ERRHANDLER_NULL)
+    simgrid::smpi::Errhandler::unref(errhandler_);
+  errhandler_ = errhandler;
+  if (errhandler_ != MPI_ERRHANDLER_NULL)
+    errhandler_->ref();
 }
 
-MPI_Comm Comm::split_type(int type, int /*key*/, MPI_Info)
+MPI_Comm Comm::split_type(int type, int /*key*/, const Info*)
 {
   //MPI_UNDEFINED can be given to some nodes... but we need them to still perform the smp part which is collective
   if(type != MPI_COMM_TYPE_SHARED && type != MPI_UNDEFINED){
index 3829b15..0846a25 100644 (file)
@@ -1,5 +1,5 @@
 /* smpi_datatype.cpp -- MPI primitives to handle datatypes                  */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -107,14 +107,16 @@ Datatype::Datatype(int ident, int size, MPI_Aint lb, MPI_Aint ub, int flags) : D
 {
   id = std::to_string(ident);
 }
-Datatype::Datatype(int size,MPI_Aint lb, MPI_Aint ub, int flags) : name_(nullptr), size_(size), lb_(lb), ub_(ub), flags_(flags), refcount_(1){
+
+Datatype::Datatype(int size, MPI_Aint lb, MPI_Aint ub, int flags) : size_(size), lb_(lb), ub_(ub), flags_(flags)
+{
 #if SIMGRID_HAVE_MC
   if(MC_is_active())
     MC_ignore(&(refcount_), sizeof(refcount_));
 #endif
 }
 
-//for predefined types, so in_use = 0.
+// for predefined types, so refcount_ = 0.
 Datatype::Datatype(char* name, int ident, int size, MPI_Aint lb, MPI_Aint ub, int flags)
     : name_(name), id(std::to_string(ident)), size_(size), lb_(lb), ub_(ub), flags_(flags), refcount_(0)
 {
@@ -125,7 +127,8 @@ Datatype::Datatype(char* name, int ident, int size, MPI_Aint lb, MPI_Aint ub, in
 #endif
 }
 
-Datatype::Datatype(Datatype *datatype, int* ret) : name_(nullptr), size_(datatype->size_), lb_(datatype->lb_), ub_(datatype->ub_), flags_(datatype->flags_), refcount_(1)
+Datatype::Datatype(Datatype* datatype, int* ret)
+    : size_(datatype->size_), lb_(datatype->lb_), ub_(datatype->ub_), flags_(datatype->flags_)
 {
   flags_ &= ~DT_FLAG_PREDEFINED;
   *ret = MPI_SUCCESS;
@@ -253,7 +256,7 @@ void Datatype::set_name(const char* name){
   name_ = xbt_strdup(name);
 }
 
-int Datatype::pack(const void* inbuf, int incount, void* outbuf, int outcount, int* position, MPI_Comm)
+int Datatype::pack(const void* inbuf, int incount, void* outbuf, int outcount, int* position, const Comm*)
 {
   if (outcount - *position < incount*static_cast<int>(size_))
     return MPI_ERR_OTHER;
@@ -262,7 +265,7 @@ int Datatype::pack(const void* inbuf, int incount, void* outbuf, int outcount, i
   return MPI_SUCCESS;
 }
 
-int Datatype::unpack(const void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Comm)
+int Datatype::unpack(const void* inbuf, int insize, int* position, void* outbuf, int outcount, const Comm*)
 {
   if (outcount*static_cast<int>(size_)> insize)
     return MPI_ERR_OTHER;
index 9b1140d..65b4bd8 100644 (file)
@@ -1,5 +1,5 @@
 /* smpi_datatype.cpp -- MPI primitives to handle datatypes                  */
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -93,11 +93,13 @@ Type_Vector::Type_Vector(int size, MPI_Aint lb, MPI_Aint ub, int flags, int coun
 
 Type_Hindexed::Type_Hindexed(int size, MPI_Aint lb, MPI_Aint ub, int flags, int count, const int* block_lengths,
                              const MPI_Aint* block_indices, MPI_Datatype old_type)
-    : Datatype(size, lb, ub, flags), block_count_(count), old_type_(old_type)
+    : Datatype(size, lb, ub, flags)
+    , block_count_(count)
+    , block_lengths_(new int[count])
+    , block_indices_(new MPI_Aint[count])
+    , old_type_(old_type)
 {
   old_type_->ref();
-  block_lengths_ = new int[count];
-  block_indices_ = new MPI_Aint[count];
   for (int i = 0; i < count; i++) {
     block_lengths_[i] = block_lengths[i];
     block_indices_[i] = block_indices[i];
@@ -106,11 +108,13 @@ Type_Hindexed::Type_Hindexed(int size, MPI_Aint lb, MPI_Aint ub, int flags, int
 
 Type_Hindexed::Type_Hindexed(int size, MPI_Aint lb, MPI_Aint ub, int flags, int count, const int* block_lengths,
                              const int* block_indices, MPI_Datatype old_type, MPI_Aint factor)
-    : Datatype(size, lb, ub, flags), block_count_(count), old_type_(old_type)
+    : Datatype(size, lb, ub, flags)
+    , block_count_(count)
+    , block_lengths_(new int[count])
+    , block_indices_(new MPI_Aint[count])
+    , old_type_(old_type)
 {
   old_type_->ref();
-  block_lengths_ = new int[count];
-  block_indices_ = new MPI_Aint[count];
   for (int i = 0; i < count; i++) {
     block_lengths_[i] = block_lengths[i];
     block_indices_[i] = block_indices[i] * factor;
@@ -177,10 +181,14 @@ Type_Indexed::Type_Indexed(int size, MPI_Aint lb, MPI_Aint ub, int flags, int co
 {
 }
 
-Type_Struct::Type_Struct(int size,MPI_Aint lb, MPI_Aint ub, int flags, int count, const int* block_lengths, const MPI_Aint* block_indices, const MPI_Datatype* old_types): Datatype(size, lb, ub, flags), block_count_(count){
-  block_lengths_= new int[count];
-  block_indices_= new MPI_Aint[count];
-  old_types_=  new MPI_Datatype[count];
+Type_Struct::Type_Struct(int size, MPI_Aint lb, MPI_Aint ub, int flags, int count, const int* block_lengths,
+                         const MPI_Aint* block_indices, const MPI_Datatype* old_types)
+    : Datatype(size, lb, ub, flags)
+    , block_count_(count)
+    , block_lengths_(new int[count])
+    , block_indices_(new MPI_Aint[count])
+    , old_types_(new MPI_Datatype[count])
+{
   for (int i = 0; i < count; i++) {
     block_lengths_[i]=block_lengths[i];
     block_indices_[i]=block_indices[i];
index 43df91e..5db2285 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 0c0cab3..787a182 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -66,7 +66,7 @@ void F2C::free_f(int id)
 int F2C::add_f()
 {
   if (f2c_lookup_ == nullptr)
-    f2c_lookup_ = new std::unordered_map<std::string, F2C*>;
+    f2c_lookup_ = new std::unordered_map<std::string, F2C*>();
 
   char key[KEY_SIZE];
   my_f2c_id_=f2c_id_;
@@ -78,7 +78,7 @@ int F2C::add_f()
 int F2C::c2f()
 {
   if (f2c_lookup_ == nullptr) {
-    f2c_lookup_ = new std::unordered_map<std::string, F2C*>;
+    f2c_lookup_ = new std::unordered_map<std::string, F2C*>();
   }
 
   if(my_f2c_id_==-1)
@@ -91,7 +91,7 @@ int F2C::c2f()
 F2C* F2C::f2c(int id)
 {
   if (f2c_lookup_ == nullptr)
-    f2c_lookup_ = new std::unordered_map<std::string, F2C*>;
+    f2c_lookup_ = new std::unordered_map<std::string, F2C*>();
 
   if(id >= 0){
     char key[KEY_SIZE];
index c9ac602..b92dbc4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -27,6 +27,8 @@ namespace simgrid{
 namespace smpi{
 
   File::File(MPI_Comm comm, const char *filename, int amode, MPI_Info info): comm_(comm), flags_(amode), info_(info) {
+    if (info_ != MPI_INFO_NULL)
+      info_->ref();
     std::string fullname=filename;
     if (simgrid::s4u::Host::current()->get_disks().empty())
       xbt_die("SMPI/IO : Trying to open file on a diskless host ! Add one to your platform file");
@@ -51,12 +53,14 @@ namespace smpi{
       int size= comm_->size() + FP_SIZE;
       list_ = new char[size];
       errhandler_= SMPI_default_File_Errhandler;
+      errhandler_->ref();
       memset(list_, 0, size);
       shared_file_pointer_ = new MPI_Offset();
       shared_mutex_ = s4u::Mutex::create();
       *shared_file_pointer_ = 0;
       win_=new Win(list_, size, 1, MPI_INFO_NULL, comm_);
     }else{
+      errhandler_ = MPI_ERRHANDLER_NULL;
       win_=new Win(list_, 0, 1, MPI_INFO_NULL, comm_);
     }
     simgrid::smpi::colls::bcast(&shared_file_pointer_, 1, MPI_AINT, 0, comm);
@@ -72,6 +76,10 @@ namespace smpi{
     }
     delete win_;
     delete file_;
+    if (info_ != MPI_INFO_NULL)
+      simgrid::smpi::Info::unref(info_);
+    if (errhandler_ != MPI_ERRHANDLER_NULL)
+      simgrid::smpi::Errhandler::unref(errhandler_);
   }
 
   int File::close(MPI_File *fh){
@@ -83,7 +91,7 @@ namespace smpi{
     return MPI_SUCCESS;
   }
 
-  int File::del(const char* filename, MPI_Info)
+  int File::del(const char* filename, const Info*)
   {
     //get the file with MPI_MODE_DELETE_ON_CLOSE and then close it
     File* f = new File(MPI_COMM_SELF,filename,MPI_MODE_DELETE_ON_CLOSE|MPI_MODE_RDWR, nullptr);
@@ -198,7 +206,7 @@ namespace smpi{
     MPI_Offset movesize = datatype->get_extent()*count;
     MPI_Offset writesize = datatype->size()*count;
     XBT_DEBUG("Position before write in MPI_File %s : %llu",fh->file_->get_path(),fh->file_->tell());
-    MPI_Offset write = fh->file_->write(writesize, 1);
+    MPI_Offset write = fh->file_->write(writesize, true);
     XBT_VERB("Write in MPI_File %s, %lld bytes written, readsize %lld bytes, movesize %lld", fh->file_->get_path(), write, writesize, movesize);
     if(writesize!=movesize){
       fh->file_->seek(position+movesize, SEEK_SET);
@@ -240,7 +248,8 @@ namespace smpi{
     return ret;
   }
 
-  int File::set_view(MPI_Offset disp, MPI_Datatype etype, MPI_Datatype filetype, const char *datarep, MPI_Info info){
+  int File::set_view(MPI_Offset /*disp*/, MPI_Datatype etype, MPI_Datatype filetype, const char* datarep, const Info*)
+  {
     etype_=etype;
     filetype_=filetype;
     datarep_=std::string(datarep);
@@ -248,7 +257,8 @@ namespace smpi{
     return MPI_SUCCESS;
   }
 
-  int File::get_view(MPI_Offset *disp, MPI_Datatype *etype, MPI_Datatype *filetype, char *datarep){
+  int File::get_view(MPI_Offset* /*disp*/, MPI_Datatype* etype, MPI_Datatype* filetype, char* datarep)
+  {
     *etype=etype_;
     *filetype=filetype_;
     snprintf(datarep, MPI_MAX_NAME_STRING+1, "%s", datarep_.c_str());
@@ -268,31 +278,41 @@ namespace smpi{
     return simgrid::smpi::colls::barrier(comm_);
   }
 
-  MPI_Info File::info(){
-    if(info_== MPI_INFO_NULL)
+  MPI_Info File::info()
+  {
+    if (info_ == MPI_INFO_NULL)
       info_ = new Info();
     info_->ref();
     return info_;
   }
 
-  void File::set_info(MPI_Info info){
-    if(info_!= MPI_INFO_NULL)
-      info->ref();
-    info_=info;
+  void File::set_info(MPI_Info info)
+  {
+    if (info_ != MPI_INFO_NULL)
+      simgrid::smpi::Info::unref(info_);
+    info_ = info;
+    if (info_ != MPI_INFO_NULL)
+      info_->ref();
   }
 
   MPI_Comm File::comm(){
     return comm_;
   }
 
-  MPI_Errhandler File::errhandler(){
+  MPI_Errhandler File::errhandler()
+  {
+    if (errhandler_ != MPI_ERRHANDLER_NULL)
+      errhandler_->ref();
     return errhandler_;
   }
 
-  void File::set_errhandler(MPI_Errhandler errhandler){
-    errhandler_=errhandler;
-    if(errhandler_!= MPI_ERRHANDLER_NULL)
-      errhandler->ref();
+  void File::set_errhandler(MPI_Errhandler errhandler)
+  {
+    if (errhandler_ != MPI_ERRHANDLER_NULL)
+      simgrid::smpi::Errhandler::unref(errhandler_);
+    errhandler_ = errhandler;
+    if (errhandler_ != MPI_ERRHANDLER_NULL)
+      errhandler_->ref();
   }
 }
 }
index 14d1ff4..67655d4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index c20ae58..564b22f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 33badb3..bfc555c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -14,7 +14,8 @@ std::unordered_map<int, void*>* Keyval::attributes(){
   return &attributes_;
 }
 
-template <> int Keyval::call_deleter<Comm>(Comm* obj, smpi_key_elem elem, int keyval, void* value, int* /*flag*/)
+template <>
+int Keyval::call_deleter<Comm>(Comm* obj, const s_smpi_key_elem_t* elem, int keyval, void* value, int* /*flag*/)
 {
   int ret = MPI_SUCCESS;
   if(elem->delete_fn.comm_delete_fn!=MPI_NULL_DELETE_FN)
@@ -24,7 +25,8 @@ template <> int Keyval::call_deleter<Comm>(Comm* obj, smpi_key_elem elem, int ke
   return ret;
 }
 
-template <> int Keyval::call_deleter<Win>(Win* obj, smpi_key_elem elem, int keyval, void* value, int* /*flag*/)
+template <>
+int Keyval::call_deleter<Win>(Win* obj, const s_smpi_key_elem_t* elem, int keyval, void* value, int* /*flag*/)
 {
   int ret = MPI_SUCCESS;
   if(elem->delete_fn.win_delete_fn!=MPI_NULL_DELETE_FN)
@@ -35,7 +37,7 @@ template <> int Keyval::call_deleter<Win>(Win* obj, smpi_key_elem elem, int keyv
 }
 
 template <>
-int Keyval::call_deleter<Datatype>(Datatype* obj, smpi_key_elem elem, int keyval, void* value, int* /*flag*/)
+int Keyval::call_deleter<Datatype>(Datatype* obj, const s_smpi_key_elem_t* elem, int keyval, void* value, int* /*flag*/)
 {
   int ret = MPI_SUCCESS;
   if(elem->delete_fn.type_delete_fn!=MPI_NULL_DELETE_FN)
index 9b755c7..84a3d82 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index c907155..6a8ac60 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -108,58 +108,49 @@ void Request::unref(MPI_Request* request)
   }
 }
 
-int Request::match_recv(void* a, void* b, simgrid::kernel::activity::CommImpl*)
+bool Request::match_common(MPI_Request req, MPI_Request sender, MPI_Request receiver)
 {
-  MPI_Request ref = static_cast<MPI_Request>(a);
-  MPI_Request req = static_cast<MPI_Request>(b);
-  XBT_DEBUG("Trying to match a recv of src %d against %d, tag %d against %d, id %d against %d",ref->src_,req->src_, ref->tag_, req->tag_,ref->comm_->id(),req->comm_->id());
-
-  xbt_assert(ref, "Cannot match recv against null reference");
-  xbt_assert(req, "Cannot match recv against null request");
-  if((ref->comm_->id()==MPI_UNDEFINED || req->comm_->id() == MPI_UNDEFINED || (ref->comm_->id()==req->comm_->id()))
-    && ((ref->src_ == MPI_ANY_SOURCE  && (ref->comm_->group()->rank(req->src_) != MPI_UNDEFINED)) || req->src_ == ref->src_)
-    && ((ref->tag_ == MPI_ANY_TAG && req->tag_ >=0) || req->tag_ == ref->tag_)){
-    //we match, we can transfer some values
-    if(ref->src_ == MPI_ANY_SOURCE)
-      ref->real_src_ = req->src_;
-    if(ref->tag_ == MPI_ANY_TAG)
-      ref->real_tag_ = req->tag_;
-    if(ref->real_size_ < req->real_size_)
-      ref->truncated_ = true;
-    if (req->detached_)
-      ref->detached_sender_=req; //tie the sender to the receiver, as it is detached and has to be freed in the receiver
-    if(req->cancelled_==0)
+  xbt_assert(sender, "Cannot match against null sender");
+  xbt_assert(receiver, "Cannot match against null receiver");
+  XBT_DEBUG("Trying to match %s of sender src %d against %d, tag %d against %d, id %d against %d",
+            (req == receiver ? "send" : "recv"), sender->src_, receiver->src_, sender->tag_, receiver->tag_,
+            sender->comm_->id(), receiver->comm_->id());
+
+  if ((receiver->comm_->id() == MPI_UNDEFINED || sender->comm_->id() == MPI_UNDEFINED ||
+       receiver->comm_->id() == sender->comm_->id()) &&
+      ((receiver->src_ == MPI_ANY_SOURCE && (receiver->comm_->group()->rank(sender->src_) != MPI_UNDEFINED)) ||
+       receiver->src_ == sender->src_) &&
+      ((receiver->tag_ == MPI_ANY_TAG && sender->tag_ >= 0) || receiver->tag_ == sender->tag_)) {
+    // we match, we can transfer some values
+    if (receiver->src_ == MPI_ANY_SOURCE)
+      receiver->real_src_ = sender->src_;
+    if (receiver->tag_ == MPI_ANY_TAG)
+      receiver->real_tag_ = sender->tag_;
+    if (receiver->real_size_ < sender->real_size_)
+      receiver->truncated_ = true;
+    if (sender->detached_)
+      receiver->detached_sender_ = sender; // tie the sender to the receiver, as it is detached and has to be freed in
+                                           // the receiver
+    if (req->cancelled_ == 0)
       req->cancelled_ = -1; // mark as uncancelable
     XBT_DEBUG("match succeeded");
-    return 1;
-  }else return 0;
+    return true;
+  }
+  return false;
 }
 
-int Request::match_send(void* a, void* b, simgrid::kernel::activity::CommImpl*)
+bool Request::match_recv(void* a, void* b, simgrid::kernel::activity::CommImpl*)
 {
   MPI_Request ref = static_cast<MPI_Request>(a);
   MPI_Request req = static_cast<MPI_Request>(b);
-  XBT_DEBUG("Trying to match a send of src %d against %d, tag %d against %d, id %d against %d",ref->src_,req->src_, ref->tag_, req->tag_,ref->comm_->id(),req->comm_->id());
-  xbt_assert(ref, "Cannot match send against null reference");
-  xbt_assert(req, "Cannot match send against null request");
-
-  if((ref->comm_->id()==MPI_UNDEFINED || req->comm_->id() == MPI_UNDEFINED || (ref->comm_->id()==req->comm_->id()))
-      && ((req->src_ == MPI_ANY_SOURCE  && (req->comm_->group()->rank(ref->src_) != MPI_UNDEFINED)) || req->src_ == ref->src_)
-      && ((req->tag_ == MPI_ANY_TAG && ref->tag_ >=0)|| req->tag_ == ref->tag_)){
-    if(req->src_ == MPI_ANY_SOURCE)
-      req->real_src_ = ref->src_;
-    if(req->tag_ == MPI_ANY_TAG)
-      req->real_tag_ = ref->tag_;
-    if(req->real_size_ < ref->real_size_)
-      req->truncated_ = true;
-    if (ref->detached_)
-      req->detached_sender_=ref; //tie the sender to the receiver, as it is detached and has to be freed in the receiver
-    if(req->cancelled_==0)
-      req->cancelled_ = -1; // mark as uncancelable
-    XBT_DEBUG("match succeeded");
-    return 1;
-  } else
-    return 0;
+  return match_common(req, req, ref);
+}
+
+bool Request::match_send(void* a, void* b, simgrid::kernel::activity::CommImpl*)
+{
+  MPI_Request ref = static_cast<MPI_Request>(a);
+  MPI_Request req = static_cast<MPI_Request>(b);
+  return match_common(req, ref, req);
 }
 
 void Request::print_request(const char *message)
@@ -793,7 +784,7 @@ void Request::iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status*
 
   if (request->action_ != nullptr){
     kernel::activity::CommImplPtr sync_comm = boost::static_pointer_cast<kernel::activity::CommImpl>(request->action_);
-    MPI_Request req                         = static_cast<MPI_Request>(sync_comm->src_data_);
+    const Request* req                      = static_cast<MPI_Request>(sync_comm->src_data_);
     *flag = 1;
     if (status != MPI_STATUS_IGNORE && (req->flags_ & MPI_REQ_PREPARED) == 0) {
       status->MPI_SOURCE = comm->group()->rank(req->src_);
@@ -1120,7 +1111,7 @@ void Request::free_f(int id)
   }
 }
 
-int Request::get_status(MPI_Request req, int* flag, MPI_Status* status)
+int Request::get_status(const Request* req, int* flag, MPI_Status* status)
 {
   *flag=0;
 
index 7c8d6e1..b048fe7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -32,7 +32,8 @@ void Status::set_cancelled(MPI_Status * status, int flag)
   status->cancelled=flag;
 }
 
-void Status::set_elements (MPI_Status * status, MPI_Datatype , int count){
+void Status::set_elements(MPI_Status* status, const Datatype*, int count)
+{
   status->count=count;
 }
 
index 058b4bd..d2d0eed 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 #include <vector>
 
 /* static functions */
-static int assignnodes(int ndim, int nfactor, int *pfacts,int **pdims);
+static int assignnodes(int ndim, int nfactor, const int* pfacts, int** pdims);
 static int getfactors(int num, int *nfators, int **factors);
 
 
 namespace simgrid{
 namespace smpi{
 
+void Topo::setComm(MPI_Comm comm)
+{
+  xbt_assert(not comm_);
+  comm_ = comm;
+  if (comm_)
+    comm_->topo_ = this;
+}
+
 /*******************************************************************************
  * Cartesian topologies
  ******************************************************************************/
@@ -72,7 +80,8 @@ Topo_Cart::Topo_Cart(MPI_Comm comm_old, int ndims, const int dims[], const int p
   } else {
     if(comm_cart != nullptr){
       if (rank == 0) {
-        *comm_cart = new  Comm(new  Group(MPI_COMM_SELF->group()), this);
+        MPI_Group group = new Group(MPI_COMM_SELF->group());
+        *comm_cart      = new Comm(group, this);
       } else {
         *comm_cart = MPI_COMM_NULL;
       }
@@ -264,7 +273,7 @@ int Topo_Cart::Dims_create(int nnodes, int ndims, int dims[])
   /* Get # of free-to-be-assigned processes and # of free dimensions */
   int freeprocs = nnodes;
   int freedims = 0;
-  int *p = dims;
+  const int* p  = dims;
   for (int i = 0; i < ndims; ++i) {
     if (*p == 0) {
       ++freedims;
@@ -340,7 +349,7 @@ int Topo_Cart::Dims_create(int nnodes, int ndims, int dims[])
  *          - ptr to array of dimensions (returned value)
  *  Returns:    - 0 or ERROR
  */
-static int assignnodes(int ndim, int nfactor, int *pfacts, int **pdims)
+static int assignnodes(int ndim, int nfactor, const int* pfacts, int** pdims)
 {
   int *pmin;
 
index 9efd479..58a6448 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -22,12 +22,20 @@ namespace smpi{
 std::unordered_map<int, smpi_key_elem> Win::keyvals_;
 int Win::keyval_id_=0;
 
-Win::Win(void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, int allocated, int dynamic): base_(base), size_(size), disp_unit_(disp_unit), assert_(0), info_(info), comm_(comm), allocated_(allocated), dynamic_(dynamic){
-  int comm_size = comm->size();
-  rank_         = comm->rank();
+Win::Win(void* base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, int allocated, int dynamic)
+    : base_(base)
+    , size_(size)
+    , disp_unit_(disp_unit)
+    , info_(info)
+    , comm_(comm)
+    , rank_(comm->rank())
+    , allocated_(allocated)
+    , dynamic_(dynamic)
+{
   XBT_DEBUG("Creating window");
   if(info!=MPI_INFO_NULL)
     info->ref();
+  int comm_size          = comm->size();
   name_                  = nullptr;
   opened_                = 0;
   group_                 = MPI_GROUP_NULL;
@@ -43,6 +51,7 @@ Win::Win(void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm,
   }
   mode_=0;
   errhandler_=MPI_ERRORS_ARE_FATAL;
+  errhandler_->ref();
   comm->add_rma_win(this);
   comm->ref();
 
@@ -66,9 +75,10 @@ Win::~Win(){
   if (name_ != nullptr){
     xbt_free(name_);
   }
-  if(info_!=MPI_INFO_NULL){
-    MPI_Info_free(&info_);
-  }
+  if (info_ != MPI_INFO_NULL)
+    simgrid::smpi::Info::unref(info_);
+  if (errhandler_ != MPI_ERRHANDLER_NULL)
+    simgrid::smpi::Errhandler::unref(errhandler_);
 
   comm_->remove_rma_win(this);
 
@@ -118,8 +128,9 @@ void Win::get_group(MPI_Group* group){
   }
 }
 
-MPI_Info Win::info(){
-  if(info_== MPI_INFO_NULL)
+MPI_Info Win::info()
+{
+  if (info_ == MPI_INFO_NULL)
     info_ = new Info();
   info_->ref();
   return info_;
@@ -145,10 +156,13 @@ int Win::dynamic(){
   return dynamic_;
 }
 
-void Win::set_info(MPI_Info info){
-  if(info_!= MPI_INFO_NULL)
-    info->ref();
-  info_=info;
+void Win::set_info(MPI_Info info)
+{
+  if (info_ != MPI_INFO_NULL)
+    simgrid::smpi::Info::unref(info_);
+  info_ = info;
+  if (info_ != MPI_INFO_NULL)
+    info_->ref();
 }
 
 void Win::set_name(const char* name){
@@ -193,7 +207,7 @@ int Win::put(const void *origin_addr, int origin_count, MPI_Datatype origin_data
               MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Request* request)
 {
   //get receiver pointer
-  MPI_Win recv_win = connected_wins_[target_rank];
+  const Win* recv_win = connected_wins_[target_rank];
 
   if(opened_==0){//check that post/start has been done
     // no fence or start .. lock ok ?
@@ -253,7 +267,7 @@ int Win::get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
               MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Request* request)
 {
   //get sender pointer
-  MPI_Win send_win = connected_wins_[target_rank];
+  const Win* send_win = connected_wins_[target_rank];
 
   if(opened_==0){//check that post/start has been done
     // no fence or start .. lock ok ?
@@ -268,7 +282,7 @@ int Win::get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
   if(target_count*target_datatype->get_extent()>send_win->size_)
     return MPI_ERR_ARG;
 
-  void* send_addr = static_cast<void*>(static_cast<char*>(send_win->base_) + target_disp * send_win->disp_unit_);
+  const void* send_addr = static_cast<void*>(static_cast<char*>(send_win->base_) + target_disp * send_win->disp_unit_);
   XBT_DEBUG("Entering MPI_Get from %d", target_rank);
 
   if(target_rank != comm_->rank()){
@@ -312,7 +326,7 @@ int Win::accumulate(const void *origin_addr, int origin_count, MPI_Datatype orig
 {
   XBT_DEBUG("Entering MPI_Win_Accumulate");
   //get receiver pointer
-  MPI_Win recv_win = connected_wins_[target_rank];
+  const Win* recv_win = connected_wins_[target_rank];
 
   if(opened_==0){//check that post/start has been done
     // no fence or start .. lock ok ?
@@ -368,7 +382,7 @@ int Win::get_accumulate(const void* origin_addr, int origin_count, MPI_Datatype
                         int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Request*)
 {
   //get sender pointer
-  MPI_Win send_win = connected_wins_[target_rank];
+  const Win* send_win = connected_wins_[target_rank];
 
   if(opened_==0){//check that post/start has been done
     // no fence or start .. lock ok ?
@@ -400,11 +414,11 @@ int Win::get_accumulate(const void* origin_addr, int origin_count, MPI_Datatype
   return MPI_SUCCESS;
 }
 
-int Win::compare_and_swap(const void *origin_addr, void *compare_addr,
-        void *result_addr, MPI_Datatype datatype, int target_rank,
-        MPI_Aint target_disp){
+int Win::compare_and_swap(const void* origin_addr, const void* compare_addr, void* result_addr, MPI_Datatype datatype,
+                          int target_rank, MPI_Aint target_disp)
+{
   //get sender pointer
-  MPI_Win send_win = connected_wins_[target_rank];
+  const Win* send_win = connected_wins_[target_rank];
 
   if(opened_==0){//check that post/start has been done
     // no fence or start .. lock ok ?
@@ -718,7 +732,7 @@ int Win::finish_comms(int rank){
 
 int Win::shared_query(int rank, MPI_Aint* size, int* disp_unit, void* baseptr)
 {
-  MPI_Win target_win = rank != MPI_PROC_NULL ? connected_wins_[rank] : nullptr;
+  const Win* target_win = rank != MPI_PROC_NULL ? connected_wins_[rank] : nullptr;
   for (int i = 0; not target_win && i < comm_->size(); i++) {
     if (connected_wins_[i]->size_ > 0)
       target_win = connected_wins_[i];
@@ -729,21 +743,25 @@ int Win::shared_query(int rank, MPI_Aint* size, int* disp_unit, void* baseptr)
     *static_cast<void**>(baseptr) = target_win->base_;
   } else {
     *size                         = 0;
-    *static_cast<void**>(baseptr) = xbt_malloc(0);
+    *static_cast<void**>(baseptr) = nullptr;
   }
   return MPI_SUCCESS;
 }
 
 MPI_Errhandler Win::errhandler()
 {
+  if (errhandler_ != MPI_ERRHANDLER_NULL)
+    errhandler_->ref();
   return errhandler_;
 }
 
 void Win::set_errhandler(MPI_Errhandler errhandler)
 {
+  if (errhandler_ != MPI_ERRHANDLER_NULL)
+    simgrid::smpi::Errhandler::unref(errhandler_);
   errhandler_ = errhandler;
   if (errhandler_ != MPI_ERRHANDLER_NULL)
-    errhandler->ref();
+    errhandler_->ref();
 }
 } // namespace smpi
 } // namespace simgrid
index 9888163..be0d713 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index b31fb73..2f209af 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 7bd5141..4245c78 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index d956584..53e5655 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index cc67e00..2c93726 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -46,7 +46,7 @@ void LoadBalancer::run()
 {
   simgrid::s4u::Engine* engine                     = simgrid::s4u::Engine::get_instance();
   std::vector<simgrid::s4u::Host*> available_hosts =
-      engine->get_filtered_hosts([](simgrid::s4u::Host* host) { return host->is_on(); });
+      engine->get_filtered_hosts([](const simgrid::s4u::Host* host) { return host->is_on(); });
   xbt_assert(available_hosts.size() > 0, "No hosts available; are they all switched off?");
 
   // TODO: Account for daemon background load (-> use especially the availability file)
@@ -54,7 +54,7 @@ void LoadBalancer::run()
   std::vector<simgrid::s4u::ActorPtr> all_actors =
       engine->get_filtered_actors([](simgrid::s4u::ActorPtr actor) { return not actor->is_daemon(); });
 
-  for (auto& actor : all_actors) {
+  for (auto const& actor : all_actors) {
     new_mapping.assign(actor, actor->get_host());
   }
   // Sort the actors, from highest to lowest load; we then just iterate over these actors
@@ -76,7 +76,7 @@ void LoadBalancer::run()
     heap_handle update_handle                  = usable_hosts.push(host); // Required to update elements in the heap
     additional_load[host]                      = {update_handle, 0};      // Save the handle for later
     const double total_flops_computed          = sg_host_get_computed_flops(host);
-    for (auto& actor : actors) {
+    for (auto const& actor : actors) {
       additional_load[host].load += actor_computation[actor->get_pid()] / total_flops_computed; // Normalize load - this allows comparison
                                                                                                 // even between hosts with different frequencies
       XBT_DEBUG("Actor %li -> %f", actor->get_pid(), actor_computation[actor->get_pid()]);
@@ -86,7 +86,7 @@ void LoadBalancer::run()
   }
 
   // Implementation of the Greedy algorithm
-  for (auto& actor : all_actors) {
+  for (auto const& actor : all_actors) {
     simgrid::s4u::Host* target_host = usable_hosts.top(); // This is the host with the lowest load
 
     simgrid::s4u::Host* cur_mapped_host = new_mapping.get_host(actor);
index 4924337..315a7b1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -46,11 +46,8 @@ public:
   void for_each_actor(simgrid::s4u::Host* host, const std::function<void(simgrid::s4u::ActorPtr)>& callback)
   {
     auto range = host_to_actors.equal_range(host);
-    std::for_each(
-        range.first,
-        range.second,
-        [&callback](host_to_actors_map_t::value_type& x) { callback(x.second); }
-    );
+    std::for_each(range.first, range.second,
+                  [&callback](host_to_actors_map_t::value_type const& x) { callback(x.second); });
   }
 };
 
index 5e928f2..be546b3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -54,7 +54,7 @@ public:
     simgrid::s4u::Host* cur_host = simgrid::s4u::this_actor::get_host();
     simgrid::s4u::Host* migrate_to_host;
 
-    TRACE_migration_call(my_proc_id, nullptr);
+    TRACE_migration_call(get_pid(), nullptr);
 
     // We only migrate every "cfg_migration_frequency"-times, not at every call
     migration_call_counter[simgrid::s4u::Actor::self()]++;
@@ -68,7 +68,7 @@ public:
     static bool was_executed = false;
     if (not was_executed) {
       was_executed = true;
-      XBT_DEBUG("Process %li runs the load balancer", my_proc_id);
+      XBT_DEBUG("Process %li runs the load balancer", get_pid());
       smpi_bench_begin();
       lb.run();
       smpi_bench_end();
@@ -82,17 +82,17 @@ public:
     if (cur_host != migrate_to_host) { // Origin and dest are not the same -> migrate
       std::vector<simgrid::s4u::Host*> migration_hosts = {cur_host, migrate_to_host};
       std::vector<double> comp_amount                  = {0, 0};
-      std::vector<double> comm_amount = {0, /*must not be 0*/ std::max(args.memory_consumption, 1.0), 0, 0};
+      std::vector<double> comm_amount = {0, /*must not be 0*/ std::max(get_args().memory_consumption, 1.0), 0, 0};
 
       xbt_os_timer_t timer = smpi_process()->timer();
       xbt_os_threadtimer_start(timer);
-      simgrid::s4u::this_actor::parallel_execute(migration_hosts, comp_amount, comm_amount, -1.0);
+      simgrid::s4u::this_actor::parallel_execute(migration_hosts, comp_amount, comm_amount);
       xbt_os_threadtimer_stop(timer);
       smpi_execute(xbt_os_timer_elapsed(timer));
 
       // Update the process and host mapping in SimGrid.
-      XBT_DEBUG("Migrating process %li from %s to %s", my_proc_id, cur_host->get_cname(), migrate_to_host->get_cname());
-      TRACE_smpi_process_change_host(my_proc_id, migrate_to_host);
+      XBT_DEBUG("Migrating process %li from %s to %s", get_pid(), cur_host->get_cname(), migrate_to_host->get_cname());
+      TRACE_smpi_process_change_host(get_pid(), migrate_to_host);
       simgrid::s4u::this_actor::set_host(migrate_to_host);
     }
 
index 55b2e16..00d2344 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index e609cea..dcf80e7 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env sh
 
-# Copyright (c) 2007-2019. The SimGrid Team.
+# Copyright (c) 2007-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
@@ -48,9 +48,6 @@ else
     list_add LINKARGS "-lsimgrid" ${LINKER_UNDEFINED_ERROR:+"-Wl,-z,defs"}
 fi
 
-# By default, we execute the commands instead of only showing them to cmake
-Show=
-
 list_set CMDARGS
 while [ $# -gt 0 ]; do
     ARG="$1"
@@ -84,7 +81,7 @@ while [ $# -gt 0 ]; do
             ;;
        '-show'|'-compile-info'|'-link-info')
             # Dry run displaying commands instead of executing them. Useful to cmake
-           Show=echo
+           show=1
            ;;
         *)
             list_add CMDARGS "${ARG}"
@@ -100,4 +97,8 @@ list_add_not_empty CMDLINE "${CMDARGS}"
 list_add_not_empty CMDLINE "${LINKARGS}"
 
 eval $(list_get CMDLINE)
-$Show "$@"
+if [ "x$VERBOSE" = x1 -o "x$show" = x1 ] ; then
+  echo "$@"
+  [ "x$show" = x1 ] && exit 0
+fi
+"$@"
index dafc880..1e09148 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env sh
 
-# Copyright (c) 2014-2019. The SimGrid Team.
+# Copyright (c) 2014-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
@@ -32,9 +32,6 @@ else
     list_add LINKARGS "@libdir@\libsimgrid.dll"
 fi
 
-# By default, we execute the commands instead of only showing them to cmake
-show=
-
 list_set CMDARGS
 while [ $# -gt 0 ]; do
     ARG="$1"
index 68928b5..859db13 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/env sh
 
-# Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
@@ -41,9 +41,6 @@ filter_and_compile() {
 
 NEEDS_OUTPUT=1
 
-# By default, we execute the commands instead of only showing them to cmake
-Show=
-
 list_set CMDLINE "${REAL_FORTRAN_COMPILER}"
 list_add_not_empty CMDLINE "${FFLAGS}"
 while [ $# -gt 0 ]; do
@@ -85,7 +82,7 @@ while [ $# -gt 0 ]; do
             ;;
        '-show'|'-compile-info'|'-link-info')
             # Dry run displaying commands instead of executing them. Useful to cmake
-           Show=echo
+           show=1
            ;;
         *)
             list_add CMDLINE "${ARG}"
@@ -102,4 +99,8 @@ list_add_not_empty CMDLINE ${CMAKE_LINKARGS}
 list_add_not_empty CMDLINE "${LINKARGS}"
 
 eval $(list_get CMDLINE)
-$Show "$@"
+if [ "x$VERBOSE" = x1 -o "x$show" = x1 ] ; then
+  echo "$@"
+  [ "x$show" = x1 ] && exit 0
+fi
+"$@"
index 6b23f7c..91f1afe 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/env sh
 
-# Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
@@ -56,9 +56,6 @@ filter_and_compile_f90() {
 TRACE_CALL_LOCATION=0
 NEEDS_OUTPUT=1
 
-# By default, we execute the commands instead of only showing them to cmake
-Show=
-
 list_set CMDLINE "${REAL_FORTRAN_COMPILER}"
 list_add_not_empty CMDLINE "${FFLAGS}"
 while [ $# -gt 0 ]; do
@@ -118,7 +115,7 @@ while [ $# -gt 0 ]; do
             ;;
        '-show'|'-compile-info'|'-link-info')
             # Dry run displaying commands instead of executing them. Useful to cmake
-           Show=echo
+           show=1
            ;;
         *)
             list_add CMDLINE "${ARG}"
@@ -135,4 +132,8 @@ list_add_not_empty CMDLINE ${CMAKE_LINKARGS}
 list_add_not_empty CMDLINE "${LINKARGS}"
 
 eval $(list_get CMDLINE)
-$Show "$@"
+if [ "x$VERBOSE" = x1 -o "x$show" = x1 ] ; then
+  echo "$@"
+  [ "x$show" = x1 ] && exit 0
+fi
+"$@"
index 99e1a94..3a79f5a 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env sh
 
-# Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
index 9aa0a2a..b86d801 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/env sh
 
-# Copyright (c) 2013-2019. The SimGrid Team.
+# Copyright (c) 2013-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
index d8d97be..2366c33 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -82,7 +82,7 @@ void HostImpl::turn_off(kernel::actor::ActorImpl* issuer)
   }
   // When a host is turned off, we want to keep only the actors that should restart for when it will boot again.
   // Then get rid of the others.
-  auto elm = remove_if(begin(actors_at_boot_), end(actors_at_boot_), [](kernel::actor::ProcessArg* arg) {
+  auto elm = remove_if(begin(actors_at_boot_), end(actors_at_boot_), [](const kernel::actor::ProcessArg* arg) {
     if (arg->auto_restart)
       return false;
     delete arg;
@@ -111,7 +111,14 @@ std::vector<s4u::Disk*> HostImpl::get_disks()
   return disks;
 }
 
-void HostImpl::add_disk(s4u::Disk* disk)
+void HostImpl::set_disks(const std::vector<kernel::resource::DiskImpl*>& disks, s4u::Host* host)
+{
+  disks_ = std::move(disks);
+  for (auto d : disks_)
+    d->set_host(host);
+}
+
+void HostImpl::add_disk(const s4u::Disk* disk)
 {
   disks_.push_back(disk->get_impl());
 }
@@ -136,6 +143,13 @@ std::vector<const char*> HostImpl::get_attached_storages()
       storages.push_back(s.second->get_iface()->get_cname());
   return storages;
 }
-
+std::unordered_map<std::string, s4u::Storage*>* HostImpl::get_mounted_storages()
+{
+  std::unordered_map<std::string, s4u::Storage*>* mounts = new std::unordered_map<std::string, s4u::Storage*>();
+  for (auto const& m : storage_) {
+    mounts->insert({m.first, m.second->get_iface()});
+  }
+  return mounts;
+}
 } // namespace surf
 } // namespace simgrid
index d48e4bb..bb01090 100644 (file)
@@ -1,10 +1,10 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#ifndef SURF_HOST_INTERFACE_HPP_
-#define SURF_HOST_INTERFACE_HPP_
+#ifndef SURF_HOST_INTERFACE_HPP
+#define SURF_HOST_INTERFACE_HPP
 
 #include "src/kernel/actor/ActorImpl.hpp"
 #include "src/kernel/resource/DiskImpl.hpp"
@@ -45,6 +45,8 @@ public:
 class XBT_PRIVATE HostImpl : public xbt::PropertyHolder {
   std::vector<kernel::actor::ProcessArg*> actors_at_boot_;
   s4u::Host* piface_ = nullptr; // FIXME: why don't we store a s4u::Host here as we do everywhere else?
+  std::map<std::string, kernel::resource::StorageImpl*> storage_;
+  std::vector<kernel::resource::DiskImpl*> disks_;
 
 public:
   friend simgrid::vm::VirtualMachineImpl;
@@ -52,14 +54,14 @@ public:
   virtual ~HostImpl();
 
   std::vector<s4u::Disk*> get_disks();
-  void add_disk(s4u::Disk* disk);
+  void set_disks(const std::vector<kernel::resource::DiskImpl*>& disks, s4u::Host* host);
+  void add_disk(const s4u::Disk* disk);
   void remove_disk(const std::string& disk_name);
 
   /** @brief Get the vector of storages (by names) attached to the Host */
   virtual std::vector<const char*> get_attached_storages();
-
-  std::map<std::string, kernel::resource::StorageImpl*> storage_;
-  std::vector<kernel::resource::DiskImpl*> disks_;
+  std::unordered_map<std::string, s4u::Storage*>* get_mounted_storages();
+  void set_storages(const std::map<std::string, kernel::resource::StorageImpl*>& storages) { storage_ = storages; }
 
   s4u::Host* get_iface() { return piface_; }
 
@@ -85,4 +87,4 @@ public:
 
 XBT_PUBLIC_DATA simgrid::surf::HostModel* surf_host_model;
 
-#endif /* SURF_Host_INTERFACE_HPP_ */
+#endif /* SURF_HOST_INTERFACE_HPP */
index 801ad1b..4db2a48 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -41,9 +41,9 @@ StorageImpl::StorageImpl(kernel::resource::Model* model, const std::string& name
     : Resource(model, name, maxminSystem->constraint_new(this, std::max(bread, bwrite)))
     , piface_(name, this)
     , typeId_(type_id)
+    , attach_(attach)
     , content_name_(content_name)
     , size_(size)
-    , attach_(attach)
 {
   StorageImpl::turn_on();
   XBT_DEBUG("Create resource with Bread '%f' Bwrite '%f' and Size '%llu'", bread, bwrite, size);
index 338268c..b1c6047 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -61,8 +61,18 @@ public:
  */
 class StorageImpl : public Resource, public xbt::PropertyHolder {
   s4u::Storage piface_;
+  lmm::Constraint* constraint_read_;  /* Constraint for maximum write bandwidth*/
+  lmm::Constraint* constraint_write_; /* Constraint for maximum write bandwidth*/
+
+  std::string typeId_;
+  bool currently_destroying_ = false;
+  // Name of the host to which this storage is attached. Only used at platform parsing time, then the interface stores
+  // the Host directly.
+  std::string attach_;
 
 public:
+  const std::string content_name_; // Only used at parsing time then goes to the FileSystemExtension
+  const sg_size_t size_;           // Only used at parsing time then goes to the FileSystemExtension
   /** @brief Storage constructor */
   StorageImpl(Model* model, const std::string& name, kernel::lmm::System* maxmin_system, double bread, double bwrite,
               const std::string& type_id, const std::string& content_name, sg_size_t size, const std::string& attach);
@@ -72,6 +82,9 @@ public:
   ~StorageImpl() override;
 
   s4u::Storage* get_iface() { return &piface_; }
+  const char* get_type() { return typeId_.c_str(); }
+  lmm::Constraint* get_read_constraint() const { return constraint_read_; }
+  lmm::Constraint* get_write_constraint() const { return constraint_write_; }
   /** @brief Check if the Storage is used (if an action currently uses its resources) */
   bool is_used() override;
 
@@ -98,19 +111,6 @@ public:
    */
   virtual StorageAction* write(sg_size_t size) = 0;
   const std::string& get_host() const { return attach_; }
-
-  lmm::Constraint* constraint_write_; /* Constraint for maximum write bandwidth*/
-  lmm::Constraint* constraint_read_;  /* Constraint for maximum write bandwidth*/
-
-  std::string typeId_;
-  std::string content_name_; // Only used at parsing time then goes to the FileSystemExtension
-  sg_size_t size_;          // Only used at parsing time then goes to the FileSystemExtension
-
-private:
-  bool currently_destroying_ = false;
-  // Name of the host to which this storage is attached. Only used at platform parsing time, then the interface stores
-  // the Host directly.
-  std::string attach_;
 };
 
 /**********
index e947415..a526b56 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -64,7 +64,7 @@ CpuCas01Model::CpuCas01Model(Model::UpdateAlgo algo) : CpuModel(algo)
 
   bool select = config::get_value<bool>("cpu/maxmin-selective-update");
 
-  if (algo == Model::UpdateAlgo::LAZY) {
+  if (is_update_lazy()) {
     xbt_assert(select || config::is_default("cpu/maxmin-selective-update"),
                "You cannot disable cpu selective update when using the lazy update mechanism");
     select = true;
@@ -102,7 +102,7 @@ bool CpuCas01::is_used()
 /** @brief take into account changes of speed (either load or max) */
 void CpuCas01::on_speed_change()
 {
-  lmm::Variable* var       = nullptr;
+  const lmm::Variable* var;
   const lmm::Element* elem = nullptr;
 
   get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(),
@@ -137,8 +137,8 @@ void CpuCas01::apply_event(profile::Event* event, double value)
         get_host()->turn_on();
       }
     } else {
-      lmm::Constraint* cnst    = get_constraint();
-      lmm::Variable* var       = nullptr;
+      const lmm::Constraint* cnst = get_constraint();
+      const lmm::Variable* var;
       const lmm::Element* elem = nullptr;
       double date              = surf_get_clock();
 
@@ -188,7 +188,7 @@ CpuAction* CpuCas01::sleep(double duration)
     action->set_state(Action::State::IGNORED);
 
   get_model()->get_maxmin_system()->update_variable_penalty(action->get_variable(), 0.0);
-  if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) { // remove action from the heap
+  if (get_model()->is_update_lazy()) { // remove action from the heap
     get_model()->get_action_heap().remove(action);
     // this is necessary for a variable with weight 0 since such variables are ignored in lmm and we need to set its
     // max_duration correctly at the next call to share_resources
@@ -208,7 +208,7 @@ CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double sp
                 model->get_maxmin_system()->variable_new(this, 1.0 / requested_core, requested_core * speed, 1))
     , requested_core_(requested_core)
 {
-  if (model->get_update_algorithm() == Model::UpdateAlgo::LAZY)
+  if (model->is_update_lazy())
     set_last_update();
   model->get_maxmin_system()->expand(constraint, get_variable(), 1.0);
 }
index 11cdd36..f01f62b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 606961a..f85cce4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -25,7 +25,6 @@ namespace resource {
 void CpuModel::update_actions_state_lazy(double now, double /*delta*/)
 {
   while (not get_action_heap().empty() && double_equals(get_action_heap().top_date(), now, sg_surf_precision)) {
-
     auto* action = static_cast<CpuAction*>(get_action_heap().pop());
     XBT_CDEBUG(surf_kernel, "Something happened to action %p", action);
 
index 10a4cf4..1e77a39 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index b97d8fa..6810cf3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -23,7 +23,7 @@ namespace resource {
  * Trace *
  *********/
 
-CpuTiProfile::CpuTiProfile(profile::Profile* profile)
+CpuTiProfile::CpuTiProfile(const profile::Profile* profile)
 {
   double integral = 0;
   double time = 0;
@@ -222,7 +222,6 @@ CpuTiTmgr::CpuTiTmgr(kernel::profile::Profile* speed_profile, double value) : sp
 
   /* no availability file, fixed trace */
   if (not speed_profile) {
-    type_  = Type::FIXED;
     value_ = value;
     XBT_DEBUG("No availability trace. Constant value = %f", value);
     return;
@@ -230,7 +229,6 @@ CpuTiTmgr::CpuTiTmgr(kernel::profile::Profile* speed_profile, double value) : sp
 
   /* only one point available, fixed trace */
   if (speed_profile->event_list.size() == 1) {
-    type_  = Type::FIXED;
     value_ = speed_profile->event_list.front().value_;
     return;
   }
@@ -272,8 +270,8 @@ void CpuTiModel::create_pm_vm_models()
   xbt_assert(surf_cpu_model_pm == nullptr, "CPU model already initialized. This should not happen.");
   xbt_assert(surf_cpu_model_vm == nullptr, "CPU model already initialized. This should not happen.");
 
-  surf_cpu_model_pm = new simgrid::kernel::resource::CpuTiModel();
-  surf_cpu_model_vm = new simgrid::kernel::resource::CpuTiModel();
+  surf_cpu_model_pm = new CpuTiModel();
+  surf_cpu_model_vm = new CpuTiModel();
 }
 
 CpuTiModel::CpuTiModel() : CpuModel(Model::UpdateAlgo::FULL)
@@ -286,7 +284,7 @@ CpuTiModel::~CpuTiModel()
   surf_cpu_model_pm = nullptr;
 }
 
-kernel::resource::Cpu* CpuTiModel::create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate, int core)
+Cpu* CpuTiModel::create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate, int core)
 {
   return new CpuTi(this, host, speed_per_pstate, core);
 }
@@ -316,7 +314,7 @@ void CpuTiModel::update_actions_state(double now, double /*delta*/)
   while (not get_action_heap().empty() && double_equals(get_action_heap().top_date(), now, sg_surf_precision)) {
     auto* action = static_cast<CpuTiAction*>(get_action_heap().pop());
     XBT_DEBUG("Action %p: finish", action);
-    action->finish(kernel::resource::Action::State::FINISHED);
+    action->finish(Action::State::FINISHED);
     /* update remaining amount of all actions */
     action->cpu_->update_remaining_amount(surf_get_clock());
   }
@@ -325,7 +323,7 @@ void CpuTiModel::update_actions_state(double now, double /*delta*/)
 /************
  * Resource *
  ************/
-CpuTi::CpuTi(CpuTiModel* model, simgrid::s4u::Host* host, const std::vector<double>& speed_per_pstate, int core)
+CpuTi::CpuTi(CpuTiModel* model, s4u::Host* host, const std::vector<double>& speed_per_pstate, int core)
     : Cpu(model, host, speed_per_pstate, core)
 {
   xbt_assert(core == 1, "Multi-core not handled by this model yet");
@@ -341,6 +339,7 @@ CpuTi::~CpuTi()
   set_modified(false);
   delete speed_integrated_trace_;
 }
+
 void CpuTi::set_speed_profile(kernel::profile::Profile* profile)
 {
   delete speed_integrated_trace_;
@@ -350,7 +349,7 @@ void CpuTi::set_speed_profile(kernel::profile::Profile* profile)
   if (profile && profile->event_list.size() > 1) {
     kernel::profile::DatedValue val = profile->event_list.back();
     if (val.date_ < 1e-12) {
-      auto* prof   = new simgrid::kernel::profile::Profile();
+      auto* prof   = new kernel::profile::Profile();
       speed_.event = prof->schedule(&profile::future_evt_set, this);
     }
   }
@@ -384,11 +383,10 @@ void CpuTi::apply_event(kernel::profile::Event* event, double value)
 
       /* put all action running on cpu to failed */
       for (CpuTiAction& action : action_set_) {
-        if (action.get_state() == kernel::resource::Action::State::INITED ||
-            action.get_state() == kernel::resource::Action::State::STARTED ||
-            action.get_state() == kernel::resource::Action::State::IGNORED) {
+        if (action.get_state() == Action::State::INITED || action.get_state() == Action::State::STARTED ||
+            action.get_state() == Action::State::IGNORED) {
           action.set_finish_time(date);
-          action.set_state(kernel::resource::Action::State::FAILED);
+          action.set_state(Action::State::FAILED);
           get_model()->get_action_heap().remove(&action);
         }
       }
@@ -449,7 +447,7 @@ void CpuTi::update_actions_finish_time(double now)
     }
     /* add in action heap */
     if (min_finish != NO_MAX_DURATION)
-      get_model()->get_action_heap().update(&action, min_finish, kernel::resource::ActionHeap::Type::unset);
+      get_model()->get_action_heap().update(&action, min_finish, ActionHeap::Type::unset);
     else
       get_model()->get_action_heap().remove(&action);
 
@@ -509,7 +507,7 @@ void CpuTi::update_remaining_amount(double now)
   last_update_ = now;
 }
 
-kernel::resource::CpuAction* CpuTi::execution_start(double size)
+CpuAction* CpuTi::execution_start(double size)
 {
   XBT_IN("(%s,%g)", get_cname(), size);
   auto* action = new CpuTiAction(this, size);
@@ -520,7 +518,7 @@ kernel::resource::CpuAction* CpuTi::execution_start(double size)
   return action;
 }
 
-kernel::resource::CpuAction* CpuTi::sleep(double duration)
+CpuAction* CpuTi::sleep(double duration)
 {
   if (duration > 0)
     duration = std::max(duration, sg_surf_precision);
@@ -529,9 +527,9 @@ kernel::resource::CpuAction* CpuTi::sleep(double duration)
   auto* action = new CpuTiAction(this, 1.0);
 
   action->set_max_duration(duration);
-  action->set_suspend_state(kernel::resource::Action::SuspendStates::SLEEPING);
+  action->set_suspend_state(Action::SuspendStates::SLEEPING);
   if (duration == NO_MAX_DURATION)
-    action->set_state(simgrid::kernel::resource::Action::State::IGNORED);
+    action->set_state(Action::State::IGNORED);
 
   action_set_.push_back(*action);
 
@@ -548,7 +546,7 @@ void CpuTi::set_modified(bool modified)
     }
   } else {
     if (cpu_ti_hook.is_linked())
-      simgrid::xbt::intrusive_erase(modified_cpus, *this);
+      xbt::intrusive_erase(modified_cpus, *this);
   }
 }
 
@@ -564,7 +562,7 @@ CpuTiAction::~CpuTiAction()
 {
   /* remove from action_set */
   if (action_ti_hook.is_linked())
-    simgrid::xbt::intrusive_erase(cpu_->action_set_, *this);
+    xbt::intrusive_erase(cpu_->action_set_, *this);
   /* remove from heap */
   get_model()->get_action_heap().remove(this);
   cpu_->set_modified(true);
@@ -619,7 +617,7 @@ void CpuTiAction::set_max_duration(double duration)
     min_finish = get_finish_time();
 
   /* add in action heap */
-  get_model()->get_action_heap().update(this, min_finish, kernel::resource::ActionHeap::Type::unset);
+  get_model()->get_action_heap().update(this, min_finish, ActionHeap::Type::unset);
 
   XBT_OUT();
 }
index d2cfa0e..4ce90e2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -27,7 +27,7 @@ class XBT_PRIVATE CpuTi;
  *********/
 class CpuTiProfile {
 public:
-  explicit CpuTiProfile(profile::Profile* profile);
+  explicit CpuTiProfile(const profile::Profile* profile);
 
   double integrate_simple(double a, double b);
   double integrate_simple_point(double a);
@@ -45,7 +45,7 @@ class CpuTiTmgr {
   };
 
 public:
-  explicit CpuTiTmgr(double value) : type_(Type::FIXED), value_(value){};
+  explicit CpuTiTmgr(double value) : value_(value){};
   CpuTiTmgr(profile::Profile* speed_profile, double value);
   CpuTiTmgr(const CpuTiTmgr&) = delete;
   CpuTiTmgr& operator=(const CpuTiTmgr&) = delete;
@@ -55,7 +55,7 @@ public:
   double get_power_scale(double a);
 
 private:
-  Type type_;
+  Type type_ = Type::FIXED;
   double value_;                 /*< Percentage of cpu speed available. Value fixed between 0 and 1 */
 
   /* Dynamic */
index aabe4f8..8e849d8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index b14d6f9..5c99284 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 18b646e..5d1b3f9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 7ab9e0e..408707d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index c8f084c..25b0ba3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -104,7 +104,6 @@ LinkImpl* NetworkCm02Model::create_link(const std::string& name, const std::vect
 void NetworkCm02Model::update_actions_state_lazy(double now, double /*delta*/)
 {
   while (not get_action_heap().empty() && double_equals(get_action_heap().top_date(), now, sg_surf_precision)) {
-
     auto* action = static_cast<NetworkCm02Action*>(get_action_heap().pop());
     XBT_DEBUG("Something happened to action %p", action);
 
@@ -190,7 +189,7 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
   action->latency_ = latency;
   action->rate_ = rate;
 
-  if (get_update_algorithm() == Model::UpdateAlgo::LAZY) {
+  if (is_update_lazy()) {
     action->set_last_update();
   }
 
@@ -215,7 +214,7 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
 
   if (action->latency_ > 0) {
     action->set_variable(get_maxmin_system()->variable_new(action, 0.0, -1.0, constraints_per_variable));
-    if (get_update_algorithm() == Model::UpdateAlgo::LAZY) {
+    if (is_update_lazy()) {
       // add to the heap the event when the latency is payed
       double date = action->latency_ + action->get_last_update();
 
@@ -346,7 +345,7 @@ void NetworkCm02Link::set_bandwidth(double value)
   if (sg_weight_S_parameter > 0) {
     double delta = sg_weight_S_parameter / value - sg_weight_S_parameter / (bandwidth_.peak * bandwidth_.scale);
 
-    kernel::lmm::Variable* var;
+    const kernel::lmm::Variable* var;
     const kernel::lmm::Element* elem     = nullptr;
     const kernel::lmm::Element* nextelem = nullptr;
     int numelem                  = 0;
@@ -362,7 +361,7 @@ void NetworkCm02Link::set_bandwidth(double value)
 void NetworkCm02Link::set_latency(double value)
 {
   double delta                 = value - latency_.peak;
-  kernel::lmm::Variable* var   = nullptr;
+  const kernel::lmm::Variable* var;
   const kernel::lmm::Element* elem     = nullptr;
   const kernel::lmm::Element* nextelem = nullptr;
   int numelem                  = 0;
index 0999119..e664839 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index d13d0bc..ad2f6e0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -30,7 +30,6 @@ NetworkConstantModel::NetworkConstantModel() : NetworkModel(Model::UpdateAlgo::F
 LinkImpl* NetworkConstantModel::create_link(const std::string& name, const std::vector<double>& /*bandwidth*/,
                                             double /*latency*/, s4u::Link::SharingPolicy)
 {
-
   xbt_die("Refusing to create the link %s: there is no link in the Constant network model. "
           "Please remove any link from your platform (and switch to routing='None')",
           name.c_str());
index ac6b625..f007fcb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 1e62ea1..70782d1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -41,8 +41,8 @@ static void IB_action_state_changed_callback(simgrid::kernel::resource::NetworkA
   ((NetworkIBModel*)surf_network_model)->active_comms.erase(&action);
 }
 
-static void IB_action_init_callback(simgrid::kernel::resource::NetworkAction& action, simgrid::s4u::Host* src,
-                                    simgrid::s4u::Host* dst)
+static void IB_action_init_callback(simgrid::kernel::resource::NetworkAction& action, const simgrid::s4u::Host* src,
+                                    const simgrid::s4u::Host* dst)
 {
   simgrid::kernel::resource::NetworkIBModel* ibModel = (simgrid::kernel::resource::NetworkIBModel*)surf_network_model;
   simgrid::kernel::resource::IBNode* act_src         = &ibModel->active_nodes.at(src->get_name());
@@ -94,19 +94,19 @@ NetworkIBModel::NetworkIBModel() : NetworkSmpiModel()
 
   try {
     Be = std::stod(radical_elements.front());
-  } catch (std::invalid_argument& ia) {
+  } catch (const std::invalid_argument& ia) {
     throw std::invalid_argument(std::string("First part of smpi/IB-penalty-factors is not numerical:") + ia.what());
   }
 
   try {
     Bs = std::stod(radical_elements.at(1));
-  } catch (std::invalid_argument& ia) {
+  } catch (const std::invalid_argument& ia) {
     throw std::invalid_argument(std::string("Second part of smpi/IB-penalty-factors is not numerical:") + ia.what());
   }
 
   try {
     ys = std::stod(radical_elements.back());
-  } catch (std::invalid_argument& ia) {
+  } catch (const std::invalid_argument& ia) {
     throw std::invalid_argument(std::string("Third part of smpi/IB-penalty-factors is not numerical:") + ia.what());
   }
 }
index ee33677..8df5bc0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team.
+/* Copyright (c) 2014-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -19,13 +19,10 @@ namespace resource {
 
 class XBT_PRIVATE IBNode;
 
-class XBT_PRIVATE ActiveComm {
-public:
-  IBNode* destination;
-  NetworkAction* action;
-  double init_rate;
-  ActiveComm() : destination(nullptr), action(nullptr), init_rate(-1){};
-  virtual ~ActiveComm() = default;
+struct XBT_PRIVATE ActiveComm {
+  IBNode* destination   = nullptr;
+  NetworkAction* action = nullptr;
+  double init_rate      = -1;
 };
 
 class IBNode {
@@ -36,8 +33,8 @@ public:
   // store the number of comms received from each node
   std::map<IBNode*, int> ActiveCommsDown;
   // number of comms the node is receiving
-  int nbActiveCommsDown;
-  explicit IBNode(int id) : id(id), nbActiveCommsDown(0){};
+  int nbActiveCommsDown = 0;
+  explicit IBNode(int id) : id(id){};
   virtual ~IBNode() = default;
 };
 
index 5a23538..ccb7e03 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -76,7 +76,6 @@ double NetworkModel::next_occurring_event_full(double now)
 LinkImpl::LinkImpl(NetworkModel* model, const std::string& name, lmm::Constraint* constraint)
     : Resource(model, name, constraint), piface_(this)
 {
-
   if (name != "__loopback__")
     xbt_assert(not s4u::Link::by_name_or_null(name), "Link '%s' declared several times in the platform.", name.c_str());
 
@@ -139,7 +138,7 @@ void LinkImpl::turn_off()
     Resource::turn_off();
     s4u::Link::on_state_change(this->piface_);
 
-    kernel::lmm::Variable* var       = nullptr;
+    const kernel::lmm::Variable* var;
     const kernel::lmm::Element* elem = nullptr;
     double now                       = surf_get_clock();
     while ((var = get_constraint()->get_variable(&elem))) {
index 69fbcb2..3ecd3bb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -157,7 +157,6 @@ public:
 
   Metric latency_                   = {0.0, 0, nullptr};
   Metric bandwidth_                 = {1.0, 0, nullptr};
-
 };
 
 /**********
index 711f4f2..728f834 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -165,7 +165,7 @@ NetworkNS3Model::NetworkNS3Model() : NetworkModel(Model::UpdateAlgo::FULL)
     pt.extension_set<NetPointNs3>(new NetPointNs3());
     XBT_VERB("SimGrid's %s is known as node %d within ns-3", pt.get_cname(), pt.extension<NetPointNs3>()->node_num);
   });
-  surf::on_cluster.connect(&clusterCreation_cb);
+  routing::on_cluster_creation.connect(&clusterCreation_cb);
 
   s4u::Engine::on_platform_created.connect(&postparse_cb);
   s4u::NetZone::on_route_creation.connect(&routeCreation_cb);
@@ -310,7 +310,6 @@ void LinkNS3::set_latency_profile(profile::Profile*)
 NetworkNS3Action::NetworkNS3Action(Model* model, double totalBytes, s4u::Host* src, s4u::Host* dst)
     : NetworkAction(model, totalBytes, false), src_(src), dst_(dst)
 {
-  
   // If there is no other started actions, we need to move NS-3 forward to be sync with SimGrid
   if (model->get_started_action_set()->size()==1){
     while(double_positive(surf_get_clock() - ns3::Simulator::Now().GetSeconds(), sg_surf_precision)){
index 0f9900c..f828efd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index f96bc1a..2c9ab11 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 2864fc1..3915097 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index f7b761f..7a0896e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -27,14 +27,14 @@ NetworkWifiLink::NetworkWifiLink(NetworkCm02Model* model, const std::string& nam
   simgrid::s4u::Link::on_creation(*get_iface());
 }
 
-void NetworkWifiLink::set_host_rate(s4u::Host* host, int rate_level)
+void NetworkWifiLink::set_host_rate(const s4u::Host* host, int rate_level)
 {
   auto insert_done = host_rates_.insert(std::make_pair(host->get_name(), rate_level));
   if (insert_done.second == false)
     insert_done.first->second = rate_level;
 }
 
-double NetworkWifiLink::get_host_rate(sg_host_t host)
+double NetworkWifiLink::get_host_rate(const s4u::Host* host)
 {
   std::map<xbt::string, int>::iterator host_rates_it;
   host_rates_it = host_rates_.find(host->get_name());
index c84527b..a7887c1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -30,9 +30,9 @@ public:
   NetworkWifiLink(NetworkCm02Model* model, const std::string& name, std::vector<double> bandwidths,
                   lmm::System* system);
 
-  void set_host_rate(s4u::Host* host, int rate_level);
+  void set_host_rate(const s4u::Host* host, int rate_level);
   /** @brief Get the AP rate associated to the host (or -1 if not associated to the AP) */
-  double get_host_rate(s4u::Host* host);
+  double get_host_rate(const s4u::Host* host);
 
   s4u::Link::SharingPolicy get_sharing_policy() override;
   void apply_event(kernel::profile::Event*, double) override { THROW_UNIMPLEMENTED; }
index 72171b3..180d0a4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index d33a563..ca2056d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 3b1ca2e..43591c0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -71,8 +71,8 @@ double HostL07Model::next_occurring_event(double now)
   double min = HostModel::next_occurring_event_full(now);
   for (kernel::resource::Action const& action : *get_started_action_set()) {
     const L07Action& net_action = static_cast<const L07Action&>(action);
-    if (net_action.latency_ > 0 && (min < 0 || net_action.latency_ < min)) {
-      min = net_action.latency_;
+    if (net_action.get_latency() > 0 && (min < 0 || net_action.get_latency() < min)) {
+      min = net_action.get_latency();
       XBT_DEBUG("Updating min with %p (start %f): %f", &net_action, net_action.get_start_time(), min);
     }
   }
@@ -86,13 +86,13 @@ void HostL07Model::update_actions_state(double /*now*/, double delta)
   for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) {
     L07Action& action = static_cast<L07Action&>(*it);
     ++it; // increment iterator here since the following calls to action.finish() may invalidate it
-    if (action.latency_ > 0) {
-      if (action.latency_ > delta) {
-        double_update(&(action.latency_), delta, sg_surf_precision);
+    if (action.get_latency() > 0) {
+      if (action.get_latency() > delta) {
+        action.update_latency(delta, sg_surf_precision);
       } else {
-        action.latency_ = 0.0;
+        action.set_latency(0.0);
       }
-      if ((action.latency_ <= 0.0) && (action.is_suspended() == 0)) {
+      if ((action.get_latency() <= 0.0) && (action.is_suspended() == 0)) {
         action.updateBound();
         get_maxmin_system()->update_variable_penalty(action.get_variable(), 1.0);
         action.set_last_update();
@@ -119,10 +119,10 @@ void HostL07Model::update_actions_state(double /*now*/, double delta)
 
     /* Need to check that none of the model has failed */
     int i                         = 0;
-    kernel::lmm::Constraint* cnst = action.get_variable()->get_constraint(i);
+    const kernel::lmm::Constraint* cnst = action.get_variable()->get_constraint(i);
     while (cnst != nullptr) {
       i++;
-      kernel::resource::Resource* constraint_id = cnst->get_id();
+      const kernel::resource::Resource* constraint_id = cnst->get_id();
       if (not constraint_id->is_on()) {
         XBT_DEBUG("Action (%p) Failed!!", &action);
         action.finish(kernel::resource::Action::State::FAILED);
@@ -210,7 +210,7 @@ L07Action::L07Action(kernel::resource::Model* model, const std::vector<s4u::Host
 kernel::resource::Action* NetworkL07Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
 {
   std::vector<s4u::Host*> host_list = {src, dst};
-  double* flops_amount = new double[2]();
+  const double* flops_amount        = new double[2]();
   double* bytes_amount = new double[4]();
 
   bytes_amount[1] = size;
@@ -288,12 +288,12 @@ bool CpuL07::is_used()
 /** @brief take into account changes of speed (either load or max) */
 void CpuL07::on_speed_change()
 {
-  kernel::lmm::Variable* var = nullptr;
+  const kernel::lmm::Variable* var;
   const kernel::lmm::Element* elem = nullptr;
 
   get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(), speed_.peak * speed_.scale);
   while ((var = get_constraint()->get_variable(&elem))) {
-    kernel::resource::Action* action = static_cast<kernel::resource::Action*>(var->get_id());
+    const kernel::resource::Action* action = static_cast<kernel::resource::Action*>(var->get_id());
 
     get_model()->get_maxmin_system()->update_variable_bound(action->get_variable(), speed_.scale * speed_.peak);
   }
@@ -362,7 +362,7 @@ void LinkL07::set_bandwidth(double value)
 
 void LinkL07::set_latency(double value)
 {
-  kernel::lmm::Variable* var = nullptr;
+  const kernel::lmm::Variable* var;
   L07Action *action;
   const kernel::lmm::Element* elem = nullptr;
 
@@ -395,7 +395,6 @@ void L07Action::updateBound()
   if (communicationAmount_ != nullptr) {
     for (size_t i = 0; i < host_count; i++) {
       for (size_t j = 0; j < host_count; j++) {
-
         if (communicationAmount_[i * host_count + j] > 0) {
           double lat = 0.0;
           std::vector<kernel::resource::LinkImpl*> route;
index 2caab73..4025bee 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -112,6 +112,16 @@ public:
  * Action *
  **********/
 class L07Action : public kernel::resource::CpuAction {
+  std::vector<s4u::Host*> hostList_;
+  bool free_arrays_ = false; // By default, computationAmount_ and friends are freed by caller. But not for sequential
+                             // exec and regular comms
+  const double* computationAmount_;   /* pointer to the data that lives in s4u action -- do not free unless if
+                                       * free_arrays */
+  const double* communicationAmount_; /* pointer to the data that lives in s4u action -- do not free unless if
+                                       * free_arrays */
+  double latency_;
+  double rate_;
+
   friend CpuAction* CpuL07::execution_start(double size);
   friend CpuAction* CpuL07::sleep(double duration);
   friend CpuAction* HostL07Model::execute_parallel(const std::vector<s4u::Host*>& host_list, const double* flops_amount,
@@ -126,18 +136,9 @@ public:
   ~L07Action();
 
   void updateBound();
-
-  std::vector<s4u::Host*> hostList_;
-  const double* computationAmount_;   /* pointer to the data that lives in s4u action -- do not free unless if
-                                       * free_arrays */
-  const double* communicationAmount_; /* pointer to the data that lives in s4u action -- do not free unless if
-                                       * free_arrays */
-  double latency_;
-  double rate_;
-
-private:
-  bool free_arrays_ = false; // By default, computationAmount_ and friends are freed by caller. But not for sequential
-                             // exec and regular comms
+  double get_latency() const { return latency_; }
+  void set_latency(double latency) { latency_ = latency; }
+  void update_latency(double delta, double precision) { double_update(&latency_, delta, precision); }
 };
 
 } // namespace surf
index 6300328..43a1913 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -33,11 +33,12 @@ XBT_PRIVATE std::map<std::string, simgrid::kernel::resource::StorageImpl*> mount
 XBT_PRIVATE std::vector<std::string> known_storages;
 
 namespace simgrid {
-namespace surf {
-
-simgrid::xbt::signal<void(kernel::routing::ClusterCreationArgs const&)> on_cluster;
-}
-}
+namespace kernel {
+namespace routing {
+xbt::signal<void(ClusterCreationArgs const&)> on_cluster_creation;
+} // namespace routing
+} // namespace kernel
+} // namespace simgrid
 
 static int surf_parse_models_setup_already_called = 0;
 std::map<std::string, simgrid::kernel::resource::StorageType*> storage_types;
@@ -57,7 +58,7 @@ void sg_platf_init()
 
 /** Module management function: frees all internal data structures */
 void sg_platf_exit() {
-  simgrid::surf::on_cluster.disconnect_slots();
+  simgrid::kernel::routing::on_cluster_creation.disconnect_slots();
   simgrid::s4u::Engine::on_platform_created.disconnect_slots();
 
   /* make sure that we will reinit the models while loading the platf once reinited */
@@ -66,7 +67,7 @@ void sg_platf_exit() {
 }
 
 /** @brief Add a host to the current AS */
-void sg_platf_new_host(simgrid::kernel::routing::HostCreationArgs* args)
+void sg_platf_new_host(const simgrid::kernel::routing::HostCreationArgs* args)
 {
   std::map<std::string, std::string> props;
   if (args->properties) {
@@ -78,12 +79,10 @@ void sg_platf_new_host(simgrid::kernel::routing::HostCreationArgs* args)
   simgrid::s4u::Host* host =
       routing_get_current()->create_host(args->id, args->speed_per_pstate, args->core_amount, &props);
 
-  host->pimpl_->storage_ = mount_list;
+  host->pimpl_->set_storages(mount_list);
   mount_list.clear();
 
-  host->pimpl_->disks_ = std::move(args->disks);
-  for (auto d : host->pimpl_->disks_)
-    d->set_host(host);
+  host->pimpl_->set_disks(args->disks, host);
 
   /* Change from the defaults */
   if (args->state_trace)
@@ -115,7 +114,7 @@ simgrid::kernel::routing::NetPoint* sg_platf_new_router(const std::string& name,
   return netpoint;
 }
 
-static void sg_platf_new_link(simgrid::kernel::routing::LinkCreationArgs* link, const std::string& link_name)
+static void sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link, const std::string& link_name)
 {
   simgrid::kernel::resource::LinkImpl* l =
       surf_network_model->create_link(link_name, link->bandwidths, link->latency, link->policy);
@@ -132,7 +131,7 @@ static void sg_platf_new_link(simgrid::kernel::routing::LinkCreationArgs* link,
     l->set_state_profile(link->state_trace);
 }
 
-void sg_platf_new_link(simgrid::kernel::routing::LinkCreationArgs* link)
+void sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link)
 {
   if (link->policy == simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX) {
     sg_platf_new_link(link, link->id + "_UP");
@@ -195,7 +194,7 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster
     simgrid::kernel::routing::HostCreationArgs host;
     host.id = host_id;
     if ((cluster->properties != nullptr) && (not cluster->properties->empty())) {
-      host.properties = new std::unordered_map<std::string, std::string>;
+      host.properties = new std::unordered_map<std::string, std::string>();
 
       for (auto const& elm : *cluster->properties)
         host.properties->insert({elm.first, elm.second});
@@ -217,8 +216,8 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster
     // other columns are to store one or more link for the node
 
     //add a loopback link
-    simgrid::s4u::Link* linkUp   = nullptr;
-    simgrid::s4u::Link* linkDown = nullptr;
+    const simgrid::s4u::Link* linkUp   = nullptr;
+    const simgrid::s4u::Link* linkDown = nullptr;
     if(cluster->loopback_bw > 0 || cluster->loopback_lat > 0){
       std::string tmp_link = link_id + "_loopback";
       XBT_DEBUG("<loopback\tid=\"%s\"\tbw=\"%f\"/>", tmp_link.c_str(), cluster->loopback_bw);
@@ -277,7 +276,6 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster
 
   //Make the backbone
   if ((cluster->bb_bw > 0) || (cluster->bb_lat > 0)) {
-
     simgrid::kernel::routing::LinkCreationArgs link;
     link.id        = std::string(cluster->id)+ "_backbone";
     link.bandwidths.push_back(cluster->bb_bw);
@@ -293,7 +291,7 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster
   XBT_DEBUG("</AS>");
   sg_platf_new_Zone_seal();
 
-  simgrid::surf::on_cluster(*cluster);
+  simgrid::kernel::routing::on_cluster_creation(*cluster);
   delete cluster->radicals;
 }
 
@@ -309,7 +307,7 @@ void routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl* bb)
   XBT_DEBUG("Add a backbone to AS '%s'", current_routing->get_cname());
 }
 
-void sg_platf_new_cabinet(simgrid::kernel::routing::CabinetCreationArgs* cabinet)
+void sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet)
 {
   for (int const& radical : *cabinet->radicals) {
     std::string hostname = cabinet->prefix + std::to_string(radical) + cabinet->suffix;
@@ -336,7 +334,7 @@ void sg_platf_new_cabinet(simgrid::kernel::routing::CabinetCreationArgs* cabinet
   delete cabinet->radicals;
 }
 
-simgrid::kernel::resource::DiskImpl* sg_platf_new_disk(simgrid::kernel::routing::DiskCreationArgs* disk)
+simgrid::kernel::resource::DiskImpl* sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk)
 {
   simgrid::kernel::resource::DiskImpl* d = surf_disk_model->createDisk(disk->id, disk->read_bw, disk->write_bw);
   if (disk->properties) {
@@ -352,7 +350,7 @@ void sg_platf_new_storage(simgrid::kernel::routing::StorageCreationArgs* storage
   xbt_assert(std::find(known_storages.begin(), known_storages.end(), storage->id) == known_storages.end(),
              "Refusing to add a second storage named \"%s\"", storage->id.c_str());
 
-  simgrid::kernel::resource::StorageType* stype;
+  const simgrid::kernel::resource::StorageType* stype;
   auto st = storage_types.find(storage->type_id);
   if (st != storage_types.end()) {
     stype = st->second;
@@ -386,7 +384,7 @@ void sg_platf_new_storage(simgrid::kernel::routing::StorageCreationArgs* storage
   }
 }
 
-void sg_platf_new_storage_type(simgrid::kernel::routing::StorageTypeCreationArgs* storage_type)
+void sg_platf_new_storage_type(const simgrid::kernel::routing::StorageTypeCreationArgs* storage_type)
 {
   xbt_assert(storage_types.find(storage_type->id) == storage_types.end(),
              "Reading a storage type, processing unit \"%s\" already exists", storage_type->id.c_str());
@@ -446,7 +444,7 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor)
     }
     xbt_die("%s", msg.c_str());
   }
-  simgrid::simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(actor->function);
+  const simgrid::simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(actor->function);
   xbt_assert(factory, "Error while creating an actor from the XML file: Function '%s' not registered", actor->function);
 
   double start_time = actor->start_time;
@@ -463,7 +461,6 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor)
   host->pimpl_->add_actor_at_boot(arg);
 
   if (start_time > SIMIX_get_clock()) {
-
     arg = new simgrid::kernel::actor::ProcessArg(actor_name, code, nullptr, host, kill_time, properties, auto_restart);
 
     XBT_DEBUG("Process %s@%s will be started at time %f", arg->name.c_str(), arg->host->get_cname(), start_time);
@@ -494,7 +491,7 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor)
   }
 }
 
-void sg_platf_new_peer(simgrid::kernel::routing::PeerCreationArgs* peer)
+void sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer)
 {
   simgrid::kernel::routing::VivaldiZone* as = dynamic_cast<simgrid::kernel::routing::VivaldiZone*>(current_routing);
   xbt_assert(as, "<peer> tag can only be used in Vivaldi netzones.");
@@ -566,7 +563,7 @@ static void surf_config_models_setup()
  *
  * @param zone the parameters defining the Zone to build.
  */
-simgrid::kernel::routing::NetZoneImpl* sg_platf_new_Zone_begin(simgrid::kernel::routing::ZoneCreationArgs* zone)
+simgrid::kernel::routing::NetZoneImpl* sg_platf_new_Zone_begin(const simgrid::kernel::routing::ZoneCreationArgs* zone)
 {
   if (not surf_parse_models_setup_already_called) {
     simgrid::s4u::Engine::on_platform_creation();
@@ -642,7 +639,7 @@ simgrid::kernel::routing::NetZoneImpl* sg_platf_new_Zone_begin(simgrid::kernel::
   return new_zone;
 }
 
-void sg_platf_new_Zone_set_properties(std::unordered_map<std::string, std::string>* props)
+void sg_platf_new_Zone_set_properties(const std::unordered_map<std::string, std::string>* props)
 {
   xbt_assert(current_routing, "Cannot set properties of the current Zone: none under construction");
 
@@ -665,15 +662,15 @@ void sg_platf_new_Zone_seal()
 }
 
 /** @brief Add a link connecting a host to the rest of its AS (which must be cluster or vivaldi) */
-void sg_platf_new_hostlink(simgrid::kernel::routing::HostLinkCreationArgs* hostlink)
+void sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* hostlink)
 {
   simgrid::kernel::routing::NetPoint* netpoint = simgrid::s4u::Host::by_name(hostlink->id)->get_netpoint();
   xbt_assert(netpoint, "Host '%s' not found!", hostlink->id.c_str());
   xbt_assert(dynamic_cast<simgrid::kernel::routing::ClusterZone*>(current_routing),
              "Only hosts from Cluster and Vivaldi ASes can get a host_link.");
 
-  simgrid::s4u::Link* linkUp   = simgrid::s4u::Link::by_name_or_null(hostlink->link_up);
-  simgrid::s4u::Link* linkDown = simgrid::s4u::Link::by_name_or_null(hostlink->link_down);
+  const simgrid::s4u::Link* linkUp   = simgrid::s4u::Link::by_name_or_null(hostlink->link_up);
+  const simgrid::s4u::Link* linkDown = simgrid::s4u::Link::by_name_or_null(hostlink->link_down);
 
   xbt_assert(linkUp, "Link '%s' not found!", hostlink->link_up.c_str());
   xbt_assert(linkDown, "Link '%s' not found!", hostlink->link_down.c_str());
index 90a77b4..50439d8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -21,7 +21,7 @@ extern std::map<std::string, simgrid::kernel::resource::StorageType*> storage_ty
 void check_disk_attachment()
 {
   for (auto const& s : simgrid::s4u::Engine::get_instance()->get_all_storages()) {
-    simgrid::kernel::routing::NetPoint* host_elm =
+    const simgrid::kernel::routing::NetPoint* host_elm =
         simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(s->get_impl()->get_host());
     if (not host_elm)
       surf_parse_error(std::string("Unable to attach storage ") + s->get_cname() + ": host " +
@@ -52,7 +52,7 @@ StorageN11Model::StorageN11Model()
 StorageImpl* StorageN11Model::createStorage(const std::string& id, const std::string& type_id,
                                             const std::string& content_name, const std::string& attach)
 {
-  StorageType* storage_type = storage_types.at(type_id);
+  const StorageType* storage_type = storage_types.at(type_id);
 
   double Bread =
       surf_parse_get_bandwidth(storage_type->model_properties->at("Bread").c_str(), "property Bread, storage", type_id);
@@ -127,10 +127,10 @@ StorageN11Action::StorageN11Action(Model* model, double cost, bool failed, Stora
   model->get_maxmin_system()->expand(storage->get_constraint(), get_variable(), 1.0);
   switch(type) {
     case s4u::Io::OpType::READ:
-      model->get_maxmin_system()->expand(storage->constraint_read_, get_variable(), 1.0);
+      model->get_maxmin_system()->expand(storage->get_read_constraint(), get_variable(), 1.0);
       break;
     case s4u::Io::OpType::WRITE:
-      model->get_maxmin_system()->expand(storage->constraint_write_, get_variable(), 1.0);
+      model->get_maxmin_system()->expand(storage->get_write_constraint(), get_variable(), 1.0);
       break;
     default:
       THROW_UNIMPLEMENTED;
index fdd2abf..cad3774 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index f111cc2..7c98371 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 05ea270..1e2286c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -48,7 +48,7 @@ static void XBT_ATTRIB_DESTRUCTOR(800) simgrid_free_plugin_description()
 XBT_PUBLIC void simgrid_add_plugin_description(const char* name, const char* description, void_f_void_t init_fun)
 {
   if (not surf_plugin_description)
-    surf_plugin_description = new std::vector<surf_model_description_t>;
+    surf_plugin_description = new std::vector<surf_model_description_t>();
   surf_plugin_description->emplace_back(surf_model_description_t{name, description, init_fun});
 }
 
@@ -231,7 +231,7 @@ void surf_exit()
 {
   simgrid::s4u::Engine::shutdown();
   for (auto const& e : storage_types) {
-    simgrid::kernel::resource::StorageType* stype = e.second;
+    const simgrid::kernel::resource::StorageType* stype = e.second;
     delete stype->properties;
     delete stype->model_properties;
     delete stype;
index ef68675..465ad06 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -8,6 +8,7 @@
 
 #include "src/internal_config.h"
 #include "src/surf/surf_private.hpp"
+#include "xbt/function_types.h"
 
 #include <cmath>
 #include <set>
index 3b4aa08..630a4f8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 6c8b9d0..070894d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 6133bea..71a6398 100644 (file)
@@ -1,6 +1,6 @@
 /* platf_private.h - Interface to the SimGrid platforms which visibility should be limited to this directory */
 
-/* Copyright (c) 2004-2019. The SimGrid Team.
+/* Copyright (c) 2004-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -187,23 +187,33 @@ public:
   std::string id;
   int routing;
 };
-}}}
+
+extern XBT_PRIVATE xbt::signal<void(ClusterCreationArgs const&)> on_cluster_creation;
+
+} // namespace routing
+} // namespace kernel
+} // namespace simgrid
 
 /********** Routing **********/
 void routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl* bb);
 /*** END of the parsing cruft ***/
 
 XBT_PUBLIC simgrid::kernel::routing::NetZoneImpl*
-sg_platf_new_Zone_begin(simgrid::kernel::routing::ZoneCreationArgs* zone);         // Begin description of new Zone
-XBT_PUBLIC void sg_platf_new_Zone_set_properties(std::unordered_map<std::string, std::string>* props);
+sg_platf_new_Zone_begin(const simgrid::kernel::routing::ZoneCreationArgs* zone); // Begin description of new Zone
+XBT_PUBLIC void sg_platf_new_Zone_set_properties(const std::unordered_map<std::string, std::string>* props);
 XBT_PUBLIC void sg_platf_new_Zone_seal();                                          // That Zone is fully described
 
-XBT_PUBLIC void sg_platf_new_host(simgrid::kernel::routing::HostCreationArgs* host);      // Add a host      to the current Zone
-XBT_PUBLIC void sg_platf_new_hostlink(simgrid::kernel::routing::HostLinkCreationArgs* h);     // Add a host_link to the current Zone
-XBT_PUBLIC void sg_platf_new_link(simgrid::kernel::routing::LinkCreationArgs* link);          // Add a link      to the current Zone
-XBT_PUBLIC void sg_platf_new_peer(simgrid::kernel::routing::PeerCreationArgs* peer);          // Add a peer      to the current Zone
+XBT_PUBLIC void
+sg_platf_new_host(const simgrid::kernel::routing::HostCreationArgs* host); // Add a host to the current Zone
+XBT_PUBLIC void
+sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* h); // Add a host_link to the current Zone
+XBT_PUBLIC void
+sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link); // Add a link to the current Zone
+XBT_PUBLIC void
+sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer); // Add a peer to the current Zone
 XBT_PUBLIC void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* clust);   // Add a cluster   to the current Zone
-XBT_PUBLIC void sg_platf_new_cabinet(simgrid::kernel::routing::CabinetCreationArgs* cabinet); // Add a cabinet   to the current Zone
+XBT_PUBLIC void
+sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet); // Add a cabinet to the current Zone
 XBT_PUBLIC simgrid::kernel::routing::NetPoint* // Add a router    to the current Zone
     sg_platf_new_router(const std::string&, const char* coords);
 
@@ -213,10 +223,10 @@ XBT_PUBLIC void sg_platf_new_bypassRoute(simgrid::kernel::routing::RouteCreation
 XBT_PUBLIC void sg_platf_new_trace(simgrid::kernel::routing::ProfileCreationArgs* trace);
 
 XBT_PUBLIC simgrid::kernel::resource::DiskImpl*
-sg_platf_new_disk(simgrid::kernel::routing::DiskCreationArgs* disk); // Add a disk to the current host
+sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk); // Add a disk to the current host
 
 XBT_PUBLIC void sg_platf_new_storage(simgrid::kernel::routing::StorageCreationArgs* storage); // Add a storage to the current Zone
-XBT_PUBLIC void sg_platf_new_storage_type(simgrid::kernel::routing::StorageTypeCreationArgs* storage_type);
+XBT_PUBLIC void sg_platf_new_storage_type(const simgrid::kernel::routing::StorageTypeCreationArgs* storage_type);
 XBT_PUBLIC void sg_platf_new_mount(simgrid::kernel::routing::MountCreationArgs* mount);
 
 XBT_PUBLIC void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor);
@@ -236,11 +246,4 @@ XBT_PUBLIC int surf_parse_get_debug();
 XBT_PUBLIC void surf_parse_set_debug(int bdebug);
 XBT_PUBLIC int surf_parse_lex_destroy();
 
-namespace simgrid {
-namespace surf {
-
-extern XBT_PRIVATE simgrid::xbt::signal<void(kernel::routing::ClusterCreationArgs const&)> on_cluster;
-}
-}
-
 #endif                          /* SG_PLATF_H */
index 7800a14..1a0e0ad 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -62,7 +62,7 @@ void parse_platform_file(const std::string& file)
 {
   const char* cfile = file.c_str();
   int len           = strlen(cfile);
-  int is_lua        = len > 3 && file[len - 3] == 'l' && file[len - 2] == 'u' && file[len - 1] == 'a';
+  bool is_lua       = len > 3 && file[len - 3] == 'l' && file[len - 2] == 'u' && file[len - 1] == 'a';
 
   sg_platf_init();
 
index 2cd4006..3cf6edf 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -55,7 +55,7 @@ void surf_parse_assert_netpoint(const std::string& hostname, const std::string&
   std::vector<simgrid::kernel::routing::NetPoint*> netpoints =
       simgrid::s4u::Engine::get_instance()->get_all_netpoints();
   std::sort(netpoints.begin(), netpoints.end(),
-            [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) {
+            [](const simgrid::kernel::routing::NetPoint* a, const simgrid::kernel::routing::NetPoint* b) {
               return a->get_name() < b->get_name();
             });
   bool first = true;
index e8bc29b..6f3cf12 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 8b62106..92f2ff8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index e732b9c..1d6be9f 100644 (file)
@@ -1,6 +1,6 @@
 /* automaton - representation of büchi automaton */
 
-/* Copyright (c) 2011-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2011-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -28,7 +28,8 @@ xbt_automaton_t xbt_automaton_new(void){
   return automaton;
 }
 
-xbt_automaton_state_t xbt_automaton_state_new(xbt_automaton_t a, int type, char* id){
+xbt_automaton_state_t xbt_automaton_state_new(const_xbt_automaton_t a, int type, const char* id)
+{
   xbt_automaton_state_t state = xbt_new0(struct xbt_automaton_state, 1);
   state->type = type;
   state->id = xbt_strdup(id);
@@ -38,7 +39,9 @@ xbt_automaton_state_t xbt_automaton_state_new(xbt_automaton_t a, int type, char*
   return state;
 }
 
-xbt_automaton_transition_t xbt_automaton_transition_new(xbt_automaton_t a, xbt_automaton_state_t src, xbt_automaton_state_t dst, xbt_automaton_exp_label_t label){
+xbt_automaton_transition_t xbt_automaton_transition_new(const_xbt_automaton_t a, xbt_automaton_state_t src,
+                                                        xbt_automaton_state_t dst, xbt_automaton_exp_label_t label)
+{
   xbt_automaton_transition_t transition = xbt_new0(struct xbt_automaton_transition, 1);
   if(src != NULL){
     xbt_dynar_push(src->out, &transition);
@@ -81,7 +84,7 @@ xbt_automaton_exp_label_t xbt_automaton_exp_label_new_not(xbt_automaton_exp_labe
   return label;
 }
 
-xbt_automaton_exp_label_t xbt_automaton_exp_label_new_predicat(char* p)
+xbt_automaton_exp_label_t xbt_automaton_exp_label_new_predicat(const char* p)
 {
   xbt_automaton_exp_label_t label = xbt_new0(struct xbt_automaton_exp_label, 1);
   label->type                     = AUT_PREDICAT;
@@ -96,16 +99,19 @@ xbt_automaton_exp_label_t xbt_automaton_exp_label_new_one(void)
   return label;
 }
 
-xbt_dynar_t xbt_automaton_get_states(xbt_automaton_t a){
+xbt_dynar_t xbt_automaton_get_states(const_xbt_automaton_t a)
+{
   return a->states;
 }
 
-xbt_dynar_t xbt_automaton_get_transitions(xbt_automaton_t a){
+xbt_dynar_t xbt_automaton_get_transitions(const_xbt_automaton_t a)
+{
   return a->transitions;
 }
 
-xbt_automaton_transition_t xbt_automaton_get_transition(XBT_ATTRIB_UNUSED xbt_automaton_t a, xbt_automaton_state_t src,
-                                                        xbt_automaton_state_t dst)
+xbt_automaton_transition_t xbt_automaton_get_transition(XBT_ATTRIB_UNUSED const_xbt_automaton_t a,
+                                                        const_xbt_automaton_state_t src,
+                                                        const_xbt_automaton_state_t dst)
 {
   xbt_automaton_transition_t transition;
   unsigned int cursor;
@@ -116,11 +122,13 @@ xbt_automaton_transition_t xbt_automaton_get_transition(XBT_ATTRIB_UNUSED xbt_au
   return NULL;
 }
 
-xbt_automaton_state_t xbt_automaton_transition_get_source(xbt_automaton_transition_t t){
+xbt_automaton_state_t xbt_automaton_transition_get_source(const_xbt_automaton_transition_t t)
+{
   return t->src;
 }
 
-xbt_automaton_state_t xbt_automaton_transition_get_destination(xbt_automaton_transition_t t){
+xbt_automaton_state_t xbt_automaton_transition_get_destination(const_xbt_automaton_transition_t t)
+{
   return t->dst;
 }
 
@@ -134,15 +142,18 @@ void xbt_automaton_transition_set_destination(xbt_automaton_transition_t t, xbt_
   xbt_dynar_push(dst->in,&t);
 }
 
-xbt_dynar_t xbt_automaton_state_get_out_transitions(xbt_automaton_state_t s){
+xbt_dynar_t xbt_automaton_state_get_out_transitions(const_xbt_automaton_state_t s)
+{
   return s->out;
 }
 
-xbt_dynar_t xbt_automaton_state_get_in_transitions(xbt_automaton_state_t s){
+xbt_dynar_t xbt_automaton_state_get_in_transitions(const_xbt_automaton_state_t s)
+{
   return s->in;
 }
 
-xbt_automaton_state_t xbt_automaton_state_exists(xbt_automaton_t a, char *id){
+xbt_automaton_state_t xbt_automaton_state_exists(const_xbt_automaton_t a, const char* id)
+{
   xbt_automaton_state_t state = NULL;
   unsigned int cursor = 0;
   xbt_dynar_foreach(a->states, cursor, state){
@@ -152,7 +163,8 @@ xbt_automaton_state_t xbt_automaton_state_exists(xbt_automaton_t a, char *id){
   return NULL;
 }
 
-void xbt_automaton_display(xbt_automaton_t a){
+void xbt_automaton_display(const_xbt_automaton_t a)
+{
   unsigned int cursor;
   xbt_automaton_state_t state = NULL;
 
@@ -173,7 +185,8 @@ void xbt_automaton_display(xbt_automaton_t a){
   }
 }
 
-void xbt_automaton_exp_label_display(xbt_automaton_exp_label_t label){
+void xbt_automaton_exp_label_display(const_xbt_automaton_exp_label_t label)
+{
   printf("(");
   switch(label->type){
     case 0:
@@ -202,7 +215,8 @@ void xbt_automaton_exp_label_display(xbt_automaton_exp_label_t label){
   printf(")");
 }
 
-xbt_automaton_state_t xbt_automaton_get_current_state(xbt_automaton_t a){
+xbt_automaton_state_t xbt_automaton_get_current_state(const_xbt_automaton_t a)
+{
   return a->current_state;
 }
 
@@ -211,7 +225,7 @@ static int call_simple_function(int function(void) )
   return function();
 }
 
-xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new(xbt_automaton_t a, const char* id,
+xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new(const_xbt_automaton_t a, const char* id,
                                                                             int (*fct)(void))
 {
   xbt_automaton_propositional_symbol_t prop_symb = xbt_new0(struct xbt_automaton_propositional_symbol, 1);
@@ -223,7 +237,7 @@ xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new(xbt_
   return prop_symb;
 }
 
-XBT_PUBLIC xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new_pointer(xbt_automaton_t a,
+XBT_PUBLIC xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new_pointer(const_xbt_automaton_t a,
                                                                                                const char* id,
                                                                                                int* value)
 {
@@ -237,7 +251,7 @@ XBT_PUBLIC xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symb
 }
 
 XBT_PUBLIC xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symbol_new_callback(
-    xbt_automaton_t a, const char* id, xbt_automaton_propositional_symbol_callback_type callback, void* data,
+    const_xbt_automaton_t a, const char* id, xbt_automaton_propositional_symbol_callback_type callback, void* data,
     xbt_automaton_propositional_symbol_free_function_type free_function)
 {
   xbt_automaton_propositional_symbol_t prop_symb = xbt_new0(struct xbt_automaton_propositional_symbol, 1);
@@ -249,7 +263,7 @@ XBT_PUBLIC xbt_automaton_propositional_symbol_t xbt_automaton_propositional_symb
   return prop_symb;
 }
 
-XBT_PUBLIC int xbt_automaton_propositional_symbol_evaluate(xbt_automaton_propositional_symbol_t symbol)
+XBT_PUBLIC int xbt_automaton_propositional_symbol_evaluate(const_xbt_automaton_propositional_symbol_t symbol)
 {
   if (symbol->callback)
     return (symbol->callback)(symbol->data);
@@ -258,52 +272,35 @@ XBT_PUBLIC int xbt_automaton_propositional_symbol_evaluate(xbt_automaton_proposi
 }
 
 XBT_PUBLIC xbt_automaton_propositional_symbol_callback_type
-xbt_automaton_propositional_symbol_get_callback(xbt_automaton_propositional_symbol_t symbol)
+xbt_automaton_propositional_symbol_get_callback(const_xbt_automaton_propositional_symbol_t symbol)
 {
   return symbol->callback;
 }
 
-XBT_PUBLIC void* xbt_automaton_propositional_symbol_get_data(xbt_automaton_propositional_symbol_t symbol)
+XBT_PUBLIC void* xbt_automaton_propositional_symbol_get_data(const_xbt_automaton_propositional_symbol_t symbol)
 {
   return symbol->data;
 }
 
-XBT_PUBLIC const char* xbt_automaton_propositional_symbol_get_name(xbt_automaton_propositional_symbol_t symbol)
+XBT_PUBLIC const char* xbt_automaton_propositional_symbol_get_name(const_xbt_automaton_propositional_symbol_t symbol)
 {
   return symbol->pred;
 }
 
-int xbt_automaton_state_compare(xbt_automaton_state_t s1, xbt_automaton_state_t s2){
-
+int xbt_automaton_state_compare(const_xbt_automaton_state_t s1, const_xbt_automaton_state_t s2)
+{
   /* single id for each state, id and type sufficient for comparison*/
-
-  if(strcmp(s1->id, s2->id))
-    return 1;
-
-  if(s1->type != s2->type)
-    return 1;
-
-  return 0;
-
+  return (strcmp(s1->id, s2->id) != 0) || (s1->type != s2->type);
 }
 
-int xbt_automaton_transition_compare(const void *t1, const void *t2){
-
-  if(xbt_automaton_state_compare(((xbt_automaton_transition_t)t1)->src, ((xbt_automaton_transition_t)t2)->src))
-    return 1;
-
-  if(xbt_automaton_state_compare(((xbt_automaton_transition_t)t1)->dst, ((xbt_automaton_transition_t)t2)->dst))
-    return 1;
-
-  if(xbt_automaton_exp_label_compare(((xbt_automaton_transition_t)t1)->label,((xbt_automaton_transition_t)t2)->label))
-    return 1;
-
-  return 0;
-
+int xbt_automaton_transition_compare(const_xbt_automaton_transition_t t1, const_xbt_automaton_transition_t t2)
+{
+  return xbt_automaton_state_compare(t1->src, t2->src) || xbt_automaton_state_compare(t1->dst, t2->dst) ||
+         xbt_automaton_exp_label_compare(t1->label, t2->label);
 }
 
-int xbt_automaton_exp_label_compare(xbt_automaton_exp_label_t l1, xbt_automaton_exp_label_t l2){
-
+int xbt_automaton_exp_label_compare(const_xbt_automaton_exp_label_t l1, const_xbt_automaton_exp_label_t l2)
+{
   if(l1->type != l2->type)
     return 1;
 
@@ -311,16 +308,14 @@ int xbt_automaton_exp_label_compare(xbt_automaton_exp_label_t l1, xbt_automaton_
   switch(l1->type){
   case 0 : // OR
   case 1 : // AND
-    if(xbt_automaton_exp_label_compare(l1->u.or_and.left_exp, l2->u.or_and.left_exp))
-      res = 1;
-    else
-      res = xbt_automaton_exp_label_compare(l1->u.or_and.right_exp, l2->u.or_and.right_exp);
+    res = xbt_automaton_exp_label_compare(l1->u.or_and.left_exp, l2->u.or_and.left_exp) ||
+          xbt_automaton_exp_label_compare(l1->u.or_and.right_exp, l2->u.or_and.right_exp);
     break;
   case 2 : // NOT
     res = xbt_automaton_exp_label_compare(l1->u.exp_not, l2->u.exp_not);
     break;
   case 3 : // predicat
-    res = strcmp(l1->u.predicat, l2->u.predicat);
+    res = strcmp(l1->u.predicat, l2->u.predicat) != 0;
     break;
   case 4 : // 1
     res = 0;
@@ -332,12 +327,13 @@ int xbt_automaton_exp_label_compare(xbt_automaton_exp_label_t l1, xbt_automaton_
   return res;
 }
 
-int xbt_automaton_propositional_symbols_compare_value(xbt_dynar_t s1, xbt_dynar_t s2){
+int xbt_automaton_propositional_symbols_compare_value(const_xbt_dynar_t s1, const_xbt_dynar_t s2)
+{
   unsigned int nb_elem = xbt_dynar_length(s1);
 
   for (unsigned int cursor = 0; cursor < nb_elem; cursor++) {
-    int* iptr1 = xbt_dynar_get_ptr(s1, cursor);
-    int* iptr2 = xbt_dynar_get_ptr(s2, cursor);
+    const int* iptr1 = xbt_dynar_get_ptr(s1, cursor);
+    const int* iptr2 = xbt_dynar_get_ptr(s2, cursor);
     if(*iptr1 != *iptr2)
       return 1;
   }
index 98e6db8..7e8339a 100644 (file)
@@ -744,7 +744,7 @@ int yy_flex_debug = 0;
 #define YY_RESTORE_YY_MORE_OFFSET
 char *yytext;
 #line 1 "parserPromela.lex"
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index bb18110..8f4fb02 100644 (file)
@@ -1,6 +1,6 @@
 /* methods for implementation of automaton from promela description */
 
-/* Copyright (c) 2011-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2011-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 static xbt_automaton_t parsed_automaton;
 char* state_id_src;
 
-static void new_state(char* id, int src){
+static void new_state(const char* id, int src)
+{
   char* saveptr = NULL; // for strtok_r()
   char* id_copy = xbt_strdup(id);
-  char* first_part = strtok_r(id_copy, "_", &saveptr);
+  const char* first_part = strtok_r(id_copy, "_", &saveptr);
   int type = 0 ; // -1=initial state; 0=intermediate state; 1=final state
 
   if(strcmp(first_part,"accept")==0){
     type = 1;
   }else{
-    char* second_part = strtok_r(NULL, "_", &saveptr);
+    const char* second_part = strtok_r(NULL, "_", &saveptr);
     if(strcmp(second_part,"init")==0){
       type = -1;
     }
@@ -49,7 +50,7 @@ static void new_state(char* id, int src){
   }
 }
 
-static void new_transition(char* id, xbt_automaton_exp_label_t label)
+static void new_transition(const char* id, xbt_automaton_exp_label_t label)
 {
   new_state(id, 0);
   xbt_automaton_state_t state_dst = xbt_automaton_state_exists(parsed_automaton, id);
index 23c9ec2..5708b6c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 0024345..a4b8541 100644 (file)
@@ -86,8 +86,8 @@
 
 void yyerror(const char *s);
 
-static void new_state(char* id, int src);
-static void new_transition(char* id, xbt_automaton_exp_label_t label);
+static void new_state(const char* id, int src);
+static void new_transition(const char* id, xbt_automaton_exp_label_t label);
 
 
 #line 94 "parserPromela.tab.cacc"
index e41de7e..4f6e4de 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -15,8 +15,8 @@
 
 void yyerror(const char *s);
 
-static void new_state(char* id, int src);
-static void new_transition(char* id, xbt_automaton_exp_label_t label);
+static void new_state(const char* id, int src);
+static void new_transition(const char* id, xbt_automaton_exp_label_t label);
 
 %}
 
index 17f5e9c..349ed11 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2005-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2005-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 #include <xbt/sysdep.h>
 #include <xbt/virtu.h>
 
-#include <cstddef>
+#include <cstdio>
 #include <cstdlib>
-#include <cstring>
-#include <fstream>
 #include <sstream>
-#include <sys/stat.h>
-#include <vector>
-
-#include <boost/algorithm/string.hpp>
 
 // Try to detect and use the C++ itanium ABI for name demangling:
 #ifdef __GXX_ABI_VERSION
@@ -57,95 +51,32 @@ std::unique_ptr<char, std::function<void(char*)>> demangle(const char* name)
 }
 
 class BacktraceImpl {
-  short refcount_ = 1;
-
+#if HAVE_BOOST_STACKTRACE_BACKTRACE || HAVE_BOOST_STACKTRACE_ADDR2LINE
+  const boost::stacktrace::stacktrace st = boost::stacktrace::stacktrace();
+#else
+  const char st[1] = ""; // fallback value
+#endif
 public:
-  void ref() { refcount_++; }
-  bool unref()
+  std::string resolve() const
   {
-    refcount_--;
-    if (refcount_ == 0) {
-      delete this;
-      return true;
-    } else {
-      return false;
-    }
+    std::stringstream ss;
+    ss << st;
+    return ss.str();
   }
-#if HAVE_BOOST_STACKTRACE_BACKTRACE || HAVE_BOOST_STACKTRACE_ADDR2LINE
-  boost::stacktrace::stacktrace st;
-#endif
 };
 
-Backtrace::Backtrace()
-{
-#if HAVE_BOOST_STACKTRACE_BACKTRACE || HAVE_BOOST_STACKTRACE_ADDR2LINE
-  impl_     = new BacktraceImpl();
-  impl_->st = boost::stacktrace::stacktrace();
-#endif
-}
-Backtrace::Backtrace(const Backtrace& bt)
-{
-  impl_ = bt.impl_;
-  if (impl_)
-    impl_->ref();
-}
-
-Backtrace::Backtrace(Backtrace&& bt)
-{
-  impl_    = bt.impl_;
-  bt.impl_ = nullptr;
-}
-
-Backtrace& Backtrace::operator=(const Backtrace& rhs)
-{
-  if (this != &rhs) {
-    if (impl_)
-      impl_->unref();
-    impl_ = rhs.impl_;
-    if (impl_)
-      impl_->ref();
-  }
-  return *this;
-}
-
-Backtrace& Backtrace::operator=(Backtrace&& rhs)
-{
-  if (this != &rhs) {
-    if (impl_)
-      impl_->unref();
-    impl_     = rhs.impl_;
-    rhs.impl_ = nullptr;
-  }
-  return *this;
-}
+Backtrace::Backtrace() : impl_(std::make_shared<BacktraceImpl>()) {}
 
-Backtrace::~Backtrace()
+std::string Backtrace::resolve() const
 {
-  if (impl_)
-    impl_->unref();
-}
-
-std::string const Backtrace::resolve() const
-{
-  std::string result("");
-
-#if HAVE_BOOST_STACKTRACE_BACKTRACE || HAVE_BOOST_STACKTRACE_ADDR2LINE
-  std::stringstream ss;
-  ss << impl_->st;
-  result.append(ss.str());
-#endif
-  return result;
+  return impl_->resolve();
 }
 
 void Backtrace::display() const
 {
   std::string backtrace = resolve();
-  if (backtrace.empty()) {
-    fprintf(stderr, "(backtrace not set -- did you install Boost.Stacktrace?)\n");
-    return;
-  }
-  fprintf(stderr, "Backtrace (displayed in actor %s):\n", xbt_procname());
-  std::fprintf(stderr, "%s\n", backtrace.c_str());
+  std::fprintf(stderr, "Backtrace (displayed in actor %s):\n%s\n", xbt_procname(),
+               backtrace.empty() ? "(backtrace not set -- did you install Boost.Stacktrace?)" : backtrace.c_str());
 }
 
 } // namespace xbt
index 60d5f21..b689db3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.     */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -141,14 +141,7 @@ private:
   bool isdefault = true;
 
 public:
-  /* Callback */
-  xbt_cfg_cb_t old_callback = nullptr;
-
   ConfigurationElement(const std::string& key, const std::string& desc) : key(key), desc(desc) {}
-  ConfigurationElement(const std::string& key, const std::string& desc, xbt_cfg_cb_t cb)
-      : key(key), desc(desc), old_callback(cb)
-  {
-  }
 
   virtual ~ConfigurationElement() = default;
 
@@ -188,9 +181,6 @@ public:
   TypedConfigurationElement(const std::string& key, const std::string& desc, T value = T())
       : ConfigurationElement(key, desc), content(std::move(value))
   {}
-  TypedConfigurationElement(const std::string& key, const std::string& desc, T value, xbt_cfg_cb_t cb)
-      : ConfigurationElement(key, desc, cb), content(std::move(value))
-  {}
   TypedConfigurationElement(const std::string& key, const std::string& desc, T value, std::function<void(T&)> callback)
       : ConfigurationElement(key, desc), content(std::move(value)), callback(std::move(callback))
   {}
@@ -202,8 +192,6 @@ public:
 
   void update()
   {
-    if (old_callback)
-      this->old_callback(get_key().c_str());
     if (this->callback)
       this->callback(this->content);
   }
index f870f33..e9c2856 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.     */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 44361dc..5184ea2 100644 (file)
@@ -1,6 +1,6 @@
 /* dict - a generic dictionary, variation over hash table                   */
 
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -33,8 +33,7 @@ constexpr int MAX_FILL_PERCENT = 80;
  */
 xbt_dict_t xbt_dict_new_homogeneous(void_f_pvoid_t free_ctn)
 {
-  if (dict_elm_mallocator == nullptr)
-    xbt_dict_preinit();
+  xbt_dict_preinit();
 
   xbt_dict_t dict;
 
@@ -79,7 +78,7 @@ void xbt_dict_free(xbt_dict_t * dict)
 }
 
 /** Returns the amount of elements in the dict */
-unsigned int xbt_dict_size(xbt_dict_t dict)
+unsigned int xbt_dict_size(const_xbt_dict_t dict)
 {
   return (dict != nullptr ? static_cast<unsigned int>(dict->count) : static_cast<unsigned int>(0));
 }
@@ -192,29 +191,12 @@ void xbt_dict_set(xbt_dict_t dict, const char* key, void* data)
  * @param key_len the size of the @a key
  * @return the data that we are looking for
  *
- * Search the given @a key. Throws std::out_of_range when not found.
+ * Search the given @a key. Returns nullptr when not found.
  */
-void *xbt_dict_get_ext(xbt_dict_t dict, const char *key, int key_len)
+void* xbt_dict_get_or_null_ext(const_xbt_dict_t dict, const char* key, int key_len)
 {
   unsigned int hash_code = xbt_str_hash_ext(key, key_len);
-  xbt_dictelm_t current = dict->table[hash_code & dict->table_size];
-
-  while (current != nullptr && (hash_code != current->hash_code || key_len != current->key_len
-          || memcmp(key, current->key, key_len))) {
-    current = current->next;
-  }
-
-  if (current == nullptr)
-    throw std::out_of_range(simgrid::xbt::string_printf("key %.*s not found", key_len, key));
-
-  return current->content;
-}
-
-/** @brief like xbt_dict_get_ext(), but returning nullptr when not found */
-void *xbt_dict_get_or_null_ext(xbt_dict_t dict, const char *key, int key_len)
-{
-  unsigned int hash_code = xbt_str_hash_ext(key, key_len);
-  xbt_dictelm_t current = dict->table[hash_code & dict->table_size];
+  const s_xbt_dictelm* current = dict->table[hash_code & dict->table_size];
 
   while (current != nullptr && (hash_code != current->hash_code || key_len != current->key_len
           || memcmp(key, current->key, key_len))) {
@@ -227,24 +209,6 @@ void *xbt_dict_get_or_null_ext(xbt_dict_t dict, const char *key, int key_len)
   return current->content;
 }
 
-/**
- * @brief retrieve the key associated to that object. Warning, that's a linear search
- *
- * Returns nullptr if the object cannot be found
- */
-char *xbt_dict_get_key(xbt_dict_t dict, const void *data)
-{
-  for (int i = 0; i <= dict->table_size; i++) {
-    xbt_dictelm_t current = dict->table[i];
-    while (current != nullptr) {
-      if (current->content == data)
-        return current->key;
-      current = current->next;
-    }
-  }
-  return nullptr;
-}
-
 /**
  * @brief Retrieve data from the dict (null-terminated key)
  *
@@ -252,12 +216,16 @@ char *xbt_dict_get_key(xbt_dict_t dict, const void *data)
  * @param key the key to find data
  * @return the data that we are looking for
  *
- * Search the given @a key. Throws std::out_of_range when not found.
- * Check xbt_dict_get_or_null() for a version returning nullptr without exception when not found.
+ * Search the given @a key. Returns nullptr when not found.
  */
-void *xbt_dict_get(xbt_dict_t dict, const char *key)
+void* xbt_dict_get_or_null(const_xbt_dict_t dict, const char* key)
 {
-  return xbt_dict_get_elm(dict, key)->content;
+  const s_xbt_dictelm* current = xbt_dict_get_elm_or_null(dict, key);
+
+  if (current == nullptr)
+    return nullptr;
+
+  return current->content;
 }
 
 /**
@@ -267,36 +235,9 @@ void *xbt_dict_get(xbt_dict_t dict, const char *key)
  * @param key the key to find data
  * @return the s_xbt_dictelm_t that we are looking for
  *
- * Search the given @a key. Throws std::out_of_range when not found.
- * Check xbt_dict_get_or_null() for a version returning nullptr without exception when not found.
- */
-xbt_dictelm_t xbt_dict_get_elm(xbt_dict_t dict, const char *key)
-{
-  xbt_dictelm_t current = xbt_dict_get_elm_or_null(dict, key);
-
-  if (current == nullptr)
-    throw std::out_of_range(simgrid::xbt::string_printf("key %s not found", key));
-
-  return current;
-}
-
-/**
- * @brief like xbt_dict_get(), but returning nullptr when not found
+ * Search the given @a key. Returns nullptr when not found.
  */
-void *xbt_dict_get_or_null(xbt_dict_t dict, const char *key)
-{
-  xbt_dictelm_t current = xbt_dict_get_elm_or_null(dict, key);
-
-  if (current == nullptr)
-    return nullptr;
-
-  return current->content;
-}
-
-/**
- * @brief like xbt_dict_get_elm(), but returning nullptr when not found
- */
-xbt_dictelm_t xbt_dict_get_elm_or_null(xbt_dict_t dict, const char *key)
+xbt_dictelm_t xbt_dict_get_elm_or_null(const_xbt_dict_t dict, const char* key)
 {
   unsigned int hash_code = xbt_str_hash(key);
   xbt_dictelm_t current = dict->table[hash_code & dict->table_size];
@@ -344,45 +285,11 @@ void xbt_dict_remove_ext(xbt_dict_t dict, const char *key, int key_len)
   dict->count--;
 }
 
-/**
- * @brief Remove data from the dict (null-terminated key)
- *
- * @param dict the dict
- * @param key the key of the data to be removed
- *
- * Remove the entry associated with the given @a key
- */
-void xbt_dict_remove(xbt_dict_t dict, const char *key)
-{
-  xbt_dict_remove_ext(dict, key, strlen(key));
-}
-
-/** @brief Remove all data from the dict */
-void xbt_dict_reset(xbt_dict_t dict)
-{
-  if (dict->count == 0)
-    return;
-
-  for (int i = 0; i <= dict->table_size; i++) {
-    xbt_dictelm_t previous = nullptr;
-    xbt_dictelm_t current = dict->table[i];
-    while (current != nullptr) {
-      previous = current;
-      current = current->next;
-      xbt_dictelm_free(dict, previous);
-    }
-    dict->table[i] = nullptr;
-  }
-
-  dict->count = 0;
-  dict->fill = 0;
-}
-
 /**
  * @brief Return the number of elements in the dict.
  * @param dict a dictionary
  */
-int xbt_dict_length(xbt_dict_t dict)
+int xbt_dict_length(const_xbt_dict_t dict)
 {
   return dict->count;
 }
@@ -390,7 +297,7 @@ int xbt_dict_length(xbt_dict_t dict)
 /**
  * @brief test if the dict is empty or not
  */
-int xbt_dict_is_empty(xbt_dict_t dict)
+int xbt_dict_is_empty(const_xbt_dict_t dict)
 {
   return not dict || (xbt_dict_length(dict) == 0);
 }
index 5ee224a..a514ddb 100644 (file)
@@ -1,6 +1,6 @@
 /* dict_cursor - iterators over dictionaries                               */
 
-/* Copyright (c) 2004-2019. The SimGrid Team.
+/* Copyright (c) 2004-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -22,7 +22,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_dict_cursor, xbt_dict, "To traverse dictiona
 /** @brief Creator
  *  @param dict the dict
  */
-inline xbt_dict_cursor_t xbt_dict_cursor_new(const xbt_dict_t dict)
+inline xbt_dict_cursor_t xbt_dict_cursor_new(const_xbt_dict_t dict)
 {
   xbt_dict_cursor_t res = xbt_new(struct s_xbt_dict_cursor, 1);
   res->dict = dict;
@@ -45,7 +45,7 @@ inline void xbt_dict_cursor_free(xbt_dict_cursor_t * cursor)
 /*
  * Sanity check to see if the head contains something
  */
-static inline void __cursor_not_null(xbt_dict_cursor_t cursor)
+static inline void __cursor_not_null(const_xbt_dict_cursor_t cursor)
 {
   xbt_assert(cursor, "Null cursor");
 }
@@ -70,7 +70,7 @@ inline void xbt_dict_cursor_rewind(xbt_dict_cursor_t cursor)
  * @param      dict   on what to let the cursor iterate
  * @param[out] cursor dest address
  */
-inline void xbt_dict_cursor_first(const xbt_dict_t dict, xbt_dict_cursor_t * cursor)
+inline void xbt_dict_cursor_first(const_xbt_dict_t dict, xbt_dict_cursor_t* cursor)
 {
   XBT_CDEBUG(xbt_dict_cursor, "xbt_dict_cursor_first");
   if (!*cursor) {
@@ -123,7 +123,7 @@ inline void xbt_dict_cursor_step(xbt_dict_cursor_t cursor)
  */
 inline int xbt_dict_cursor_get_or_free(xbt_dict_cursor_t * cursor, char **key, void **data)
 {
-  xbt_dictelm_t current;
+  const struct s_xbt_dictelm* current;
 
   XBT_CDEBUG(xbt_dict_cursor, "xbt_dict_get_or_free");
 
@@ -146,7 +146,7 @@ inline int xbt_dict_cursor_get_or_free(xbt_dict_cursor_t * cursor, char **key, v
  * @param cursor: the cursor
  * @returns the current key
  */
-inline char *xbt_dict_cursor_get_key(xbt_dict_cursor_t cursor)
+inline char* xbt_dict_cursor_get_key(const_xbt_dict_cursor_t cursor)
 {
   __cursor_not_null(cursor);
 
@@ -158,7 +158,7 @@ inline char *xbt_dict_cursor_get_key(xbt_dict_cursor_t cursor)
  * @param cursor the cursor
  * @returns the current data
  */
-inline void *xbt_dict_cursor_get_data(xbt_dict_cursor_t cursor)
+inline void* xbt_dict_cursor_get_data(const_xbt_dict_cursor_t cursor)
 {
   __cursor_not_null(cursor);
 
index 9c5bc3b..e438f3b 100644 (file)
@@ -1,6 +1,6 @@
 /* dict - a generic dictionary, variation over hash table                   */
 
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -25,7 +25,7 @@ xbt_dictelm_t xbt_dictelm_new(const char* key, int key_len, unsigned int hash_co
   return element;
 }
 
-void xbt_dictelm_free(xbt_dict_t dict, xbt_dictelm_t element)
+void xbt_dictelm_free(const_xbt_dict_t dict, xbt_dictelm_t element)
 {
   if (element) {
     char *key = element->key;
@@ -40,7 +40,7 @@ void xbt_dictelm_free(xbt_dict_t dict, xbt_dictelm_t element)
   }
 }
 
-void xbt_dictelm_set_data(xbt_dict_t dict, xbt_dictelm_t element, void* data)
+void xbt_dictelm_set_data(const_xbt_dict_t dict, xbt_dictelm_t element, void* data)
 {
   void_f_pvoid_t free_f = dict->free_f;
   if (free_f && element->content)
index 15a5d69..89ff10d 100644 (file)
@@ -1,7 +1,7 @@
 /* dict_elm - elements of generic dictionaries                             */
 /* This file is not to be loaded from anywhere but dict.cpp                 */
 
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -34,8 +34,8 @@ XBT_PRIVATE void * dict_elm_mallocator_new_f(void);
 
 /*####[ Function prototypes ]################################################*/
 XBT_PRIVATE xbt_dictelm_t xbt_dictelm_new(const char* key, int key_len, unsigned int hash_code, void* content);
-XBT_PRIVATE void xbt_dictelm_free(xbt_dict_t dict, xbt_dictelm_t element);
-XBT_PRIVATE void xbt_dictelm_set_data(xbt_dict_t dict, xbt_dictelm_t element, void* data);
+XBT_PRIVATE void xbt_dictelm_free(const_xbt_dict_t dict, xbt_dictelm_t element);
+XBT_PRIVATE void xbt_dictelm_set_data(const_xbt_dict_t dict, xbt_dictelm_t element, void* data);
 
 SG_END_DECL
 
index c7588cd..ed105ea 100644 (file)
@@ -1,6 +1,6 @@
 /* dict - a generic dictionary, variation over hash table                   */
 
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -49,10 +49,10 @@ static xbt_dict_t new_fixture()
   return head;
 }
 
-static void search_ext(xbt_dict_t head, const char* key, const char* data)
+static void search_ext(const_xbt_dict_t head, const char* key, const char* data)
 {
   INFO("Search " << STR(key));
-  char* found = (char*)xbt_dict_get(head, key);
+  char* found = (char*)xbt_dict_get_or_null(head, key);
   INFO("Found " << STR(found));
   if (data) {
     REQUIRE(found); // data do not match expectations: found null while searching for data
@@ -63,7 +63,7 @@ static void search_ext(xbt_dict_t head, const char* key, const char* data)
   }
 }
 
-static void search(xbt_dict_t head, const char* key)
+static void search(const_xbt_dict_t head, const char* key)
 {
   search_ext(head, key, key);
 }
@@ -71,10 +71,10 @@ static void search(xbt_dict_t head, const char* key)
 static void debugged_remove(xbt_dict_t head, const char* key)
 {
   INFO("Remove '" << STR(key) << "'");
-  xbt_dict_remove(head, key);
+  xbt_dict_remove_ext(head, key, strlen(key));
 }
 
-static void traverse(xbt_dict_t head)
+static void traverse(const_xbt_dict_t head)
 {
   xbt_dict_cursor_t cursor = nullptr;
   char* key;
@@ -87,13 +87,13 @@ static void traverse(xbt_dict_t head)
   }
 }
 
-static void search_not_found(xbt_dict_t head, const char* data)
+static void search_not_found(const_xbt_dict_t head, const char* data)
 {
   INFO("Search " << STR(data) << " (expected not to be found)");
-  REQUIRE_THROWS_AS(xbt_dict_get(head, data), std::out_of_range);
+  REQUIRE(xbt_dict_get_or_null(head, data) == nullptr);
 }
 
-static void count(xbt_dict_t dict, int length)
+static void count(const_xbt_dict_t dict, int length)
 {
   INFO("Count elements (expecting " << length << ")");
   REQUIRE(xbt_dict_length(dict) == length); // Announced length differs
@@ -108,26 +108,7 @@ static void count(xbt_dict_t dict, int length)
   REQUIRE(effective == length); // Effective length differs
 }
 
-static void count_check_get_key(xbt_dict_t dict, int length)
-{
-  xbt_dict_cursor_t cursor;
-  char* key;
-  void* data;
-  int effective = 0;
-
-  INFO("Count elements (expecting " << length << "), and test the getkey function");
-  REQUIRE(xbt_dict_length(dict) == length); // Announced length differs
-
-  xbt_dict_foreach (dict, cursor, key, data) {
-    effective++;
-    char* key2 = xbt_dict_get_key(dict, data);
-    xbt_assert(not strcmp(key, key2), "The data was registered under %s instead of %s as expected", key2, key);
-  }
-
-  REQUIRE(effective == length); // Effective length differs
-}
-
-static int countelems(xbt_dict_t head)
+static int countelems(const_xbt_dict_t head)
 {
   xbt_dict_cursor_t cursor;
   char* key;
@@ -142,7 +123,6 @@ static int countelems(xbt_dict_t head)
 
 TEST_CASE("xbt::dict: dict data container", "dict")
 {
-
   SECTION("Basic usage: change, retrieve and traverse homogeneous dicts")
   {
     INFO("Traversal the null dictionary");
@@ -156,7 +136,7 @@ TEST_CASE("xbt::dict: dict data container", "dict")
 
     INFO("Traverse the full dictionary");
     head = new_fixture();
-    count_check_get_key(head, 7);
+    count(head, 7);
 
     debugged_add_ext(head, "toto", "tutu");
     search_ext(head, "toto", "tutu");
@@ -171,29 +151,29 @@ TEST_CASE("xbt::dict: dict data container", "dict")
 
     /* CHANGING */
     head = new_fixture();
-    count_check_get_key(head, 7);
+    count(head, 7);
     INFO("Change 123 to 'Changed 123'");
     xbt_dict_set(head, "123", xbt_strdup("Changed 123"));
-    count_check_get_key(head, 7);
+    count(head, 7);
 
     INFO("Change 123 back to '123'");
     xbt_dict_set(head, "123", xbt_strdup("123"));
-    count_check_get_key(head, 7);
+    count(head, 7);
 
     INFO("Change 12a to 'Dummy 12a'");
     xbt_dict_set(head, "12a", xbt_strdup("Dummy 12a"));
-    count_check_get_key(head, 7);
+    count(head, 7);
 
     INFO("Change 12a to '12a'");
     xbt_dict_set(head, "12a", xbt_strdup("12a"));
-    count_check_get_key(head, 7);
+    count(head, 7);
 
     INFO("Traverse the resulting dictionary");
     traverse(head);
 
     /* RETRIEVE */
     INFO("Search 123");
-    char* data = (char*)xbt_dict_get(head, "123");
+    const char* data = (char*)xbt_dict_get_or_null(head, "123");
     REQUIRE((data && strcmp("123", data) == 0));
 
     search_not_found(head, "Can't be found");
@@ -253,13 +233,6 @@ TEST_CASE("xbt::dict: dict data container", "dict")
     REQUIRE_THROWS_AS(debugged_remove(head, "12346"), std::out_of_range);
     traverse(head);
 
-    INFO("Free dict, create new fresh one, and then reset the dict");
-    xbt_dict_free(&head);
-    head = new_fixture();
-    xbt_dict_reset(head);
-    count(head, 0);
-    traverse(head);
-
     INFO("Free the dictionary twice");
     xbt_dict_free(&head);
     xbt_dict_free(&head);
@@ -300,7 +273,7 @@ TEST_CASE("xbt::dict: dict data container", "dict")
       INFO("using 1000 elements with " << SIZEOFKEY << " chars long randomized keys.");
       xbt_dict_t head = xbt_dict_new_homogeneous(free);
       for (int j = 0; j < 1000; j++) {
-        char* data = nullptr;
+        const char* data = nullptr;
         char* key  = (char*)xbt_malloc(SIZEOFKEY);
 
         do {
@@ -312,8 +285,8 @@ TEST_CASE("xbt::dict: dict data container", "dict")
         } while (data != nullptr);
 
         xbt_dict_set(head, key, key);
-        data = (char*)xbt_dict_get(head, key);
-        REQUIRE(not strcmp(key, data)); // Retrieved value != Injected value
+        data = (char*)xbt_dict_get_or_null(head, key);
+        REQUIRE((data && not strcmp(key, data))); // Retrieved value != Injected value
 
         count(head, j + 1);
       }
@@ -339,10 +312,10 @@ TEST_CASE("xbt::dict: dict data container", "dict")
     for (int i = 0; i < 20; i++) {
       for (int j = 0; j < NB_ELM; j++) {
         snprintf(key, 10, "%d", j);
-        void* data = xbt_dict_get(head, key);
-        REQUIRE(not strcmp(key, (char*)data)); // with get, key != data
-        data = xbt_dict_get_ext(head, key, strlen(key));
-        REQUIRE(not strcmp(key, (char*)data)); // with get_ext, key != data
+        void* data = xbt_dict_get_or_null(head, key);
+        REQUIRE((data && not strcmp(key, (char*)data))); // with get, key != data
+        data = xbt_dict_get_or_null_ext(head, key, strlen(key));
+        REQUIRE((data && not strcmp(key, (char*)data))); // with get_ext, key != data
       }
     }
     xbt_free(key);
@@ -351,7 +324,7 @@ TEST_CASE("xbt::dict: dict data container", "dict")
     key = (char*)xbt_malloc(10);
     for (int j = 0; j < NB_ELM; j++) {
       snprintf(key, 10, "%d", j);
-      xbt_dict_remove(head, key);
+      xbt_dict_remove_ext(head, key, strlen(key));
     }
     xbt_free(key);
 
@@ -372,8 +345,8 @@ TEST_CASE("xbt::dict: dict data container", "dict")
 
     INFO("Check elements");
     for (int i = 0; i < count; ++i) {
-      xbt_dict_get_ext(dict, (char*)&i, sizeof(i));
-      REQUIRE(xbt_dict_size(dict) == (unsigned)count); // Unexpected value at index i
+      void* data = xbt_dict_get_or_null_ext(dict, (char*)&i, sizeof(i));
+      REQUIRE((intptr_t)data == i); // Unexpected value at index i
     }
 
     INFO("Free the array");
index 5c62e73..31bbef2 100644 (file)
@@ -1,6 +1,6 @@
 /* a generic DYNamic ARray implementation.                                  */
 
-/* Copyright (c) 2004-2019. The SimGrid Team.
+/* Copyright (c) 2004-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -17,7 +17,7 @@
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_dyn, xbt, "Dynamic arrays");
 
-static inline void _sanity_check_dynar(xbt_dynar_t dynar)
+static inline void _sanity_check_dynar(const_xbt_dynar_t dynar)
 {
   xbt_assert(dynar, "dynar is nullptr");
 }
@@ -27,19 +27,15 @@ static inline void _sanity_check_idx(int idx)
   xbt_assert(idx >= 0, "dynar idx(=%d) < 0", idx);
 }
 
-static inline void _check_inbound_idx(xbt_dynar_t dynar, int idx)
+static inline void _check_inbound_idx(const_xbt_dynar_t dynar, int idx)
 {
-  if (idx < 0 || idx >= static_cast<int>(dynar->used)) {
-    throw std::out_of_range(simgrid::xbt::string_printf("dynar is not that long. You asked %d, but it's only %lu long",
-                                                        idx, static_cast<unsigned long>(dynar->used)));
-  }
+  xbt_assert(idx >= 0 && idx < static_cast<int>(dynar->used),
+             "dynar is not that long. You asked %d, but it's only %lu long", idx, dynar->used);
 }
 
-static inline void _check_populated_dynar(xbt_dynar_t dynar)
+static inline void _check_populated_dynar(const_xbt_dynar_t dynar)
 {
-  if (dynar->used == 0) {
-    throw std::out_of_range(simgrid::xbt::string_printf("dynar %p is empty", dynar));
-  }
+  xbt_assert(dynar->used > 0, "dynar %p is empty", dynar);
 }
 
 static inline void _xbt_dynar_resize(xbt_dynar_t dynar, unsigned long new_size)
@@ -50,7 +46,7 @@ static inline void _xbt_dynar_resize(xbt_dynar_t dynar, unsigned long new_size)
   }
 }
 
-static inline void _xbt_dynar_expand(xbt_dynar_t const dynar, const unsigned long nb)
+static inline void _xbt_dynar_expand(xbt_dynar_t dynar, unsigned long nb)
 {
   const unsigned long old_size = dynar->size;
 
@@ -61,7 +57,7 @@ static inline void _xbt_dynar_expand(xbt_dynar_t const dynar, const unsigned lon
   }
 }
 
-static inline void *_xbt_dynar_elm(const xbt_dynar_t dynar, const unsigned long idx)
+static inline void* _xbt_dynar_elm(const_xbt_dynar_t dynar, unsigned long idx)
 {
   char *const data = (char *) dynar->data;
   const unsigned long elmsize = dynar->elmsize;
@@ -69,19 +65,12 @@ static inline void *_xbt_dynar_elm(const xbt_dynar_t dynar, const unsigned long
   return data + idx * elmsize;
 }
 
-static inline void _xbt_dynar_get_elm(void *const dst, const xbt_dynar_t dynar, const unsigned long idx)
+static inline void _xbt_dynar_get_elm(void* dst, const_xbt_dynar_t dynar, unsigned long idx)
 {
-  void *const elm = _xbt_dynar_elm(dynar, idx);
-
+  const void* const elm = _xbt_dynar_elm(dynar, idx);
   memcpy(dst, elm, dynar->elmsize);
 }
 
-void xbt_dynar_dump(xbt_dynar_t dynar)
-{
-  XBT_INFO("Dynar dump: size=%lu; used=%lu; elmsize=%lu; data=%p; free_f=%p",
-        dynar->size, dynar->used, dynar->elmsize, dynar->data, dynar->free_f);
-}
-
 /** @brief Constructor
  *
  * @param elmsize size of each element in the dynar
@@ -90,7 +79,7 @@ void xbt_dynar_dump(xbt_dynar_t dynar)
  * Creates a new dynar. If a free_func is provided, the elements have to be pointer of pointer. That is to say that
  * dynars can contain either base types (int, char, double, etc) or pointer of pointers (struct **).
  */
-xbt_dynar_t xbt_dynar_new(const unsigned long elmsize, void_f_pvoid_t const free_f)
+xbt_dynar_t xbt_dynar_new(const unsigned long elmsize, void_f_pvoid_t free_f)
 {
   xbt_dynar_t dynar = xbt_new0(s_xbt_dynar_t, 1);
 
@@ -103,26 +92,6 @@ xbt_dynar_t xbt_dynar_new(const unsigned long elmsize, void_f_pvoid_t const free
   return dynar;
 }
 
-/** @brief Initialize a dynar structure that was not malloc'ed
- * This can be useful to keep temporary dynars on the stack
- */
-void xbt_dynar_init(xbt_dynar_t dynar, const unsigned long elmsize, void_f_pvoid_t const free_f)
-{
-  dynar->size    = 0;
-  dynar->used    = 0;
-  dynar->elmsize = elmsize;
-  dynar->data    = nullptr;
-  dynar->free_f  = free_f;
-}
-
-/** @brief Destroy a dynar that was created with xbt_dynar_init */
-void xbt_dynar_free_data(xbt_dynar_t dynar)
-{
-  xbt_dynar_reset(dynar);
-  if (dynar)
-    xbt_free(dynar->data);
-}
-
 /** @brief Destructor of the structure not touching to the content
  *
  * @param dynar poor victim
@@ -144,7 +113,7 @@ void xbt_dynar_free_container(xbt_dynar_t* dynar)
  *
  * @param dynar who to squeeze
  */
-void xbt_dynar_reset(xbt_dynar_t const dynar)
+void xbt_dynar_reset(xbt_dynar_t dynar)
 {
   _sanity_check_dynar(dynar);
 
@@ -155,28 +124,6 @@ void xbt_dynar_reset(xbt_dynar_t const dynar)
   dynar->used = 0;
 }
 
-/** @brief Merge dynar d2 into d1
- *
- * @param d1 dynar to keep
- * @param d2 dynar to merge into d1. This dynar is free at end.
- */
-void xbt_dynar_merge(xbt_dynar_t* d1, xbt_dynar_t* d2)
-{
-  if((*d1)->elmsize != (*d2)->elmsize)
-    xbt_die("Element size must are not equal");
-
-  const unsigned long elmsize = (*d1)->elmsize;
-
-  void *ptr = _xbt_dynar_elm((*d2), 0);
-  _xbt_dynar_resize(*d1, (*d1)->size + (*d2)->size);
-  void *elm = _xbt_dynar_elm((*d1), (*d1)->used);
-
-  memcpy(elm, ptr, ((*d2)->size)*elmsize);
-  (*d1)->used += (*d2)->used;
-  (*d2)->used = 0;
-  xbt_dynar_free(d2);
-}
-
 /**
  * @brief Shrink the dynar by removing empty slots at the end of the internal array
  * @param dynar a dynar
@@ -207,18 +154,11 @@ void xbt_dynar_free(xbt_dynar_t* dynar)
   }
 }
 
-/** @brief free a dynar passed as void* (handy to store dynar in dynars or dict) */
-void xbt_dynar_free_voidp(void* d)
-{
-  xbt_dynar_t dynar = (xbt_dynar_t)d;
-  xbt_dynar_free(&dynar);
-}
-
 /** @brief Count of dynar's elements
  *
  * @param dynar the dynar we want to measure
  */
-unsigned long xbt_dynar_length(const xbt_dynar_t dynar)
+unsigned long xbt_dynar_length(const_xbt_dynar_t dynar)
 {
   return (dynar ? (unsigned long) dynar->used : (unsigned long) 0);
 }
@@ -227,7 +167,7 @@ unsigned long xbt_dynar_length(const xbt_dynar_t dynar)
  *
  *@param dynar the dynat we want to check
  */
-int xbt_dynar_is_empty(const xbt_dynar_t dynar)
+int xbt_dynar_is_empty(const_xbt_dynar_t dynar)
 {
   return (xbt_dynar_length(dynar) == 0);
 }
@@ -238,7 +178,7 @@ int xbt_dynar_is_empty(const xbt_dynar_t dynar)
  * @param idx index of the slot we want to retrieve
  * @param[out] dst where to put the result to.
  */
-void xbt_dynar_get_cpy(const xbt_dynar_t dynar, const unsigned long idx, void* const dst)
+void xbt_dynar_get_cpy(const_xbt_dynar_t dynar, unsigned long idx, void* dst)
 {
   _sanity_check_dynar(dynar);
   _check_inbound_idx(dynar, idx);
@@ -255,7 +195,7 @@ void xbt_dynar_get_cpy(const xbt_dynar_t dynar, const unsigned long idx, void* c
  * @warning The returned value is the actual content of the dynar.
  * Make a copy before fooling with it.
  */
-void* xbt_dynar_get_ptr(const xbt_dynar_t dynar, const unsigned long idx)
+void* xbt_dynar_get_ptr(const_xbt_dynar_t dynar, unsigned long idx)
 {
   void *res;
   _sanity_check_dynar(dynar);
@@ -265,7 +205,7 @@ void* xbt_dynar_get_ptr(const xbt_dynar_t dynar, const unsigned long idx)
   return res;
 }
 
-void* xbt_dynar_set_at_ptr(const xbt_dynar_t dynar, const unsigned long idx)
+void* xbt_dynar_set_at_ptr(const xbt_dynar_t dynar, unsigned long idx)
 {
   _sanity_check_dynar(dynar);
 
@@ -279,47 +219,12 @@ void* xbt_dynar_set_at_ptr(const xbt_dynar_t dynar, const unsigned long idx)
   return _xbt_dynar_elm(dynar, idx);
 }
 
-/** @brief Set the Nth element of a dynar (expanded if needed). Previous value at this position is NOT freed
- *
- * @param dynar information dealer
- * @param idx index of the slot we want to modify
- * @param src What will be feeded to the dynar
- *
- * If you want to free the previous content, use xbt_dynar_replace().
- */
-void xbt_dynar_set(xbt_dynar_t dynar, const int idx, const void* const src)
-{
-  memcpy(xbt_dynar_set_at_ptr(dynar, idx), src, dynar->elmsize);
-}
-
-/** @brief Set the Nth element of a dynar (expanded if needed). Previous value is freed
- *
- * @param dynar
- * @param idx
- * @param object
- *
- * Set the Nth element of a dynar, expanding the dynar if needed, AND DO free the previous value at this position. If
- * you don't want to free the previous content, use xbt_dynar_set().
- */
-void xbt_dynar_replace(xbt_dynar_t dynar, const unsigned long idx, const void* const object)
-{
-  _sanity_check_dynar(dynar);
-
-  if (idx < dynar->used && dynar->free_f) {
-    void *const old_object = _xbt_dynar_elm(dynar, idx);
-
-    dynar->free_f(old_object);
-  }
-
-  xbt_dynar_set(dynar, idx, object);
-}
-
 /** @brief Make room for a new element, and return a pointer to it
  *
  * You can then use regular affectation to set its value instead of relying on the slow memcpy. This is what
  * xbt_dynar_insert_at_as() does.
  */
-void* xbt_dynar_insert_at_ptr(xbt_dynar_t const dynar, const int idx)
+void* xbt_dynar_insert_at_ptr(xbt_dynar_t dynar, int idx)
 {
   void *res;
   unsigned long old_used;
@@ -350,7 +255,7 @@ void* xbt_dynar_insert_at_ptr(xbt_dynar_t const dynar, const int idx)
  * Set the Nth element of a dynar, expanding the dynar if needed, and moving the previously existing value and all
  * subsequent ones to one position right in the dynar.
  */
-void xbt_dynar_insert_at(xbt_dynar_t const dynar, const int idx, const void* const src)
+void xbt_dynar_insert_at(xbt_dynar_t dynar, int idx, const void* src)
 {
   /* checks done in xbt_dynar_insert_at_ptr */
   memcpy(xbt_dynar_insert_at_ptr(dynar, idx), src, dynar->elmsize);
@@ -364,7 +269,7 @@ void xbt_dynar_insert_at(xbt_dynar_t const dynar, const int idx, const void* con
  * If the object argument of this function is a non-null pointer, the removed element is copied to this address. If not,
  * the element is freed using the free_f function passed at dynar creation.
  */
-void xbt_dynar_remove_at(xbt_dynar_t const dynar, const int idx, void* const object)
+void xbt_dynar_remove_at(xbt_dynar_t dynar, int idx, void* object)
 {
   _sanity_check_dynar(dynar);
   _check_inbound_idx(dynar, idx);
@@ -385,68 +290,6 @@ void xbt_dynar_remove_at(xbt_dynar_t const dynar, const int idx, void* const obj
   dynar->used--;
 }
 
-/** @brief Remove a slice of the dynar, sliding the rest of the values to the left
- *
- * This function removes an n-sized slice that starts at element idx. It is equivalent to xbt_dynar_remove_at with a
- * nullptr object argument if n equals to 1.
- *
- * Each of the removed elements is freed using the free_f function passed at dynar creation.
- */
-void xbt_dynar_remove_n_at(xbt_dynar_t const dynar, const unsigned int n, const int idx)
-{
-  if (not n)
-    return;
-
-  _sanity_check_dynar(dynar);
-  _check_inbound_idx(dynar, idx);
-  _check_inbound_idx(dynar, idx + n - 1);
-
-  if (dynar->free_f) {
-    for (unsigned long cur = idx; cur < idx + n; cur++) {
-      dynar->free_f(_xbt_dynar_elm(dynar, cur));
-    }
-  }
-
-  unsigned long nb_shift = dynar->used - n - idx;
-
-  if (nb_shift) {
-    unsigned long offset = nb_shift * dynar->elmsize;
-    memmove(_xbt_dynar_elm(dynar, idx), _xbt_dynar_elm(dynar, idx + n), offset);
-  }
-
-  dynar->used -= n;
-}
-
-/** @brief Returns the position of the element in the dynar
- *
- * Beware that if your dynar contains pointed values (such as strings) instead of scalar, this function compares the
- * pointer value, not what's pointed. The only solution to search for a pointed value is then to write the foreach loop
- * yourself:
- * @code
- * signed int position = -1;
- * xbt_dynar_foreach(dynar, iter, elem) {
- *    if (not memcmp(elem, searched_element, sizeof(*elem))) {
- *        position = iter;
- *        break;
- *    }
- * }
- * @endcode
- *
- * Raises std::out_of_range if not found. If you have less than 2 millions elements, you probably want to use
- * #xbt_dynar_search_or_negative() instead, so that you don't have to try/catch on element not found.
- */
-unsigned int xbt_dynar_search(xbt_dynar_t const dynar, void* const elem)
-{
-  unsigned long it;
-
-  for (it = 0; it < dynar->used; it++)
-    if (not memcmp(_xbt_dynar_elm(dynar, it), elem, dynar->elmsize)) {
-      return it;
-    }
-
-  throw std::out_of_range(simgrid::xbt::string_printf("Element %p not part of dynar %p", elem, dynar));
-}
-
 /** @brief Returns the position of the element in the dynar (or -1 if not found)
  *
  * Beware that if your dynar contains pointed values (such as strings) instead of scalar, this function is probably not
@@ -455,7 +298,7 @@ unsigned int xbt_dynar_search(xbt_dynar_t const dynar, void* const elem)
  * Note that usually, the dynar indices are unsigned integers. If you have more than 2 million elements in your dynar,
  * this very function will not work (but the other will).
  */
-signed int xbt_dynar_search_or_negative(xbt_dynar_t const dynar, void* const elem)
+signed int xbt_dynar_search_or_negative(const_xbt_dynar_t dynar, const void* elem)
 {
   unsigned long it;
 
@@ -472,7 +315,7 @@ signed int xbt_dynar_search_or_negative(xbt_dynar_t const dynar, void* const ele
  * Beware that if your dynar contains pointed values (such as strings) instead of scalar, this function is probably not
  * what you want. Check the documentation of xbt_dynar_search() for more info.
  */
-int xbt_dynar_member(xbt_dynar_t const dynar, void* const elem)
+int xbt_dynar_member(const_xbt_dynar_t dynar, const void* elem)
 {
   unsigned long it;
 
@@ -489,13 +332,13 @@ int xbt_dynar_member(xbt_dynar_t const dynar, void* const elem)
  * You can then use regular affectation to set its value instead of relying on the slow memcpy. This is what
  * xbt_dynar_push_as() does.
  */
-void* xbt_dynar_push_ptr(xbt_dynar_t const dynar)
+void* xbt_dynar_push_ptr(xbt_dynar_t dynar)
 {
   return xbt_dynar_insert_at_ptr(dynar, dynar->used);
 }
 
 /** @brief Add an element at the end of the dynar */
-void xbt_dynar_push(xbt_dynar_t const dynar, const void* const src)
+void xbt_dynar_push(xbt_dynar_t dynar, const void* src)
 {
   /* checks done in xbt_dynar_insert_at_ptr */
   memcpy(xbt_dynar_insert_at_ptr(dynar, dynar->used), src, dynar->elmsize);
@@ -506,7 +349,7 @@ void xbt_dynar_push(xbt_dynar_t const dynar, const void* const src)
  * You can then use regular affectation to set its value instead of relying on the slow memcpy. This is what
  * xbt_dynar_pop_as() does.
  */
-void* xbt_dynar_pop_ptr(xbt_dynar_t const dynar)
+void* xbt_dynar_pop_ptr(xbt_dynar_t dynar)
 {
   _check_populated_dynar(dynar);
   XBT_CDEBUG(xbt_dyn, "Pop %p", (void *) dynar);
@@ -515,7 +358,7 @@ void* xbt_dynar_pop_ptr(xbt_dynar_t const dynar)
 }
 
 /** @brief Get and remove the last element of the dynar */
-void xbt_dynar_pop(xbt_dynar_t const dynar, void* const dst)
+void xbt_dynar_pop(xbt_dynar_t dynar, void* dst)
 {
   /* sanity checks done by remove_at */
   XBT_CDEBUG(xbt_dyn, "Pop %p", (void *) dynar);
@@ -526,7 +369,7 @@ void xbt_dynar_pop(xbt_dynar_t const dynar, void* const dst)
  *
  * This is less efficient than xbt_dynar_push()
  */
-void xbt_dynar_unshift(xbt_dynar_t const dynar, const void* const src)
+void xbt_dynar_unshift(xbt_dynar_t dynar, const void* src)
 {
   /* sanity checks done by insert_at */
   xbt_dynar_insert_at(dynar, 0, src);
@@ -536,7 +379,7 @@ void xbt_dynar_unshift(xbt_dynar_t const dynar, const void* const src)
  *
  * This is less efficient than xbt_dynar_pop()
  */
-void xbt_dynar_shift(xbt_dynar_t const dynar, void* const dst)
+void xbt_dynar_shift(xbt_dynar_t dynar, void* dst)
 {
   /* sanity checks done by remove_at */
   xbt_dynar_remove_at(dynar, 0, dst);
@@ -546,7 +389,7 @@ void xbt_dynar_shift(xbt_dynar_t const dynar, void* const dst)
  *
  * The mapped function may change the value of the element itself, but should not mess with the structure of the dynar.
  */
-void xbt_dynar_map(const xbt_dynar_t dynar, void_f_pvoid_t const op)
+void xbt_dynar_map(const_xbt_dynar_t dynar, void_f_pvoid_t op)
 {
   char *const data = (char *) dynar->data;
   const unsigned long elmsize = dynar->elmsize;
@@ -565,7 +408,7 @@ void xbt_dynar_map(const xbt_dynar_t dynar, void_f_pvoid_t const op)
  *
  * This function can be used while traversing without problem.
  */
-void xbt_dynar_cursor_rm(xbt_dynar_t dynar, unsigned int* const cursor)
+void xbt_dynar_cursor_rm(xbt_dynar_t dynar, unsigned int* cursor)
 {
   xbt_dynar_remove_at(dynar, *cursor, nullptr);
   *cursor -= 1;
@@ -597,7 +440,7 @@ void xbt_dynar_cursor_rm(xbt_dynar_t dynar, unsigned int* const cursor)
  * @param dynar the dynar to sort
  * @param compar_fn comparison function of type (int (compar_fn*) (const void*) (const void*)).
  */
-void xbt_dynar_sort(xbt_dynar_t dynar, int_f_cpvoid_cpvoid_t compar_fn)
+void xbt_dynar_sort(const_xbt_dynar_t dynar, int_f_cpvoid_cpvoid_t compar_fn)
 {
   if (dynar->data != nullptr)
     qsort(dynar->data, dynar->used, dynar->elmsize, compar_fn);
@@ -619,50 +462,3 @@ void* xbt_dynar_to_array(xbt_dynar_t dynar)
   xbt_free(dynar);
   return res;
 }
-
-/** @brief Compare two dynars
- *
- *  @param d1 first dynar to compare
- *  @param d2 second dynar to compare
- *  @param compar function to use to compare elements
- *  @return 0 if d1 and d2 are equal and 1 if not equal
- *
- *  d1 and d2 should be dynars of pointers. The compar function takes two  elements and returns 0 when they are
- *  considered equal, and a value different of zero when they are considered different. Finally, d2 is destroyed
- *  afterwards.
- */
-int xbt_dynar_compare(xbt_dynar_t d1, xbt_dynar_t d2, int (*compar)(const void*, const void*))
-{
-  int i ;
-  int size;
-  if ((not d1) && (not d2))
-    return 0;
-  if ((not d1) || (not d2)) {
-    XBT_DEBUG("nullptr dynar d1=%p d2=%p",d1,d2);
-    xbt_dynar_free(&d2);
-    return 1;
-  }
-  if((d1->elmsize)!=(d2->elmsize)) {
-    XBT_DEBUG("Size of elmsize d1=%lu d2=%lu",d1->elmsize,d2->elmsize);
-    xbt_dynar_free(&d2);
-    return 1; // xbt_die
-  }
-  if(xbt_dynar_length(d1) != xbt_dynar_length(d2)) {
-    XBT_DEBUG("Size of dynar d1=%lu d2=%lu",xbt_dynar_length(d1),xbt_dynar_length(d2));
-    xbt_dynar_free(&d2);
-    return 1;
-  }
-
-  size = xbt_dynar_length(d1);
-  for(i=0;i<size;i++) {
-    void *data1 = xbt_dynar_get_as(d1, i, void *);
-    void *data2 = xbt_dynar_get_as(d2, i, void *);
-    XBT_DEBUG("link[%d] d1=%p d2=%p",i,data1,data2);
-    if(compar(data1,data2)){
-      xbt_dynar_free(&d2);
-      return 1;
-    }
-  }
-  xbt_dynar_free(&d2);
-  return 0;
-}
index 5f642de..60b0106 100644 (file)
@@ -1,6 +1,6 @@
 /* a generic DYNamic ARray implementation.                                  */
 
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -14,7 +14,6 @@ constexpr int NB_ELEM = 5000;
 
 TEST_CASE("xbt::dynar: generic C vector", "dynar")
 {
-
   SECTION("Dynars of integers")
   {
     /* Vars_decl [doxygen cruft] */
@@ -41,7 +40,7 @@ TEST_CASE("xbt::dynar: generic C vector", "dynar")
 
     /* 2. Traverse manually the dynar */
     for (int i = 0; i < NB_ELEM; i++) {
-      int* iptr = (int*)xbt_dynar_get_ptr(d, i);
+      const int* iptr = (int*)xbt_dynar_get_ptr(d, i);
       REQUIRE(i == *iptr); // The retrieved value is not the same than the injected one
     }
 
@@ -76,19 +75,6 @@ TEST_CASE("xbt::dynar: generic C vector", "dynar")
     }
     REQUIRE(xbt_dynar_is_empty(d));
 
-    for (int i = 0; i < NB_ELEM; i++) {
-      xbt_dynar_push_as(d, int, -1);
-    }
-    int* pi;
-    xbt_dynar_foreach_ptr(d, cursor, pi) { *pi = 0; }
-    xbt_dynar_foreach (d, cursor, cpt) {
-      REQUIRE(cpt == 0); // The value is not the same as the expected one.
-    }
-    xbt_dynar_foreach_ptr(d, cursor, pi) { *pi = 1; }
-    xbt_dynar_foreach (d, cursor, cpt) {
-      REQUIRE(cpt == 1); // The value is not the same as the expected one
-    }
-
     /* 5. Free the resources */
     xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
     xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing  it only once */
@@ -112,25 +98,12 @@ TEST_CASE("xbt::dynar: generic C vector", "dynar")
     for (int i = 0; i < NB_ELEM; i++) {
       xbt_dynar_push_as(d, int, i);
     }
-    for (int i = 0; i < NB_ELEM / 5; i++) {
-      xbt_dynar_insert_at_as(d, NB_ELEM / 2, int, i);
-    }
 
-    for (int i = 0; i < NB_ELEM / 2; i++) {
+    for (int i = 0; i < NB_ELEM; i++) {
       int val;
       xbt_dynar_shift(d, &val);
       REQUIRE(val == i); // The retrieved value is not the same than the injected one at the beginning
     }
-    for (int i = 999; i >= 0; i--) {
-      int val;
-      xbt_dynar_shift(d, &val);
-      REQUIRE(val == i); // The retrieved value is not the same than the injected one in the middle
-    }
-    for (int i = 2500; i < NB_ELEM; i++) {
-      int val;
-      xbt_dynar_shift(d, &val);
-      REQUIRE(val == i); // The retrieved value is not the same than the injected one at the end
-    }
     xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
     xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing  it only once */
     /* in your code is naturally the way to go outside a regression test */
@@ -183,27 +156,6 @@ TEST_CASE("xbt::dynar: generic C vector", "dynar")
     }
     REQUIRE(xbt_dynar_is_empty(d));
     xbt_dynar_free(&d);
-
-    /* ********************* */
-    INFO("==== Insert " << NB_ELEM << " int in reverse order, traverse them, remove them");
-    d = xbt_dynar_new(sizeof(int), nullptr);
-    for (int i = NB_ELEM - 1; i >= 0; i--) {
-      xbt_dynar_replace(d, i, &i);
-    }
-
-    /* 3. Traverse the dynar */
-    xbt_dynar_foreach (d, cursor, cpt) {
-      REQUIRE(cursor == (unsigned)cpt); // The retrieved value is not the same than the injected one
-    }
-    /* end_of_traversal */
-
-    for (int i = NB_ELEM - 1; i >= 0; i--) {
-      int val;
-      xbt_dynar_remove_at(d, xbt_dynar_length(d) - 1, &val);
-      REQUIRE(val == i); // The retrieved value is not the same than the injected one
-    }
-    REQUIRE(xbt_dynar_is_empty(d));
-    xbt_dynar_free(&d);
   }
 
   /*******************************************************************************/
@@ -330,13 +282,6 @@ TEST_CASE("xbt::dynar: generic C vector", "dynar")
       s1 = xbt_strdup(buf);
       xbt_dynar_push(d, &s1);
     }
-    for (int k = 0; k < 3; k++) {
-      for (int i = 0; i < NB_ELEM; i++) {
-        snprintf(buf, 1023, "%d", i);
-        s1 = xbt_strdup(buf);
-        xbt_dynar_replace(d, i, &s1);
-      }
-    }
     for (int i = 0; i < NB_ELEM; i++) {
       snprintf(buf, 1023, "%d", i);
       xbt_dynar_shift(d, &s2);
index 2d0748a..8879309 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2005-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2005-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -55,8 +55,7 @@ void log_exception(e_xbt_log_priority_t prio, const char* context, std::exceptio
       return;
     try {
       with_nested->rethrow_nested();
-    }
-    catch (std::exception& nested_exception) {
+    } catch (const std::exception& nested_exception) {
       log_exception(prio, "Caused by", nested_exception);
     }
     // We could catch nested_exception or WithContextException but we don't bother:
@@ -100,14 +99,14 @@ static void handler()
   }
 
   // Parse error are handled differently, as the call stack does not matter, only the file location
-  catch (simgrid::ParseError& e) {
+  catch (const simgrid::ParseError& e) {
     XBT_ERROR("%s", e.what());
     XBT_ERROR("Exiting now.");
     std::abort();
   }
 
   // We manage C++ exception ourselves
-  catch (std::exception& e) {
+  catch (const std::exception& e) {
     log_exception(xbt_log_priority_critical, "Uncaught exception", e);
     show_backtrace(bt);
     std::abort();
index 004c9fb..3dfe275 100644 (file)
@@ -1,6 +1,6 @@
 /* a generic graph library.                                                 */
 
-/* Copyright (c) 2006-2019. The SimGrid Team.
+/* Copyright (c) 2006-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -32,7 +32,7 @@ xbt_graph_t xbt_graph_new_graph(unsigned short int directed, void *data)
 }
 
 /** @brief add a node to the given graph */
-xbt_node_t xbt_graph_new_node(xbt_graph_t g, void *data)
+xbt_node_t xbt_graph_new_node(const s_xbt_graph_t* g, void* data)
 {
   xbt_node_t node= xbt_new0(struct xbt_node, 1);
   node->data = data;
@@ -50,7 +50,7 @@ xbt_node_t xbt_graph_new_node(xbt_graph_t g, void *data)
 }
 
 /** @brief add an edge to the given graph */
-xbt_edge_t xbt_graph_new_edge(xbt_graph_t g, xbt_node_t src, xbt_node_t dst, void *data)
+xbt_edge_t xbt_graph_new_edge(const s_xbt_graph_t* g, xbt_node_t src, xbt_node_t dst, void* data)
 {
   xbt_edge_t edge = xbt_new0(struct xbt_edge, 1);
   xbt_dynar_push(src->out, &edge);
@@ -69,7 +69,7 @@ xbt_edge_t xbt_graph_new_edge(xbt_graph_t g, xbt_node_t src, xbt_node_t dst, voi
 }
 
 /** @brief Get the edge connecting src and dst */
-xbt_edge_t xbt_graph_get_edge(xbt_graph_t g, xbt_node_t src, xbt_node_t dst)
+xbt_edge_t xbt_graph_get_edge(const s_xbt_graph_t* g, const s_xbt_node_t* src, const s_xbt_node_t* dst)
 {
   xbt_edge_t edge;
   unsigned int cursor;
@@ -90,7 +90,7 @@ xbt_edge_t xbt_graph_get_edge(xbt_graph_t g, xbt_node_t src, xbt_node_t dst)
 }
 
 /** @brief Get the user data associated to a node */
-void *xbt_graph_node_get_data(xbt_node_t node)
+void* xbt_graph_node_get_data(const s_xbt_node_t* node)
 {
   return node->data;
 }
@@ -102,7 +102,7 @@ void xbt_graph_node_set_data(xbt_node_t node, void *data)
 }
 
 /** @brief Get the user data associated to a edge */
-void *xbt_graph_edge_get_data(xbt_edge_t edge)
+void* xbt_graph_edge_get_data(const s_xbt_edge_t* edge)
 {
   return edge->data;
 }
@@ -150,31 +150,31 @@ void xbt_graph_free_graph(xbt_graph_t g, void_f_pvoid_t node_free_function, void
 }
 
 /** @brief Retrieve the graph's nodes as a dynar */
-xbt_dynar_t xbt_graph_get_nodes(xbt_graph_t g)
+xbt_dynar_t xbt_graph_get_nodes(const s_xbt_graph_t* g)
 {
   return g->nodes;
 }
 
 /** @brief Retrieve the graph's edges as a dynar */
-xbt_dynar_t xbt_graph_get_edges(xbt_graph_t g)
+xbt_dynar_t xbt_graph_get_edges(const s_xbt_graph_t* g)
 {
   return g->edges;
 }
 
 /** @brief Retrieve the node at the source of the given edge */
-xbt_node_t xbt_graph_edge_get_source(xbt_edge_t e)
+xbt_node_t xbt_graph_edge_get_source(const s_xbt_edge_t* e)
 {
   return e->src;
 }
 
 /** @brief Retrieve the node being the target of the given edge */
-xbt_node_t xbt_graph_edge_get_target(xbt_edge_t e)
+xbt_node_t xbt_graph_edge_get_target(const s_xbt_edge_t* e)
 {
   return e->dst;
 }
 
 /** @brief Retrieve the outgoing edges of the given node */
-xbt_dynar_t xbt_graph_node_get_outedges(xbt_node_t n)
+xbt_dynar_t xbt_graph_node_get_outedges(const s_xbt_node_t* n)
 {
   return n->out;
 }
index a72858e..0f28f5d 100644 (file)
@@ -1,6 +1,6 @@
 /* log - a generic logging facility in the spirit of log4j                  */
 
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -123,10 +123,8 @@ void xbt_log_init(int *argc, char **argv)
   }
 }
 
-static void log_cat_exit(xbt_log_category_t cat)
+static void log_cat_exit(const s_xbt_log_category_t* cat)
 {
-  xbt_log_category_t child;
-
   if (cat->appender) {
     if (cat->appender->free_)
       cat->appender->free_(cat->appender);
@@ -138,7 +136,7 @@ static void log_cat_exit(xbt_log_category_t cat)
     xbt_free(cat->layout);
   }
 
-  for (child = cat->firstChild; child != nullptr; child = child->nextSibling)
+  for (auto const* child = cat->firstChild; child != nullptr; child = child->nextSibling)
     log_cat_exit(child);
 }
 
@@ -157,14 +155,14 @@ static constexpr size_t XBT_LOG_DYNAMIC_BUFFER_SIZE = 4096;
 
 void _xbt_log_event_log(xbt_log_event_t ev, const char *fmt, ...)
 {
-  xbt_log_category_t cat = ev->cat;
+  const xbt_log_category_s* cat = ev->cat;
 
   xbt_assert(ev->priority >= 0, "Negative logging priority naturally forbidden");
   xbt_assert(static_cast<size_t>(ev->priority) < sizeof(xbt_log_priority_names)/sizeof(xbt_log_priority_names[0]),
              "Priority %d is greater than the biggest allowed value", ev->priority);
 
   while (1) {
-    xbt_log_appender_t appender = cat->appender;
+    const s_xbt_log_appender_t* appender = cat->appender;
 
     if (appender != nullptr) {
       xbt_assert(cat->layout, "No valid layout for the appender of category %s", cat->name);
@@ -180,7 +178,6 @@ void _xbt_log_event_log(xbt_log_event_t ev, const char *fmt, ...)
       if (done) {
         appender->do_append(appender, buff);
       } else {
-
         /* The static buffer was too small, use a dynamically expanded one */
         ev->buffer_size = XBT_LOG_DYNAMIC_BUFFER_SIZE;
         ev->buffer      = static_cast<char*>(xbt_malloc(ev->buffer_size));
@@ -283,7 +280,7 @@ int _xbt_log_cat_init(xbt_log_category_t category, e_xbt_log_priority_t priority
 
     if (XBT_LOG_ISENABLED(log, xbt_log_priority_debug)) {
       std::string res;
-      xbt_log_category_t cpp = category->parent->firstChild;
+      const xbt_log_category_s* cpp = category->parent->firstChild;
       while (cpp) {
         res += std::string(" ") + cpp->name;
         cpp = cpp->nextSibling;
@@ -341,7 +338,7 @@ void xbt_log_parent_set(xbt_log_category_t cat, xbt_log_category_t parent)
   cat->isThreshInherited = 1;
 }
 
-static void _set_inherited_thresholds(xbt_log_category_t cat)
+static void _set_inherited_thresholds(const s_xbt_log_category_t* cat)
 {
   xbt_log_category_t child = cat->firstChild;
 
@@ -632,7 +629,7 @@ static void xbt_log_help_categories_rec(xbt_log_category_t category, const std::
     cats.push_back(cat);
 
   std::sort(begin(cats), end(cats),
-            [](xbt_log_category_t a, xbt_log_category_t b) { return strcmp(a->name, b->name) < 0; });
+            [](const s_xbt_log_category_t* a, const s_xbt_log_category_t* b) { return strcmp(a->name, b->name) < 0; });
 
   for (auto const& cat : cats) {
     XBT_HELP("%s%s: %s", this_prefix.c_str(), cat->name, cat->description);
index 01eb726..e49cb06 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -8,14 +8,14 @@
 
 #include "xbt/log.h"
 struct xbt_log_appender_s {
-  void (*do_append) (xbt_log_appender_t this_appender, char *event);
-  void (*free_) (xbt_log_appender_t this_);
+  void (*do_append)(const s_xbt_log_appender_t* this_appender, const char* event);
+  void (*free_)(const s_xbt_log_appender_t* this_);
   void *data;
 };
 
 struct xbt_log_layout_s {
-  int (*do_layout) (xbt_log_layout_t l, xbt_log_event_t event, const char *fmt);
-  void (*free_) (xbt_log_layout_t l);
+  int (*do_layout)(const s_xbt_log_layout_t* l, xbt_log_event_t event, const char* fmt);
+  void (*free_)(const s_xbt_log_layout_t* l);
   void *data;
 };
 
index e32dd76..8fff0ce 100644 (file)
@@ -1,6 +1,6 @@
 /* mallocator - recycle objects to avoid malloc() / free()                  */
 
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 77f9149..3afd974 100644 (file)
@@ -1,6 +1,6 @@
 /* mallocator - recycle objects to avoid malloc() / free()                  */
 
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 43ce328..248d12d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -197,7 +197,7 @@ std::vector<VmMap> get_memory_map(pid_t pid)
 
     /* Ok we are good enough to try to get the info we need */
     /* First get the start and the end address of the map   */
-    char* tok = strtok_r(lfields[0], "-", &saveptr);
+    const char* tok = strtok_r(lfields[0], "-", &saveptr);
     if (tok == nullptr) {
       std::fprintf(stderr,
                    "Start and end address of the map are not concatenated by a hyphen (-). Recovery impossible.\n");
index 5938899..55b13e9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 411ca29..86dae30 100644 (file)
@@ -1,6 +1,6 @@
 /* Free a block of memory allocated by `mmalloc'. */
 
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 9b15c06..3f31adf 100644 (file)
@@ -4,7 +4,7 @@
    behavior.  It should also still be possible to build the library
    as a standard library with multiple objects. */
 
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 7523018..002d9c5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index b1c1551..8fa77c3 100644 (file)
@@ -1,6 +1,6 @@
 /* Initialization for access to a mmap'd malloc managed region. */
 
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index ca3b40d..e3ba23c 100644 (file)
@@ -1,6 +1,6 @@
 /* Memory allocator `malloc'. */
 
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -50,7 +50,7 @@ static void *align(struct mdesc *mdp, size_t size)
 /** Initialize heapinfo about the heapinfo pages :)
  *
  */
-static void initialize_heapinfo_heapinfo(xbt_mheap_t mdp)
+static void initialize_heapinfo_heapinfo(const s_xbt_mheap_t* mdp)
 {
   // Update heapinfo about the heapinfo pages (!):
   xbt_assert((uintptr_t) mdp->heapinfo % BLOCKSIZE == 0);
index fa83579..99bc655 100644 (file)
@@ -1,6 +1,6 @@
 /* Support for an sbrk-like function that uses mmap. */
 
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -145,7 +145,7 @@ void *mmorecore(struct mdesc *mdp, ssize_t size)
   return (result);
 }
 
-void *__mmalloc_remap_core(xbt_mheap_t mdp)
+void* __mmalloc_remap_core(const s_xbt_mheap_t* mdp)
 {
   /* FIXME:  Quick hack, needs error checking and other attention. */
 
index db3ee33..63ccf0f 100644 (file)
@@ -1,6 +1,6 @@
 /* Declarations for `mmalloc' and friends. */
 
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -276,7 +276,7 @@ XBT_PUBLIC_DATA struct mdesc* __mmalloc_default_mdp;
 
 /* Remap a mmalloc region that was previously mapped. */
 
-XBT_PUBLIC void* __mmalloc_remap_core(xbt_mheap_t mdp);
+XBT_PUBLIC void* __mmalloc_remap_core(const s_xbt_mheap_t* mdp);
 
 XBT_PUBLIC void* mmorecore(struct mdesc* mdp, ssize_t size);
 
index 20a0290..7639ede 100644 (file)
@@ -1,6 +1,6 @@
 /* Change the size of a block allocated by `mmalloc'. */
 
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 8e07028..23211e9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team.
+/* Copyright (c) 2004-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index bcd8540..f97c979 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index a4c8017..46d16b5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index e7ba9e2..21003c6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.               */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.               */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 83ee865..b7c10e8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.               */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.               */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index bf85795..79223df 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2005-2019. The SimGrid Team.
+/* Copyright (c) 2005-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 68d036f..3a7d768 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 3900999..03036fa 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.               */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.               */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index fbb0a88..344dab7 100644 (file)
@@ -1,6 +1,6 @@
 /* file_appender - a dumb log appender which simply prints to a file        */
 
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
 #include <cstdio>
 #include <cstring>
 
-static void append_file(xbt_log_appender_t this_, char *str) {
+static void append_file(const s_xbt_log_appender_t* this_, const char* str)
+{
   fputs(str, (FILE *) this_->data);
 }
 
-static void free_(xbt_log_appender_t this_)
+static void free_(const s_xbt_log_appender_t* this_)
 {
   fclose(static_cast<FILE*>(this_->data));
 }
@@ -86,20 +87,21 @@ static void open_append2_file(xbt_log_append2_file_t data){
   }
 }
 
-static void append2_file(xbt_log_appender_t this_, char *str) {
-   xbt_log_append2_file_t d=(xbt_log_append2_file_t) this_->data;
-   xbt_assert(d->file);
-   if(ftell(d->file)>=d->limit) {
-     open_append2_file(d);
-   }
-   fputs(str, d->file);
-   if(d->count<0){
-     fputs(APPEND2_END_TOKEN,d->file);
-     fseek(d->file,-((signed long)strlen(APPEND2_END_TOKEN)),SEEK_CUR);
-   }
+static void append2_file(const s_xbt_log_appender_t* this_, const char* str)
+{
+  xbt_log_append2_file_t d = (xbt_log_append2_file_t)this_->data;
+  xbt_assert(d->file);
+  if (ftell(d->file) >= d->limit) {
+    open_append2_file(d);
+  }
+  fputs(str, d->file);
+  if (d->count < 0) {
+    fputs(APPEND2_END_TOKEN, d->file);
+    fseek(d->file, -((signed long)strlen(APPEND2_END_TOKEN)), SEEK_CUR);
+  }
 }
 
-static void free_append2_(xbt_log_appender_t this_)
+static void free_append2_(const s_xbt_log_appender_t* this_)
 {
   xbt_log_append2_file_t data = static_cast<xbt_log_append2_file_t>(this_->data);
   if (data->file)
index 6a675dd..670d4d5 100644 (file)
@@ -1,6 +1,6 @@
 /* layout_simple - a dumb log layout                                        */
 
-/* Copyright (c) 2007-2019. The SimGrid Team.                               */
+/* Copyright (c) 2007-2020. The SimGrid Team.                               */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -68,7 +68,7 @@ static constexpr const char* ERRMSG =
 #define show_int(data) show_it((data), "d")
 #define show_double(data) show_it((data), "f")
 
-static int xbt_log_layout_format_doit(xbt_log_layout_t l, xbt_log_event_t ev, const char* msg_fmt)
+static int xbt_log_layout_format_doit(const s_xbt_log_layout_t* l, xbt_log_event_t ev, const char* msg_fmt)
 {
   char *p = ev->buffer;
   int rem_size = ev->buffer_size;
@@ -175,7 +175,7 @@ static int xbt_log_layout_format_doit(xbt_log_layout_t l, xbt_log_event_t ev, co
   return 1;
 }
 
-static void xbt_log_layout_format_free(xbt_log_layout_t lay)
+static void xbt_log_layout_format_free(const s_xbt_log_layout_t* lay)
 {
   xbt_free(lay->data);
 }
index 6e4b400..5cc0a65 100644 (file)
@@ -1,6 +1,6 @@
 /* layout_simple - a dumb log layout                                        */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -23,7 +23,7 @@ extern int xbt_log_no_loc;
     p += (len);                                                                                                        \
   } while (0)
 
-static int xbt_log_layout_simple_doit(xbt_log_layout_t, xbt_log_event_t ev, const char* fmt)
+static int xbt_log_layout_simple_doit(const s_xbt_log_layout_t*, xbt_log_event_t ev, const char* fmt)
 {
   char *p = ev->buffer;
   int rem_size = ev->buffer_size;
index bfdf869..324c2bf 100644 (file)
@@ -1,6 +1,6 @@
 /* module handling                                                          */
 
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 #if HAVE_UNISTD_H
 # include <unistd.h>
 #endif
+#include <string>
+#include <vector>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(module, xbt, "module handling");
 
 XBT_LOG_NEW_CATEGORY(smpi, "All SMPI categories"); /* lives here even if that's a bit odd to solve linking issues: this is used in xbt_log_file_appender to detect whether SMPI is used (and thus whether we should unbench the writing to disk) */
 
-char *xbt_binary_name = NULL;   /* Name of the system process containing us (mandatory to retrieve neat backtraces) */
-xbt_dynar_t xbt_cmdline = NULL; /* all we got in argv */
+namespace simgrid {
+namespace xbt {
+std::string binary_name;          /* Name of the system process containing us (mandatory to retrieve neat backtraces) */
+std::vector<std::string> cmdline; /* all we got in argv */
+} // namespace xbt
+} // namespace simgrid
 
 int xbt_initialized = 0;
 simgrid::config::Flag<bool> cfg_dbg_clean_atexit{
@@ -57,19 +63,16 @@ static void xbt_postexit();
 
 #ifndef __GNUC__
 /* Should not be necessary but for some reason, DllMain is called twice at attachment and at detachment.*/
-static int xbt_dll_process_is_attached = 0;
-
 /* see also http://msdn.microsoft.com/en-us/library/ms682583%28VS.85%29.aspx */
 /* and http://www.microsoft.com/whdc/driver/kernel/DLL_bestprac.mspx */
 static BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 {
-  if (fdwReason == DLL_PROCESS_ATTACH
-      && xbt_dll_process_is_attached == 0) {
-    xbt_dll_process_is_attached = 1;
+  static bool xbt_dll_process_is_attached = false;
+  if (fdwReason == DLL_PROCESS_ATTACH && not xbt_dll_process_is_attached) {
+    xbt_dll_process_is_attached = true;
     xbt_preinit();
-  } else if (fdwReason == DLL_PROCESS_DETACH
-      && xbt_dll_process_is_attached == 1) {
-    xbt_dll_process_is_attached = 0;
+  } else if (fdwReason == DLL_PROCESS_DETACH && xbt_dll_process_is_attached) {
+    xbt_dll_process_is_attached = false;
   }
   return 1;
 }
@@ -106,7 +109,6 @@ static void xbt_postexit()
     return;
   xbt_initialized--;
   xbt_dict_postexit();
-  xbt_dynar_free(&xbt_cmdline);
   xbt_log_postexit();
 #if SIMGRID_HAVE_MC
   mmalloc_postexit();
@@ -124,10 +126,9 @@ void xbt_init(int *argc, char **argv)
 
   simgrid::xbt::install_exception_handler();
 
-  xbt_binary_name = argv[0];
-  xbt_cmdline     = xbt_dynar_new(sizeof(char*), NULL);
+  simgrid::xbt::binary_name = argv[0];
   for (int i = 0; i < *argc; i++)
-    xbt_dynar_push(xbt_cmdline,&(argv[i]));
+    simgrid::xbt::cmdline.push_back(argv[i]);
 
   xbt_log_init(argc, argv);
 }
index ce487f4..e28fe03 100644 (file)
@@ -1,6 +1,6 @@
 /* xbt_os_file.cpp -- portable interface to file-related functions          */
 
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -25,7 +25,7 @@ simgrid::xbt::Path::Path()
 {
 #if HAVE_UNISTD_H
   char buffer[2048];
-  char* ret = getcwd(buffer, 2048);
+  const char* ret = getcwd(buffer, 2048);
   xbt_assert(ret == buffer, "Error during getcwd: %s", strerror(errno));
   path_ = std::string(buffer);
 #else
@@ -36,13 +36,13 @@ simgrid::xbt::Path::Path()
 std::string simgrid::xbt::Path::get_dir_name()
 {
   std::string p(path_);
-  char *res = dirname(&p[0]);
+  const char* res = dirname(&p[0]);
   return std::string(res, strlen(res));
 }
 
 std::string simgrid::xbt::Path::get_base_name()
 {
   std::string p(path_);
-  char *res = basename(&p[0]);
+  const char* res = basename(&p[0]);
   return std::string(res, strlen(res));
 }
index 14bde58..65829c9 100644 (file)
@@ -1,6 +1,6 @@
 /* Classical synchro schema, implemented on top of SimGrid                  */
 
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -57,12 +57,12 @@ int xbt_cond_timedwait(xbt_cond_t cond, xbt_mutex_t mutex, double delay)
 
 void xbt_cond_signal(xbt_cond_t cond)
 {
-  cond->cond_.notify_one();
+  cond->get_iface()->notify_one();
 }
 
 void xbt_cond_broadcast(xbt_cond_t cond)
 {
-  cond->cond_.notify_all();
+  cond->get_iface()->notify_all();
 }
 
 void xbt_cond_destroy(xbt_cond_t cond)
index d07e6ac..4d67b49 100644 (file)
@@ -1,6 +1,6 @@
 /* xbt_os_time.c -- portable interface to time-related functions            */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -140,7 +140,7 @@ void xbt_os_timer_free(xbt_os_timer_t timer)
   free(timer);
 }
 
-double xbt_os_timer_elapsed(xbt_os_timer_t timer)
+double xbt_os_timer_elapsed(const_xbt_os_timer_t timer)
 {
 #if HAVE_POSIX_GETTIME && defined (_POSIX_THREAD_CPUTIME)
   return ((double) timer->stop.tv_sec) - ((double) timer->start.tv_sec) + ((double) timer->elapse.tv_sec ) +
index 2c51d9d..c75acf1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -124,8 +124,7 @@ int replay_runner(const char* actor_name, const char* trace_filename)
       delete evt;
     }
     if (action_queues.find(actor_name_string) != action_queues.end()) {
-      std::queue<ReplayAction*>* myqueue = action_queues.at(actor_name_string);
-      delete myqueue;
+      delete action_queues.at(actor_name_string);
       action_queues.erase(actor_name_string);
     }
   } else { // Should have got my trace file in argument
index b38ad7d..6106399 100644 (file)
@@ -1,6 +1,6 @@
 /* xbt_str.cpp - various helping functions to deal with strings             */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index e1e7600..e7d70b0 100644 (file)
@@ -1,6 +1,6 @@
 /* xbt_str.cpp - various helping functions to deal with strings             */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 557a2d3..5902f3a 100644 (file)
@@ -1,6 +1,6 @@
 /* virtualization layer for XBT */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -11,7 +11,7 @@
 
 int xbt_getpid()
 {
-  smx_actor_t self = SIMIX_process_self();
+  const simgrid::kernel::actor::ActorImpl* self = SIMIX_process_self();
   return self == nullptr ? 0 : self->get_pid();
 }
 
index f7e2f17..f4c0217 100644 (file)
@@ -1,6 +1,6 @@
 /* xbt_modinter - How to init/exit the XBT modules                          */
 
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 48f4d4a..bc9e49d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index baefd9e..a843dd9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 48d21ac..65ec3f4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -23,10 +23,8 @@ static std::default_random_engine rnd_engine;
 
 static simgrid::mc::RemoteClient* process;
 
-static
-uintptr_t eval_binary_operation(
-  simgrid::dwarf::ExpressionContext& state, int op, uintptr_t a, uintptr_t b) {
-
+static uintptr_t eval_binary_operation(simgrid::dwarf::ExpressionContext const& state, int op, uintptr_t a, uintptr_t b)
+{
   Dwarf_Op ops[15];
   ops[0].atom = DW_OP_const8u;
   ops[0].number = a;
@@ -45,105 +43,101 @@ uintptr_t eval_binary_operation(
   return stack.top();
 }
 
-static
-void basic_test(simgrid::dwarf::ExpressionContext const& state) {
+static void basic_test(simgrid::dwarf::ExpressionContext const& state)
+{
   try {
+    Dwarf_Op ops[60];
 
-  Dwarf_Op ops[60];
+    uintptr_t a = rnd_engine();
+    uintptr_t b = rnd_engine();
 
-  uintptr_t a = rnd_engine();
-  uintptr_t b = rnd_engine();
+    simgrid::dwarf::ExpressionStack stack;
 
-  simgrid::dwarf::ExpressionStack stack;
+    bool caught_ex = false;
+    try {
+      ops[0].atom = DW_OP_drop;
+      simgrid::dwarf::execute(ops, 1, state, stack);
+    } catch (const simgrid::dwarf::evaluation_error&) {
+      caught_ex = true;
+    }
+    if (not caught_ex)
+      fprintf(stderr, "Exception expected");
 
-  bool caught_ex = false;
-  try {
-    ops[0].atom = DW_OP_drop;
+    ops[0].atom = DW_OP_lit21;
     simgrid::dwarf::execute(ops, 1, state, stack);
-  } catch (const simgrid::dwarf::evaluation_error&) {
-    caught_ex = true;
-  }
-  if (not caught_ex)
-    fprintf(stderr, "Exception expected");
-
-  ops[0].atom = DW_OP_lit21;
-  simgrid::dwarf::execute(ops, 1, state, stack);
-  assert(stack.size() == 1);
-  assert(stack.top() == 21);
-
-  ops[0].atom = DW_OP_const8u;
-  ops[0].number = a;
-  simgrid::dwarf::execute(ops, 1, state, stack);
-  assert(stack.size() == 2);
-  assert(stack.top() == a);
-
-  ops[0].atom = DW_OP_drop;
-  ops[1].atom = DW_OP_drop;
-  simgrid::dwarf::execute(ops, 2, state, stack);
-  assert(stack.empty());
-
-  stack.clear();
-  ops[0].atom = DW_OP_lit21;
-  ops[1].atom = DW_OP_plus_uconst;
-  ops[1].number = a;
-  simgrid::dwarf::execute(ops, 2, state, stack);
-  assert(stack.size() == 1);
-  assert(stack.top() == a + 21);
-
-  stack.clear();
-  ops[0].atom = DW_OP_const8u;
-  ops[0].number = a;
-  ops[1].atom = DW_OP_dup;
-  ops[2].atom = DW_OP_plus;
-  simgrid::dwarf::execute(ops, 3, state, stack);
-  assert(stack.size() == 1);
-  assert(stack.top() == a + a);
+    assert(stack.size() == 1);
+    assert(stack.top() == 21);
 
-  stack.clear();
-  ops[0].atom = DW_OP_const8u;
-  ops[0].number = a;
-  ops[1].atom = DW_OP_const8u;
-  ops[1].number = b;
-  ops[2].atom = DW_OP_over;
-  simgrid::dwarf::execute(ops, 3, state, stack);
-  assert(stack.size() == 3);
-  assert(stack.top()  == a);
-  assert(stack.top(1) == b);
-  assert(stack.top(2) == a);
-
-  stack.clear();
-  ops[0].atom = DW_OP_const8u;
-  ops[0].number = a;
-  ops[1].atom = DW_OP_const8u;
-  ops[1].number = b;
-  ops[2].atom = DW_OP_swap;
-  simgrid::dwarf::execute(ops, 3, state, stack);
-  assert(stack.size() == 2);
-  assert(stack.top()  == a);
-  assert(stack.top(1) == b);
+    ops[0].atom   = DW_OP_const8u;
+    ops[0].number = a;
+    simgrid::dwarf::execute(ops, 1, state, stack);
+    assert(stack.size() == 2);
+    assert(stack.top() == a);
 
+    ops[0].atom = DW_OP_drop;
+    ops[1].atom = DW_OP_drop;
+    simgrid::dwarf::execute(ops, 2, state, stack);
+    assert(stack.empty());
+
+    stack.clear();
+    ops[0].atom   = DW_OP_lit21;
+    ops[1].atom   = DW_OP_plus_uconst;
+    ops[1].number = a;
+    simgrid::dwarf::execute(ops, 2, state, stack);
+    assert(stack.size() == 1);
+    assert(stack.top() == a + 21);
+
+    stack.clear();
+    ops[0].atom   = DW_OP_const8u;
+    ops[0].number = a;
+    ops[1].atom   = DW_OP_dup;
+    ops[2].atom   = DW_OP_plus;
+    simgrid::dwarf::execute(ops, 3, state, stack);
+    assert(stack.size() == 1);
+    assert(stack.top() == a + a);
+
+    stack.clear();
+    ops[0].atom   = DW_OP_const8u;
+    ops[0].number = a;
+    ops[1].atom   = DW_OP_const8u;
+    ops[1].number = b;
+    ops[2].atom   = DW_OP_over;
+    simgrid::dwarf::execute(ops, 3, state, stack);
+    assert(stack.size() == 3);
+    assert(stack.top() == a);
+    assert(stack.top(1) == b);
+    assert(stack.top(2) == a);
+
+    stack.clear();
+    ops[0].atom   = DW_OP_const8u;
+    ops[0].number = a;
+    ops[1].atom   = DW_OP_const8u;
+    ops[1].number = b;
+    ops[2].atom   = DW_OP_swap;
+    simgrid::dwarf::execute(ops, 3, state, stack);
+    assert(stack.size() == 2);
+    assert(stack.top() == a);
+    assert(stack.top(1) == b);
   } catch (const simgrid::dwarf::evaluation_error&) {
     fprintf(stderr,"Expression evaluation error");
   }
 }
 
-static
-void test_deref(simgrid::dwarf::ExpressionContext const& state) {
+static void test_deref(simgrid::dwarf::ExpressionContext const& state)
+{
   try {
+    uintptr_t foo = 42;
 
-  uintptr_t foo = 42;
+    Dwarf_Op ops[60];
+    ops[0].atom   = DW_OP_const8u;
+    ops[0].number = (uintptr_t)&foo;
+    ops[1].atom   = DW_OP_deref;
 
-  Dwarf_Op ops[60];
-  ops[0].atom = DW_OP_const8u;
-  ops[0].number = (uintptr_t) &foo;
-  ops[1].atom = DW_OP_deref;
-
-  simgrid::dwarf::ExpressionStack stack;
-
-  simgrid::dwarf::execute(ops, 2, state, stack);
-  assert(stack.size() == 1);
-  assert(stack.top()  == foo);
+    simgrid::dwarf::ExpressionStack stack;
 
+    simgrid::dwarf::execute(ops, 2, state, stack);
+    assert(stack.size() == 1);
+    assert(stack.top() == foo);
   } catch (const simgrid::dwarf::evaluation_error&) {
     fprintf(stderr,"Expression evaluation error");
   }
index c3f876e..12f9031 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -55,12 +55,14 @@ static simgrid::mc::Variable* find_local_variable(
   return nullptr;
 }
 
-static void test_local_variable(simgrid::mc::ObjectInformation* info, const char* function, const char* variable, void* address, unw_cursor_t* cursor) {
+static void test_local_variable(simgrid::mc::ObjectInformation* info, const char* function, const char* variable,
+                                const void* address, unw_cursor_t* cursor)
+{
   simgrid::mc::Frame* subprogram = find_function_by_name(info, function);
   assert(subprogram);
   // TODO, Lookup frame by IP and test against name instead
 
-  simgrid::mc::Variable* var = find_local_variable(subprogram, variable);
+  const simgrid::mc::Variable* var = find_local_variable(subprogram, variable);
   assert(var);
 
   void* frame_base = subprogram->frame_base(*cursor);
@@ -70,8 +72,8 @@ static void test_local_variable(simgrid::mc::ObjectInformation* info, const char
   xbt_assert(location.address() == address, "Bad resolution of local variable %s of %s", variable, function);
 }
 
-static const simgrid::mc::Variable* test_global_variable(simgrid::mc::RemoteClient& process,
-                                                         simgrid::mc::ObjectInformation* info, const char* name,
+static const simgrid::mc::Variable* test_global_variable(const simgrid::mc::RemoteClient& process,
+                                                         const simgrid::mc::ObjectInformation* info, const char* name,
                                                          void* address, long byte_size)
 {
   const simgrid::mc::Variable* variable = info->find_variable(name);
@@ -83,7 +85,7 @@ static const simgrid::mc::Variable* test_global_variable(simgrid::mc::RemoteClie
 
   auto i = process.binary_info->types.find(variable->type_id);
   xbt_assert(i != process.binary_info->types.end(), "Missing type for %s", name);
-  simgrid::mc::Type* type = &i->second;
+  const simgrid::mc::Type* type = &i->second;
   xbt_assert(type->byte_size == byte_size, "Byte size mismatch for %s", name);
   return variable;
 }
@@ -102,7 +104,7 @@ struct s_foo {
   int i;
 };
 
-static void test_type_by_name(simgrid::mc::RemoteClient& process, s_foo /*my_foo*/)
+static void test_type_by_name(const simgrid::mc::RemoteClient& process, s_foo /*my_foo*/)
 {
   assert(process.binary_info->full_types_by_name.find("struct s_foo") != process.binary_info->full_types_by_name.end());
 }
index c367cdf..da35e9a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -48,7 +48,7 @@ static int receiver(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 static int sender(int argc, char *argv[])
 {
   xbt_assert(argc == 2);
-  char* message_name = argv[1];
+  const char* message_name = argv[1];
 #ifndef DISABLE_THE_MUTEX
   sg_mutex_lock(mutex);
 #endif
index 57c291a..76cc597 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 96bc97f..0970308 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index c88d170..4afeb0c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 7abd4e9..4c2bdef 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -39,13 +39,13 @@ int count_pieces(unsigned int bitfield)
   return count;
 }
 
-int peer_has_not_piece(peer_t peer, unsigned int piece)
+int peer_has_not_piece(const s_peer_t* peer, unsigned int piece)
 {
   return !(peer->bitfield & 1U << piece);
 }
 
 /** Check that a piece is not currently being download by the peer. */
-int peer_is_not_downloading_piece(peer_t peer, unsigned int piece)
+int peer_is_not_downloading_piece(const s_peer_t* peer, unsigned int piece)
 {
   return !(peer->current_pieces & 1U << piece);
 }
@@ -174,7 +174,7 @@ void seed_loop(peer_t peer, double deadline)
 /** @brief Retrieves the peer list from the tracker
  *  @param peer current peer data
  */
-int get_peers_data(peer_t peer)
+int get_peers_data(const s_peer_t* peer)
 {
   int success    = 0;
   double timeout = MSG_get_clock() + GET_PEERS_TIMEOUT;
@@ -274,7 +274,7 @@ int has_finished(unsigned int bitfield)
   return bitfield == (1U << FILE_PIECES) - 1U;
 }
 
-int nb_interested_peers(peer_t peer)
+int nb_interested_peers(const s_peer_t* peer)
 {
   xbt_dict_cursor_t cursor = NULL;
   char* key;
@@ -287,7 +287,7 @@ int nb_interested_peers(peer_t peer)
   return nb;
 }
 
-void update_active_peers_set(peer_t peer, connection_t remote_peer)
+void update_active_peers_set(const s_peer_t* peer, connection_t remote_peer)
 {
   if ((remote_peer->interested != 0) && (remote_peer->choked_upload == 0)) {
     // add in the active peers set
@@ -450,7 +450,7 @@ void remove_current_piece(peer_t peer, connection_t remote_peer, unsigned int cu
  *  @param peer peer we want to update the list
  *  @param bitfield bitfield
  */
-void update_pieces_count_from_bitfield(peer_t peer, unsigned int bitfield)
+void update_pieces_count_from_bitfield(const s_peer_t* peer, unsigned int bitfield)
 {
   for (int i = 0; i < FILE_PIECES; i++) {
     if (bitfield & (1U << i)) {
@@ -469,7 +469,7 @@ void update_pieces_count_from_bitfield(peer_t peer, unsigned int bitfield)
  * @param remote_peer: information about the connection
  * @return the piece to download if possible. -1 otherwise
  */
-int select_piece_to_download(peer_t peer, connection_t remote_peer)
+int select_piece_to_download(const s_peer_t* peer, const s_connection_t* remote_peer)
 {
   int piece = partially_downloaded_piece(peer, remote_peer);
   // strict priority policy
@@ -670,7 +670,7 @@ void update_choked_peers(peer_t peer)
 /** @brief Update "interested" state of peers: send "not interested" to peers that don't have any more pieces we want.
  *  @param peer our peer data
  */
-void update_interested_after_receive(peer_t peer)
+void update_interested_after_receive(const s_peer_t* peer)
 {
   char* key;
   xbt_dict_cursor_t cursor;
@@ -703,7 +703,7 @@ void update_bitfield_blocks(peer_t peer, int index, int block_index, int block_l
 }
 
 /** Returns if a peer has completed the download of a piece */
-int piece_complete(peer_t peer, int index)
+int piece_complete(const s_peer_t* peer, int index)
 {
   for (int i = 0; i < PIECES_BLOCKS; i++) {
     if (!(peer->bitfield_blocks & 1ULL << (index * PIECES_BLOCKS + i))) {
@@ -714,7 +714,7 @@ int piece_complete(peer_t peer, int index)
 }
 
 /** Returns the first block that a peer doesn't have in a piece. If the peer has all blocks of the piece, returns -1. */
-int get_first_block(peer_t peer, int piece)
+int get_first_block(const s_peer_t* peer, int piece)
 {
   for (int i = 0; i < PIECES_BLOCKS; i++) {
     if (!(peer->bitfield_blocks & 1ULL << (piece * PIECES_BLOCKS + i))) {
@@ -725,13 +725,13 @@ int get_first_block(peer_t peer, int piece)
 }
 
 /** Indicates if the remote peer has a piece not stored by the local peer */
-int is_interested(peer_t peer, connection_t remote_peer)
+int is_interested(const s_peer_t* peer, const s_connection_t* remote_peer)
 {
   return remote_peer->bitfield & (peer->bitfield ^ ((1 << FILE_PIECES) - 1));
 }
 
 /** Indicates if the remote peer has a piece not stored by the local peer nor requested by the local peer */
-int is_interested_and_free(peer_t peer, connection_t remote_peer)
+int is_interested_and_free(const s_peer_t* peer, const s_connection_t* remote_peer)
 {
   for (int i = 0; i < FILE_PIECES; i++) {
     if (peer_has_not_piece(peer, i) && connection_has_piece(remote_peer, i) && peer_is_not_downloading_piece(peer, i)) {
@@ -742,7 +742,7 @@ int is_interested_and_free(peer_t peer, connection_t remote_peer)
 }
 
 /** Returns a piece that is partially downloaded and stored by the remote peer if any -1 otherwise. */
-int partially_downloaded_piece(peer_t peer, connection_t remote_peer)
+int partially_downloaded_piece(const s_peer_t* peer, const s_connection_t* remote_peer)
 {
   for (int i = 0; i < FILE_PIECES; i++) {
     if (peer_has_not_piece(peer, i) && connection_has_piece(remote_peer, i) && peer_is_not_downloading_piece(peer, i) &&
@@ -756,7 +756,7 @@ int partially_downloaded_piece(peer_t peer, connection_t remote_peer)
  *  @param peer peer
  *  @param remote_peer peer data to the peer we want to send the request
  */
-void send_request_to_peer(peer_t peer, connection_t remote_peer, int piece)
+void send_request_to_peer(const s_peer_t* peer, connection_t remote_peer, int piece)
 {
   remote_peer->current_piece = piece;
   xbt_assert(connection_has_piece(remote_peer, piece));
@@ -777,7 +777,7 @@ void send_request_to_peer(peer_t peer, connection_t remote_peer, int piece)
  *  @param peer peer data
  *  @param mailbox destination mailbox
  */
-void send_interested(peer_t peer, const char* mailbox)
+void send_interested(const s_peer_t* peer, const char* mailbox)
 {
   msg_task_t task = task_message_new(MESSAGE_INTERESTED, peer->hostname, peer->mailbox, peer->id,
                                      task_message_size(MESSAGE_INTERESTED));
@@ -789,7 +789,7 @@ void send_interested(peer_t peer, const char* mailbox)
  *  @param peer peer data
  *  @param mailbox destination mailbox
  */
-void send_notinterested(peer_t peer, const char* mailbox)
+void send_notinterested(const s_peer_t* peer, const char* mailbox)
 {
   msg_task_t task = task_message_new(MESSAGE_NOTINTERESTED, peer->hostname, peer->mailbox, peer->id,
                                      task_message_size(MESSAGE_NOTINTERESTED));
@@ -800,7 +800,7 @@ void send_notinterested(peer_t peer, const char* mailbox)
 /** @brief Send a handshake message to all the peers the peer has.
  *  @param peer peer data
  */
-void send_handshake_all(peer_t peer)
+void send_handshake_all(const s_peer_t* peer)
 {
   connection_t remote_peer;
   xbt_dict_cursor_t cursor = NULL;
@@ -817,7 +817,7 @@ void send_handshake_all(peer_t peer)
  *  @param peer peer data
  *  @param mailbox mailbox where to we send the message
  */
-void send_handshake(peer_t peer, const char* mailbox)
+void send_handshake(const s_peer_t* peer, const char* mailbox)
 {
   XBT_DEBUG("Sending a HANDSHAKE to %s", mailbox);
   msg_task_t task = task_message_new(MESSAGE_HANDSHAKE, peer->hostname, peer->mailbox, peer->id,
@@ -826,7 +826,7 @@ void send_handshake(peer_t peer, const char* mailbox)
 }
 
 /** Send a "choked" message to a peer. */
-void send_choked(peer_t peer, const char* mailbox)
+void send_choked(const s_peer_t* peer, const char* mailbox)
 {
   XBT_DEBUG("Sending a CHOKE to %s", mailbox);
   msg_task_t task =
@@ -835,7 +835,7 @@ void send_choked(peer_t peer, const char* mailbox)
 }
 
 /** Send a "unchoked" message to a peer */
-void send_unchoked(peer_t peer, const char* mailbox)
+void send_unchoked(const s_peer_t* peer, const char* mailbox)
 {
   XBT_DEBUG("Sending a UNCHOKE to %s", mailbox);
   msg_task_t task =
@@ -844,7 +844,7 @@ void send_unchoked(peer_t peer, const char* mailbox)
 }
 
 /** Send a "HAVE" message to all peers we are connected to */
-void send_have(peer_t peer, int piece)
+void send_have(const s_peer_t* peer, int piece)
 {
   XBT_DEBUG("Sending HAVE message to all my peers");
   connection_t remote_peer;
@@ -860,7 +860,7 @@ void send_have(peer_t peer, int piece)
 /** @brief Send a bitfield message to all the peers the peer has.
  *  @param peer peer data
  */
-void send_bitfield(peer_t peer, const char* mailbox)
+void send_bitfield(const s_peer_t* peer, const char* mailbox)
 {
   XBT_DEBUG("Sending a BITFIELD to %s", mailbox);
   msg_task_t task = task_message_bitfield_new(peer->hostname, peer->mailbox, peer->id, peer->bitfield, FILE_PIECES);
@@ -868,7 +868,7 @@ void send_bitfield(peer_t peer, const char* mailbox)
 }
 
 /** Send a "request" message to a pair, containing a request for a piece */
-void send_request(peer_t peer, const char* mailbox, int piece, int block_index, int block_length)
+void send_request(const s_peer_t* peer, const char* mailbox, int piece, int block_index, int block_length)
 {
   XBT_DEBUG("Sending a REQUEST to %s for piece %d (%d,%d)", mailbox, piece, block_index, block_length);
   msg_task_t task = task_message_request_new(peer->hostname, peer->mailbox, peer->id, piece, block_index, block_length);
@@ -876,7 +876,7 @@ void send_request(peer_t peer, const char* mailbox, int piece, int block_index,
 }
 
 /** Send a "piece" message to a pair, containing a piece of the file */
-void send_piece(peer_t peer, const char* mailbox, int piece, int block_index, int block_length)
+void send_piece(const s_peer_t* peer, const char* mailbox, int piece, int block_index, int block_length)
 {
   XBT_DEBUG("Sending the PIECE %d (%d,%d) to %s", piece, block_index, block_length, mailbox);
   xbt_assert(piece >= 0, "Tried to send a piece that doesn't exist.");
index 21d6a13..e6f4631 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -41,7 +41,7 @@ typedef s_peer_t* peer_t;
 int peer(int argc, char* argv[]);
 void get_status(char** status, unsigned int bitfield);
 
-int get_peers_data(peer_t peer);
+int get_peers_data(const s_peer_t* peer);
 void leech_loop(peer_t peer, double deadline);
 void seed_loop(peer_t peer, double deadline);
 
@@ -52,43 +52,43 @@ int has_finished(unsigned int bitfield);
 
 void handle_message(peer_t peer, msg_task_t task);
 
-void update_pieces_count_from_bitfield(peer_t peer, unsigned int bitfield);
+void update_pieces_count_from_bitfield(const s_peer_t* peer, unsigned int bitfield);
 void update_choked_peers(peer_t peer);
 
-void update_interested_after_receive(peer_t peer);
+void update_interested_after_receive(const s_peer_t* peer);
 
 void update_bitfield_blocks(peer_t peer, int index, int block_index, int block_length);
-int piece_complete(peer_t peer, int index);
-int get_first_block(peer_t peer, int piece);
+int piece_complete(const s_peer_t* peer, int index);
+int get_first_block(const s_peer_t* peer, int piece);
 
-int peer_has_not_piece(peer_t peer, unsigned int piece);
-int peer_is_not_downloading_piece(peer_t peer, unsigned int piece);
+int peer_has_not_piece(const s_peer_t* peer, unsigned int piece);
+int peer_is_not_downloading_piece(const s_peer_t* peer, unsigned int piece);
 int count_pieces(unsigned int bitfield);
 
-int nb_interested_peers(peer_t peer);
-int is_interested(peer_t peer, connection_t remote_peer);
-int is_interested_and_free(peer_t peer, connection_t remote_peer);
-int partially_downloaded_piece(peer_t peer, connection_t remote_peer);
+int nb_interested_peers(const s_peer_t* peer);
+int is_interested(const s_peer_t* peer, const s_connection_t* remote_peer);
+int is_interested_and_free(const s_peer_t* peer, const s_connection_t* remote_peer);
+int partially_downloaded_piece(const s_peer_t* peer, const s_connection_t* remote_peer);
 
 void request_new_piece_to_peer(peer_t peer, connection_t remote_peer);
-void send_request_to_peer(peer_t peer, connection_t remote_peer, int piece);
+void send_request_to_peer(const s_peer_t* peer, connection_t remote_peer, int piece);
 void remove_current_piece(peer_t peer, connection_t remote_peer, unsigned int current_piece);
 
-void update_active_peers_set(peer_t peer, connection_t remote_peer);
-int select_piece_to_download(peer_t peer, connection_t remote_peer);
+void update_active_peers_set(const s_peer_t* peer, connection_t remote_peer);
+int select_piece_to_download(const s_peer_t* peer, const s_connection_t* remote_peer);
 
-void send_handshake_all(peer_t peer);
+void send_handshake_all(const s_peer_t* peer);
 
-void send_interested(peer_t peer, const char* mailbox);
+void send_interested(const s_peer_t* peer, const char* mailbox);
 
-void send_notinterested(peer_t peer, const char* mailbox);
-void send_handshake(peer_t peer, const char* mailbox);
-void send_bitfield(peer_t peer, const char* mailbox);
-void send_choked(peer_t peer, const char* mailbox);
-void send_unchoked(peer_t peer, const char* mailbox);
-void send_have(peer_t peer, int piece);
+void send_notinterested(const s_peer_t* peer, const char* mailbox);
+void send_handshake(const s_peer_t* peer, const char* mailbox);
+void send_bitfield(const s_peer_t* peer, const char* mailbox);
+void send_choked(const s_peer_t* peer, const char* mailbox);
+void send_unchoked(const s_peer_t* peer, const char* mailbox);
+void send_have(const s_peer_t* peer, int piece);
 
-void send_request(peer_t peer, const char* mailbox, int piece, int block_index, int block_length);
-void send_piece(peer_t peer, const char* mailbox, int piece, int block_index, int block_length);
+void send_request(const s_peer_t* peer, const char* mailbox, int piece, int block_index, int block_length);
+void send_piece(const s_peer_t* peer, const char* mailbox, int piece, int block_index, int block_length);
 
 #endif /* BITTORRENT_PEER_H */
index aebee13..ce6ff27 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 816cf1f..93ba317 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index d632552..59f1b53 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -39,7 +39,7 @@ void connection_free(void* data)
   xbt_free(co);
 }
 
-int connection_has_piece(connection_t connection, unsigned int piece)
+int connection_has_piece(const s_connection_t* connection, unsigned int piece)
 {
   return (connection->bitfield & 1U << piece);
 }
index 5a4459b..bb44b69 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -35,5 +35,5 @@ connection_t connection_new(int id);
 void connection_add_speed_value(connection_t connection, double speed);
 /** Frees a connection object */
 void connection_free(void* data);
-int connection_has_piece(connection_t connection, unsigned int piece);
+int connection_has_piece(const s_connection_t* connection, unsigned int piece);
 #endif /* BITTORRENT_CONNECTION_H_ */
index 04e689e..2fc26ce 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-# Copyright (c) 2012-2019. The SimGrid Team.
+# Copyright (c) 2012-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
index ba830b7..ae04633 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -41,7 +41,7 @@ int tracker(int argc, char* argv[])
         // Retrieve the data sent by the peer.
         tracker_task_data_t data = MSG_task_get_data(task_received);
         // Add the peer to our peer list.
-        if (is_in_list(peers_list, data->peer_id) == 0) {
+        if (!is_in_list(peers_list, data->peer_id)) {
           xbt_dynar_push_as(peers_list, int, data->peer_id);
         }
         // Sending peers to the peer
@@ -126,7 +126,7 @@ void tracker_task_data_free(tracker_task_data_t task)
  * @param peers dynar containing the peers
  * @param id identifier of the peer to test
  */
-int is_in_list(xbt_dynar_t peers, int id)
+int is_in_list(const_xbt_dynar_t peers, int id)
 {
   return xbt_dynar_member(peers, &id);
 }
index 4f7a94d..8975121 100644 (file)
@@ -1,11 +1,11 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#ifndef BITTORRENT_TRACKER_H_
-#define BITTORRENT_TRACKER_H_
+#ifndef BITTORRENT_TRACKER_H
+#define BITTORRENT_TRACKER_H
 #include "bittorrent.h"
 #include <xbt/dynar.h>
 /**
@@ -38,5 +38,5 @@ tracker_task_data_t tracker_task_data_new(const char* issuer_host_name, const ch
                                           int downloaded, int left);
 void tracker_task_data_free(tracker_task_data_t task);
 
-int is_in_list(xbt_dynar_t peers, int id);
+int is_in_list(const_xbt_dynar_t peers, int id);
 #endif /* BITTORRENT_TRACKER_H */
index 5bce6a6..79d4d53 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 326e6a6..df2f0bd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index e834d65..0d7f10d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 584ae57..081b7f4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 2a1fbe3..dd3b1d7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index bfffe74..6ff1af3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -29,7 +29,7 @@ void* xbt_dynar_iterator_next(xbt_dynar_iterator_t it)
   if (it->current >= it->length) {
     return NULL;
   } else {
-    int* next = xbt_dynar_get_ptr(it->indices_list, it->current);
+    const int* next = xbt_dynar_get_ptr(it->indices_list, it->current);
     it->current++;
     return xbt_dynar_get_ptr(it->list, *next);
   }
index 6b2cfa7..0b3c3be 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 951e86f..2c1c62a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index f9c4878..a76d087 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 160dbe9..2e0707a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -8,7 +8,7 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_peer, "Messages specific for the peer");
 
-void peer_init_chain(peer_t peer, message_t msg)
+void peer_init_chain(peer_t peer, const s_message_t* msg)
 {
   peer->prev         = msg->prev_hostname;
   peer->next         = msg->next_hostname;
@@ -16,7 +16,7 @@ void peer_init_chain(peer_t peer, message_t msg)
   peer->init         = 1;
 }
 
-static void peer_forward_msg(peer_t peer, message_t msg)
+static void peer_forward_msg(const s_peer_t* peer, const s_message_t* msg)
 {
   msg_task_t task = task_message_data_new(NULL, msg->data_length);
   XBT_DEBUG("Sending (isend) from %s into mailbox %s", peer->me, peer->next);
@@ -27,7 +27,7 @@ static void peer_forward_msg(peer_t peer, message_t msg)
 int peer_execute_task(peer_t peer, msg_task_t task)
 {
   int done      = 0;
-  message_t msg = MSG_task_get_data(task);
+  const s_message_t* msg = MSG_task_get_data(task);
 
   XBT_DEBUG("Peer %s got message of type %u\n", peer->me, msg->type);
   if (msg->type == MESSAGE_BUILD_CHAIN)
@@ -97,7 +97,7 @@ void peer_init(peer_t p, int argc, char* argv[])
   }
 }
 
-void peer_shutdown(peer_t p)
+void peer_shutdown(const s_peer_t* p)
 {
   unsigned int size = xbt_dynar_length(p->pending_sends);
   unsigned int idx;
@@ -128,7 +128,7 @@ void peer_delete(peer_t p)
   xbt_free(p);
 }
 
-void peer_print_stats(peer_t p, float elapsed_time)
+void peer_print_stats(const s_peer_t* p, float elapsed_time)
 {
   XBT_INFO("### %f %llu bytes (Avg %f MB/s); copy finished (simulated).", elapsed_time, p->bytes,
            p->bytes / 1024.0 / 1024.0 / elapsed_time);
index 62c6fc4..f7ab334 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -32,11 +32,11 @@ typedef s_peer_t* peer_t;
 /* Peer: helper functions */
 msg_error_t peer_wait_for_message(peer_t peer);
 int peer_execute_task(peer_t peer, msg_task_t task);
-void peer_init_chain(peer_t peer, message_t msg);
+void peer_init_chain(peer_t peer, const s_message_t* msg);
 void peer_delete(peer_t p);
-void peer_shutdown(peer_t p);
+void peer_shutdown(const s_peer_t* p);
 void peer_init(peer_t p, int argc, char* argv[]);
-void peer_print_stats(peer_t p, float elapsed_time);
+void peer_print_stats(const s_peer_t* p, float elapsed_time);
 
 int peer(int argc, char* argv[]);
 
index bbc8dcf..d826725 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index dc780b9..18e6047 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 44b1aae..f3047af 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 2b943e5..ef2c868 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index ea4da01..49d7523 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index b364e4f..0e66bae 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index d3603d7..1e27f3b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -11,7 +11,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example")
 
 static void vm_migrate(msg_vm_t vm, msg_host_t dst_pm)
 {
-  msg_host_t src_pm = MSG_vm_get_pm(vm);
+  const_sg_host_t src_pm = MSG_vm_get_pm(vm);
   double mig_sta    = MSG_get_clock();
   MSG_vm_migrate(vm, dst_pm);
   double mig_end = MSG_get_clock();
@@ -23,8 +23,8 @@ static void vm_migrate(msg_vm_t vm, msg_host_t dst_pm)
 static int migration_worker_main(int argc, char* argv[])
 {
   xbt_assert(argc == 3);
-  char* vm_name     = argv[1];
-  char* dst_pm_name = argv[2];
+  const char* vm_name     = argv[1];
+  const char* dst_pm_name = argv[2];
 
   msg_vm_t vm       = (msg_vm_t)MSG_host_by_name(vm_name);
   msg_host_t dst_pm = MSG_host_by_name(dst_pm_name);
@@ -34,7 +34,7 @@ static int migration_worker_main(int argc, char* argv[])
   return 0;
 }
 
-static void vm_migrate_async(msg_vm_t vm, msg_host_t dst_pm)
+static void vm_migrate_async(const_sg_vm_t vm, const_sg_host_t dst_pm)
 {
   const char* vm_name     = MSG_vm_get_name(vm);
   const char* dst_pm_name = MSG_host_get_name(dst_pm);
@@ -54,7 +54,7 @@ static int master_main(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[
 {
   msg_host_t pm0 = MSG_host_by_name("Fafard");
   msg_host_t pm1 = MSG_host_by_name("Tremblay");
-  msg_host_t pm2 = MSG_host_by_name("Bourassa");
+  const_sg_host_t pm2 = MSG_host_by_name("Bourassa");
 
   msg_vm_t vm0 = MSG_vm_create_core(pm0, "VM0");
   MSG_vm_set_ramsize(vm0, 1e9); // 1Gbytes
index 0985122..9c96a2c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 77fabb5..313c1df 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 358775a..e6b525c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index e0afcf4..034d29f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index c1b73bb..c1bed6c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index eb97efd..968fefd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 9b1152b..19097d1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index b4a467a..4f772e8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 5c4f339..73abb69 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 3d6cf51..3456513 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -36,7 +36,7 @@ static int host(int argc, char* argv[])
     sg_size_t write = MSG_file_write(file, MSG_file_get_size(file) * 1024);
     XBT_INFO("Have written %llu bytes to '%s'.", write, filename);
 
-    msg_host_t src  = MSG_host_self();
+    const_sg_host_t src = MSG_host_self();
     msg_host_t dest = MSG_host_by_name(argv[3]);
     if (xbt_str_parse_int(argv[5], "Argument 5 (move or copy) must be an int, not '%s'")) {
       XBT_INFO("Move '%s' (of size %llu) from '%s' to '%s'", filename, MSG_file_get_size(file), MSG_host_get_name(src),
@@ -56,7 +56,7 @@ static int host(int argc, char* argv[])
 int main(int argc, char** argv)
 {
   unsigned int cur;
-  msg_storage_t st;
+  const_sg_storage_t st;
 
   MSG_init(&argc, argv);
   MSG_storage_file_system_init();
index a2feefc..6444f5f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -15,7 +15,6 @@ static int host(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
   msg_file_t file = NULL;
   sg_size_t read;
   sg_size_t write;
-  msg_storage_t st;
   const char* st_name;
 
   switch (MSG_process_self_PID()) {
@@ -42,7 +41,7 @@ static int host(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 
   const char* filename = MSG_file_get_name(file);
   XBT_INFO("\tOpen file '%s'", filename);
-  st = MSG_storage_get_by_name(st_name);
+  const_sg_storage_t st = MSG_storage_get_by_name(st_name);
 
   XBT_INFO("\tCapacity of the storage element '%s' is stored on: %llu / %llu", filename, MSG_storage_get_used_size(st),
            MSG_storage_get_size(st));
index 3524b06..0638896 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 3838b06..245d7c4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -70,7 +70,7 @@ static int david(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 static int bob(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 {
   /* this host also tests the properties of the AS*/
-  msg_netzone_t root = MSG_zone_get_root();
+  const_sg_netzone_t root = MSG_zone_get_root();
   XBT_INFO("== Print the properties of the AS");
   XBT_INFO("   Process property: filename -> %s", MSG_zone_get_property_value(root, "filename"));
   XBT_INFO("   Process property: date -> %s", MSG_zone_get_property_value(root, "date"));
index 0e727f1..1976cf0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index d6560d5..f8227a2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 9e7a4ad..0b355e0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 055c763..2f25c67 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index afa3c7f..4454ee8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 66322d2..c2a2639 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -28,7 +28,7 @@ static int emigrant(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
   controlled_process = MSG_process_self(); /* - Get controlled at checkpoint */
   MSG_barrier_wait(barrier);
   MSG_process_suspend(MSG_process_self());
-  msg_host_t h = MSG_process_get_host(MSG_process_self());
+  const_sg_host_t h = MSG_process_get_host(MSG_process_self());
   XBT_INFO("I've been moved on this new host: %s", MSG_host_get_name(h));
   XBT_INFO("Uh, nothing to do here. Stopping now");
   return 0;
index f28573d..da79593 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index e8beb07..5b087b7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index bc52e13..80ccaa9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index e8e2aed..a014f65 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 653845b..3a10981 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -12,7 +12,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example")
 static int tester(int, char**)
 {
   msg_task_t task = MSG_task_create("name", 0, 10, NULL);
-  msg_comm_t comm = MSG_task_isend(task, "mailbox");
+  const_msg_comm_t comm = MSG_task_isend(task, "mailbox");
 
   XBT_INFO("MSG_task_listen_from returns() %d (should return my pid, which is %d)", MSG_task_listen_from("mailbox"),
            MSG_process_get_PID(MSG_process_self()));
index 65810c2..77be8b4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 3fabf6e..aa9dc64 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 783367f..aa5868a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 89189a9..99932ff 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 01558b2..98f5980 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 0701ffa..6d6c6dd 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -11,7 +11,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_cloud_interrupt_migration, "Messages specific f
 
 static void vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm)
 {
-  simgrid::s4u::Host* src_pm = vm->get_pm();
+  const simgrid::s4u::Host* src_pm = vm->get_pm();
   double mig_sta             = simgrid::s4u::Engine::get_clock();
   sg_vm_migrate(vm, dst_pm);
   double mig_end = simgrid::s4u::Engine::get_clock();
index b9c1d9f..7604ded 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 07838b5..763af3c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -143,7 +143,7 @@ static void receiver(std::vector<std::string> args)
       default:
         xbt_die("Unknown receiver spec for test %u: '%c'", test, args[0][test - 1]);
     }
-    std::string* receivedStr = static_cast<std::string*>(received);
+    const std::string* receivedStr = static_cast<std::string*>(received);
     xbt_assert(*receivedStr == mboxName);
     delete receivedStr;
     XBT_INFO("Test %u OK", test);
index 1261137..5edb401 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 1e64d69..8002e01 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -21,7 +21,7 @@ static void server()
 
   xbt_assert(mailbox->listen()); // True (1)
   XBT_INFO("Task listen works on regular mailboxes");
-  std::string* res = static_cast<std::string*>(mailbox->get());
+  const std::string* res = static_cast<std::string*>(mailbox->get());
 
   xbt_assert(*res == "Some data", "Data received: %s", res->c_str());
   XBT_INFO("Data successfully received from regular mailbox");
index b7a4de5..e879deb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 9f1099d..8620544 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -25,7 +25,7 @@ static void killall()
 {
   simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name("mailbox");
   for (int i = 0; i < 3; i++) {
-    int* pid = static_cast<int*>(mailbox->get());
+    const int* pid = static_cast<int*>(mailbox->get());
     XBT_INFO("Killing process \"%d\".", *pid);
     simgrid::s4u::Actor::by_pid(*pid)->kill();
   }
index 4803505..2cc23e4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2013-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -11,7 +11,7 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(storage, "Messages specific for this simulation");
 
-static void display_disk_properties(simgrid::s4u::Disk* disk)
+static void display_disk_properties(const simgrid::s4u::Disk* disk)
 {
   const std::unordered_map<std::string, std::string>* props = disk->get_properties();
   if (not props->empty()) {
@@ -57,11 +57,11 @@ static void hsm_put(const std::string& remote_host, const std::string& src, cons
   simgrid::s4u::this_actor::sleep_for(.4);
 }
 
-static void display_disk_content(simgrid::s4u::Disk* disk)
+static void display_disk_content(const simgrid::s4u::Disk* disk)
 {
   XBT_INFO("*** Dump a disk ***");
   XBT_INFO("Print the content of the disk: %s", disk->get_cname());
-  std::map<std::string, sg_size_t>* content = disk->extension<simgrid::s4u::FileSystemDiskExt>()->get_content();
+  const std::map<std::string, sg_size_t>* content = disk->extension<simgrid::s4u::FileSystemDiskExt>()->get_content();
   if (not content->empty()) {
     for (auto const& entry : *content)
       XBT_INFO("  %s size: %llu bytes", entry.first.c_str(), entry.second);
@@ -74,7 +74,7 @@ static void get_set_disk_data(simgrid::s4u::Disk* disk)
 {
   XBT_INFO("*** GET/SET DATA for disk: %s ***", disk->get_cname());
 
-  std::string* data = static_cast<std::string*>(disk->get_data());
+  const std::string* data = static_cast<std::string*>(disk->get_data());
   XBT_INFO("Get data: '%s'", data ? data->c_str() : "No User Data");
   disk->set_data(new std::string("Some data"));
   data = static_cast<std::string*>(disk->get_data());
@@ -84,7 +84,6 @@ static void get_set_disk_data(simgrid::s4u::Disk* disk)
 
 static void dump_platform_disks()
 {
-
   for (auto const& h : simgrid::s4u::Engine::get_instance()->get_all_hosts())
     for (auto const& d : h->get_disks()) {
       if (h == d->get_host())
@@ -93,7 +92,7 @@ static void dump_platform_disks()
     }
 }
 
-static void disk_info(simgrid::s4u::Host* host)
+static void disk_info(const simgrid::s4u::Host* host)
 {
   XBT_INFO("*** Disk info on %s ***", host->get_cname());
 
@@ -128,7 +127,7 @@ static void server()
 
   XBT_INFO("Server waiting for transfers ...");
   while (1) {
-    std::string* msg = static_cast<std::string*>(mailbox->get());
+    const std::string* msg = static_cast<std::string*>(mailbox->get());
     if (*msg == "finalize") { // Shutdown ...
       delete msg;
       break;
index 443a4f1..6c30765 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -12,10 +12,10 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging for the current example");
 
 static int name_compare_hosts(const void *n1, const void *n2)
 {
-  return strcmp(sg_host_get_name(*(sg_host_t *) n1), sg_host_get_name(*(sg_host_t *) n2));
+  return strcmp(sg_host_get_name(*(const sg_host_t*)n1), sg_host_get_name(*(const sg_host_t*)n2));
 }
 
-static void scheduleDAX(xbt_dynar_t dax)
+static void scheduleDAX(const_xbt_dynar_t dax)
 {
   unsigned int cursor;
   SD_task_t task;
index 4fce8a8..a21fa7c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team.
+/* Copyright (c) 2008-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(basic_link_test, sd, "SimDag test basic_link_test");
 
 static int cmp_link(const void*a, const void*b) {
-  return strcmp(sg_link_name(*(SD_link_t*)a)  , sg_link_name(*(SD_link_t*)b));
+  return strcmp(sg_link_name(*(const SD_link_t*)a), sg_link_name(*(const SD_link_t*)b));
 }
 
 int main(int argc, char **argv)
 {
-  const char *user_data = "some user_data";
+  char user_data[] = "some user_data";
 
   /* initialization of SD */
   SD_init(&argc, argv);
@@ -30,7 +30,7 @@ int main(int argc, char **argv)
   for (int i=0; i < count; i++){
     XBT_INFO("%s: latency = %.5f, bandwidth = %f", sg_link_name(links[i]),
              sg_link_latency(links[i]), sg_link_bandwidth(links[i]));
-    sg_link_data_set(links[i], (void*) user_data);
+    sg_link_data_set(links[i], user_data);
     xbt_assert(!strcmp(user_data, (const char*)sg_link_data(links[i])),"User data was corrupted.");
   }
   xbt_free(links);
index c262726..4a075a8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team.
+/* Copyright (c) 2008-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -18,8 +18,8 @@ int main(int argc, char **argv)
   sg_host_t *hosts = sg_host_list();
   if (argc >= 3) {
     if (!strcmp(argv[2], "ONE_LINK")) {
-      sg_host_t h1 = hosts[0];
-      sg_host_t h2 = hosts[1];
+      const_sg_host_t h1 = hosts[0];
+      const_sg_host_t h2 = hosts[1];
       const char *name1 = sg_host_get_name(h1);
       const char *name2 = sg_host_get_name(h2);
 
@@ -39,10 +39,10 @@ int main(int argc, char **argv)
     if (!strcmp(argv[2], "FULL_LINK")) {
       int list_size = sg_host_count();
       for (int i = 0; i < list_size; i++) {
-        sg_host_t h1 = hosts[i];
+        const_sg_host_t h1 = hosts[i];
         const char *name1 = sg_host_get_name(h1);
         for (int j = 0; j < list_size; j++) {
-          sg_host_t h2 = hosts[j];
+          const_sg_host_t h2 = hosts[j];
           const char *name2 = sg_host_get_name(h2);
           fprintf(stderr, "Route between %s and %s\n", name1, name2);
           xbt_dynar_t route = xbt_dynar_new(sizeof(SD_link_t), NULL);
index 62f1409..f43d6bb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 1ef6a32..8393f19 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 72b5d00..0f33b38 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index b552917..6c20f52 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 2a3bded..b5d79d9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 2fbc28c..7d42df7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 5bb7024..9fe19dc 100644 (file)
@@ -1,6 +1,6 @@
 /* Latency tests                                                            */
 
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 5b564eb..857bf68 100644 (file)
@@ -1,6 +1,6 @@
 /* Latency tests                                                            */
 
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index ef40f41..f43d4f7 100644 (file)
@@ -1,6 +1,6 @@
 /* Latency tests                                                            */
 
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 035c49f..63612ed 100644 (file)
@@ -1,6 +1,6 @@
 /* Latency tests                                                            */
 
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 35867d5..afecf14 100644 (file)
@@ -1,6 +1,6 @@
 /* Latency tests                                                            */
 
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index db5784f..c2b7d73 100644 (file)
@@ -1,6 +1,6 @@
 /* Latency tests                                                            */
 
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 2542bce..c9134a1 100644 (file)
@@ -1,6 +1,6 @@
 /* Latency tests                                                            */
 
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 107f633..9ae5391 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 824e0a5..e6c4b15 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 7feb036..d0dcfa9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team.
+/* Copyright (c) 2008-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -33,8 +33,8 @@ int main(int argc, char **argv)
     j = rand()%host_count;
   } while(i==j);
 
-  sg_host_t h1 = hosts[i];
-  sg_host_t h2 = hosts[j];
+  const_sg_host_t h1 = hosts[i];
+  const_sg_host_t h2 = hosts[j];
   printf("%d\tand\t%d\t\t",i,j);
   xbt_dynar_t route = xbt_dynar_new(sizeof(SD_link_t), NULL);
 
index abe16dd..e1f7f00 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index da1a39a..6e18fe0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -45,7 +45,7 @@ static void dump_hosts()
   unsigned int totalHosts = sg_host_count();
   sg_host_t* hosts        = sg_host_list();
   std::sort(hosts, hosts + totalHosts,
-            [](sg_host_t a, sg_host_t b) { return strcmp(sg_host_get_name(a), sg_host_get_name(b)) < 0; });
+            [](const_sg_host_t a, const_sg_host_t b) { return strcmp(sg_host_get_name(a), sg_host_get_name(b)) < 0; });
 
   for (unsigned int i = 0; i < totalHosts; i++) {
     std::printf("  <host id=\"%s\" speed=\"%.0f\"", hosts[i]->get_cname(), sg_host_speed(hosts[i]));
@@ -75,11 +75,12 @@ static void dump_links()
   unsigned int totalLinks    = sg_link_count();
   simgrid::s4u::Link** links = sg_link_list();
 
-  std::sort(links, links + totalLinks,
-            [](simgrid::s4u::Link* a, simgrid::s4u::Link* b) { return strcmp(sg_link_name(a), sg_link_name(b)) < 0; });
+  std::sort(links, links + totalLinks, [](const simgrid::s4u::Link* a, const simgrid::s4u::Link* b) {
+    return strcmp(sg_link_name(a), sg_link_name(b)) < 0;
+  });
 
   for (unsigned int i = 0; i < totalLinks; i++) {
-    simgrid::s4u::Link* link = links[i];
+    const simgrid::s4u::Link* link = links[i];
     std::printf("  <link id=\"");
 
     std::printf("%s\" bandwidth=\"%.0f\" latency=\"%.9f\"", link->get_cname(), link->get_bandwidth(), link->get_latency());
@@ -98,7 +99,7 @@ static void dump_routers()
   std::vector<simgrid::kernel::routing::NetPoint*> netpoints =
       simgrid::s4u::Engine::get_instance()->get_all_netpoints();
   std::sort(netpoints.begin(), netpoints.end(),
-            [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) {
+            [](const simgrid::kernel::routing::NetPoint* a, const simgrid::kernel::routing::NetPoint* b) {
               return a->get_name() < b->get_name();
             });
 
@@ -112,19 +113,19 @@ static void dump_routes()
   unsigned int totalHosts = sg_host_count();
   sg_host_t* hosts        = sg_host_list();
   std::sort(hosts, hosts + totalHosts,
-            [](sg_host_t a, sg_host_t b) { return strcmp(sg_host_get_name(a), sg_host_get_name(b)) < 0; });
+            [](const_sg_host_t a, const_sg_host_t b) { return strcmp(sg_host_get_name(a), sg_host_get_name(b)) < 0; });
   std::vector<simgrid::kernel::routing::NetPoint*> netpoints =
       simgrid::s4u::Engine::get_instance()->get_all_netpoints();
   std::sort(netpoints.begin(), netpoints.end(),
-            [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) {
+            [](const simgrid::kernel::routing::NetPoint* a, const simgrid::kernel::routing::NetPoint* b) {
               return a->get_name() < b->get_name();
             });
 
   for (unsigned int it_src = 0; it_src < totalHosts; it_src++) { // Routes from host
-    simgrid::s4u::Host* host1               = hosts[it_src];
+    const simgrid::s4u::Host* host1         = hosts[it_src];
     simgrid::kernel::routing::NetPoint* src = host1->get_netpoint();
     for (unsigned int it_dst = 0; it_dst < totalHosts; it_dst++) { // Routes to host
-      simgrid::s4u::Host* host2 = hosts[it_dst];
+      const simgrid::s4u::Host* host2 = hosts[it_dst];
       std::vector<simgrid::kernel::resource::LinkImpl*> route;
       simgrid::kernel::routing::NetPoint* dst = host2->get_netpoint();
       simgrid::kernel::routing::NetZoneImpl::get_global_route(src, dst, route, nullptr);
@@ -161,7 +162,7 @@ static void dump_routes()
         }
       }
       for (unsigned int it_dst = 0; it_dst < totalHosts; it_dst++) { // Routes to host
-        simgrid::s4u::Host* host2 = hosts[it_dst];
+        const simgrid::s4u::Host* host2 = hosts[it_dst];
         std::printf("  <route src=\"%s\" dst=\"%s\">\n  ", value1->get_cname(), host2->get_cname());
         std::vector<simgrid::kernel::resource::LinkImpl*> route;
         simgrid::kernel::routing::NetPoint* netcardDst = host2->get_netpoint();
index 201e05e..142dc5c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index e48c032..d5bed78 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -22,14 +22,14 @@ int main(int argc, char **argv)
   std::vector<simgrid::kernel::routing::NetPoint*> netpoints =
       simgrid::s4u::Engine::get_instance()->get_all_netpoints();
   std::sort(netpoints.begin(), netpoints.end(),
-            [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) {
+            [](const simgrid::kernel::routing::NetPoint* a, const simgrid::kernel::routing::NetPoint* b) {
               return a->get_name() < b->get_name();
             });
 
   int it;
   sg_host_t host;
   xbt_dynar_foreach(hosts, it, host) {
-    simgrid::kernel::routing::NetPoint* nc = host->get_netpoint();
+    const simgrid::kernel::routing::NetPoint* nc = host->get_netpoint();
     const char *type = "buggy";
     if (nc->is_router())
       type = "router";
index 09627be..fe03948 100644 (file)
@@ -1,6 +1,6 @@
 /* check_defaults -- simple program displaying its context factory          */
 
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 71cb9cb..6fd72c9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index d6c044f..d2100f3 100644 (file)
@@ -1,6 +1,6 @@
 /* stack_overflow -- simple program generating a stack overflow             */
 
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index e8a57f1..967f8cc 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 673f567..16c35f2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team.
+/* Copyright (c) 2014-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 72327a3..a8c7a5d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 8453576..d48014c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index e08316e..f1959a2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 9e7eea7..15e1f9e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index dd103ba..a5e55bf 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 99a3632..f26106d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index fc2bc73..44a933b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index be0ae6a..7fd00f4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 4c9e397..2789562 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2020. The SimGrid Team.
  * All rights reserved.                           */
 
 /* This program is free software; you can redistribute it and/or modify it
index 0ac4c66..962e9c1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 7f45d9a..1fc7f8d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index f1de933..69a127f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team.
+/* Copyright (c) 2019-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index d5b27ae..a4088a2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -17,7 +17,8 @@ static void set(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
 }
 
 // Return the number of times that an element is equal to (i+value)%256 between buf[start] and buf[stop-1].
-static  int count_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
+static int count_all(const uint8_t* buf, size_t start, size_t stop, uint8_t value)
+{
   size_t occ = 0;
   for(size_t i = start ; i < stop ; i++) {
     if(buf[i] == (i+value)%256) {
@@ -28,7 +29,8 @@ static  int count_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
 }
 
 // Return true iff the values from buf[start] to buf[stop-1] are all equal to (i+value)%256.
-static int check_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
+static int check_all(const uint8_t* buf, size_t start, size_t stop, uint8_t value)
+{
   size_t occ = count_all(buf, start, stop, value);
   return occ == stop-start;
 }
index 9b3f422..1a255df 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -16,7 +16,8 @@ static void set(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
 }
 
 // Return the number of times that an element is equal to (i+value)%256 between buf[start] and buf[stop-1].
-static int count_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
+static int count_all(const uint8_t* buf, size_t start, size_t stop, uint8_t value)
+{
   size_t occ = 0;
   for(size_t i = start ; i < stop ; i++) {
     if(buf[i] == (i+value)%256) {
@@ -27,13 +28,15 @@ static int count_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
 }
 
 // Return true iff the values from buf[start] to buf[stop-1] are all equal to (i+value)%256.
-static int check_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
+static int check_all(const uint8_t* buf, size_t start, size_t stop, uint8_t value)
+{
   size_t occ = count_all(buf, start, stop, value);
   return occ == stop-start;
 }
 
 // Return true iff "enough" elements are equal to (i+value)%256 between buf[start] and buf[stop-1].
-static int check_enough(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
+static int check_enough(const uint8_t* buf, size_t start, size_t stop, uint8_t value)
+{
   int page_size = 0x1000;
   size_t size = stop-start;
   if(size <= 2*page_size) // we are not sure to have a whole page that is shared
index 5696f75..19aafb0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 6e739ad..c09c350 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index a218e8c..53e8033 100644 (file)
@@ -52,6 +52,7 @@ int main(int argc, char **argv)
         MPI_Waitall(NUM_LOOPS, req, MPI_STATUSES_IGNORE);
 
     MPI_Barrier(MPI_COMM_WORLD);
+    free(req);
 
     /* test issends */
     MPI_Type_create_indexed_block(count, 1, displs, MPI_INT, &newtype);
@@ -71,6 +72,7 @@ int main(int argc, char **argv)
         MPI_Waitall(NUM_LOOPS, req, MPI_STATUSES_IGNORE);
 
     MPI_Barrier(MPI_COMM_WORLD);
+    free(req);
 
     /* test irsends */
     MPI_Type_create_indexed_block(count, 1, displs, MPI_INT, &newtype);
@@ -91,6 +93,8 @@ int main(int argc, char **argv)
     MPI_Waitall(NUM_LOOPS, req, MPI_STATUSES_IGNORE);
 
     MPI_Barrier(MPI_COMM_WORLD);
+    free(req);
+    free(displs);
 
     MPI_Finalize();
 
index 3554d67..987787e 100755 (executable)
@@ -655,7 +655,11 @@ sub RunMPIProgram {
            # Skip FORTRAN STOP
            if (/FORTRAN STOP/) { next; }
            $inline .= $_;
-           if (/^==[0-9]+== ?WARNING: ASan doesn't fully support/) {
+           if (m{^==[0-9]+== ?WARNING: ASan doesn't fully support} ||
+               m{^==[0-9]+== ?WARNING: ASan is ignoring requested __asan_handle_no_return: stack top:} ||
+               m{^False positive error reports may follow$} ||
+               m{^For details see http://code.google.com/p/address-sanitizer/issues/detail\?id=189$} ||
+               m{^For details see https://github.com/google/sanitizers/issues/189$}) {
                next;
            }
            if (/^\s*No [Ee]rrors\s*$/ && $found_noerror == 0) {
index 143b479..7a79bb3 100644 (file)
@@ -5,14 +5,15 @@
 
 
 static int myvalue = 0;
-static void test_opts(int* argc, char **argv[]){
+static void test_opts(int argc, char* const argv[])
+{
   int found = 0;
   static struct option long_options[] = {
   {(char*)"long",     no_argument, 0,  0 },
   {0,         0,                 0,  0 }
   };
   while (1) {
-    int ret = getopt_long_only(*argc, *argv, "s", long_options, NULL);
+    int ret = getopt_long_only(argc, argv, "s", long_options, NULL);
     if(ret==-1)
       break;
 
@@ -38,7 +39,7 @@ int main(int argc, char **argv)
 
     MPI_Init(&argc, &argv);
     /* test getopt_long function */
-    test_opts(&argc, &argv);
+    test_opts(argc, argv);
 
     MPI_Comm_rank(MPI_COMM_WORLD, &me);
 
index 0a76bed..fe36b7c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2019. The SimGrid Team.
+/* Copyright (c) 2011-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -11,7 +11,8 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(dsend,"the dsend test");
 
-static void test_opts(int* argc, char **argv[]){
+static void test_opts(int argc, char* const argv[])
+{
   int found = 0;
   int option_index = 0;
   static struct option long_options[] = {
@@ -19,7 +20,7 @@ static void test_opts(int* argc, char **argv[]){
   {0,         0,                 0,  0 }
   };
   while (1) {
-    int ret = getopt_long(*argc, *argv, "s", long_options, &option_index);
+    int ret = getopt_long(argc, argv, "s", long_options, &option_index);
     if(ret==-1)
       break;
 
@@ -48,7 +49,7 @@ int main(int argc, char *argv[])
   MPI_Init(NULL, NULL);
 
   /* test getopt_long function */
-  test_opts(&argc, &argv);
+  test_opts(argc, argv);
 
   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
   MPI_Request r;
index dcaf7e6..681817e 100644 (file)
@@ -1,6 +1,6 @@
 /* A simple example ping-pong program to test MPI_Send and MPI_Recv */
 
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -9,11 +9,11 @@
 #include <stdio.h>
 #include <mpi.h>
 
-static void test_opts(int* argc, char **argv[]){
+static void test_opts(int argc, char* const argv[])
+{
   int found = 0;
   int ret;
-  while ((ret = getopt(*argc, *argv, "s")) >= 0)
-  {
+  while ((ret = getopt(argc, argv, "s")) >= 0) {
     if (ret == 's')
       found = 1;
   }
@@ -33,7 +33,7 @@ int main(int argc, char *argv[])
   int err = MPI_Init(&argc, &argv); /* Initialize MPI */
 
   /* test getopt function */
-  test_opts(&argc, &argv);
+  test_opts(argc, argv);
 
   if (err != MPI_SUCCESS) {
     printf("MPI initialization failed!\n");
index 5acc708..e0c4146 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2019. The SimGrid Team.
+/* Copyright (c) 2009-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 29b3492..515c691 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 1e0a864..142000e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index f4ed05c..4256885 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 7588020..81d5195 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 62b886b..9b8fe09 100644 (file)
@@ -1,6 +1,6 @@
 /* A few tests for the maxmin library                                       */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 7e0bd91..5394298 100644 (file)
@@ -1,6 +1,6 @@
 /* A few crash tests for the maxmin library                                 */
 
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 0d1238d..e1b96f9 100644 (file)
@@ -1,6 +1,6 @@
 /* A few basic tests for the surf library                                   */
 
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -46,9 +46,9 @@ int main(int argc, char **argv)
   simgrid::s4u::Host* hostB = sg_host_by_name("Cpu B");
 
   /* Let's do something on it */
-  simgrid::kernel::resource::Action* actionA = hostA->pimpl_cpu->execution_start(1000.0);
-  simgrid::kernel::resource::Action* actionB = hostB->pimpl_cpu->execution_start(1000.0);
-  simgrid::kernel::resource::Action* actionC = hostB->pimpl_cpu->sleep(7.32);
+  const simgrid::kernel::resource::Action* actionA = hostA->pimpl_cpu->execution_start(1000.0);
+  const simgrid::kernel::resource::Action* actionB = hostB->pimpl_cpu->execution_start(1000.0);
+  const simgrid::kernel::resource::Action* actionC = hostB->pimpl_cpu->sleep(7.32);
 
   simgrid::kernel::resource::Action::State stateActionA = actionA->get_state();
   simgrid::kernel::resource::Action::State stateActionB = actionB->get_state();
index 3550332..fa1f4da 100644 (file)
@@ -1,6 +1,6 @@
 /* A few basic tests for the surf library                                   */
 
-/* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index dc15e71..d6929d6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 665f37f..603aa29 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2018-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2018-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index b0c8165..a997332 100644 (file)
@@ -1,6 +1,6 @@
 /* log_large_test -- log a very large string to test the dynamic variants   */
 
-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 91eccc5..5a67278 100644 (file)
@@ -1,6 +1,6 @@
 /* log_usage - A test of normal usage of the log facilities                 */
 
-/* Copyright (c) 2004-2019. The SimGrid Team.
+/* Copyright (c) 2004-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 9217257..63007c6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index d7341f5..b827a05 100644 (file)
@@ -1,6 +1,6 @@
 /* synchro_crashtest -- tries to crash the logging mechanism by doing parallel logs*/
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 21f3fba..e9a34f2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index fef46f2..fa3e9a7 100644 (file)
@@ -1,6 +1,6 @@
 /* parmap_test -- test parmap                                               */
 
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 4668527..ec5f34c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 5f1795d..9f9ec90 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env perl
 
-# Copyright (c) 2005-2019. The SimGrid Team.
+# Copyright (c) 2005-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
index 668cb5e..0abc7ab 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env perl
 
-# Copyright (c) 2006-2019. The SimGrid Team.
+# Copyright (c) 2006-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
index 7d624b6..15812e4 100644 (file)
@@ -389,7 +389,6 @@ set(SIMIX_SRC
   src/kernel/future.cpp
   src/simix/libsmx.cpp
   src/simix/smx_context.cpp
-  src/kernel/context/context_private.hpp
   src/kernel/context/Context.cpp
   src/kernel/context/Context.hpp
   src/kernel/context/ContextRaw.cpp
@@ -880,6 +879,7 @@ set(DOC_SOURCES
   docs/requirements.txt
   docs/source/conf.py
   docs/source/Doxyfile
+  docs/find-missing.ignore
   docs/find-missing.py
   docs/source/_ext/autodoxy.py
   docs/source/_ext/showfile.css
@@ -912,8 +912,9 @@ set(DOC_SOURCES
   docs/source/ns3.rst
   docs/source/outcomes.rst
   docs/source/platform.rst
-  docs/source/platform_howtos.rst
   docs/source/Platform_Examples.rst
+  docs/source/platform_howtos.rst
+  docs/source/Platform_Routing.rst
   docs/source/Plugins.rst
   docs/source/XML_Reference.rst
 
@@ -1089,6 +1090,7 @@ set(CMAKE_SOURCE_FILES
   tools/cmake/test_prog/prog_makecontext.c
   tools/cmake/test_prog/prog_stackgrowth.c
   tools/cmake/test_prog/prog_stacksetup.c
+  tools/cmake/test_prog/prog_tsan.cpp
   tools/cmake/cross-mingw.cmake
   tools/smpi/generate_smpi_defines.pl
   tools/stack-cleaner/as
index e752365..7bf32b9 100644 (file)
@@ -98,7 +98,11 @@ if(CMAKE_COMPILER_IS_GNUCC)
     message(WARNING "Failed to find relative source directory. Using \".\".")
     set(RELATIVE_SOURCE_DIR ".")
   endif()
-  set(optCFLAGS "${optCFLAGS} -fdebug-prefix-map=${CMAKE_SOURCE_DIR}=${RELATIVE_SOURCE_DIR}")
+  if (CMAKE_C_COMPILER_VERSION VERSION_LESS "8.0")
+    set(optCFLAGS "${optCFLAGS} -fdebug-prefix-map=${CMAKE_SOURCE_DIR}=${RELATIVE_SOURCE_DIR}")
+  else()
+    set(optCFLAGS "${optCFLAGS} -ffile-prefix-map=${CMAKE_SOURCE_DIR}=${RELATIVE_SOURCE_DIR}")
+  endif()
 endif()
 
 # Configure LTO
@@ -224,9 +228,12 @@ if(enable_thread_sanitizer)
     set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -fsanitize=thread -fno-omit-frame-pointer -no-pie")
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer -no-pie")
     set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -fsanitize=thread -no-pie")
-    set(HAVE_SANITIZER_THREAD TRUE CACHE INTERNAL "")
+    try_compile(HAVE_SANITIZER_THREAD ${CMAKE_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_tsan.cpp)
+    try_compile(HAVE_SANITIZER_THREAD_FIBER_SUPPORT ${CMAKE_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_tsan.cpp
+      COMPILE_DEFINITIONS -DCHECK_FIBER_SUPPORT)
 else()
     set(HAVE_SANITIZER_THREAD FALSE CACHE INTERNAL "")
+    set(HAVE_SANITIZER_THREAD_FIBER_SUPPORT FALSE CACHE INTERNAL "")
 endif()
 
 if(enable_undefined_sanitizer)
index bb6ecba..7803938 100644 (file)
@@ -3,9 +3,9 @@
 ##   This file is loaded only if the Java option is activated
 ##
 
-find_package(Java 1.7 COMPONENTS Runtime Development)
+find_package(Java 1.8 COMPONENTS Runtime Development)
 if (NOT ${Java_FOUND})
-  message(FATAL_ERROR "Java not found (need at least Java7). Please install the JDK or disable that option")
+  message(FATAL_ERROR "Java not found (need at least Java8). Please install the JDK or disable that option")
 endif()
 set(Java_FOUND 1)
 include(UseJava)
index 14540fb..9151c96 100644 (file)
@@ -1,6 +1,6 @@
 # Search for libunwind and components, both includes and libraries
 #
-# Copyright (C) 2003-2019 The SimGrid Team.
+# Copyright (C) 2003-2020 The SimGrid Team.
 # This is distributed under the LGPL licence but please contact us for
 # relicensing if you need. This is merely free software, no matter the licence.
 #
index 9c4da5b..35bf1db 100644 (file)
@@ -1,11 +1,3 @@
-IF(enable_smpi AND NOT WIN32)
-  execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpicc)
-  execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpicxx)
-  execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpiff)
-  execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpif90)
-  execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpirun)
-ENDIF()
-
 SET(TESH_OPTION "--ignore-jenkins")
 SET(TESH_COMMAND "${PYTHON_EXECUTABLE}" ${CMAKE_BINARY_DIR}/bin/tesh)
 
index eb33cb0..107ffd4 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env perl
 
-# Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
index 8a8d26b..31c3f0a 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env perl
 
-# Copyright (c) 2012-2019. The SimGrid Team.
+# Copyright (c) 2012-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
index 2ae9eba..8342810 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019. The SimGrid Team.
+/* Copyright (c) 2017-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 429875e..babedbb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 26a058a..9eee1b4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team.
+/* Copyright (c) 2010-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index fe1f26a..6a9193c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
diff --git a/tools/cmake/test_prog/prog_tsan.cpp b/tools/cmake/test_prog/prog_tsan.cpp
new file mode 100644 (file)
index 0000000..41ef8ba
--- /dev/null
@@ -0,0 +1,27 @@
+/* Copyright (c) 2020. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+/* Check availability of ThreadSanitizer */
+
+#if defined(__has_feature)
+#define HAS_FEATURE(x) __has_feature(x)
+#else
+#define HAS_FEATURE(x) 0
+#endif
+
+#if not HAS_FEATURE(thread_sanitizer) && not defined(__SANITIZE_THREAD__)
+#error "TSan feature not found."
+#endif
+
+#if defined(CHECK_FIBER_SUPPORT)
+#include <sanitizer/tsan_interface.h>
+// Verify the existence of the fiber annotation interface, with the expected signature
+void* (*create_fiber)(unsigned)       = __tsan_create_fiber;
+void (*destroy_fiber)(void*)          = __tsan_destroy_fiber;
+void (*switch_fiber)(void*, unsigned) = __tsan_switch_to_fiber;
+#endif
+
+int main(void) {}
index 43fe4f3..2c3255a 100755 (executable)
@@ -1,6 +1,6 @@
 #! /usr/bin/env perl
 
-# Copyright (c) 2010-2019. The SimGrid Team.
+# Copyright (c) 2010-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
index 2a0d365..61af70c 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env perl
 
-# Copyright (c) 2008-2019. The SimGrid Team.
+# Copyright (c) 2008-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
index 96b2bb1..e01e4d6 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 
-# Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.
+# Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
index 5054de8..c3e404b 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 # Copyright (c) 2015, David Martin. All rights reserved.
-# Copyright (c) 2017-2019. The SimGrid team. All rights reserved.
+# Copyright (c) 2017-2020. The SimGrid team. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are met:
index 7494197..14c471e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2019. The SimGrid Team.
+/* Copyright (c) 2008-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
index 03530bd..2b7247a 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 
-# Copyright (c) 2013-2019. The SimGrid Team.
+# Copyright (c) 2013-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
index 944a912..9ccf4d4 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 
-# Copyright (c) 2011-2019. The SimGrid Team.
+# Copyright (c) 2011-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
index ceea60d..7494a16 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env perl
 
-# Copyright (c) 2013-2019. The SimGrid Team.
+# Copyright (c) 2013-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
index 61fdd6d..6cccb33 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 
-# Copyright (c) 2014-2019. The SimGrid Team.
+# Copyright (c) 2014-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
index 73fc613..b4ae59e 100755 (executable)
@@ -43,47 +43,28 @@ onoff() {
   fi
 }
 
-# Check that we have what we need, or die quickly.
-# The paths are not the same on all platforms, unfortunately.
-#test -e /bin/tar  || die 1 "I need tar to compile. Please fix your slave."
-#test -e /bin/gzip || die 1 "I need gzip to compile. Please fix your slave."
-#test -e /usr/include/libunwind.h || die 1 "I need libunwind to compile. Please fix your slave."
-#test -e /usr/include/valgrind/valgrind.h || die 1 "I need valgrind to compile. Please fix your slave."
-
-if type lsb_release >/dev/null 2>&1; then
-  if [ -f /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ]; then
-    #To identify the windows underneath the winbuntu
-    PATH="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:$PATH"
-    major=$(powershell.exe -command "[environment]::OSVersion.Version.Major" | sed 's/\r//g')
-    build=$(powershell.exe -command "[environment]::OSVersion.Version.Build"| sed 's/\r//g')
-    os=Windows
-    ver="$major v$build - WSL $(lsb_release -sd)"
-  else
+if type lsb_release >/dev/null 2>&1; then # recent versions of Debian/Ubuntu
     # linuxbase.org
     os=$(lsb_release -si)
     ver="$(lsb_release -sr) ($(lsb_release -sc))"
-  fi
-elif [ -f /etc/lsb-release ]; then
-    # For some versions of Debian/Ubuntu without lsb_release command
+elif [ -f /etc/lsb-release ]; then # For some versions of Debian/Ubuntu without lsb_release command
     . /etc/lsb-release
     os=$DISTRIB_ID
     ver=$DISTRIB_RELEASE
-elif [ -f /etc/debian_version ]; then
-    # Older Debian/Ubuntu/etc.
+elif [ -f /etc/debian_version ]; then # Older Debian/Ubuntu/etc.
     os=Debian
     ver=$(cat /etc/debian_version)
-elif [ -f /etc/redhat-release ]; then
+elif [ -f /etc/redhat-release ]; then #RH, Fedora, Centos
     read -r os ver < /etc/redhat-release
-elif [ -f /usr/bin/sw_vers ]; then
+elif [ -f /usr/bin/sw_vers ]; then #osx
     os=$(sw_vers -productName)
     ver=$(sw_vers -productVersion)
-elif [ -f /bin/freebsd-version ]; then
+elif [ -f /bin/freebsd-version ]; then #freebsd
     os=$(uname -s)
     ver=$(freebsd-version -u)
-elif [ -f /etc/version ]; then
+elif [ -f /etc/release ]; then #openindiana
     read -r os ver < /etc/release
-elif [ -f /etc/os-release ]; then
-    # freedesktop.org and systemd, put last as usually missing useful info
+elif [ -f /etc/os-release ]; then # freedesktop.org and systemd, put last as usually missing useful info
     . /etc/os-release
     os=$NAME
     ver=$VERSION_ID
@@ -93,6 +74,17 @@ else
     os=$(uname -s)
     ver=$(uname -r)
 fi
+
+# Are we running on wsl ?
+if [ -f /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ]; then
+    #To identify the windows underneath the linux
+    PATH="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:$PATH"
+    major=$(powershell.exe -command "[environment]::OSVersion.Version.Major" | sed 's/\r//g')
+    build=$(powershell.exe -command "[environment]::OSVersion.Version.Build"| sed 's/\r//g')
+    ver="$major v$build - WSL $os $ver"
+    os=Windows
+fi
+
 case $(uname -m) in
 x86_64)
     bits="64 bits"
@@ -221,10 +213,6 @@ echo "XX   pwd: "$(pwd)
 echo "XX"
 
 ctest -T test --output-on-failure --no-compress-output || true
-if [ -f Testing/TAG ] ; then
-   xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/$( head -n 1 < Testing/TAG )/Test.xml > CTestResults.xml
-   mv CTestResults.xml $WORKSPACE
-fi
 
 if test -n "$INSTALL" && [ ${branch_name} = "origin/master" ] ; then
   echo "XX"
index b2bb493..a04800b 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-# Copyright (c) 2013-2019. The SimGrid Team.
+# Copyright (c) 2013-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
index f7cc5c4..b2858a7 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2013-2019. The SimGrid Team.
+# Copyright (c) 2013-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
index e71b44f..421834b 100644 (file)
    fun:_dl_init
 }
 
-# There's a constant leak of 56 bytes in the depths of libc which
-# manifests, for example, when using backtrace()
-{
-   Memory leak in libc/dlopen with -pthread
-   Memcheck:Leak
-   fun:malloc
-   fun:_dl_map_object_deps
-   fun:dl_open_worker
-   fun:_dl_catch_error
-   fun:_dl_open
-   fun:do_dlopen
-   fun:_dl_catch_error
-   fun:dlerror_run
-   fun:__libc_dlopen_mode
-}
-
-# Another problem in glibc, where makecontext does not reset the EBP register,
+# There's problem in glibc, where makecontext does not reset the EBP register,
 # and backtrace goes too far when walking up the stack frames
 {
    Invalid read in backtrace, called after makecontext
    fun:_dl_start
 }
 
+# There are memory leaks when using dlopen
+{
+   Memory leak in libc/dlopen
+   Memcheck:Leak
+   ...
+   fun:_dlerror_run
+}
+
 # 72704 bytes leak from GCC >5.1 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64535
 {
    Memory leak in dl_init
    fun:smpi_simulated_main_
 }
 
-#SMPI leaks the dlopen handle used to load the program
-{
-   dlopen handle leaks (1/3)
-   Memcheck:Leak
-   match-leak-kinds:reachable
-   fun:malloc
-   ...
-   fun:dlopen@@GLIBC_*
-}
-
-{
-   dlopen handle leaks (2/3)
-   Memcheck:Leak
-   match-leak-kinds:reachable
-   fun:calloc
-   ...
-   fun:dlopen@@GLIBC_*
-}
-
-{
-   dlopen handle leaks (3/3)
-   Memcheck:Leak
-   match-leak-kinds:reachable
-   fun:realloc
-   ...
-   fun:dlopen@@GLIBC_*
-}
-
 # Memory leaks appearing to be in libcgraph.  They can be seen with the
 # following simple program:
 # ,----
index f42b336..ce87016 100755 (executable)
@@ -5,7 +5,7 @@ eval 'exec perl -S $0 ${1+"$@"}'
 # This script updates the simgrid XML file passed as argument (modification in place)
 # It is built to do the conversion incrementally.
 
-# Copyright (c) 2006-2019. The SimGrid Team.
+# Copyright (c) 2006-2020. The SimGrid Team.
 # All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify it
@@ -160,7 +160,7 @@ In <host> and <peer>, rename the 'availability_file' attribute into 'speed_file'
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.
+Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.
 
 This program is free software; you may redistribute it and/or modify it
 under the terms of GNU LGPL (v2.1) license.
index 2e0d94a..3abc35a 100755 (executable)
@@ -5,12 +5,11 @@
 tesh -- testing shell
 ========================
 
-Copyright (c) 2012-2019. The SimGrid Team. All rights reserved.
+Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.
 
 This program is free software; you can redistribute it and/or modify it
 under the terms of the license (GNU LGPL) which comes with this package.
 
-
 #TODO: child of child of child that printfs. Does it work?
 #TODO: a child dies after its parent. What happen?
 
@@ -25,7 +24,6 @@ under the terms of the license (GNU LGPL) which comes with this package.
 
 """
 
-
 import sys
 import os
 import shlex
@@ -47,14 +45,12 @@ else:
 #
 #
 
-
 def isWindows():
     return sys.platform.startswith('win')
 
 # Singleton metaclass that works in Python 2 & 3
 # http://stackoverflow.com/questions/6760685/creating-a-singleton-in-python
 
-
 class _Singleton(type):
     """ A metaclass that creates a Singleton base class when called. """
     _instances = {}
@@ -64,11 +60,9 @@ class _Singleton(type):
             cls._instances[cls] = super(_Singleton, cls).__call__(*args, **kwargs)
         return cls._instances[cls]
 
-
 class Singleton(_Singleton('SingletonMeta', (object,), {})):
     pass
 
-
 SIGNALS_TO_NAMES_DICT = dict((getattr(signal, n), n)
                              for n in dir(signal) if n.startswith('SIG') and '_' not in n)
 
@@ -314,8 +308,8 @@ class Cmd(object):
             vdefault = m.group(2)
             if vname in os.environ:
                 return "$" + vname
-            else:
-                return vdefault
+            return vdefault
+
         self.args = re.sub(r"\${(\w+):=([^}]*)}", replace_perl_variables, self.args)
 
         # replace bash environment variables ($THINGS) to their values
@@ -427,7 +421,7 @@ class Cmd(object):
             logs.append("(ignoring the output of <{cmd}> as requested)".format(cmd=cmdName))
         else:
             stdouta = stdout_data.split("\n")
-            while len(stdouta) > 0 and stdouta[-1] == "":
+            while stdouta and stdouta[-1] == "":
                 del stdouta[-1]
             stdouta = self.remove_ignored_lines(stdouta)
             stdcpy = stdouta[:]
@@ -447,7 +441,7 @@ class Cmd(object):
                     lineterm="",
                     fromfile='expected',
                     tofile='obtained'))
-            if len(diff) > 0:
+            if diff:
                 logs.append("Output of <{cmd}> mismatch:".format(cmd=cmdName))
                 if self.sort >= 0:  # If sorted, truncate the diff output and show the unsorted version
                     difflen = 0
@@ -471,7 +465,7 @@ class Cmd(object):
                 if TeshState().keep:
                     f = open('obtained', 'w')
                     obtained = stdout_data.split("\n")
-                    while len(obtained) > 0 and obtained[-1] == "":
+                    while obtained and obtained[-1] == "":
                         del obtained[-1]
                     obtained = self.remove_ignored_lines(obtained)
                     for line in obtained:
@@ -514,14 +508,12 @@ class Cmd(object):
     def can_run(self):
         return self.args is not None
 
-
 ##############
 #
 # Main
 #
 #
 
-
 if __name__ == '__main__':
     signal.signal(signal.SIGINT, signal_handler)
     signal.signal(signal.SIGTERM, signal_handler)
@@ -609,7 +601,7 @@ if __name__ == '__main__':
     line = f.readfullline()
     while line is not None:
         # print(">>============="+line+"==<<")
-        if len(line) == 0:
+        if not line:
             #print ("END CMD block")
             if cmd.run_if_possible():
                 cmd = Cmd()