Skip to content

Commit

Permalink
Fix all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KabirSamsi committed Oct 29, 2024
1 parent c2b5eb7 commit bb87d61
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
24 changes: 19 additions & 5 deletions rio/frontend/policy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,29 @@ let rec sub cl st (p : Ast.policy) used =
List.map (fun (x, i) -> (sub cl st x used, i))
in

(* Temporary compilation removes FIFOs for test cases *)
let rec extract_subpol (p : t) =
match p with
| Class _ -> p
| Fifo plst ->
if List.length plst = 1 then extract_subpol (List.hd plst)
else Fifo (List.map extract_subpol plst)
| RoundRobin plst -> RoundRobin (List.map extract_subpol plst)
| Strict plst -> Strict (List.map extract_subpol plst)
| WeightedFair wplst ->
WeightedFair (List.map (fun (x, y) -> (extract_subpol x, y)) wplst)
in

match p with
| Var x -> sub cl st (lookup st x) used
| Fifo p -> Fifo (sub_set cl st p used)
| RoundRobin plst -> RoundRobin (sub_plst cl st plst)
| Strict plst -> Strict (sub_plst cl st plst)
| RoundRobin plst -> extract_subpol (RoundRobin (sub_plst cl st plst))
| Strict plst -> extract_subpol (Strict (sub_plst cl st plst))
| WeightedFair (plst, wts) ->
WeightedFair
(sub_weighted_plst cl st
(List.combine plst (List.map float_of_int wts)))
extract_subpol
(WeightedFair
(sub_weighted_plst cl st
(List.combine plst (List.map float_of_int wts))))
| _ -> failwith "ERROR: unsupported policy"

(* Look up any variables and substitute them in. *)
Expand Down
19 changes: 8 additions & 11 deletions rio/tests/parsing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,25 @@ let wc_tests =
"fifo[A]";
make_test "fifo of 3" "progs/work_conserving/fifo_n_classes.sched"
"fifo[A, B, C]";
make_test "rr of 1" "progs/work_conserving/rr_1_class.sched" "rr[fifo[A]]";
make_test "rr of 1" "progs/work_conserving/rr_1_class.sched" "rr[A]";
make_test "rr of 2" "progs/work_conserving/rr_2_classes.sched"
"rr[fifo[A, B]]";
make_test "multiple assignments"
"progs/work_conserving/rr_hier_merge_sugar.sched"
"rr[fifo[BX, BY], rr[fifo[RP], fifo[RT]]]";
"rr[fifo[BX, BY], rr[RP, RT]]";
make_test "2 assignments w/ substitutions"
"progs/work_conserving/rr_hier.sched"
"rr[fifo[B], rr[fifo[RP], fifo[RT]]]";
"progs/work_conserving/rr_hier.sched" "rr[B, rr[RP, RT]]";
make_test "3 classes with substitutions"
"progs/work_conserving/rr_n_class_hier.sched"
"rr[fifo[A], fifo[B], rr[rr[fifo[CU], fifo[CV]], rr[fifo[CW], fifo[CX]]]]";
make_test "rr of 3" "progs/work_conserving/rr_n_classes.sched"
"rr[fifo[A], fifo[B], fifo[C]]";
"rr[A, B, rr[rr[CU, CV], rr[CW, CX]]]";
make_test "rr of 3" "progs/work_conserving/rr_n_classes.sched" "rr[A, B, C]";
make_test "rr and strict substitutions"
"progs/work_conserving/rr_strict_n_classes_hier.sched"
"strict[fifo[A], fifo[B], rr[rr[fifo[CU], fifo[CV]], strict[fifo[CW], \
fifo[CX]]]]";
"strict[A, B, rr[rr[CU, CV], strict[CW, CX]]]";
make_test "strict of 3" "progs/work_conserving/strict_n_classes.sched"
"strict[fifo[C], fifo[B], fifo[A]]";
"strict[C, B, A]";
make_test "wfq of 3" "progs/work_conserving/wfq_n_classes.sched"
"wfq[(fifo[A], 1.00), (fifo[B], 2.00), (fifo[C], 3.00)]";
"wfq[(A, 1.00), (B, 2.00), (C, 3.00)]";
]

let _nwc_tests =
Expand Down

0 comments on commit bb87d61

Please sign in to comment.