Skip to content

Commit

Permalink
more tests; support internal shared variable sync
Browse files Browse the repository at this point in the history
  • Loading branch information
rmanohar committed Feb 4, 2023
1 parent c16f083 commit 1be0040
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 1 deletion.
15 changes: 15 additions & 0 deletions actsim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ ActSimCore::ActSimCore (Process *p)
I.H = NULL;
I.obj = NULL;

_is_internal_parallel = 0;

if (!root_scope->isExpanded()) {
fatal_error ("Need to expand ACT prior to starting a simulation");
}
Expand Down Expand Up @@ -343,6 +345,12 @@ ChpSim *ActSimCore::_add_chp (act_chp *c)
if (!pgi->chp) {
ChpSimGraph *stop;
NEW (pgi->chp, chpsimgraph_info);
if (c->c && c->c->type == ACT_CHP_COMMA) {
setInternalParallel (1);
}
else {
setInternalParallel (0);
}
pgi->chp->g = ChpSimGraph::buildChpSimGraph (this, c->c, &stop);
pgi->chp->e = NULL;
pgi->chp->max_count = ChpSimGraph::max_pending_count;
Expand Down Expand Up @@ -407,6 +415,13 @@ ChpSim *ActSimCore::_add_hse (act_chp *c)
if (!pgi->hse) {
ChpSimGraph *stop;
NEW (pgi->hse, chpsimgraph_info);

if (c->c && c->c->type == ACT_CHP_COMMA) {
setInternalParallel (1);
}
else {
setInternalParallel (0);
}
pgi->hse->g = ChpSimGraph::buildChpSimGraph (this, c->c, &stop);
pgi->hse->max_count = ChpSimGraph::max_pending_count;
pgi->hse->max_stats = ChpSimGraph::max_stats;
Expand Down
9 changes: 9 additions & 0 deletions actsim.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,11 @@ class ActSimCore {
return f;
}


int isInternalParallel() { return _is_internal_parallel; }
void setInternalParallel (int v) { _is_internal_parallel = v; }


protected:
Act *a;

Expand Down Expand Up @@ -550,6 +555,10 @@ class ActSimCore {
stateinfo_t *_rootsi; /* root stateinfo; needed for globals
*/

int _is_internal_parallel; /* used to let the graph construction
phase know that there is internal
parallelism */

struct iHashtable *_W; /* watchpoints */
struct iHashtable *_B; /* breakpoints */

Expand Down
2 changes: 1 addition & 1 deletion chpsim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4215,7 +4215,7 @@ static chpsimstmt *gc_to_chpsim (act_chp_gc_t *gc, ActSimCore *s)
if (flags & 0x1) {
ret->u.cond.is_probe = 1;
}
if (flags & 0x2) {
if ((flags & 0x2) || s->isInternalParallel()) {
ret->u.cond.is_shared = 1;
}
return ret;
Expand Down
17 changes: 17 additions & 0 deletions test/92.act
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
defproc my_source(chan!(enum<1>) X) {
chp {
X!0; X!4; X!3
}
}

defproc my_sink(chan?(enum<1>) X) {
enum<1> x;
chp {
*[ X?x; log(x) ]
}
}

defproc test() {
my_source s;
my_sink t(s.X);
}
15 changes: 15 additions & 0 deletions test/93.act
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
defproc test()
{
bool xr, xa;

chp {
(xr-; xr+; [xa]; xr-; [~xa]; log ("hi");
xr+; [xa]; xr-; [~xa]; log ("hi");
xr+; [xa]; xr-; [~xa]; log ("hi");
xr+; [xa]; xr-; [~xa]; log ("hi");
xr+; [xa]; xr-; [~xa]; log ("hi");
xr+; [xa]; xr-; [~xa]; log ("hi") )
||
(xa-; *[ [xr]; xa+; [~xr]; xa- ])
}
}
4 changes: 4 additions & 0 deletions test/runs/92.act.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
WARNING: my_sink<>: substituting chp model (requested prs, not found)
WARNING: my_source<>: substituting chp model (requested prs, not found)
** FATAL ** Process my_sink<>: enumeration assigned illegal value
** Max=1; Value: 4 (0x4)
1 change: 1 addition & 0 deletions test/runs/92.act.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[ 10] <t> 0
1 change: 1 addition & 0 deletions test/runs/93.act.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WARNING: test<>: substituting chp model (requested prs, not found)
6 changes: 6 additions & 0 deletions test/runs/93.act.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[ 50] <> hi
[ 90] <> hi
[ 130] <> hi
[ 170] <> hi
[ 210] <> hi
[ 250] <> hi

0 comments on commit 1be0040

Please sign in to comment.