From 1be004027ae311769c66af06b02a8ff6256e84ed Mon Sep 17 00:00:00 2001 From: Rajit Manohar Date: Sat, 4 Feb 2023 11:34:05 -0500 Subject: [PATCH] more tests; support internal shared variable sync --- actsim.cc | 15 +++++++++++++++ actsim.h | 9 +++++++++ chpsim.cc | 2 +- test/92.act | 17 +++++++++++++++++ test/93.act | 15 +++++++++++++++ test/runs/92.act.stderr | 4 ++++ test/runs/92.act.stdout | 1 + test/runs/93.act.stderr | 1 + test/runs/93.act.stdout | 6 ++++++ 9 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 test/92.act create mode 100644 test/93.act create mode 100644 test/runs/92.act.stderr create mode 100644 test/runs/92.act.stdout create mode 100644 test/runs/93.act.stderr create mode 100644 test/runs/93.act.stdout diff --git a/actsim.cc b/actsim.cc index 8e9e9a6..bd11d60 100644 --- a/actsim.cc +++ b/actsim.cc @@ -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"); } @@ -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; @@ -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; diff --git a/actsim.h b/actsim.h index 2d300af..e052106 100644 --- a/actsim.h +++ b/actsim.h @@ -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; @@ -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 */ diff --git a/chpsim.cc b/chpsim.cc index 34b82ac..f694571 100644 --- a/chpsim.cc +++ b/chpsim.cc @@ -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; diff --git a/test/92.act b/test/92.act new file mode 100644 index 0000000..20f4001 --- /dev/null +++ b/test/92.act @@ -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); +} diff --git a/test/93.act b/test/93.act new file mode 100644 index 0000000..d99c1f4 --- /dev/null +++ b/test/93.act @@ -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- ]) + } +} diff --git a/test/runs/92.act.stderr b/test/runs/92.act.stderr new file mode 100644 index 0000000..32ed59f --- /dev/null +++ b/test/runs/92.act.stderr @@ -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) diff --git a/test/runs/92.act.stdout b/test/runs/92.act.stdout new file mode 100644 index 0000000..446bfae --- /dev/null +++ b/test/runs/92.act.stdout @@ -0,0 +1 @@ +[ 10] 0 diff --git a/test/runs/93.act.stderr b/test/runs/93.act.stderr new file mode 100644 index 0000000..78d54cb --- /dev/null +++ b/test/runs/93.act.stderr @@ -0,0 +1 @@ +WARNING: test<>: substituting chp model (requested prs, not found) diff --git a/test/runs/93.act.stdout b/test/runs/93.act.stdout new file mode 100644 index 0000000..3af8cfe --- /dev/null +++ b/test/runs/93.act.stdout @@ -0,0 +1,6 @@ +[ 50] <> hi +[ 90] <> hi +[ 130] <> hi +[ 170] <> hi +[ 210] <> hi +[ 250] <> hi