Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid
authormlaurent <mathieu.laurent@ens-rennes.fr>
Mon, 27 Mar 2023 08:24:38 +0000 (10:24 +0200)
committermlaurent <mathieu.laurent@ens-rennes.fr>
Mon, 27 Mar 2023 08:24:38 +0000 (10:24 +0200)
25 files changed:
examples/cpp/mc-bugged1/s4u-mc-bugged1.tesh
examples/cpp/mc-bugged2/s4u-mc-bugged2.tesh
examples/cpp/mc-electric-fence/s4u-mc-electric-fence.tesh
examples/cpp/mc-failing-assert/s4u-mc-failing-assert-nodpor.tesh
examples/cpp/mc-failing-assert/s4u-mc-failing-assert.tesh
examples/cpp/synchro-barrier/s4u-mc-synchro-barrier.tesh
examples/cpp/synchro-mutex/s4u-mc-synchro-mutex.tesh
examples/cpp/synchro-semaphore/s4u-mc-synchro-semaphore.tesh
examples/smpi/mc/only_send_deterministic.tesh
examples/sthread/pthread-mc-mutex-simple.tesh
examples/sthread/pthread-mc-mutex-simpledeadlock.tesh
examples/sthread/pthread-mc-producer-consumer.tesh
src/mc/api/ActorState.hpp
src/mc/api/State.cpp
src/mc/api/State.hpp
src/mc/api/guide/BasicGuide.hpp
src/mc/api/guide/WaitGuide.hpp [new file with mode: 0644]
src/mc/explo/DFSExplorer.cpp
src/mc/explo/DFSExplorer.hpp
src/mc/mc_config.cpp
src/mc/mc_config.hpp
src/mc/remote/AppSide.cpp
src/mc/transition/Transition.cpp
src/smpi/mpi/smpi_request.cpp
tools/cmake/DefinePackages.cmake

index adbd452..0d3b1f4 100644 (file)
@@ -9,54 +9,6 @@ $ ${bindir:=.}/../../../bin/simgrid-mc ${bindir:=.}/s4u-mc-bugged1 ${platfdir:=.
 > [  0.000000] (1:server@HostA) OK
 > [  0.000000] (4:client@HostD) Sent!
 > [  0.000000] (2:client@HostB) Sent!
-> [  0.000000] (1:server@HostA) OK
-> [  0.000000] (3:client@HostC) Sent!
-> [  0.000000] (4:client@HostD) Sent!
-> [  0.000000] (2:client@HostB) Sent!
-> [  0.000000] (1:server@HostA) OK
-> [  0.000000] (4:client@HostD) Sent!
-> [  0.000000] (3:client@HostC) Sent!
-> [  0.000000] (2:client@HostB) Sent!
-> [  0.000000] (3:client@HostC) Sent!
-> [  0.000000] (1:server@HostA) OK
-> [  0.000000] (4:client@HostD) Sent!
-> [  0.000000] (2:client@HostB) Sent!
-> [  0.000000] (4:client@HostD) Sent!
-> [  0.000000] (1:server@HostA) OK
-> [  0.000000] (3:client@HostC) Sent!
-> [  0.000000] (2:client@HostB) Sent!
-> [  0.000000] (4:client@HostD) Sent!
-> [  0.000000] (3:client@HostC) Sent!
-> [  0.000000] (1:server@HostA) OK
-> [  0.000000] (2:client@HostB) Sent!
-> [  0.000000] (3:client@HostC) Sent!
-> [  0.000000] (1:server@HostA) OK
-> [  0.000000] (4:client@HostD) Sent!
-> [  0.000000] (2:client@HostB) Sent!
-> [  0.000000] (3:client@HostC) Sent!
-> [  0.000000] (1:server@HostA) OK
-> [  0.000000] (4:client@HostD) Sent!
-> [  0.000000] (2:client@HostB) Sent!
-> [  0.000000] (1:server@HostA) OK
-> [  0.000000] (3:client@HostC) Sent!
-> [  0.000000] (4:client@HostD) Sent!
-> [  0.000000] (2:client@HostB) Sent!
-> [  0.000000] (1:server@HostA) OK
-> [  0.000000] (4:client@HostD) Sent!
-> [  0.000000] (3:client@HostC) Sent!
-> [  0.000000] (2:client@HostB) Sent!
-> [  0.000000] (3:client@HostC) Sent!
-> [  0.000000] (1:server@HostA) OK
-> [  0.000000] (4:client@HostD) Sent!
-> [  0.000000] (2:client@HostB) Sent!
-> [  0.000000] (4:client@HostD) Sent!
-> [  0.000000] (1:server@HostA) OK
-> [  0.000000] (3:client@HostC) Sent!
-> [  0.000000] (2:client@HostB) Sent!
-> [  0.000000] (4:client@HostD) Sent!
-> [  0.000000] (3:client@HostC) Sent!
-> [  0.000000] (1:server@HostA) OK
-> [  0.000000] (2:client@HostB) Sent!
 > [  0.000000] (3:client@HostC) Sent!
 > [  0.000000] (1:server@HostA) OK
 > [  0.000000] (4:client@HostD) Sent!
@@ -66,14 +18,14 @@ $ ${bindir:=.}/../../../bin/simgrid-mc ${bindir:=.}/s4u-mc-bugged1 ${platfdir:=.
 > [  0.000000] (0:maestro@) **************************
 > [  0.000000] (0:maestro@) Counter-example execution trace:
 > [  0.000000] (0:maestro@)   1: iRecv(mbox=0)
+> [  0.000000] (0:maestro@)   4: iSend(mbox=0)
+> [  0.000000] (0:maestro@)   1: WaitComm(from 4 to 1, mbox=0, no timeout)
+> [  0.000000] (0:maestro@)   1: iRecv(mbox=0)
 > [  0.000000] (0:maestro@)   2: iSend(mbox=0)
 > [  0.000000] (0:maestro@)   1: WaitComm(from 2 to 1, mbox=0, no timeout)
 > [  0.000000] (0:maestro@)   1: iRecv(mbox=0)
 > [  0.000000] (0:maestro@)   2: WaitComm(from 2 to 1, mbox=0, no timeout)
-> [  0.000000] (0:maestro@)   4: iSend(mbox=0)
-> [  0.000000] (0:maestro@)   1: WaitComm(from 4 to 1, mbox=0, no timeout)
-> [  0.000000] (0:maestro@)   1: iRecv(mbox=0)
 > [  0.000000] (0:maestro@)   3: iSend(mbox=0)
 > [  0.000000] (0:maestro@)   1: WaitComm(from 3 to 1, mbox=0, no timeout)
-> [  0.000000] (0:maestro@) You can debug the problem (and see the whole details) by rerunning out of simgrid-mc with --cfg=model-check/replay:'1;2;1;1;2;4;1;1;3;1'
-> [  0.000000] (0:maestro@) DFS exploration ended. 59 unique states visited; 14 backtracks (192 transition replays, 119 states visited overall)
\ No newline at end of file
+> [  0.000000] (0:maestro@) You can debug the problem (and see the whole details) by rerunning out of simgrid-mc with --cfg=model-check/replay:'1;4;1;1;2;1;1;2;3;1'
+> [  0.000000] (0:maestro@) DFS exploration ended. 32 unique states visited; 2 backtracks (36 transition replays, 2 states visited overall)
\ No newline at end of file
index a104fb8..a291922 100644 (file)
@@ -16,4 +16,4 @@ $ ${bindir:=.}/../../../bin/simgrid-mc --cfg=model-check/sleep-set:true ${bindir
 > [0.000000] [mc_explo/INFO]   3: iSend(mbox=0)
 > [0.000000] [mc_explo/INFO]   1: WaitComm(from 3 to 1, mbox=0, no timeout)
 > [0.000000] [mc_explo/INFO] You can debug the problem (and see the whole details) by rerunning out of simgrid-mc with --cfg=model-check/replay:'1;3;1;1;3;3;1'
-> [0.000000] [mc_dfs/INFO] DFS exploration ended. 2091 unique states visited; 529 backtracks (8359 transition replays, 5739 states visited overall)
+> [0.000000] [mc_dfs/INFO] DFS exploration ended. 307 unique states visited; 41 backtracks (623 transition replays, 275 states visited overall)
index ba390d6..329064b 100644 (file)
@@ -8,21 +8,15 @@ $ ${bindir:=.}/../../../bin/simgrid-mc ${bindir:=.}/s4u-mc-electric-fence ${plat
 > [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
 > [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
 > [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
-> [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
-> [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
-> [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
 > [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
 > [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
 > [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
-> [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
 > [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
-> [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
 > [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
-> [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
+> [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
 > [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
 > [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
 > [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
-> [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
 > [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
 > [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
 > [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
@@ -38,30 +32,21 @@ $ ${bindir:=.}/../../../bin/simgrid-mc ${bindir:=.}/s4u-mc-electric-fence ${plat
 > [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
 > [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
 > [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
-> [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
-> [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
 > [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
+> [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
 > [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
 > [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
 > [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
-> [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
-> [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
 > [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
 > [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
 > [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
 > [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
-> [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
-> [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
 > [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
 > [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
 > [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
 > [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
-> [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
-> [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
-> [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
 > [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
 > [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
-> [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
 > [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
 > [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
 > [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
@@ -77,16 +62,22 @@ $ ${bindir:=.}/../../../bin/simgrid-mc ${bindir:=.}/s4u-mc-electric-fence ${plat
 > [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
 > [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
 > [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
-> [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
 > [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
 > [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
 > [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
+> [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
+> [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
+> [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
+> [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
 > [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
 > [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
 > [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
 > [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
 > [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
+> [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
+> [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
+> [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
 > [HostC:client:(3) 0.000000] [electric_fence/INFO] Sent!
 > [HostA:server:(1) 0.000000] [electric_fence/INFO] OK
 > [HostB:client:(2) 0.000000] [electric_fence/INFO] Sent!
-> [0.000000] [mc_dfs/INFO] DFS exploration ended. 169 unique states visited; 29 backtracks (261 transition replays, 64 states visited overall)
\ No newline at end of file
+> [0.000000] [mc_dfs/INFO] DFS exploration ended. 154 unique states visited; 26 backtracks (234 transition replays, 55 states visited overall)
\ No newline at end of file
index c0d8fc0..623de96 100644 (file)
@@ -9,12 +9,12 @@ $ ${bindir:=.}/../../../bin/simgrid-mc --cfg=model-check/reduction:none -- ${bin
 > [0.000000] [mc_explo/INFO] *** PROPERTY NOT VALID ***
 > [0.000000] [mc_explo/INFO] **************************
 > [0.000000] [mc_explo/INFO] Counter-example execution trace:
-> [0.000000] [mc_explo/INFO]   1: iRecv(mbox=0)
 > [0.000000] [mc_explo/INFO]   3: iSend(mbox=0)
+> [0.000000] [mc_explo/INFO]   1: iRecv(mbox=0)
 > [0.000000] [mc_explo/INFO]   1: WaitComm(from 3 to 1, mbox=0, no timeout)
 > [0.000000] [mc_explo/INFO]   1: iRecv(mbox=0)
 > [0.000000] [mc_explo/INFO]   2: iSend(mbox=0)
 > [0.000000] [mc_explo/INFO]   1: WaitComm(from 2 to 1, mbox=0, no timeout)
-> [0.000000] [mc_explo/INFO] You can debug the problem (and see the whole details) by rerunning out of simgrid-mc with --cfg=model-check/replay:'1;3;1;1;2;1'
-> [0.000000] [mc_dfs/INFO] DFS exploration ended. 119 unique states visited; 36 backtracks (330 transition replays, 175 states visited overall)
+> [0.000000] [mc_explo/INFO] You can debug the problem (and see the whole details) by rerunning out of simgrid-mc with --cfg=model-check/replay:'3;1;1;1;2;1'
+> [0.000000] [mc_dfs/INFO] DFS exploration ended. 22 unique states visited; 2 backtracks (24 transition replays, 0 states visited overall)
 
index 6d4d6e5..13890b6 100644 (file)
@@ -7,16 +7,6 @@ $ ${bindir:=.}/../../../bin/simgrid-mc --cfg=model-check/sleep-set:true ${bindir
 > [  0.000000] (2:client1@Bourassa) Sent!
 > [  0.000000] (1:server@Boivin) OK
 > [  0.000000] (3:client2@Fafard) Sent!
-> [  0.000000] (1:server@Boivin) OK
-> [  0.000000] (3:client2@Fafard) Sent!
-> [  0.000000] (2:client1@Bourassa) Sent!
-> [  0.000000] (1:server@Boivin) OK
-> [  0.000000] (3:client2@Fafard) Sent!
-> [  0.000000] (2:client1@Bourassa) Sent!
-> [  0.000000] (1:server@Boivin) OK
-> [  0.000000] (3:client2@Fafard) Sent!
-> [  0.000000] (1:server@Boivin) OK
-> [  0.000000] (3:client2@Fafard) Sent!
 > [  0.000000] (0:maestro@) **************************
 > [  0.000000] (0:maestro@) *** PROPERTY NOT VALID ***
 > [  0.000000] (0:maestro@) **************************
@@ -28,4 +18,4 @@ $ ${bindir:=.}/../../../bin/simgrid-mc --cfg=model-check/sleep-set:true ${bindir
 > [  0.000000] (0:maestro@)   2: iSend(mbox=0)
 > [  0.000000] (0:maestro@)   1: WaitComm(from 2 to 1, mbox=0, no timeout)
 > [  0.000000] (0:maestro@) You can debug the problem (and see the whole details) by rerunning out of simgrid-mc with --cfg=model-check/replay:'1;3;1;1;2;1'
-> [  0.000000] (0:maestro@) DFS exploration ended. 29 unique states visited; 5 backtracks (49 transition replays, 15 states visited overall)
\ No newline at end of file
+> [  0.000000] (0:maestro@) DFS exploration ended. 13 unique states visited; 1 backtracks (15 transition replays, 1 states visited overall)
\ No newline at end of file
index fa4fc25..9fe7daf 100644 (file)
@@ -4,6 +4,7 @@ $ ${bindir:=.}/../../../bin/simgrid-mc --log=mc_dfs.thres:verbose --log=root.fmt
 > [Checker] Start a DFS exploration. Reduction is: dpor.
 > [Checker] Execute 1: BARRIER_ASYNC_LOCK(barrier: 0) (stack depth: 1, state: 1, 0 interleaves)
 > [Checker] Execute 1: BARRIER_WAIT(barrier: 0) (stack depth: 2, state: 2, 0 interleaves)
+> [Checker] There remains 0 actors, but none to interleave (depth 4).
 > [Checker] Execution came to an end at 1;1;0 (state: 3, depth: 3)
 > [Checker] Backtracking from 1;1;0
 > [Checker] DFS exploration ended. 3 unique states visited; 1 backtracks (3 transition replays, 0 states visited overall)
@@ -26,6 +27,7 @@ $ ${bindir:=.}/../../../bin/simgrid-mc --log=mc_dfs.thres:verbose --log=root.fmt
 > [Checker] Dependent Transitions:
 > [Checker]   BARRIER_ASYNC_LOCK(barrier: 0) (state=1)
 > [Checker]   BARRIER_WAIT(barrier: 0) (state=4)
+> [Checker] There remains 0 actors, but none to interleave (depth 6).
 > [Checker] Execution came to an end at 1;2;1;2;0 (state: 5, depth: 5)
 > [Checker] Backtracking from 1;2;1;2;0
 > [Checker] Execute 2: BARRIER_ASYNC_LOCK(barrier: 0) (stack depth: 1, state: 1, 0 interleaves)
@@ -44,6 +46,7 @@ $ ${bindir:=.}/../../../bin/simgrid-mc --log=mc_dfs.thres:verbose --log=root.fmt
 > [Checker] Dependent Transitions:
 > [Checker]   BARRIER_ASYNC_LOCK(barrier: 0) (state=6)
 > [Checker]   BARRIER_WAIT(barrier: 0) (state=8)
+> [Checker] There remains 0 actors, but none to interleave (depth 6).
 > [Checker] Execution came to an end at 2;1;1;2;0 (state: 9, depth: 5)
 > [Checker] Backtracking from 2;1;1;2;0
 > [Checker] DFS exploration ended. 9 unique states visited; 2 backtracks (10 transition replays, 0 states visited overall)
@@ -83,6 +86,7 @@ $ ${bindir:=.}/../../../bin/simgrid-mc --log=mc_dfs.thres:verbose --log=root.fmt
 > [Checker] Dependent Transitions:
 > [Checker]   BARRIER_ASYNC_LOCK(barrier: 0) (state=2)
 > [Checker]   BARRIER_WAIT(barrier: 0) (state=6)
+> [Checker] There remains 0 actors, but none to interleave (depth 8).
 > [Checker] Execution came to an end at 1;2;3;1;2;3;0 (state: 7, depth: 7)
 > [Checker] Backtracking from 1;2;3;1;2;3;0
 > [Checker] Execute 3: BARRIER_ASYNC_LOCK(barrier: 0) (stack depth: 2, state: 2, 0 interleaves)
@@ -117,6 +121,7 @@ $ ${bindir:=.}/../../../bin/simgrid-mc --log=mc_dfs.thres:verbose --log=root.fmt
 > [Checker] Dependent Transitions:
 > [Checker]   BARRIER_ASYNC_LOCK(barrier: 0) (state=8)
 > [Checker]   BARRIER_WAIT(barrier: 0) (state=11)
+> [Checker] There remains 0 actors, but none to interleave (depth 8).
 > [Checker] Execution came to an end at 1;3;2;1;2;3;0 (state: 12, depth: 7)
 > [Checker] Backtracking from 1;3;2;1;2;3;0
 > [Checker] DFS exploration ended. 12 unique states visited; 2 backtracks (14 transition replays, 1 states visited overall)
\ No newline at end of file
index 6dda41c..5ae1bf5 100644 (file)
@@ -26,8 +26,33 @@ $ ${bindir:=.}/../../../bin/simgrid-mc --log=mc_dfs.thres:verbose --log=root.fmt
 > [Checker] Dependent Transitions:
 > [Checker]   MUTEX_UNLOCK(mutex: 0, owner: -1) (state=3)
 > [Checker]   MUTEX_UNLOCK(mutex: 0, owner: -1) (state=6)
+> [Checker] There remains 0 actors, but none to interleave (depth 8).
 > [Checker] Execution came to an end at 1;1;1;2;2;2;0 (state: 7, depth: 7)
 > [Checker] Backtracking from 1;1;1;2;2;2;0
+> [Checker] Execute 2: MUTEX_ASYNC_LOCK(mutex: 0, owner: 2) (stack depth: 1, state: 1, 0 interleaves)
+> [Checker] Execute 1: MUTEX_ASYNC_LOCK(mutex: 0, owner: 2) (stack depth: 2, state: 8, 0 interleaves)
+> [Checker] Dependent Transitions:
+> [Checker]   MUTEX_ASYNC_LOCK(mutex: 0, owner: 2) (state=1)
+> [Checker]   MUTEX_ASYNC_LOCK(mutex: 0, owner: 2) (state=8)
+> [Checker] Execute 2: MUTEX_WAIT(mutex: 0, owner: 2) (stack depth: 3, state: 9, 0 interleaves)
+> [Checker] INDEPENDENT Transitions:
+> [Checker]   MUTEX_ASYNC_LOCK(mutex: 0, owner: 2) (state=8)
+> [Checker]   MUTEX_WAIT(mutex: 0, owner: 2) (state=9)
+> [Checker] Execute 2: MUTEX_UNLOCK(mutex: 0, owner: 1) (stack depth: 4, state: 10, 0 interleaves)
+> [Checker] INDEPENDENT Transitions:
+> [Checker]   MUTEX_ASYNC_LOCK(mutex: 0, owner: 2) (state=8)
+> [Checker]   MUTEX_UNLOCK(mutex: 0, owner: 1) (state=10)
+> [Checker] Execute 1: MUTEX_WAIT(mutex: 0, owner: 1) (stack depth: 5, state: 11, 0 interleaves)
+> [Checker] Dependent Transitions:
+> [Checker]   MUTEX_UNLOCK(mutex: 0, owner: 1) (state=10)
+> [Checker]   MUTEX_WAIT(mutex: 0, owner: 1) (state=11)
+> [Checker] Execute 1: MUTEX_UNLOCK(mutex: 0, owner: -1) (stack depth: 6, state: 12, 0 interleaves)
+> [Checker] Dependent Transitions:
+> [Checker]   MUTEX_UNLOCK(mutex: 0, owner: 1) (state=10)
+> [Checker]   MUTEX_UNLOCK(mutex: 0, owner: -1) (state=12)
+> [Checker] There remains 0 actors, but none to interleave (depth 8).
+> [Checker] Execution came to an end at 2;1;2;2;1;1;0 (state: 13, depth: 7)
+> [Checker] Backtracking from 2;1;2;2;1;1;0
 > [Checker] Execute 2: MUTEX_ASYNC_LOCK(mutex: 0, owner: 1) (stack depth: 3, state: 3, 0 interleaves)
 > [Checker] INDEPENDENT Transitions:
 > [Checker]   MUTEX_WAIT(mutex: 0, owner: 1) (state=2)
@@ -35,53 +60,31 @@ $ ${bindir:=.}/../../../bin/simgrid-mc --log=mc_dfs.thres:verbose --log=root.fmt
 > [Checker] Dependent Transitions:
 > [Checker]   MUTEX_ASYNC_LOCK(mutex: 0, owner: 1) (state=1)
 > [Checker]   MUTEX_ASYNC_LOCK(mutex: 0, owner: 1) (state=3)
-> [Checker] Execute 1: MUTEX_UNLOCK(mutex: 0, owner: 2) (stack depth: 4, state: 8, 0 interleaves)
+> [Checker] Execute 1: MUTEX_UNLOCK(mutex: 0, owner: 2) (stack depth: 4, state: 14, 0 interleaves)
 > [Checker] INDEPENDENT Transitions:
 > [Checker]   MUTEX_ASYNC_LOCK(mutex: 0, owner: 1) (state=3)
-> [Checker]   MUTEX_UNLOCK(mutex: 0, owner: 2) (state=8)
-> [Checker] Execute 2: MUTEX_WAIT(mutex: 0, owner: 2) (stack depth: 5, state: 9, 0 interleaves)
-> [Checker] Dependent Transitions:
-> [Checker]   MUTEX_UNLOCK(mutex: 0, owner: 2) (state=8)
-> [Checker]   MUTEX_WAIT(mutex: 0, owner: 2) (state=9)
-> [Checker] Execute 2: MUTEX_UNLOCK(mutex: 0, owner: -1) (stack depth: 6, state: 10, 0 interleaves)
-> [Checker] Dependent Transitions:
-> [Checker]   MUTEX_UNLOCK(mutex: 0, owner: 2) (state=8)
-> [Checker]   MUTEX_UNLOCK(mutex: 0, owner: -1) (state=10)
-> [Checker] Execution came to an end at 1;1;2;1;2;2;0 (state: 11, depth: 7)
-> [Checker] Backtracking from 1;1;2;1;2;2;0
-> [Checker] Execute 2: MUTEX_ASYNC_LOCK(mutex: 0, owner: 2) (stack depth: 1, state: 1, 0 interleaves)
-> [Checker] Execute 1: MUTEX_ASYNC_LOCK(mutex: 0, owner: 2) (stack depth: 2, state: 12, 0 interleaves)
-> [Checker] Dependent Transitions:
-> [Checker]   MUTEX_ASYNC_LOCK(mutex: 0, owner: 2) (state=1)
-> [Checker]   MUTEX_ASYNC_LOCK(mutex: 0, owner: 2) (state=12)
-> [Checker] Execute 2: MUTEX_WAIT(mutex: 0, owner: 2) (stack depth: 3, state: 13, 0 interleaves)
-> [Checker] INDEPENDENT Transitions:
-> [Checker]   MUTEX_ASYNC_LOCK(mutex: 0, owner: 2) (state=12)
-> [Checker]   MUTEX_WAIT(mutex: 0, owner: 2) (state=13)
-> [Checker] Execute 2: MUTEX_UNLOCK(mutex: 0, owner: 1) (stack depth: 4, state: 14, 0 interleaves)
-> [Checker] INDEPENDENT Transitions:
-> [Checker]   MUTEX_ASYNC_LOCK(mutex: 0, owner: 2) (state=12)
-> [Checker]   MUTEX_UNLOCK(mutex: 0, owner: 1) (state=14)
-> [Checker] Execute 1: MUTEX_WAIT(mutex: 0, owner: 1) (stack depth: 5, state: 15, 0 interleaves)
+> [Checker]   MUTEX_UNLOCK(mutex: 0, owner: 2) (state=14)
+> [Checker] Execute 2: MUTEX_WAIT(mutex: 0, owner: 2) (stack depth: 5, state: 15, 0 interleaves)
 > [Checker] Dependent Transitions:
-> [Checker]   MUTEX_UNLOCK(mutex: 0, owner: 1) (state=14)
-> [Checker]   MUTEX_WAIT(mutex: 0, owner: 1) (state=15)
-> [Checker] Execute 1: MUTEX_UNLOCK(mutex: 0, owner: -1) (stack depth: 6, state: 16, 0 interleaves)
+> [Checker]   MUTEX_UNLOCK(mutex: 0, owner: 2) (state=14)
+> [Checker]   MUTEX_WAIT(mutex: 0, owner: 2) (state=15)
+> [Checker] Execute 2: MUTEX_UNLOCK(mutex: 0, owner: -1) (stack depth: 6, state: 16, 0 interleaves)
 > [Checker] Dependent Transitions:
-> [Checker]   MUTEX_UNLOCK(mutex: 0, owner: 1) (state=14)
+> [Checker]   MUTEX_UNLOCK(mutex: 0, owner: 2) (state=14)
 > [Checker]   MUTEX_UNLOCK(mutex: 0, owner: -1) (state=16)
-> [Checker] Execution came to an end at 2;1;2;2;1;1;0 (state: 17, depth: 7)
-> [Checker] Backtracking from 2;1;2;2;1;1;0
+> [Checker] There remains 0 actors, but none to interleave (depth 8).
+> [Checker] Execution came to an end at 1;1;2;1;2;2;0 (state: 17, depth: 7)
+> [Checker] Backtracking from 1;1;2;1;2;2;0
 > [Checker] DFS exploration ended. 17 unique states visited; 3 backtracks (21 transition replays, 2 states visited overall)
 
 $ ${bindir:=.}/../../../bin/simgrid-mc --cfg=model-check/sleep-set:true -- ${bindir:=.}/s4u-synchro-mutex --cfg=actors:2 --log=s4u_test.thres:critical
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'model-check/sleep-set' to 'true'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'actors' to '2'
 > [0.000000] [mc_dfs/INFO] Start a DFS exploration. Reduction is: dpor.
-> [0.000000] [mc_dfs/INFO] DFS exploration ended. 128 unique states visited; 26 backtracks (296 transition replays, 143 states visited overall)
+> [0.000000] [mc_dfs/INFO] DFS exploration ended. 127 unique states visited; 25 backtracks (286 transition replays, 135 states visited overall)
 
 $ ${bindir:=.}/../../../bin/simgrid-mc --cfg=model-check/sleep-set:true -- ${bindir:=.}/s4u-synchro-mutex  --cfg=actors:3 --log=s4u_test.thres:critical
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'model-check/sleep-set' to 'true'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'actors' to '3'
 > [0.000000] [mc_dfs/INFO] Start a DFS exploration. Reduction is: dpor.
-> [0.000000] [mc_dfs/INFO] DFS exploration ended. 4645 unique states visited; 1082 backtracks (18004 transition replays, 12278 states visited overall)
+> [0.000000] [mc_dfs/INFO] DFS exploration ended. 4489 unique states visited; 989 backtracks (16546 transition replays, 11069 states visited overall)
\ No newline at end of file
index 54e641e..c4449b1 100644 (file)
@@ -3,4 +3,4 @@
 $ ${bindir:=.}/../../../bin/simgrid-mc --cfg=model-check/sleep-set:true --log=mc_dfs.thres:info --log=root.fmt="[Checker]%e%m%n" -- ${bindir:=.}/s4u-synchro-semaphore --log=sem_test.thres:critical --log=root.fmt="[App%e%e%e%e]%e%m%n"
 > [Checker] Configuration change: Set 'model-check/sleep-set' to 'true'
 > [Checker] Start a DFS exploration. Reduction is: dpor.
-> [Checker] DFS exploration ended. 33 unique states visited; 9 backtracks (125 transition replays, 84 states visited overall)
+> [Checker] DFS exploration ended. 30 unique states visited; 6 backtracks (67 transition replays, 32 states visited overall)
index 447496d..5bb5de2 100644 (file)
@@ -10,4 +10,4 @@ $ ../../../smpi_script/bin/smpirun -wrapper "${bindir:=.}/../../../bin/simgrid-m
 > [0.000000] [mc_comm_determinism/INFO] The recv communications pattern of the actor 0 is different! Different source for communication #1
 > [0.000000] [mc_comm_determinism/INFO] Send-deterministic : Yes
 > [0.000000] [mc_comm_determinism/INFO] Recv-deterministic : No
-> [0.000000] [mc_dfs/INFO] DFS exploration ended. 242 unique states visited; 68 backtracks (612 transition replays, 303 states visited overall)
\ No newline at end of file
+> [0.000000] [mc_dfs/INFO] DFS exploration ended. 110 unique states visited; 21 backtracks (189 transition replays, 59 states visited overall)
\ No newline at end of file
index 6c9b91c..c5dab05 100644 (file)
@@ -9,10 +9,10 @@ $ ${bindir:=.}/../../bin/simgrid-mc --cfg=model-check/setenv:LD_PRELOAD=${libdir
 > The thread 0 is terminating.
 > The thread 1 is terminating.
 > User's main is terminating.
-> The thread 0 is terminating.
 > The thread 1 is terminating.
+> The thread 0 is terminating.
 > User's main is terminating.
-> The thread 1 is terminating.
 > The thread 0 is terminating.
+> The thread 1 is terminating.
 > User's main is terminating.
 > [0.000000] [mc_dfs/INFO] DFS exploration ended. 23 unique states visited; 3 backtracks (27 transition replays, 2 states visited overall)
index c6146c5..a839f12 100644 (file)
@@ -12,12 +12,6 @@ $ ${bindir:=.}/../../bin/simgrid-mc --cfg=model-check/setenv:LD_PRELOAD=${libdir
 > The thread 0 is terminating.
 > The thread 1 is terminating.
 > User's main is terminating.
-> The thread 0 is terminating.
-> The thread 1 is terminating.
-> User's main is terminating.
-> The thread 0 is terminating.
-> The thread 1 is terminating.
-> User's main is terminating.
 > [0.000000] [mc_global/INFO] **************************
 > [0.000000] [mc_global/INFO] *** DEADLOCK DETECTED ***
 > [0.000000] [mc_global/INFO] **************************
@@ -35,4 +29,4 @@ $ ${bindir:=.}/../../bin/simgrid-mc --cfg=model-check/setenv:LD_PRELOAD=${libdir
 > [0.000000] [mc_global/INFO]   3: MUTEX_ASYNC_LOCK(mutex: 0, owner: 2)
 > [0.000000] [mc_global/INFO]   0: 
 > [0.000000] [mc_Session/INFO] You can debug the problem (and see the whole details) by rerunning out of simgrid-mc with --cfg=model-check/replay:'2;2;3;2;3;3;0'
-> [0.000000] [mc_dfs/INFO] DFS exploration ended. 38 unique states visited; 4 backtracks (52 transition replays, 11 states visited overall)
\ No newline at end of file
+> [0.000000] [mc_dfs/INFO] DFS exploration ended. 19 unique states visited; 2 backtracks (22 transition replays, 2 states visited overall)
\ No newline at end of file
index 0766ba3..22a7bdf 100644 (file)
@@ -5,4 +5,4 @@ $ ${bindir:=.}/../../bin/simgrid-mc --cfg=model-check/sleep-set:true --cfg=model
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'model-check/sleep-set' to 'true'
 > [0.000000] [sthread/INFO] Starting the simulation.
 > [0.000000] [mc_dfs/INFO] Start a DFS exploration. Reduction is: dpor.
-> [0.000000] [mc_dfs/INFO] DFS exploration ended. 719 unique states visited; 83 backtracks (1854 transition replays, 1053 states visited overall)
+> [0.000000] [mc_dfs/INFO] DFS exploration ended. 317 unique states visited; 32 backtracks (683 transition replays, 335 states visited overall)
index 97cf05a..d407e5b 100644 (file)
@@ -114,7 +114,7 @@ public:
   }
   void mark_done() { this->state_ = InterleavingType::done; }
 
-  inline Transition* get_transition(unsigned times_considered)
+  inline Transition* get_transition(unsigned times_considered) const
   {
     xbt_assert(times_considered < this->pending_transitions_.size(),
                "Actor %ld does not have a state available transition with `times_considered = %u`,\n"
index ce8daed..655ef6e 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "src/mc/api/State.hpp"
 #include "src/mc/api/guide/BasicGuide.hpp"
+#include "src/mc/api/guide/WaitGuide.hpp"
 #include "src/mc/explo/Exploration.hpp"
 #include "src/mc/mc_config.hpp"
 
@@ -16,9 +17,25 @@ namespace simgrid::mc {
 
 long State::expended_states_ = 0;
 
-State::State(RemoteApp& remote_app) : num_(++expended_states_), guide(std::make_unique<BasicGuide>())
+State::State(const State& other)
+    : transition_(other.transition_)
+    , num_(other.num_)
+    , system_state_(other.system_state_)
+    , parent_state_(nullptr)
+    , guide_(other.guide_)
+    , sleep_set_(other.sleep_set_)
 {
-  remote_app.get_actors_status(guide->actors_to_run_);
+}
+
+State::State(RemoteApp& remote_app) : num_(++expended_states_)
+{
+  XBT_VERB("Creating a guide for the state");
+  if (_sg_mc_guided == "none")
+    guide_ = std::make_shared<BasicGuide>();
+  if (_sg_mc_guided == "nb_wait")
+    guide_ = std::make_shared<WaitGuide>();
+
+  remote_app.get_actors_status(guide_->actors_to_run_);
 
   /* Stateful model checking */
   if ((_sg_mc_checkpoint > 0 && (num_ % _sg_mc_checkpoint == 0)) || _sg_mc_termination)
@@ -26,10 +43,16 @@ State::State(RemoteApp& remote_app) : num_(++expended_states_), guide(std::make_
                                                             *remote_app.get_remote_process_memory());
 }
 
-State::State(RemoteApp& remote_app, const State* parent_state)
-    : num_(++expended_states_), parent_state_(parent_state), guide(std::make_unique<BasicGuide>())
+State::State(RemoteApp& remote_app, const State* parent_state) : num_(++expended_states_), parent_state_(parent_state)
 {
-  remote_app.get_actors_status(guide->actors_to_run_);
+
+  if (_sg_mc_guided == "none")
+    guide_ = std::make_shared<BasicGuide>();
+  if (_sg_mc_guided == "nb_wait")
+    guide_ = std::make_shared<WaitGuide>();
+  *guide_ = *(parent_state->guide_);
+
+  remote_app.get_actors_status(guide_->actors_to_run_);
 
   /* Stateful model checking */
   if ((_sg_mc_checkpoint > 0 && (num_ % _sg_mc_checkpoint == 0)) || _sg_mc_termination)
@@ -44,10 +67,10 @@ State::State(RemoteApp& remote_app, const State* parent_state)
     for (auto& [aid, transition] : parent_state_->get_sleep_set()) {
       if (not parent_state_->get_transition()->depends(&transition)) {
         sleep_set_.try_emplace(aid, transition);
-        if (guide->actors_to_run_.count(aid) != 0) {
+        if (guide_->actors_to_run_.count(aid) != 0) {
           XBT_DEBUG("Actor %ld will not be explored, for it is in the sleep set", aid);
 
-          guide->actors_to_run_.at(aid).mark_done();
+          guide_->actors_to_run_.at(aid).mark_done();
         }
       } else
         XBT_DEBUG("Transition >>%s<< removed from the sleep set because it was dependent with >>%s<<",
@@ -58,7 +81,7 @@ State::State(RemoteApp& remote_app, const State* parent_state)
 
 std::size_t State::count_todo() const
 {
-  return boost::range::count_if(this->guide->actors_to_run_, [](auto& pair) { return pair.second.is_todo(); });
+  return boost::range::count_if(this->guide_->actors_to_run_, [](auto& pair) { return pair.second.is_todo(); });
 }
 
 Transition* State::get_transition() const
@@ -68,8 +91,8 @@ Transition* State::get_transition() const
 
 aid_t State::next_transition() const
 {
-  XBT_DEBUG("Search for an actor to run. %zu actors to consider", guide->actors_to_run_.size());
-  for (auto const& [aid, actor] : guide->actors_to_run_) {
+  XBT_DEBUG("Search for an actor to run. %zu actors to consider", guide_->actors_to_run_.size());
+  for (auto const& [aid, actor] : guide_->actors_to_run_) {
     /* Only consider actors (1) marked as interleaving by the checker and (2) currently enabled in the application */
     if (not actor.is_todo() || not actor.is_enabled() || actor.is_done()) {
       if (not actor.is_todo())
@@ -91,17 +114,20 @@ aid_t State::next_transition() const
 
 std::pair<aid_t, double> State::next_transition_guided() const
 {
-  return guide->next_transition();
+  return guide_->next_transition();
 }
 
 // This should be done in GuidedState, or at least interact with it
 void State::execute_next(aid_t next, RemoteApp& app)
 {
+  // First, warn the guide, so it knows how to build a proper child state
+  guide_->execute_next(next, app);
+
   // This actor is ready to be executed. Execution involves three phases:
 
   // 1. Identify the appropriate ActorState to prepare for execution
   // when simcall_handle will be called on it
-  auto& actor_state                        = guide->actors_to_run_.at(next);
+  auto& actor_state                        = guide_->actors_to_run_.at(next);
   const unsigned times_considered          = actor_state.do_consider();
   const auto* expected_executed_transition = actor_state.get_transition(times_considered);
   xbt_assert(expected_executed_transition != nullptr,
index 1dd6ecc..9288788 100644 (file)
@@ -43,7 +43,7 @@ class XBT_PRIVATE State : public xbt::Extendable<State> {
       and for guided model-checking */
   const State* parent_state_;
 
-  std::unique_ptr<GuidedState> guide;
+  std::shared_ptr<GuidedState> guide_;
 
   /* Sleep sets are composed of the actor and the corresponding transition that made it being added to the sleep
    * set. With this information, it is check whether it should be removed from it or not when exploring a new
@@ -53,6 +53,7 @@ class XBT_PRIVATE State : public xbt::Extendable<State> {
 public:
   explicit State(RemoteApp& remote_app);
   explicit State(RemoteApp& remote_app, const State* parent_state);
+  explicit State(const State& other);
   /* Returns a positive number if there is another transition to pick, or -1 if not */
   aid_t next_transition() const; // this function should disapear as it is redundant with the next one
 
@@ -67,17 +68,21 @@ public:
   long get_num() const { return num_; }
   std::size_t count_todo() const;
 
-  void consider_one(aid_t aid) { guide->consider_one(aid); }
-  void consider_best() { guide->consider_best(); }
-  void consider_all() { guide->consider_all(); }
+  /* Marking as TODO some actor in this state:
+   *  + consider_one mark aid actor (and assert it is possible)
+   *  + consider_best ensure one actor is marked by eventually marking the best regarding its guiding methode
+   *  + conside_all mark all enabled actor that are not done yet */
+  void consider_one(aid_t aid) { guide_->consider_one(aid); }
+  void consider_best() { guide_->consider_best(); }
+  void consider_all() { guide_->consider_all(); }
 
-  bool is_actor_done(aid_t actor) const { return guide->actors_to_run_.at(actor).is_done(); }
+  bool is_actor_done(aid_t actor) const { return guide_->actors_to_run_.at(actor).is_done(); }
   Transition* get_transition() const;
   void set_transition(Transition* t) { transition_ = t; }
-  std::map<aid_t, ActorState> const& get_actors_list() const { return guide->actors_to_run_; }
+  std::map<aid_t, ActorState> const& get_actors_list() const { return guide_->actors_to_run_; }
 
-  unsigned long get_actor_count() const { return guide->actors_to_run_.size(); }
-  bool is_actor_enabled(aid_t actor) { return guide->actors_to_run_.at(actor).is_enabled(); }
+  unsigned long get_actor_count() const { return guide_->actors_to_run_.size(); }
+  bool is_actor_enabled(aid_t actor) { return guide_->actors_to_run_.at(actor).is_enabled(); }
 
   Snapshot* get_system_state() const { return system_state_.get(); }
   void set_system_state(std::shared_ptr<Snapshot> state) { system_state_ = std::move(state); }
index c550675..62367a2 100644 (file)
@@ -9,9 +9,10 @@
 namespace simgrid::mc {
 
 /** Basic MC guiding class which corresponds to no guide at all (random choice) */
-// Not Yet fully implemented
 class BasicGuide : public GuidedState {
 public:
+  void operator=(const GuidedState&) { return; }
+
   std::pair<aid_t, double> next_transition() const override
   {
     for (auto const& [aid, actor] : actors_to_run_) {
diff --git a/src/mc/api/guide/WaitGuide.hpp b/src/mc/api/guide/WaitGuide.hpp
new file mode 100644 (file)
index 0000000..a18f6e3
--- /dev/null
@@ -0,0 +1,80 @@
+/* Copyright (c) 2007-2023. The SimGrid Team. All rights reserved.          */
+
+/* This program 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_MC_WAITGUIDE_HPP
+#define SIMGRID_MC_WAITGUIDE_HPP
+
+#include "src/mc/transition/Transition.hpp"
+
+namespace simgrid::mc {
+
+/** Wait MC guiding class that aims at minimizing the number of in-fly communication.
+ *  When possible, it will try to take the wait transition. */
+class WaitGuide : public GuidedState {
+  double taken_wait_ = 0;
+  bool taking_wait_  = false;
+
+public:
+  void operator=(const WaitGuide& guide) { taken_wait_ = guide.taken_wait_; }
+
+  bool is_transition_wait(Transition::Type type) const
+  {
+    return type == Transition::Type::WAITANY or type == Transition::Type::BARRIER_WAIT or
+           type == Transition::Type::MUTEX_WAIT or type == Transition::Type::SEM_WAIT;
+  }
+
+  std::pair<aid_t, double> next_transition() const override
+  {
+    std::pair<aid_t, double> if_no_wait = std::make_pair(-1, 0.0);
+    for (auto const& [aid, actor] : actors_to_run_) {
+      if (not actor.is_todo() || not actor.is_enabled() || actor.is_done())
+        continue;
+      if (is_transition_wait(actor.get_transition(actor.get_times_considered())->type_))
+        return std::make_pair(aid, -(taken_wait_ + 1));
+      if_no_wait = std::make_pair(aid, -taken_wait_);
+    }
+    return if_no_wait;
+  }
+
+  /** If we are taking a wait transition, and last transition wasn't a wait, we need to increment the number
+   *  of wait taken. On the opposite, if we took a wait before, and now we are taking another transition, we need
+   *  to decrease the count. */
+  void execute_next(aid_t aid, RemoteApp& app) override
+  {
+    auto& actor = actors_to_run_.at(aid);
+    if ((not taking_wait_) and is_transition_wait(actor.get_transition(actor.get_times_considered())->type_)) {
+      taken_wait_++;
+      taking_wait_ = true;
+      return;
+    }
+    if (taking_wait_ and (not is_transition_wait(actor.get_transition(actor.get_times_considered())->type_))) {
+      taken_wait_--;
+      taking_wait_ = false;
+      return;
+    }
+  }
+
+  void consider_best() override
+  {
+    const auto& [aid, _] = this->next_transition();
+    auto actor           = actors_to_run_.find(aid);
+    if (actor != actors_to_run_.end()) {
+      actor->second.mark_todo();
+      return;
+    }
+    for (auto& [_, actor] : actors_to_run_) {
+      if (actor.is_todo())
+        return;
+      if (actor.is_enabled() and not actor.is_done()) {
+        actor.mark_todo();
+        return;
+      }
+    }
+  }
+};
+
+} // namespace simgrid::mc
+
+#endif
index 2446342..55395e1 100644 (file)
@@ -133,8 +133,8 @@ void DFSExplorer::run()
     auto [next, _] = state->next_transition_guided();
 
     if (next < 0) { // If there is no more transition in the current state, backtrack.
-      XBT_DEBUG("There remains %lu actors, but none to interleave (depth %zu).", state->get_actor_count(),
-                stack_.size() + 1);
+      XBT_VERB("There remains %lu actors, but none to interleave (depth %zu).", state->get_actor_count(),
+               stack_.size() + 1);
 
       if (state->get_actor_count() == 0) {
         get_remote_app().finalize_app();
@@ -163,7 +163,6 @@ void DFSExplorer::run()
 
     /* Create the new expanded state (copy the state of MCed into our MCer data) */
     std::unique_ptr<State> next_state;
-
     next_state = std::make_unique<State>(get_remote_app(), state);
     on_state_creation_signal(next_state.get(), get_remote_app());
 
@@ -174,18 +173,22 @@ void DFSExplorer::run()
     XBT_DEBUG("Marking Transition >>%s<< of process %ld done and adding it to the sleep set",
               state->get_transition()->to_string().c_str(), state->get_transition()->aid_);
     state->add_sleep_set(state->get_transition()); // Actors are marked done when they are considerd in ActorState
-    
+
     /* DPOR persistent set procedure:
      * for each new transition considered, check if it depends on any other previous transition executed before it
      * on another process. If there exists one, find the more recent, and add its process to the interleave set.
      * If the process is not enabled at this  point, then add every enabled process to the interleave */
     if (reduction_mode_ == ReductionMode::dpor) {
-      aid_t issuer_id = state->get_transition()->aid_;
-      for (auto i = stack_.rbegin(); i != stack_.rend(); ++i) {
-        State* prev_state = i->get();
+      aid_t issuer_id   = state->get_transition()->aid_;
+      stack_t tmp_stack;
+      for (auto& state : stack_)
+        tmp_stack.push_back(std::make_shared<State>(State(*state)));
+      while (not tmp_stack.empty()) {
+        State* prev_state = tmp_stack.back().get();
         if (state->get_transition()->aid_ == prev_state->get_transition()->aid_) {
           XBT_DEBUG("Simcall >>%s<< and >>%s<< with same issuer %ld", state->get_transition()->to_string().c_str(),
                     prev_state->get_transition()->to_string().c_str(), issuer_id);
+          tmp_stack.pop_back();
           continue;
         } else if (prev_state->get_transition()->depends(state->get_transition())) {
           XBT_VERB("Dependent Transitions:");
@@ -193,15 +196,17 @@ void DFSExplorer::run()
           XBT_VERB("  %s (state=%ld)", state->get_transition()->to_string().c_str(), state->get_num());
 
           if (prev_state->is_actor_enabled(issuer_id)) {
-            if (not prev_state->is_actor_done(issuer_id))
+            if (not prev_state->is_actor_done(issuer_id)) {
               prev_state->consider_one(issuer_id);
-            else
+              opened_states.emplace_back(tmp_stack);
+            } else
               XBT_DEBUG("Actor %ld is already in done set: no need to explore it again", issuer_id);
           } else {
             XBT_DEBUG("Actor %ld is not enabled: DPOR may be failing. To stay sound, we are marking every enabled "
                       "transition as todo",
                       issuer_id);
             prev_state->consider_all();
+            opened_states.emplace_back(tmp_stack);
           }
           break;
         } else {
@@ -209,6 +214,7 @@ void DFSExplorer::run()
           XBT_VERB("  %s (state=%ld)", prev_state->get_transition()->to_string().c_str(), prev_state->get_num());
           XBT_VERB("  %s (state=%ld)", state->get_transition()->to_string().c_str(), state->get_num());
         }
+        tmp_stack.pop_back();
       }
     }
 
@@ -219,22 +225,23 @@ void DFSExplorer::run()
     if (_sg_mc_max_visited_states > 0)
       visited_state_ = visited_states_.addVisitedState(next_state->get_num(), next_state.get(), get_remote_app());
 
+    stack_.push_back(std::move(next_state));
+
     /* 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 */
       if (reduction_mode_ == ReductionMode::dpor)
-        next_state->consider_best(); // Take only one transition if DPOR: others may be considered later if required
-      else
-        next_state->consider_all();
-
-      dot_output("\"%ld\" -> \"%ld\" [%s];\n", state->get_num(), next_state->get_num(),
+        stack_.back()->consider_best(); // Take only one transition if DPOR: others may be considered later if required
+      else {
+        stack_.back()->consider_all();
+        opened_states.emplace_back(stack_);
+      }
+      dot_output("\"%ld\" -> \"%ld\" [%s];\n", state->get_num(), stack_.back()->get_num(),
                  state->get_transition()->dot_string().c_str());
     } else
       dot_output("\"%ld\" -> \"%ld\" [%s];\n", state->get_num(),
                  visited_state_->original_num_ == -1 ? visited_state_->num_ : visited_state_->original_num_,
                  state->get_transition()->dot_string().c_str());
-
-    stack_.push_back(std::move(next_state));
   }
 
   log_state();
@@ -247,54 +254,61 @@ void DFSExplorer::backtrack()
   on_backtracking_signal(get_remote_app());
   get_remote_app().check_deadlock();
 
+  // if no backtracking point, then set the stack_ to empty so we can end the exploration
+  if (opened_states.size() == 0) {
+    stack_ = std::list<std::shared_ptr<State>>();
+    return;
+  }
+
   /* We may backtrack from somewhere either because it's leaf, or because every enabled process are in done/sleep set.
    * In the first case, we need to remove the last transition corresponding to the Finalize */
   if (stack_.back()->get_transition()->aid_ == 0)
     stack_.pop_back();
 
-  /* 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. */
-  bool found_backtracking_point = false;
-  while (not stack_.empty() && not found_backtracking_point) {
-    std::unique_ptr<State> state = std::move(stack_.back());
-
-    stack_.pop_back();
+  stack_t backtrack;
+  double min_dist = std::numeric_limits<double>::infinity();
+  aid_t min_aid   = -1;
+  for (auto& stack : opened_states) {
+    auto [aid, dist] = stack.back()->next_transition_guided();
+    if (aid == -1)
+      continue;
+    if (dist < min_dist) {
+      min_dist  = dist;
+      min_aid   = aid;
+      backtrack = stack;
+    }
+  }
 
+  if (min_aid == -1) {
+    stack_ = std::list<std::shared_ptr<State>>();
+    return;
+  }
 
-    if (state->count_todo() == 0) { // Empty interleaving set: exploration at this level is over
-      XBT_DEBUG("Delete state %ld at depth %zu", state->get_num(), stack_.size() + 1);
+  if (backtrack.back()->count_todo() <= 1)
+    opened_states.pop_back();
 
-    } else {
-      XBT_DEBUG("Back-tracking to state %ld at depth %zu: %lu transitions left to be explored", state->get_num(),
-                stack_.size() + 1, state->count_todo());
-      stack_.push_back(
-          std::move(state)); // Put it back on the stack so we can explore the next transition of the interleave
-      found_backtracking_point = true;
-    }
+  /* If asked to rollback on a state that has a snapshot, restore it */
+  State* last_state = backtrack.back().get();
+  if (const auto* system_state = last_state->get_system_state()) {
+    system_state->restore(*get_remote_app().get_remote_process_memory());
+    on_restore_system_state_signal(last_state, get_remote_app());
+    stack_ = backtrack;
+    return;
   }
 
-  if (found_backtracking_point) {
-    /* If asked to rollback on a state that has a snapshot, restore it */
-    State* last_state = stack_.back().get();
-    if (const auto* system_state = last_state->get_system_state()) {
-      system_state->restore(*get_remote_app().get_remote_process_memory());
-      on_restore_system_state_signal(last_state, get_remote_app());
-      return;
-    }
-
-    /* if no snapshot, we need to restore the initial state and replay the transitions */
-    get_remote_app().restore_initial_state();
-    on_restore_initial_state_signal(get_remote_app());
-
-    /* Traverse the stack from the state at position start and re-execute the transitions */
-    for (std::unique_ptr<State> const& state : stack_) {
-      if (state == stack_.back()) /* If we are arrived on the target state, don't replay the outgoing transition */
-        break;
-      state->get_transition()->replay(get_remote_app());
-      on_transition_replay_signal(state->get_transition(), get_remote_app());
-      visited_states_count_++;
-    }
-  } // If no backtracing point, then the stack is empty and the exploration is over
+  /* if no snapshot, we need to restore the initial state and replay the transitions */
+  get_remote_app().restore_initial_state();
+  on_restore_initial_state_signal(get_remote_app());
+  /* Traverse the stack from the state at position start and re-execute the transitions */
+  for (std::shared_ptr<State> const& state : backtrack) {
+    if (state == backtrack.back()) /* If we are arrived on the target state, don't replay the outgoing transition */
+      break;
+    state->get_transition()->replay(get_remote_app());
+    on_transition_replay_signal(state->get_transition(), get_remote_app());
+    visited_states_count_++;
+  }
+  stack_ = backtrack;
+  XBT_DEBUG(">> Backtracked to %s", get_record_trace().to_string().c_str());
 }
 
 DFSExplorer::DFSExplorer(const std::vector<char*>& args, bool with_dpor, bool need_memory_info)
@@ -319,14 +333,16 @@ DFSExplorer::DFSExplorer(const std::vector<char*>& args, bool with_dpor, bool ne
 
   XBT_DEBUG("**************************************************");
 
+  stack_.push_back(std::move(initial_state));
+
   /* Get an enabled actor and insert it in the interleave set of the initial state */
   XBT_DEBUG("Initial state. %lu actors to consider", initial_state->get_actor_count());
   if (reduction_mode_ == ReductionMode::dpor)
-    initial_state->consider_best();
-  else
-    initial_state->consider_all();
-
-  stack_.push_back(std::move(initial_state));
+    stack_.back()->consider_best();
+  else {
+    stack_.back()->consider_all();
+    opened_states.emplace_back(stack_);
+  }
 }
 
 Exploration* create_dfs_exploration(const std::vector<char*>& args, bool with_dpor)
index 353e00c..c176baf 100644 (file)
 
 namespace simgrid::mc {
 
+typedef std::list<std::shared_ptr<State>> stack_t;
+
 class XBT_PRIVATE DFSExplorer : public Exploration {
+
   XBT_DECLARE_ENUM_CLASS(ReductionMode, none, dpor);
 
   ReductionMode reduction_mode_;
@@ -86,9 +89,13 @@ private:
   void backtrack();
 
   /** Stack representing the position in the exploration graph */
-  std::list<std::unique_ptr<State>> stack_;
+  stack_t stack_;
   VisitedStates visited_states_;
   std::unique_ptr<VisitedState> visited_state_;
+
+  /** Opened states are states that still contains todo actors.
+   *  When backtracking, we pick a state from it*/
+  std::vector<stack_t> opened_states;
 };
 
 } // namespace simgrid::mc
index 3416d5c..663961d 100644 (file)
@@ -60,6 +60,14 @@ simgrid::config::Flag<bool> _sg_mc_sleep_set{
     "model-check/sleep-set", "Whether to enable the use of sleep-set in the reduction algorithm", false,
     [](bool) { _mc_cfg_cb_check("value to enable/disable the use of sleep-set in the reduction algorithm"); }};
 
+simgrid::config::Flag<std::string> _sg_mc_guided{
+    "model-check/guided-mc", "Specify the the kind of heuristic to use for guided model-checking", "none",
+    [](std::string_view value) {
+      if (value != "none" && value != "nb_wait")
+        xbt_die("configuration option 'model-check/reduction' can only take 'none' or 'dpor' as a value");
+    }};
+
+
 simgrid::config::Flag<int> _sg_mc_checkpoint{
     "model-check/checkpoint", "Specify the amount of steps between checkpoints during stateful model-checking "
                               "(default: 0 => stateless verification). If value=1, one checkpoint is saved for each "
index a900f7c..f411e7c 100644 (file)
@@ -27,5 +27,8 @@ extern "C" XBT_PUBLIC int _sg_mc_max_visited_states;
 extern XBT_PRIVATE simgrid::config::Flag<std::string> _sg_mc_dot_output_file;
 extern XBT_PRIVATE simgrid::config::Flag<bool> _sg_mc_termination;
 extern XBT_PUBLIC simgrid::config::Flag<bool> _sg_mc_sleep_set;
+extern XBT_PUBLIC simgrid::config::Flag<std::string> _sg_mc_guided;
+
+
 
 #endif
index be9826a..a5d5ffa 100644 (file)
@@ -213,7 +213,7 @@ void AppSide::handle_actors_status() const
 
   struct s_mc_message_actors_status_answer_t answer = {};
   answer.type                                       = MessageType::ACTORS_STATUS_REPLY_COUNT;
-  answer.count            = static_cast<int>(status.size());
+  answer.count                                      = static_cast<int>(status.size());
 
   xbt_assert(channel_.send(answer) == 0, "Could not send ACTORS_STATUS_REPLY msg");
   if (answer.count > 0) {
index f2ce4ab..84ad991 100644 (file)
@@ -47,7 +47,6 @@ std::string Transition::dot_string() const
 void Transition::replay(RemoteApp& app) const
 {
   replayed_transitions_++;
-
 #if SIMGRID_HAVE_MC
   app.handle_simcall(aid_, times_considered_, false);
   app.wait_for_requests();
index 05c2e70..6b58173 100644 (file)
@@ -528,9 +528,8 @@ void Request::start()
     comm_->increment_sent_messages_count(comm_->group()->rank(src_), comm_->group()->rank(dst_), tag_);
 
     void* buf = buf_;
-    if ((flags_ & MPI_REQ_SSEND) == 0 &&
-        ((flags_ & MPI_REQ_RMA) != 0 || (flags_ & MPI_REQ_BSEND) != 0 ||
-         static_cast<int>(size_) < smpi_cfg_detached_send_thresh())) {
+    if ((flags_ & MPI_REQ_SSEND) == 0 && ((flags_ & MPI_REQ_RMA) != 0 || (flags_ & MPI_REQ_BSEND) != 0 ||
+                                          static_cast<int>(size_) < smpi_cfg_detached_send_thresh())) {
       detached_    = true;
       XBT_DEBUG("Send request %p is detached", this);
       this->ref();
index 6cc2d4c..1703fe0 100644 (file)
@@ -616,6 +616,10 @@ set(MC_SRC
   src/mc/mc_private.hpp
   src/mc/mc_record.cpp
 
+  src/mc/api/guide/BasicGuide.hpp
+  src/mc/api/guide/GuidedState.hpp
+  src/mc/api/guide/WaitGuide.hpp
+  
   src/xbt/mmalloc/mm_interface.c
   )