Skip to content

Commit 85edbfb

Browse files
febyejitperami
andauthored
Make Arm UMPromising model executable
Also: - Add tests: same as seq model + dual-core MP - Add support for initial memory instruction fetching (otherwise it wouldn't run) Co-authored-by: Thibaut Pérami <[email protected]>
1 parent 525387b commit 85edbfb

File tree

6 files changed

+454
-74
lines changed

6 files changed

+454
-74
lines changed

ArchSem/GenPromising.v

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -189,24 +189,24 @@ Module GenPromising (IWA : InterfaceWithArch) (TM : TermModelsT IWA).
189189
failing, promise_select effectively computes the allowed_promises
190190
set.*)
191191
promise_select :
192-
(* fuel *) nat -> (* tid *) nat → memoryMap → pModel.(tState) →
193-
PromMemory.t pModel.(mEvent) → Exec.res string pModel.(mEvent);
192+
(* fuel *) nat → (* tid *) nat →
193+
(* termination condition *) (registerMap → bool) →
194+
memoryMap → pModel.(tState) → PromMemory.t pModel.(mEvent) →
195+
Exec.res string pModel.(mEvent);
194196

195197
promise_select_sound :
196-
n tid initMem ts mem,
197-
∀ ev ∈ (promise_select n tid initMem ts mem),
198+
fuel tid term initMem ts mem,
199+
∀ ev ∈ (promise_select fuel tid term initMem ts mem),
198200
ev ∈ pModel.(allowed_promises) tid initMem ts mem;
199201
promise_select_complete :
200-
n tid initMem ts mem,
201-
¬ Exec.has_error (promise_select n tid initMem ts mem) →
202+
fuel tid term initMem ts mem,
203+
¬ Exec.has_error (promise_select fuel tid term initMem ts mem) →
202204
∀ ev ∈ pModel.(allowed_promises) tid initMem ts mem,
203-
ev ∈ promise_select n tid initMem ts mem
205+
ev ∈ promise_select fuel tid term initMem ts mem
204206
}.
205207
Arguments BasicExecutablePM : clear implicits.
206208

207-
208209
Module PState. (* namespace *)
209-
210210
Section PS.
211211
Context {tState : Type}.
212212
Context {mEvent : Type}.
@@ -226,7 +226,6 @@ Module GenPromising (IWA : InterfaceWithArch) (TM : TermModelsT IWA).
226226
End PS.
227227
Arguments t : clear implicits.
228228

229-
230229
Section PSProm.
231230
Context (isem : iMon ()).
232231
Context (prom : PromisingModel).
@@ -345,7 +344,7 @@ Module GenPromising (IWA : InterfaceWithArch) (TM : TermModelsT IWA).
345344
(** Get a list of possible promises for a thread by tid *)
346345
Definition promise_select_tid (fuel : nat) (st : t)
347346
(tid : fin n) : Exec.res string mEvent :=
348-
prom.(promise_select) n tid (initmem st) (tstate tid st) (events st).
347+
prom.(promise_select) fuel tid (term tid) (initmem st) (tstate tid st) (events st).
349348

350349
(** Take any promising step for that tid and promise it *)
351350
Definition cpromise_tid (fuel : nat) (tid : fin n)
@@ -361,7 +360,6 @@ Module GenPromising (IWA : InterfaceWithArch) (TM : TermModelsT IWA).
361360
search but it is obviously correct. If a thread has reached termination
362361
no progress is made in the thread (either instruction running or
363362
promises *)
364-
(* TODO: Make if/then/else syntax only work on bool *)
365363
Definition run_step (fuel : nat) : Exec.t t string () :=
366364
st ← mGet;
367365
tid ← mchoose n;
@@ -387,17 +385,14 @@ Module GenPromising (IWA : InterfaceWithArch) (TM : TermModelsT IWA).
387385

388386
(** Computational evaluate all the possible allowed final states according
389387
to the promising model prom starting from st *)
390-
Program Fixpoint run (fuel : nat) : Exec.t t string final :=
391-
match fuel with
392-
| 0%nat => mthrow "not enough fuel"
393-
| S fuel =>
394-
st ← mGet;
395-
if dec $ terminated prom term st then mret (make_final st _)
396-
else
397-
run_step fuel;;
398-
run fuel
399-
end.
400-
Solve All Obligations with naive_solver.
388+
Fixpoint run (fuel : nat) : Exec.t t string final :=
389+
st ← mGet;
390+
if decide $ terminated prom term st is left pt then mret (make_final st pt)
391+
else
392+
if fuel is S fuel then
393+
run_step (S fuel);;
394+
run fuel
395+
else mthrow "Could not finish running within the size of the fuel".
401396
End CPS.
402397
Arguments to_final_MState {_ _ _}.
403398
End CPState.

0 commit comments

Comments
 (0)