text
stringlengths
0
601k
let find_loop_heads ( module Cfg : CfgForward ) ( file : Cil . file ) : unit NH . t = let loop_heads = NH . create 100 in let global_visited_nodes = NH . create 100 in let rec iter_node path_visited_nodes node = if NS . mem node path_visited_nodes then NH . replace loop_heads node ( ) else if not ( NH . mem global_visi...
module type File = sig val file : Cil . file end
module Invariant ( File : File ) ( Cfg : MyCFG . CfgBidir ) = struct let emit_loop_head = GobConfig . get_bool " witness . invariant . loop - head " let emit_after_lock = GobConfig . get_bool " witness . invariant . after - lock " let emit_other = GobConfig . get_bool " witness . invariant . other " let loop_heads = fi...
module InvariantExp = struct module ES = SetDomain . Make ( CilType . Exp ) let rec pullOutCommonConjuncts e = let rec to_conjunct_set = function | Cil . BinOp ( LAnd , e1 , e2 , _ ) -> ES . join ( to_conjunct_set e1 ) ( to_conjunct_set e2 ) | e -> ES . singleton e in let combine_conjuncts es = ES . fold ( fun e acc ->...
type parsing_sate = Initial | EntRef of int ; ;
let internal_break_words b t =
let is_whitespace = function | ' ' | ' \ t ' | ' \ n ' | ' \ r ' -> true | _ -> false
let words_of_string s = let len = String . length s in let finish acc = List . rev acc in let rec iter acc = function | ` Skip next_ofs when next_ofs >= len -> finish acc | ` Skip next_ofs -> if is_whitespace s . [ next_ofs ] then iter acc ( ` Skip ( next_ofs + 1 ) ) else iter acc ( ` Collect ( next_ofs , next_ofs + 1 ...
type t = { count : int ref ; dict : ( string , int ) Hashtbl . t ; outputs : ( Pipeline . label , Bi_outbuf . t ) Hashtbl . t ; }
let task_init _ = { count = ref 0 ; dict = ( Hashtbl . create ( 1024 * 1024 ) : ( string , int ) Hashtbl . t ) ; outputs = ( Hashtbl . create mAX_LABEL : ( Pipeline . label , Bi_outbuf . t ) Hashtbl . t ) ; }
let label_of disco word = if disco . Task . grouping = Pipeline . Group_all then 0 else let h = ref 0 in String . iter ( fun c -> h := ! h + Char . code c ) word ; ! h mod mAX_LABEL
let output_of init disco label = try Hashtbl . find init . outputs label with Not_found -> let o = Bi_outbuf . create_channel_writer ( disco . Task . out_channel ~ label ) in Hashtbl . add init . outputs label o ; o
let task_done init disco = Hashtbl . iter ( fun k v -> Wc_b . write_wc ( output_of init disco ( label_of disco k ) ) ( k , v ) ; ) init . dict ; Hashtbl . iter ( fun _l o -> Bi_outbuf . flush_channel_writer o ) init . outputs ; disco . Task . log ( Printf . sprintf " Output % d entries ( % d keys ) into % d files . \ n...
module MapTask = struct module T = Task type init = t let task_init = task_init let task_process init disco in_chan = disco . T . log ( Printf . sprintf " Processing % s ( % d bytes ) with label % d on % s . . . \ n " disco . T . input_url disco . T . input_size disco . T . group_label disco . T . hostname ) ; let rec ...
module ReduceTask = struct module T = Task type init = t let task_init = task_init let task_process init disco in_chan = disco . T . log ( Printf . sprintf " Processing % s ( % d bytes ) with label % d on % s . . . \ n " disco . T . input_url disco . T . input_size disco . T . group_label disco . T . hostname ) ; let i...
let _ = Worker . start [ ( mAP , ( module MapTask : Task . TASK ) ) ; ( sHUFFLE , ( module ReduceTask : Task . TASK ) ) ; ( rEDUCE , ( module ReduceTask : Task . TASK ) ) ]
module Single = struct module Spec = struct [ %% versioned module Stable = struct [ @@@ no_toplevel_latest_type ] no_toplevel_latest_type module V2 = struct type ( ' witness , ' ledger_proof ) ' ledger_proof t = | Transition of Transaction_snark . Statement . Stable . V2 . t * ' witness | Merge of Transaction_snark . S...
module Spec = struct [ %% versioned module Stable = struct [ @@@ no_toplevel_latest_type ] no_toplevel_latest_type module V1 = struct type ' single t = { instances : ' single One_or_two . Stable . V1 . t ; fee : Currency . Fee . Stable . V1 . t } [ @@ deriving fields , sexp , to_yojson ] to_yojson let to_latest single_...
module Result = struct [ %% versioned module Stable = struct module V1 = struct type ( ' spec , ' single ) ' single t = { proofs : ' single One_or_two . Stable . V1 . t ; metrics : ( Core . Time . Stable . Span . V1 . t * [ ` Transition | ` Merge ] ) One_or_two . Stable . V1 . t ; spec : ' spec ; prover : Signature_lib...
module Book_view = struct module Visibility = struct type t = | Hidden | Very_hidden | Visible [ @@ deriving sexp_of ] let of_string = function | " hidden " -> Hidden | " veryHidden " -> Very_hidden | " visible " -> Visible | str -> failwithf " Expected ST_Visibility but got ' % s ' " str ( ) end type t = { active_tab ...
module Sheet = struct module State = struct type t = | Hidden | Very_hidden | Visible [ @@ deriving sexp_of ] let of_string = function | " hidden " -> Hidden | " veryHidden " -> Very_hidden | " visible " -> Visible | str -> failwithf " Expected ST_SheetState but got ' % s ' " str ( ) end type t = { id : string ; name :...
type t = { book_views : Book_view . t list ; sheets : Sheet . t list } [ @@ deriving fields , sexp_of ]
let empty = { book_views = [ ] ; sheets = [ ] }
let of_xml = expect_element " workbook " ( fun _ -> List . fold ~ init : empty ~ f ( : fun t -> let open Xml in function | Element ( " bookViews " , _ , children ) -> let book_views = List . filter_map children ~ f : Book_view . of_xml in { t with book_views } | Element ( " sheets " , _ , children ) -> let sheets = Lis...
type worker_name = { base : string ; name : string }
type Error_monad . error += Closed of worker_name
let ( ) = register_error_kind ` Permanent ~ id " : worker . closed " ~ title " : Worker closed " ~ description : " An operation on a worker could not complete before it was shut down . " ~ pp ( : fun ppf w -> Format . fprintf ppf " Worker % s [ % s ] has been shut down . " w . base w . name ) Data_encoding . ( conv ( f...
module type T = sig module Name : Worker_intf . NAME module Event : Worker_intf . EVENT module Request : Worker_intf . REQUEST module Types : Worker_intf . TYPES type ' kind t type ' kind table type ' a queue and bounded and infinite type dropbox type _ buffer_kind = | Queue : infinite queue buffer_kind | Bounded : { s...
module Make ( Name : Worker_intf . NAME ) ( Event : Worker_intf . EVENT ) ( Request : Worker_intf . REQUEST ) ( Types : Worker_intf . TYPES ) ( Logger : Worker_intf . LOGGER with module Event = Event and type Request . view = Request . view ) = struct module Name = Name module Event = Event module Request = Request mod...
let build_rpc_directory state = let dir : unit RPC_directory . t ref = ref RPC_directory . empty in let register0 s f = dir := RPC_directory . register ! dir s ( fun ( ) p q -> f p q ) in let register1 s f = dir := RPC_directory . register ! dir s ( fun ( ( ) , a ) p q -> f a p q ) in let register2 s f = dir := RPC_dir...
module type NAME = sig val base : string list type t val encoding : t Data_encoding . t val pp : Format . formatter -> t -> unit val equal : t -> t -> bool end
module type VIEW = sig type view val encoding : view Data_encoding . t val pp : Format . formatter -> view -> unit end
module type EVENT = sig type t include VIEW with type view := t val level : t -> Internal_event . level end
module type REQUEST = sig type ' a t include VIEW val view : ' a t -> view end
module type TYPES = sig type state type parameters end
module type LOGGER = sig module Event : EVENT module Request : VIEW type status = | WorkerEvent of ( Event . t * Internal_event . level ) | Request of ( Request . view * Worker_types . request_status * error list option ) | Terminated | Timeout | Crashed of error list | Started of string option | Triggering_shutdown | ...
module type STATIC = sig val worker_name : string end
module Make ( Event : Worker_intf . EVENT ) ( Request : Worker_intf . VIEW ) ( Static : STATIC ) : Worker_intf . LOGGER with module Event = Event and module Request = Request = struct module Event = Event module Request = Request type status = | WorkerEvent of ( Event . t * Internal_event . level ) | Request of ( Reque...
type context = { worker : Worker . t ; timeout : int ; timeout_fn : unit -> unit ; waiting : ( ( Jv . t , exn ) exn Result . t Lwt_mvar . t * int ) int Queue . t ; }
let demux context msg = Lwt . async ( fun ( ) -> match Queue . take_opt context . waiting with | None -> Lwt . return ( ) | Some ( mv , outstanding_execution ) outstanding_execution -> Brr . G . stop_timer outstanding_execution ; let msg : Jv . t = Message . Ev . data ( Brr . Ev . as_type msg ) msg in Lwt_mvar . put mv...
let start worker timeout timeout_fn = let context = { worker ; timeout ; timeout_fn ; waiting = Queue . create ( ) } in let ( ) = Brr . Ev . listen Message . Ev . message ( demux context ) context ( Worker . as_target worker ) worker in context
let rpc context call = let open Lwt in let jv = Conv . jv_of_rpc_call call in let mv = Lwt_mvar . create_empty ( ) in let outstanding_execution = Brr . G . set_timeout ~ ms : 10000 ( fun ( ) -> Lwt . async ( fun ( ) -> Lwt_mvar . put mv ( Error Timeout ) Timeout ) Timeout ; context . timeout_fn ( ) ) in Queue . push ( ...
module Prevalidators = struct module S = struct let list = RPC_service . get_service ~ description " : Lists the Prevalidator workers and their status . " ~ query : RPC_query . empty ~ output : ( list ( obj4 ( req " chain_id " Chain_id . encoding ) ( req " status " ( Worker_types . worker_status_encoding RPC_error . en...
module Block_validator = struct module S = struct let state = RPC_service . get_service ~ description " : Introspect the state of the block_validator worker . " ~ query : RPC_query . empty ~ output : ( Worker_types . full_status_encoding Block_validator_worker_state . Request . encoding RPC_error . encoding ) RPC_path ...
module Peer_validators = struct module S = struct let list = RPC_service . get_service ~ description " : Lists the peer validator workers and their status . " ~ query : RPC_query . empty ~ output : ( list ( obj4 ( req " peer_id " P2p_peer . Id . encoding ) ( req " status " ( Worker_types . worker_status_encoding RPC_er...
module Chain_validators = struct module S = struct let list = RPC_service . get_service ~ description " : Lists the chain validator workers and their status . " ~ query : RPC_query . empty ~ output : ( list ( obj4 ( req " chain_id " Chain_id . encoding ) ( req " status " ( Worker_types . worker_status_encoding RPC_erro...
module type Base_intf = sig type t type create_args type input type output val create : create_args -> t val close : t -> unit Deferred . t end
module type Worker_intf = sig include Base_intf val perform : t -> input -> output Deferred . t end
module type S = sig include Base_intf val is_working : t -> bool val dispatch : t -> input -> output Deferred . t end
module Make ( Worker : Worker_intf ) Worker_intf : S with type create_args := Worker . create_args and type input := Worker . input and type output := Worker . output = struct type t = { mutable thread : Worker . output Deferred . t option ; worker : Worker . t } let create args = { thread = None ; worker = Worker . cr...
type worker_status = | Launching of Time . System . t | Running of Time . System . t | Closing of Time . System . t * Time . System . t | Closed of Time . System . t * Time . System . t * error list option
let worker_status_encoding error_encoding = let open Data_encoding in union [ case ( Tag 0 ) ~ title " : Launching " ( obj2 ( req " phase " ( constant " launching " ) ) ( req " since " Time . System . encoding ) ) ( function Launching t -> Some ( ( ) , t ) | _ -> None ) ( fun ( ( ) , t ) -> Launching t ) ; case ( Tag 1...
type worker_information = { instances_number : int ; wstatus : worker_status ; queue_length : int ; }
let worker_information_encoding error_encoding = Data_encoding . ( conv ( fun { instances_number ; wstatus ; queue_length } -> ( instances_number , wstatus , queue_length ) ) ( fun ( instances_number , wstatus , queue_length ) -> { instances_number ; wstatus ; queue_length } ) ( obj3 ( req " instances " int31 ) ( req "...
type request_status = { pushed : Time . System . t ; treated : Time . System . Span . t ; completed : Time . System . Span . t ; }
let request_status_encoding = let open Data_encoding in conv ( fun { pushed ; treated ; completed } -> ( pushed , treated , completed ) ) ( fun ( pushed , treated , completed ) -> { pushed ; treated ; completed } ) ( obj3 ( req " pushed " Time . System . encoding ) ( req " treated " Time . System . Span . encoding ) ( ...
type ' req full_status = { status : worker_status ; pending_requests : ( Time . System . t * ' req ) list ; current_request : ( Time . System . t * Time . System . t * ' req ) option ; }
let full_status_encoding req_encoding error_encoding = let open Data_encoding in let requests_encoding = list ( obj2 ( req " pushed " Time . System . encoding ) ( req " request " ( dynamic_size req_encoding ) ) ) in let current_request_encoding = obj3 ( req " pushed " Time . System . encoding ) ( req " treated " Time ....
let pp_status ppf { pushed ; treated ; completed } = Format . fprintf ppf " Request pushed on % a , treated in % a , completed in % a " Time . System . pp_hum pushed Ptime . Span . pp treated Ptime . Span . pp completed
type path = | FS_path of string | Cache_id of string | Cd of path * string list
let cd dir sel = match dir with | Cd ( indir , insel ) -> Cd ( indir , insel @ sel ) | FS_path _ | Cache_id _ -> Cd ( dir , sel )
module Docker_image = struct type t = { account : string ; name : string ; tag : string option ; registry : string option ; } end
module Singularity_image = struct type t = { account : string ; name : string ; tag : string option ; registry : string option ; } end
type container_image = | Docker_image of Docker_image . t | Singularity_image of Singularity_image . t
let docker_image ? tag ? registry ~ account ~ name ( ) = Docker_image { account = account ; name = name ; tag = tag ; registry = registry ; }
type _ t = | Pure : { id : string ; value : ' a } -> ' a t | App : { id : string ; f : ( ' a -> ' b ) t ; x : ' a t ; } -> ' b t | Both : { id : string ; fst : ' a t ; snd : ' b t ; } -> ( ' a ' * b ) t | List : { id : string ; elts : ' a t list ; } -> ' a list t | Eval_path : { id : string ; workflow : path t } -> str...
let digest x = Digest . to_hex ( Digest . string ( Marshal . ( to_string x [ No_sharing ] ) ) )
let id : type s . s t -> string = function | Input { id ; _ } -> id | Select { id ; _ } -> id | Plugin { id ; _ } -> id | Pure { id ; _ } -> id | App { id ; _ } -> id | Spawn { id ; _ } -> id | Both { id ; _ } -> id | Eval_path { id ; _ } -> id | Shell { id ; _ } -> id | List { id ; _ } -> id | List_nth { id ; _ } -> i...
let any x = Any x
let compare_token x y = match x , y with | Path_token wx , Path_token wy -> String . compare ( id wx ) ( id wy ) | Path_token _ , _ -> - 1 | Path_list_token x , Path_list_token y -> ( match String . compare ( id x . elts ) ( id y . elts ) with | 0 -> compare ( x . sep , x . quote ) ( y . sep , y . quote ) | i -> i ) | ...
module Any = struct module T = struct type t = any let id ( Any w ) = id w let compare x y = String . compare ( id x ) ( id y ) let equal x y = String . equal ( id x ) ( id y ) let hash x = Hashtbl . hash ( id x ) end module Set = Set . Make ( T ) module Table = Hashtbl . Make ( T ) module Map = Map . Make ( T ) includ...
let input ? version path = let id = digest ( ` Input , path , version ) in Input { id ; path ; version }
let select dir sel = let dir , sel = match dir with | Select { dir ; sel = root ; _ } -> dir , root @ sel | Input _ | Plugin _ | Shell _ -> dir , sel | _ -> assert false in let id = digest ( " select " , id dir , sel ) in Select { id ; dir ; sel }
let pure ~ id value = Pure { id ; value }
let data value = pure ~ id ( : digest value ) value
let app f x = let id = digest ( ` App , id f , id x ) in App { id ; f ; x }
let ( $ ) = app
let both fst snd = let id = digest ( ` Both , id fst , id snd ) in Both { id ; fst ; snd }
let add_mem_dep mem deps = match mem with | None -> deps | Some mem -> any mem :: deps
let plugin ( ? descr = " " ) ( ? np = 1 ) ? mem ? version workflow = let id = digest ( ` Value , id workflow , version ) in Plugin { id ; descr ; np ; mem ; version ; task = Value_plugin workflow ; deps = add_mem_dep mem [ any workflow ] }
let path_plugin ( ? descr = " " ) ( ? np = 1 ) ? mem ? version workflow = let id = digest ( ` Value , id workflow , version ) in Plugin { id ; descr ; np ; mem ; version ; task = Path_plugin workflow ; deps = add_mem_dep mem [ any workflow ] }
let path w = Eval_path { id = digest ( ` Eval_path , id w ) ; workflow = w }
let digestible_cmd = Command . map ~ f ( : function | Path_token w -> id w | Path_list_token { elts ; sep ; quote } -> digest ( id elts , sep , quote ) | String_token w -> id w )
let shell ( ? descr = " " ) ? mem ( ? np = 1 ) ? version ( ? img = [ ] ) cmds = let cmd = Command . And_list cmds in let shell_cmd = { cmd ; images = img ; } in let id = digest ( " shell " , version , digestible_cmd cmd ) in let deps = add_mem_dep mem ( Command . deps cmd ~ compare : compare_token |> List . map ( funct...
let list elts = let id = digest ( " list " , List . map id elts ) in List { id ; elts }
let rec independent_workflows_aux cache w ~ from : u = if Any . equal w u then Any . Map . add w ( true , Any . Set . empty ) cache else if Any . Map . mem w cache then cache else ( let deps = Any . deps w in let f acc w = independent_workflows_aux acc w ~ from : u in let cache = List . fold_left f cache deps in let ch...
let independent_workflows w ~ from : u = let cache = independent_workflows_aux Any . Map . empty w ~ from : u in Any . Map . find w cache |> snd |> Any . Set . elements
let spawn elts ~ f = let hd = pure ~ id " : __should_never_be_executed__ " List . hd in let u = app hd elts in let f_u = f u in let id = digest ( ` Spawn , id elts , id f_u ) in let deps = any elts :: independent_workflows ( any f_u ) ~ from ( : any u ) in Spawn { id ; elts ; f ; deps }
let list_nth w i = let id = digest ( ` List_nth , id w , i ) in List_nth { id ; elts = w ; index = i }
let glob ? pattern ? type_selection dir = let id = digest ( ` Glob , id dir , pattern , type_selection ) in Glob { id ; dir ; pattern ; type_selection }
let trywith w failsafe = let id = digest ( ` Trywith , id w , id failsafe ) in Trywith { id ; w ; failsafe }
let ifelse cond _then_ _else_ = let id = digest ( ` Ifelse , id cond , id _then_ , id _else_ ) in Ifelse { id ; cond ; _then_ ; _else_ }
module Remove = struct let file ~ run_with path = let open KEDSL in workflow_node nothing ~ name ( : sprintf " rm -% s " ( Filename . basename path ) ) ~ ensures ( ` : Is_verified ( ` Command_returns ( Command . shell ~ host : Machine . ( as_host run_with ) ( sprintf " ls % s " path ) , 2 ) ) ) ~ make ( : Machine . qui...
module Gunzip = struct let concat ( ~ run_with : Machine . t ) bunch_of_dot_gzs ~ result_path = let open KEDSL in let program = Program . ( exec [ " mkdir " ; " - p " ; Filename . dirname result_path ] && shf " gunzip - c % s > % s " ( List . map bunch_of_dot_gzs ~ f ( : fun o -> Filename . quote o # product # path ) |...
module Cat = struct let concat ( ~ run_with : Machine . t ) bunch_of_files ~ result_path = let open KEDSL in let program = Program . ( exec [ " mkdir " ; " - p " ; Filename . dirname result_path ] && shf " cat % s > % s " ( List . map bunch_of_files ~ f ( : fun o -> Filename . quote o # product # path ) |> String . con...
module Download = struct let wget_program ? output_filename url = KEDSL . Program . exec [ " wget " ; " - O " ; Option . value output_filename ~ default : Filename . ( basename url ) ; url ] let wget_to_folder ~ host ( ~ run_program : Machine . Make_fun . t ) ~ test_file ~ destination url = let open KEDSL in let name =...
module Vcftools = struct let vcf_process_n_to_1_no_machine ~ host ~ vcftools ( ~ run_program : Machine . Make_fun . t ) ( ? more_edges = [ ] ) ~ vcfs ~ make_product ~ final_vcf command_prefix = let open KEDSL in let name = sprintf " % s -% s " command_prefix ( Filename . basename final_vcf ) in let make = run_program ~...
module Variable_tool_paths = struct let single_file ~ run_with ~ tool path = let open KEDSL in let condition = let init = Machine . Tool . init tool in let host = Machine . as_host ~ with_shell " : bash " run_with in let condition_cmd = Ketrew_pure . Program . to_single_shell_command Program . ( init && shf " test - e ...
module type Work_list = sig type elt type t val empty : t val is_empty : t -> bool val push : Remanent_parameters_sig . parameters -> Exception . method_handler -> elt -> t -> Exception . method_handler * t val pop : Remanent_parameters_sig . parameters -> Exception . method_handler -> t -> Exception . method_handler *...
module WlMake ( Ord : OrderedType with type t = int ) = ( struct module WSetMap = Map_wrapper . Make ( SetMap . Make ( Ord ) ) module WSet = WSetMap . Set type elt = Ord . t type t = elt list * elt list * WSet . t let empty = [ ] , [ ] , WSet . empty let is_empty x = let _ , _ , pool = x in WSet . is_empty pool let pus...