Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a112879
Work on getting p4benchmark generating what we need...
BillHallahan Sep 11, 2020
f753d67
thrift
BillHallahan Sep 11, 2020
34e50ff
Generating OBT commands from whippersnapper generated files
BillHallahan Sep 11, 2020
d95ce58
Adjusting OBT converions to eliminate tables in select statements
BillHallahan Sep 11, 2020
1ea62c4
minor
BillHallahan Sep 12, 2020
21d8147
Isolated error
BillHallahan Sep 13, 2020
0746e3c
Zero initalizing OBT
BillHallahan Sep 13, 2020
6f8ac2f
Generating correct files (at least in simple cases) to synthesize fro…
BillHallahan Sep 13, 2020
773b65c
Script to go from OBT to physical
BillHallahan Sep 13, 2020
bfc4a7e
generating multiple files
BillHallahan Sep 14, 2020
dab4117
timing
BillHallahan Sep 14, 2020
b2b24d9
Generating rules for pipeline
BillHallahan Sep 14, 2020
378ed13
optimizations for whippersnapper
BillHallahan Sep 15, 2020
74a29e9
Add, remove headers benchmarks from whippersnapper working
BillHallahan Sep 15, 2020
1636b9e
Plotting data
BillHallahan Sep 16, 2020
9f9f796
Missing file
BillHallahan Sep 16, 2020
fbd006c
Minor cleanup
BillHallahan Sep 16, 2020
0301e2a
Merge branch 'master' into whippersnapper
BillHallahan Sep 16, 2020
1a96d82
hot cache
BillHallahan Sep 16, 2020
fb9e438
Restartable
BillHallahan Sep 16, 2020
0d783f4
max settings
BillHallahan Sep 16, 2020
aeb0125
Minor change to reach-restrict
BillHallahan Sep 17, 2020
ae09eef
opt
BillHallahan Sep 17, 2020
05b4d92
Modified args to avenir in whippersnapper/bench.py
BillHallahan Sep 17, 2020
ccb7edd
measure identity mapping
BillHallahan Sep 17, 2020
b555c83
Various things
BillHallahan Sep 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 198 additions & 0 deletions synthesis/bin/Main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,202 @@ let onf_real : Command.t =
ONFReal.spec
ONFReal.run

module ToOBT = struct
let spec = Command.Spec.(
empty
+> flag "-DEBUG" no_arg ~doc:"print debugging statements"
+> flag "--thrift" no_arg ~doc:"parse & write bmv2/thrift commands"
+> flag "-i" no_arg ~doc:"interactive mode"
+> flag "-data" (required string) ~doc:"the input log"
+> flag "-p" no_arg ~doc:"show_result_at_end"
+> anon ("p4file" %: string)
+> anon ("log-edits" %: string)
+> anon ("phys-edits" %: string)
+> anon ("fvs" %: string)
+> anon ("assume" %: string)
+> flag "-I" (listed string) ~doc:"<dir> add directory to include search path for file"
++ opt_flags)

let run debug thrift_mode interactive data print
p4file log_edits phys_edits fvs assume inc
widening
do_slice
semantic_slicing
edits_depth
search_width
monotonic
injection
fastcx
vcache
ecache
shortening
above
minimize
hints
only_holes
allow_annotations
nlp
unique_edits
domain
restrict_mask
no_defaults
no_deletes
use_all_cexs
reach_restrict
reach_filter
hot_start
() =
let res = Benchmark.to_obt
Parameters.({
widening;
do_slice;
semantic_slicing;
edits_depth;
search_width;
debug;
thrift_mode;
monotonic;
interactive;
injection;
fastcx;
vcache;
ecache;
shortening;
above;
minimize;
hints = Option.is_some hints;
hint_type = Option.value hints ~default:"exact";
only_holes;
allow_annotations;
nlp;
unique_edits;
domain;
restrict_mask;
no_defaults;
no_deletes;
use_all_cexs;
reach_restrict;
reach_filter;
timeout = None;
hot_start})
data p4file log_edits phys_edits fvs assume inc
in
match res with
| None -> Core.Printf.printf "no example could be found\n"
| Some r when print ->
Core.Printf.printf "Edits\n";
List.iter r ~f:(fun edit ->
Tables.Edit.to_string edit
|> Core.Printf.printf "%s\n%!"
)
| Some _ -> ()

end

let to_obt : Command.t =
Command.basic_spec
~summary: "Run the onf benchmark on the real p4 programs"
ToOBT.spec
ToOBT.run

module FromOBT = struct
let spec = Command.Spec.(
empty
+> flag "-DEBUG" no_arg ~doc:"print debugging statements"
+> flag "--thrift" no_arg ~doc:"parse & write bmv2/thrift commands"
+> flag "-i" no_arg ~doc:"interactive mode"
+> flag "-data" (required string) ~doc:"the input log"
+> flag "-p" no_arg ~doc:"show_result_at_end"
+> anon ("p4file" %: string)
+> anon ("log-edits" %: string)
+> anon ("phys-edits" %: string)
+> anon ("fvs" %: string)
+> anon ("assume" %: string)
+> flag "-I" (listed string) ~doc:"<dir> add directory to include search path for file"
++ opt_flags)

let run debug thrift_mode interactive data print
p4file log_edits phys_edits fvs assume inc
widening
do_slice
semantic_slicing
edits_depth
search_width
monotonic
injection
fastcx
vcache
ecache
shortening
above
minimize
hints
only_holes
allow_annotations
nlp
unique_edits
domain
restrict_mask
no_defaults
no_deletes
use_all_cexs
reach_restrict
reach_filter
hot_start
() =
let res = Benchmark.from_obt
Parameters.({
widening;
do_slice;
semantic_slicing;
edits_depth;
search_width;
debug;
thrift_mode;
monotonic;
interactive;
injection;
fastcx;
vcache;
ecache;
shortening;
above;
minimize;
hints = Option.is_some hints;
hint_type = Option.value hints ~default:"exact";
only_holes;
allow_annotations;
nlp;
unique_edits;
domain;
restrict_mask;
no_defaults;
no_deletes;
use_all_cexs;
reach_restrict;
reach_filter;
timeout = None;
hot_start})
data p4file log_edits phys_edits fvs assume inc
in
match res with
| None -> Core.Printf.printf "no example could be found\n"
| Some r when print ->
Core.Printf.printf "Edits\n";
List.iter r ~f:(fun edit ->
Tables.Edit.to_string edit
|> Core.Printf.printf "%s\n%!"
)
| Some _ -> ()

end

let from_obt : Command.t =
Command.basic_spec
~summary: "Run the onf benchmark on the real p4 programs"
FromOBT.spec
FromOBT.run

module Equality = struct
let spec = Command.Spec.(
empty
Expand Down Expand Up @@ -1417,6 +1613,8 @@ let main : Command.t =
; ("onf-real", onf_real)
; ("obt", obt)
; ("obt-real", obt_real)
; ("to-obt", to_obt)
; ("from-obt", from_obt)
; ("eq", equality)
; ("eq-real", equality_real)
; ("wp", wp_cmd)]
Expand Down
57 changes: 57 additions & 0 deletions synthesis/lib/Benchmark.ml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,63 @@ let rec basic_onf_ipv4_real params data_file log_p4 phys_p4 log_edits_file phys_
assert (implements params (ProfData.zero ()) (problem ()) = `Yes);
measure params None problem (onos_to_edits var_mapping data_file "routing_v6" "hdr.ipv6.dst_addr")

and to_obt params data_file p4_file log_edits_file phys_edits_file fvs_file _ inc =
let var_mapping = parse_fvs fvs_file in
let fvs = List.map var_mapping ~f:snd in
let assume = Skip (* parse_file assume_file *) in

(* let print_fvs = printf "fvs = %s" (Sexp.to_string ([%sexp_of: (string * int) list] fvs)) in *)

let log = (assume %:% Encode.encode_from_p4 inc p4_file false)
|> Encode.unify_names var_mapping |> zero_init fvs |> drop_handle fvs in

let phys = OneBigTable.mk_one_big_table (ConstantProp.propogate log) |> zero_init fvs |> drop_handle fvs in
(* |> CompilerOpts.optimize fvs *)
(* let maxN n = Bigint.(of_int_exn n ** of_int_exn 2 - one) in *)
(* let fvs = parse_fvs fvs in *)
let log_edits = Runtime.parse_whippersnapper log log_edits_file in
let phys_edits = Runtime.parse phys phys_edits_file in

let problem =
Problem.make
~log ~phys ~fvs
~log_inst:Instance.(update_list params empty log_edits)
~phys_inst:Instance.(update_list params empty phys_edits)
~log_edits:[]
in
(* Core.Printf.printf "\n\n------------\n%s\n----------\n" (Problem.to_string params problem); *)
assert (implements params (ProfData.zero ()) (problem ()) = `Yes);
measure params None problem (List.map (Runtime.parse_whippersnapper log data_file) ~f:(fun r -> [r]))

and from_obt params data_file p4_file log_edits_file phys_edits_file fvs_file _ inc =
let var_mapping = parse_fvs fvs_file in
let fvs = List.map var_mapping ~f:snd in
let assume = Skip (* parse_file assume_file *) in

(* let print_fvs = printf "fvs = %s" (Sexp.to_string ([%sexp_of: (string * int) list] fvs)) in *)

let phys = (assume %:% Encode.encode_from_p4 inc p4_file false)
|> Encode.unify_names var_mapping |> zero_init fvs |> drop_handle fvs in

let log = OneBigTable.mk_one_big_table (ConstantProp.propogate phys) |> zero_init fvs |> drop_handle fvs in
(* |> CompilerOpts.optimize fvs *)
(* let maxN n = Bigint.(of_int_exn n ** of_int_exn 2 - one) in *)
(* let fvs = parse_fvs fvs in *)
let log_edits = Runtime.parse_whippersnapper log log_edits_file in
let phys_edits = Runtime.parse phys phys_edits_file in

let problem =
Problem.make
~log ~phys ~fvs
~log_inst:Instance.(update_list params empty log_edits)
~phys_inst:Instance.(update_list params empty phys_edits)
~log_edits:[]
in
(* Core.Printf.printf "\n\n------------\n%s\n----------\n" (Problem.to_string params problem); *)
assert (implements params (ProfData.zero ()) (problem ()) = `Yes);
measure params None problem (List.map (Runtime.parse log data_file) ~f:(fun r -> [r]))


and zero_init fvs cmd =
let fvs = StringSet.of_list @@ fsts @@ fvs in
let vs = free_of_cmd `Var cmd
Expand Down
4 changes: 2 additions & 2 deletions synthesis/lib/FastCX.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ let is_reachable encode_tag params problem fvs in_pkt tbl_name keys =
passive_hoare_triple ~fvs
(Packet.to_test in_pkt ~fvs)
trunc
(Hole.match_holes_table encode_tag tbl_name keys
%&% Instance.negate_rows phys_inst tbl_name)
(Hole.match_holes_table encode_tag tbl_name keys)
(* %&% Instance.negate_rows phys_inst tbl_name) *)


let hits_pred params (_: ProfData.t ref) prog inst edits e : test =
Expand Down
Loading