Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DIVINE
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
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
paradise
mirror
DIVINE
Commits
4c730505
There was an error fetching the commit references. Please try again later.
Commit
4c730505
authored
5 years ago
by
Petr Rockai
Browse files
Options
Downloads
Patches
Plain Diff
MC: Make task_queue (and hence the weaver) more flexible.
parent
7de7b7c3
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
divine/mc/search.hpp
+24
-26
24 additions, 26 deletions
divine/mc/search.hpp
divine/mc/t-search.hpp
+9
-8
9 additions, 8 deletions
divine/mc/t-search.hpp
divine/mc/t-weaver.hpp
+25
-26
25 additions, 26 deletions
divine/mc/t-weaver.hpp
divine/mc/weaver.hpp
+38
-49
38 additions, 49 deletions
divine/mc/weaver.hpp
with
96 additions
and
109 deletions
divine/mc/search.hpp
+
24
−
26
View file @
4c730505
...
...
@@ -19,41 +19,40 @@
#pragma once
#include
<divine/mc/weaver.hpp>
namespace
divine
::
mc
namespace
divine
::
mc
::
task
{
template
<
typename
State
,
typename
Label
>
struct
GraphTasks
struct
Edge
{
struct
Edge
{
State
from
,
to
;
Label
label
;
bool
isnew
;
Edge
(
State
f
,
State
t
,
Label
l
,
bool
n
)
:
from
(
f
),
to
(
t
),
label
(
l
),
isnew
(
n
)
{}
};
struct
Expand
{
State
from
;
Expand
(
State
s
)
:
from
(
s
)
{}
};
State
from
,
to
;
Label
label
;
bool
isnew
;
Edge
(
State
f
,
State
t
,
Label
l
,
bool
n
)
:
from
(
f
),
to
(
t
),
label
(
l
),
isnew
(
n
)
{}
};
struct
Start
{};
using
TQ_
=
TaskQueue
<
GraphTasks
<
State
,
Label
>
,
Start
,
Expand
,
Edge
>
;
template
<
typename
State
>
struct
Expand
{
State
from
;
Expand
(
State
s
)
:
from
(
s
)
{}
};
}
namespace
divine
::
mc
{
template
<
typename
State
,
typename
Label
>
using
GraphTQ
=
t
ypename
GraphTasks
<
State
,
Label
>
::
TQ_
;
using
GraphTQ
=
t
ask_queue
<
task
::
Start
,
task
::
Expand
<
State
>
,
task
::
Edge
<
State
,
Label
>
>
;
template
<
typename
TQ
>
struct
Search
:
TQ
::
S
kel
template
<
typename
State
,
typename
Label
>
struct
Search
:
GraphTQ
<
State
,
Label
>
::
s
kel
eton
{
using
Edge
=
typename
TQ
::
Tasks
::
Edge
;
using
Expand
=
typename
TQ
::
Tasks
::
Expand
;
using
TQ
=
GraphTQ
<
State
,
Label
>
;
using
Edge
=
task
::
Edge
<
State
,
Label
>
;
using
Expand
=
task
::
Expand
<
State
>
;
using
TQ
::
S
kel
::
run
;
using
TQ
::
s
kel
eton
::
run
;
void
run
(
TQ
&
tq
,
Edge
e
)
{
...
...
@@ -61,5 +60,4 @@ namespace divine::mc
tq
.
template
add
<
Expand
>(
e
.
to
);
}
};
}
This diff is collapsed.
Click to expand it.
divine/mc/t-search.hpp
+
9
−
8
View file @
4c730505
...
...
@@ -26,15 +26,19 @@
namespace
divine
::
t_mc
{
enum
Label
{
Red
,
Black
};
using
TQ
=
mc
::
GraphTQ
<
int
,
Label
>
;
struct
Base
:
TQ
::
Skel
using
TQ
=
mc
::
GraphTQ
<
int
,
Label
>
;
using
Edge
=
mc
::
task
::
Edge
<
int
,
Label
>
;
using
Expand
=
mc
::
task
::
Expand
<
int
>
;
struct
Base
:
TQ
::
skeleton
{
brq
::
concurrent_hash_set
<
int
>
_states
;
using
TQ
::
S
kel
::
run
;
using
TQ
::
s
kel
eton
::
run
;
void
run
(
TQ
&
tq
,
typename
TQ
::
T
ask
s
::
Start
)
void
run
(
TQ
&
tq
,
mc
::
t
ask
::
Start
)
{
_states
.
insert
(
1
);
tq
.
add
<
Expand
>
(
1
);
...
...
@@ -126,13 +130,10 @@ namespace divine::t_mc
struct
Search
{
using
Edge
=
TQ
::
Tasks
::
Edge
;
using
Expand
=
TQ
::
Tasks
::
Expand
;
template
<
typename
B
>
auto
weave
(
B
builder
)
{
return
mc
::
Weaver
<
TQ
>
().
extend
(
mc
::
Search
<
TQ
>
(),
builder
);
return
mc
::
Weaver
<
TQ
>
().
extend
(
mc
::
Search
<
int
,
Label
>
(),
builder
);
}
TEST
(
fixed
)
...
...
This diff is collapsed.
Click to expand it.
divine/mc/t-weaver.hpp
+
25
−
26
View file @
4c730505
...
...
@@ -22,57 +22,56 @@
namespace
divine
::
t_mc
{
struct
T
ask
s
struct
t
ask
1
{
struct
T1
{
int
i
;
T1
(
int
i
)
:
i
(
i
)
{}
};
int
i
;
task1
(
int
i
)
:
i
(
i
)
{}
};
struct
T2
{
int
j
;
T2
(
int
j
)
:
j
(
j
)
{}
};
struct
task2
{
int
j
;
task2
(
int
j
)
:
j
(
j
)
{}
};
using
TQ
=
mc
::
T
ask
Q
ueue
<
Tasks
,
Tasks
::
T
1
,
T
ask
s
::
T
2
>
;
using
tq
=
mc
::
t
ask
_q
ueue
<
task
1
,
t
ask2
>
;
struct
M
achine1
:
TQ
::
S
kel
struct
m
achine1
:
tq
::
s
kel
eton
{
using
TQ
::
Skel
::
run
;
void
run
(
TQ
&
tq
,
Tasks
::
T1
t
)
using
tq
::
skeleton
::
run
;
void
run
(
tq
&
q
,
task1
t
)
{
if
(
t
.
i
<
10
)
t
q
.
add
<
T
2
>
(
t
.
i
+
1
);
q
.
add
<
task
2
>
(
t
.
i
+
1
);
}
};
struct
M
achine2
:
TQ
::
S
kel
struct
m
achine2
:
tq
::
s
kel
eton
{
using
TQ
::
Skel
::
run
;
void
run
(
TQ
&
tq
,
T2
t
)
using
tq
::
skeleton
::
run
;
void
run
(
tq
&
q
,
task2
t
)
{
t
q
.
add
<
T
1
>
(
t
.
j
+
1
);
q
.
add
<
task
1
>
(
t
.
j
+
1
);
}
};
struct
C
ounter
:
Tasks
struct
c
ounter
{
int
t1
=
0
,
t2
=
0
;
void
run
(
TQ
&
,
T
1
)
{
++
t1
;
}
void
run
(
TQ
&
,
T
2
)
{
++
t2
;
}
void
run
(
tq
&
,
task
1
)
{
++
t1
;
}
void
run
(
tq
&
,
task
2
)
{
++
t2
;
}
};
struct
Weave
{
TEST
(
basic
)
{
mc
::
Weaver
<
TQ
,
M
achine1
,
M
achine2
,
C
ounter
>
weaver
;
weaver
.
add
<
T
ask
s
::
T
1
>
(
3
);
mc
::
Weaver
<
tq
,
m
achine1
,
m
achine2
,
c
ounter
>
weaver
;
weaver
.
add
<
t
ask1
>
(
3
);
weaver
.
run
();
auto
&
ctr
=
weaver
.
machine
<
C
ounter
>
();
auto
&
ctr
=
weaver
.
machine
<
c
ounter
>
();
ASSERT_EQ
(
ctr
.
t1
,
5
);
ASSERT_EQ
(
ctr
.
t2
,
4
);
}
...
...
This diff is collapsed.
Click to expand it.
divine/mc/weaver.hpp
+
38
−
49
View file @
4c730505
...
...
@@ -19,76 +19,65 @@
#pragma once
#include
<deque>
namespace
divine
::
mc
namespace
divine
::
mc
::
task
{
struct
Start
{};
}
template
<
typename
...
>
struct
MachineSkel
;
template
<
typename
TS
,
typename
TQ
,
typename
Task
,
typename
...
Tasks
>
struct
MachineSkel
<
TS
,
TQ
,
Task
,
Tasks
...
>
:
MachineSkel
<
TS
,
TQ
,
Tasks
...
>
{
using
MachineSkel
<
TS
,
TQ
,
Tasks
...
>::
run
;
void
run
(
TQ
&
,
Task
)
{}
};
namespace
divine
::
mc
{
template
<
typename
...
>
struct
task_queue
;
template
<
typename
TS
,
typename
TQ
>
struct
MachineSkel
<
TS
,
TQ
>
:
TS
template
<
>
struct
task_queue
<>
{
void
run
();
void
clear
();
template
<
typename
P
>
bool
process_next
(
P
)
{
return
false
;
}
};
template
<
typename
T
ask
Struct
,
typename
...
T
ask
List
>
struct
T
ask
Q
ueue
template
<
typename
t
ask
,
typename
...
t
ask
s
>
struct
t
ask
_q
ueue
<
task
,
tasks
...
>
:
task_queue
<
tasks
...
>
{
using
TQ
=
TaskQueue
<
TaskStruct
,
TaskList
...
>
;
using
Tasks
=
TaskStruct
;
template
<
typename
TS
>
struct
ExtendTS
:
TaskStruct
,
TS
{};
using
next
=
task_queue
<
tasks
...
>
;
using
tq
=
task_queue
<
task
,
tasks
...
>
;
std
::
deque
<
task
>
_queue
;
template
<
typename
TS
,
typename
...
Extra
>
using
E
xtend
=
T
ask
Q
ueue
<
ExtendTS
<
TS
>
,
Extra
...,
T
ask
List
...
>
;
template
<
typename
...
ex
>
using
e
xtend
=
t
ask
_q
ueue
<
ex
...,
t
ask
s
...
>
;
using
Queues
=
std
::
tuple
<
std
::
deque
<
TaskList
>
...
>
;
Queues
_queues
;
template
<
typename
Task
,
typename
...
Args
>
template
<
typename
T
,
typename
...
Args
>
void
add
(
Args
...
args
)
{
std
::
get
<
std
::
deque
<
Task
>
>
(
_queues
).
emplace_back
(
args
...
);
if
constexpr
(
std
::
is_convertible_v
<
T
,
task
>
)
_queue
.
emplace_back
(
args
...
);
else
next
::
template
add
<
T
>(
args
...
);
}
template
<
int
i
=
0
>
void
clear
()
{
if
constexpr
(
i
<
std
::
tuple_size_v
<
Queues
>
)
{
std
::
get
<
i
>
(
_queues
).
clear
();
return
clear
<
i
+
1
>
();
}
_queue
.
clear
();
next
::
clear
();
}
template
<
int
i
=
0
,
typename
P
>
template
<
typename
P
>
bool
process_next
(
P
process
)
{
if
constexpr
(
i
<
std
::
tuple_size_v
<
Queues
>
)
if
(
_queue
.
empty
()
)
return
next
::
process_next
(
process
);
else
{
auto
&
q
=
std
::
get
<
i
>
(
_queues
);
if
(
!
q
.
empty
()
)
{
process
(
q
.
front
()
);
q
.
pop_front
();
return
true
;
}
return
process_next
<
i
+
1
>
(
process
);
process
(
_queue
.
front
()
);
_queue
.
pop_front
();
return
true
;
}
else
return
false
;
}
using
Skel
=
MachineSkel
<
TaskStruct
,
TQ
,
TaskList
...
>
;
struct
skeleton
{
template
<
typename
T
>
void
run
(
tq
&
,
const
T
&
)
{}
};
};
template
<
typename
TQ
,
typename
...
Machines
>
...
...
@@ -213,12 +202,12 @@ namespace divine::mc
void
run
()
/* TODO parallel */
{
auto
process
=
[
&
](
auto
t
)
{
process_task
<
0
>
(
t
);
};
while
(
_queue
.
template
process_next
<
0
>
(
process
)
);
while
(
_queue
.
process_next
(
process
)
);
}
void
start
()
{
add
<
t
ypename
TQ
::
T
ask
s
::
Start
>
();
add
<
task
::
Start
>
();
run
();
}
};
...
...
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