Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mc-sog
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PMC-SOG
mc-sog
Commits
ea760dee
Commit
ea760dee
authored
2 years ago
by
Ghofrane Amaimi
Browse files
Options
Downloads
Patches
Plain Diff
add comments
parent
52169769
No related branches found
Branches containing commit
No related tags found
1 merge request
!6
Feature/ufscc emptiness check
Pipeline
#5016
passed
2 years ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/algorithm/CNDFS.cpp
+37
-16
37 additions, 16 deletions
src/algorithm/CNDFS.cpp
src/algorithm/CNDFS.h
+1
-1
1 addition, 1 deletion
src/algorithm/CNDFS.h
src/main.cpp
+1
-5
1 addition, 5 deletions
src/main.cpp
with
39 additions
and
22 deletions
src/algorithm/CNDFS.cpp
+
37
−
16
View file @
ea760dee
...
...
@@ -18,9 +18,10 @@
using
namespace
std
;
thread_local
bool
_cyan
{
false
};
thread_local
deque
<
CNDFS
::
_state
*>
mydeque
;
thread_local
deque
<
CNDFS
::
_state
*>
mydeque
;
thread_local
list
<
bool
>
mytempList
;
vector
<
pair
<
LDDState
*
,
const
spot
::
twa_graph_state
*>>
sharedPool
;
//vector<CNDFS::_state*> sharedPool;
CNDFS
::
CNDFS
(
ModelCheckBaseMT
*
mcl
,
const
spot
::
twa_graph_ptr
&
af
,
const
uint16_t
&
nbTh
)
:
mMcl
(
mcl
),
mAa
(
af
),
mNbTh
(
nbTh
)
{
...
...
@@ -86,7 +87,7 @@ std::ostream & operator<<(std::ostream & Str, CNDFS::_state* state) {
return
Str
;
}
//al
go line 22 test
//al
l visited accepting nodes (non seed, non red) should be red
atomic_bool
CNDFS
::
awaitCondition
(
_state
*
state
)
{
for
(
auto
qu
:
mydeque
)
...
...
@@ -119,8 +120,9 @@ void CNDFS::dfsRed(_state* state)
if
(
p
.
first
->
cyan
)
{
cout
<<
"cycle detected"
<<
endl
;
exit
(
1
);
exit
(
0
);
}
// unvisited and not red state
if
((
find
(
mydeque
.
begin
(),
mydeque
.
end
(),
state
)
!=
mydeque
.
end
())
&&
!
p
.
first
->
red
)
dfsRed
(
p
.
first
);
}
...
...
@@ -176,7 +178,8 @@ void CNDFS::computeSuccessors(_state *state)
{
// cout << "matched bdd " << matched << endl;
//new terminal state without successors
_state
*
nd
=
buildState
(
sog_current_state
->
Successors
.
at
(
i
).
first
,
// state_is_accepting() should only be called on automata with state-based acceptance
_state
*
nd
=
buildState
(
sog_current_state
->
Successors
.
at
(
i
).
first
,
const_cast
<
spot
::
state
*>
(
ii
->
dst
()),
static_cast
<
vector
<
pair
<
_state
*
,
int
>>>
(
NULL
),
mAa
->
state_is_accepting
(
ii
->
dst
()),
true
,
false
);
for
(
auto
pool
:
sharedPool
)
{
...
...
@@ -184,7 +187,11 @@ void CNDFS::computeSuccessors(_state *state)
{
nd
->
cyan
=
true
;
state
->
new_successors
.
push_back
(
make_pair
(
nd
,
transition
));
}
else
state
->
new_successors
.
push_back
(
make_pair
(
nd
,
transition
));
// state->new_successors.push_back(make_pair(pool,transition));
}
else
{
state
->
new_successors
.
push_back
(
make_pair
(
nd
,
transition
));
}
}
}
...
...
@@ -205,14 +212,15 @@ void CNDFS::dfsBlue(_state *state) {
cout
<<
"appel recursif "
<<
i
<<
endl
;
i
++
;
state
->
cyan
=
true
;
// sharedPool.push_back(state);
sharedPool
.
push_back
(
make_pair
(
state
->
left
,
state
->
right
));
computeSuccessors
(
state
);
//
cout << "state " << state << endl;
//
cout << "nbr of successors of the state "<< state->new_successors.size() << " with thread "<< idThread<< endl;
cout
<<
"
current
state "
<<
state
<<
endl
;
cout
<<
"nbr of successors of the
current
state "
<<
state
->
new_successors
.
size
()
<<
" with thread "
<<
idThread
<<
endl
;
for
(
auto
p
:
state
->
new_successors
)
{
// cout << "state " << p.first << endl;
while
((
p
.
first
->
cyan
==
false
)
&&
(
p
.
first
->
blue
==
false
))
while
((
!
p
.
first
->
cyan
)
&&
(
!
p
.
first
->
blue
))
{
dfsBlue
(
p
.
first
);
}
...
...
@@ -220,18 +228,31 @@ void CNDFS::dfsBlue(_state *state) {
state
->
blue
=
true
;
if
(
state
->
isAcceptance
)
{
cout
<<
"hello redDFS "
<<
endl
;
dfsRed
(
state
);
WaitForTestCompleted
(
state
);
std
::
lock_guard
<
std
::
mutex
>
lk
(
*
mMutex
);
cv
.
notify_all
();
for
(
auto
qu
:
mydeque
)
cout
<<
"Acceptance state detected "
<<
endl
;
if
(
state
->
left
->
isDeadLock
()
||
state
->
left
->
isDiv
())
{
qu
->
red
=
true
;
cout
<<
"cycle detected: an aggregate with deal_lock or live_lock"
<<
endl
;
exit
(
0
);
}
else
{
dfsRed
(
state
);
//looking for an accepting cycle
// the thread processed the current state waits for all visited accepting nodes (non seed, non red) to turn red
// the late red coloring forces the other acceptance states to be processed in post-order by the other threads
std
::
unique_lock
<
std
::
mutex
>
lk
(
*
mMutex
);
// WaitForTestCompleted(state);
while
(
!
awaitCondition
(
state
))
cv
.
wait
(
lk
);
// notify once we have unlocked - this is important to avoid a pessimization.
awaitCondition
(
state
)
=
true
;
cv
.
notify_all
();
for
(
auto
qu
:
mydeque
)
// prune other dfsRed
{
qu
->
red
=
true
;
}
}
cout
<<
"no cycle detected"
<<
endl
;
}
state
->
cyan
=
false
;
cout
<<
state
<<
endl
;
//
cout << state << endl;
}
spot
::
bdd_dict_ptr
*
CNDFS
::
m_dict_ptr
;
This diff is collapsed.
Click to expand it.
src/algorithm/CNDFS.h
+
1
−
1
View file @
ea760dee
...
...
@@ -27,7 +27,7 @@ private:
public:
typedef
struct
_state
{
LDDState
*
left
;
LDDState
*
left
;
const
spot
::
twa_graph_state
*
right
;
vector
<
pair
<
_state
*
,
int
>>
new_successors
;
atomic_bool
isAcceptance
{
false
};
...
...
This diff is collapsed.
Click to expand it.
src/main.cpp
+
1
−
5
View file @
ea760dee
...
...
@@ -523,13 +523,9 @@ int main(int argc, char **argv)
// TODO: Implement here Ghofrane's algorithms
if
(
algorithm
==
"UFSCC"
||
algorithm
==
"CNDFS"
)
{
std
::
cout
<<
"------------CNDFS-------------"
<<
std
::
endl
;
CNDFS
cndfs
(
mcl
,
af
,
2
);
CNDFS
cndfs
(
mcl
,
af
,
1
);
// If I increase the number of threads, a segmentation fault appears.
return
(
0
);
}
else
// run on the fly sequential model-checking
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment