-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port Over Simulator and Compiler from
pifo-tree-artifact
(#57)
This PR makes the following changes - fill in `ocamlformat` - remove `bin/` - alter WFQ to weights to be `float` instead of `int` (necessary to implement `WFQ_Ternary` in [`schedulers-in-ocaml`](https://github.com/cucapra/schedulers-in-ocaml/blob/2920e13c9dbc0c22414da326d629970aaabf2624/lib/alg.ml#L191-L195)) - alter file structure to have two libraries, `Frontend` and `Simulate` - remove NWC policies and `EDF`, `SJN`, and `SRTF` in `policy.ml`; constructing controls for them is for later - port over simulator and compiler from `schedulers-in-ocaml` - implement `Control.of_policy` (**most of the work for this PR**) - setup T2T compilation tests in `tests/compilation`: i.e. check the `.csv`s match - add two work conserving programs: ternary strict and wfq To generate graphs via our simulator, `cd` into `dsl/` and run ``` dune clean; dune build; dune test; python ../graphs/plot.py ``` This populates `graphs/`
- Loading branch information
1 parent
5f5c77e
commit 4421006
Showing
49 changed files
with
1,072 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
profile = conventional | ||
break-cases = fit-or-vertical | ||
exp-grouping = preserve | ||
parse-docstrings = true | ||
type-decl = sparse |
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
(library | ||
(name dsl_core)) | ||
(name Frontend) | ||
(public_name dsl.frontend)) | ||
|
||
(menhir | ||
(modules parser)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module Ast = Ast | ||
module Parser = Parse | ||
module Policy = Policy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
exception ParserError of string | ||
|
||
(* syntax_error_msg lexbuf is a syntax error message for the current position *) | ||
(* `syntax_error_msg lexbuf` is a syntax error message for the current | ||
position *) | ||
let syntax_error_msg lexbuf = | ||
let pos = Lexing.lexeme_start_p lexbuf in | ||
let lnum, cnum = (pos.pos_lnum, pos.pos_cnum - pos.pos_bol) in | ||
Printf.sprintf "Syntax error at line %d, character %d" lnum cnum | ||
|
||
let parse lexbuf = Parser.prog Lexer.token lexbuf | ||
|
||
(* parse s parses a program string into an AST *) | ||
(* `parse s` parses a program string `s` into an AST *) | ||
let parse_string (s : string) = | ||
let lexbuf = Lexing.from_string s in | ||
try parse lexbuf | ||
with Parser.Error -> raise (ParserError (syntax_error_msg lexbuf)) | ||
|
||
(* parse s parses a program file into an AST *) | ||
(* `parse s` parses a program file `s` into an AST *) | ||
let parse_file (f : string) = | ||
let lexbuf = Lexing.from_channel (open_in f) in | ||
try parse lexbuf | ||
with Parser.Error -> | ||
prerr_endline (syntax_error_msg lexbuf); | ||
exit 1 | ||
with Parser.Error -> raise (ParserError (syntax_error_msg lexbuf)) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
(* Changes to this type must also be reflected in `Ast.policy` in ast.ml *) | ||
type t = | ||
| Class of Ast.clss | ||
| Fifo of t list | ||
| RoundRobin of t list | ||
| Strict of t list | ||
| WeightedFair of (t * float) list | ||
|
||
exception UnboundVariable of Ast.var | ||
exception UndeclaredClass of Ast.clss | ||
exception DuplicateClass of Ast.clss | ||
|
||
let lookup s x = | ||
match List.assoc_opt x s with | ||
| Some v -> v | ||
| None -> raise (UnboundVariable x) | ||
|
||
let rec sub cl st (p : Ast.policy) used = | ||
let sub_plst cl st = List.map (fun x -> sub cl st x used) in | ||
let sub_weighted_plst cl st = | ||
List.map (fun (x, i) -> (sub cl st x used, i)) | ||
in | ||
|
||
match p with | ||
| Class c -> | ||
if List.mem c !used then raise (DuplicateClass c) | ||
else if List.mem c cl then ( | ||
used := c :: !used; | ||
(Class c : t)) | ||
else raise (UndeclaredClass c) | ||
| Var x -> sub cl st (lookup st x) used | ||
| Fifo plst -> Fifo (sub_plst cl st plst) | ||
| RoundRobin plst -> RoundRobin (sub_plst cl st plst) | ||
| Strict plst -> Strict (sub_plst cl st plst) | ||
| WeightedFair wplst -> WeightedFair (sub_weighted_plst cl st wplst) | ||
| _ -> failwith "ERROR: unsupported policy" | ||
|
||
(* Look up any variables and substitute them in. *) | ||
let of_program (cl, alst, ret) : t = sub cl alst ret (ref []) | ||
|
||
let rec to_string p = | ||
let sprintf = Printf.sprintf in | ||
let join lst = | ||
sprintf "[%s]" (lst |> List.map to_string |> String.concat ", ") | ||
in | ||
let join_weighted lst = | ||
sprintf "[%s]" | ||
(lst | ||
|> List.map (fun (x, y) -> sprintf "(%s, %.2f)" (to_string x) y) | ||
|> String.concat ", ") | ||
in | ||
|
||
match p with | ||
| Class c -> c | ||
| Fifo lst -> sprintf "fifo%s" (join lst) | ||
| RoundRobin lst -> sprintf "rr%s" (join lst) | ||
| Strict lst -> sprintf "strict%s" (join lst) | ||
| WeightedFair lst -> sprintf "wfq%s" (join_weighted lst) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.