text stringlengths 12 786k |
|---|
let remove_symbol t symbol = if For_names . is_empty t . names then t else let names = For_names . remove t . names ( Name . symbol symbol ) in { t with names } |
let remove_code_id t code_id = if For_code_ids . is_empty t . code_ids && For_code_ids . is_empty t . newer_version_of_code_ids then t else let code_ids = For_code_ids . remove t . code_ids code_id in let newer_version_of_code_ids = For_code_ids . remove t . newer_version_of_code_ids code_id in { ... |
let remove_code_id_or_symbol t ( cis : Code_id_or_symbol . t ) = Code_id_or_symbol . pattern_match cis ~ code_id ( : fun code_id -> remove_code_id t code_id ) ~ symbol ( : fun symbol -> remove_symbol t symbol ) |
let remove_continuation t k = if For_continuations . is_empty t . continuations && For_continuations . is_empty t . continuations_in_trap_actions then t else let continuations = For_continuations . remove t . continuations k in let continuations_with_traps = For_continuations . remove t . continuati... |
let remove_one_occurrence_of_value_slot_in_projections t value_slot name_mode = if For_value_slots . is_empty t . value_slots_in_projections then t else let value_slots_in_projections = For_value_slots . remove_one_occurrence t . value_slots_in_projections value_slot name_mode in { t with value_slots_in_pro... |
let greatest_name_mode_var t var = For_names . greatest_name_mode t . names ( Name . var var ) |
let downgrade_occurrences_at_strictly_greater_name_mode { names ; continuations ; continuations_with_traps ; continuations_in_trap_actions ; function_slots_in_projections ; value_slots_in_projections ; function_slots_in_declarations ; value_slots_in_declarations ; code_ids ; newer_version_of_code_id... |
let with_only_variables { names ; _ } = let names = For_names . filter names ~ f : Name . is_var in { empty with names } |
let with_only_names_and_code_ids_promoting_newer_version_of { names ; code_ids ; newer_version_of_code_ids ; _ } = let code_ids = For_code_ids . union code_ids newer_version_of_code_ids in { empty with names ; code_ids } |
let without_names_or_continuations { names = _ ; continuations = _ ; continuations_with_traps = _ ; continuations_in_trap_actions = _ ; function_slots_in_projections ; value_slots_in_projections ; function_slots_in_declarations ; value_slots_in_declarations ; code_ids ; newer_version_of_code... |
let without_code_ids t = { t with code_ids = For_code_ids . empty ; newer_version_of_code_ids = For_code_ids . empty } |
let fold_names t ~ init ~ f = For_names . fold t . names ~ init ~ f |
let fold_variables t ~ init ~ f = For_names . fold t . names ~ init ~ f ( : fun acc name -> Name . pattern_match name ~ var ( : fun var -> f acc var ) ~ symbol ( : fun _ -> acc ) ) |
let fold_continuations_including_in_trap_actions t ~ init ~ f = let init = For_continuations . fold t . continuations ~ init ~ f in For_continuations . fold t . continuations_in_trap_actions ~ init ~ f |
let filter_names t ~ f = let names = For_names . filter t . names ~ f in { t with names } |
let fold_code_ids t ~ init ~ f = For_code_ids . fold t . code_ids ~ init ~ f |
let apply_renaming ( { names ; continuations ; continuations_with_traps ; continuations_in_trap_actions ; function_slots_in_projections ; value_slots_in_projections ; function_slots_in_declarations ; value_slots_in_declarations ; code_ids ; newer_version_of_code_ids } as t ) renaming = if Ren... |
let affected_by_renaming { names ; continuations ; continuations_with_traps = _ ; continuations_in_trap_actions ; function_slots_in_projections = _ ; value_slots_in_projections = _ ; function_slots_in_declarations = _ ; value_slots_in_declarations = _ ; code_ids ; newer_version_of_code_ids... |
let restrict_to_value_slots_and_function_slots { names = _ ; continuations = _ ; continuations_with_traps = _ ; continuations_in_trap_actions = _ ; function_slots_in_projections ; value_slots_in_projections ; function_slots_in_declarations ; value_slots_in_declarations ; code_ids = _ ; new... |
type linking_error = Undefined_global of string | Unavailable_primitive of string | Uninitialized_global of string |
type error = Not_a_bytecode_file of string | Inconsistent_import of string | Unavailable_unit of string | Unsafe_file | Linking_error of string * linking_error | Corrupted_interface of string | File_not_found of string | Cannot_open_dll of string | Inconsistent_implementation of string |
let dll_filename fname = if Filename . is_implicit fname then Filename . concat ( Sys . getcwd ( ) ) fname else fname |
let read_file filename priv = let dll = dll_filename filename in if not ( Sys . file_exists dll ) then raise ( Error ( File_not_found dll ) ) ; let ( handle , data ) as res = ndl_open dll ( not priv ) in if Obj . tag ( Obj . repr res ) = Obj . string_tag then raise ( Error ( ... |
type implem_state = | Loaded | Check_inited of int |
type state = { ifaces : ( string * string ) StrMap . t ; implems : ( string * string * implem_state ) StrMap . t ; } |
let empty_state = { ifaces = StrMap . empty ; implems = StrMap . empty ; } |
let global_state = ref empty_state |
let allow_extension = ref true |
let inited = ref false |
let default_available_units ( ) = let map : ( string * Digest . t * Digest . t * string list ) list = Marshal . from_string ( ndl_getmap ( ) ) 0 in let exe = Sys . executable_name in let rank = ref 0 in global_state := List . fold_left ( fun st ( name , crc_intf , crc_impl ,... |
let init ( ) = if not ! inited then default_available_units ( ) |
let add_check_ifaces allow_ext filename ui ifaces = List . fold_left ( fun ifaces ( name , crc ) -> if name = ui . dynu_name then StrMap . add name ( crc , filename ) ifaces else try let ( old_crc , old_src ) = StrMap . find name ifaces in if old_crc <> crc then raise ( Error ( Inco... |
let check_implems filename ui implems = List . iter ( fun ( name , crc ) -> match name with " | Out_of_memory " " | Sys_error " " | Failure " " | Invalid_argument " " | End_of_file " " | Division_by_zero " " | Not_found " " | Match_failure " " | Stack_overflow " ... |
let loadunits filename handle units state = let new_ifaces = List . fold_left ( fun accu ui -> add_check_ifaces ! allow_extension filename ui accu ) state . ifaces units in let new_implems = List . fold_left ( fun accu ui -> check_implems filename ui accu ; StrMap . add ui . dynu_name ( ui . ... |
let load priv filename = init ( ) ; let ( filename , handle , units ) = read_file filename priv in let nstate = loadunits filename handle units ! global_state in if not priv then global_state := nstate |
let loadfile filename = load false filename |
let loadfile_private filename = load true filename |
let allow_only names = init ( ) ; let old = ! global_state . ifaces in let ifaces = List . fold_left ( fun ifaces name -> try StrMap . add name ( StrMap . find name old ) ifaces with Not_found -> ifaces ) StrMap . empty names in global_state := { ! global_state with ifaces = ifaces } ... |
let prohibit names = init ( ) ; let ifaces = List . fold_right StrMap . remove names ! global_state . ifaces in global_state := { ! global_state with ifaces = ifaces } ; allow_extension := false |
let digest_interface _ _ = failwith " Dynlink . digest_interface : not implemented in native code " |
let add_interfaces _ _ = failwith " Dynlink . add_interfaces : not implemented in native code " |
let add_available_units _ = failwith " Dynlink . add_available_units : not implemented in native code " |
let clear_available_units _ = failwith " Dynlink . clear_available_units : not implemented in native code " |
let allow_unsafe_modules _ = ( ) |
let error_message = function Not_a_bytecode_file name -> name ^ " is not an object file " | Inconsistent_import name -> " interface mismatch on " ^ name | Unavailable_unit name -> " no implementation available for " ^ name | Unsafe_file -> " this object file uses unsafe features " | Linking_... |
let adapt_filename f = Filename . chop_extension f ^ " . cmxs " |
[ @@@ ocaml . flambda_o3 ] = " caml_nativeint_of_float " " caml_nativeint_of_float_unboxed " [ @@ unboxed ] [ @@ noalloc ] = " caml_nativeint_to_float " " caml_nativeint_to_float_unboxed " [ @@ unboxed ] [ @@ noalloc ] |
let succ n = add n 1n |
let pred n = sub n 1n |
let abs n = if n >= 0n then n else neg n |
let min_int = shift_left 1n ( size - 1 ) |
let max_int = sub min_int 1n |
let lognot n = logxor n ( - 1n ) |
let unsigned_to_int = let max_int = of_int Stdlib . max_int in fun n -> if compare zero n <= 0 && compare n max_int <= 0 then Some ( to_int n ) else None |
let to_string n = format " % d " n |
let of_string_opt s = try Some ( of_string s ) with Failure _ -> None |
let compare ( x : t ) ( y : t ) = Stdlib . compare x y |
let equal ( x : t ) ( y : t ) = compare x y = 0 |
let unsigned_compare n m = compare ( sub n min_int ) ( sub m min_int ) |
let unsigned_div n d = if d < zero then if unsigned_compare n d < 0 then zero else one else let q = shift_left ( div ( shift_right_logical n 1 ) d ) 1 in let r = sub n ( mul q d ) in if unsigned_compare r d >= 0 then succ q else q |
let unsigned_rem n d = sub n ( mul ( unsigned_div n d ) d ) |
let ( >>= ) = Lwt . ( >>= ) |
type tls_role = TlsClient of Ssl . context | TlsServer of Ssl . context |
let io_complete op fd buffer = let ofs = buffer . Cstruct . off in let len = buffer . Cstruct . len in let buf = buffer . Cstruct . buffer in let rec loop acc ofs len = op fd buf ofs len >>= fun n -> let len ' = len - n in let acc ' = acc + n in if len ' = 0 || n = 0 then return acc ' ... |
let tls_channel_of_fd fd role ( ) = let ctx , ssl_start = match role with | TlsClient ctx -> ( ctx , Lwt_ssl . ssl_connect ) | TlsServer ctx -> ( ctx , Lwt_ssl . ssl_accept ) in ssl_start fd ctx >>= fun sock -> let read_tls buf = io_complete Lwt_ssl . read_bytes sock buf >>= fun ( ) ... |
let cleartext_channel_of_fd fd role_opt = let read_clear = Lwt_cstruct . ( complete ( read fd ) ) in let write_clear = Lwt_cstruct . ( complete ( write fd ) ) in let close_clear ( ) = Lwt_unix . close fd in let make_tls_channel = match role_opt with | None -> None | Some role -> Some ... |
let generic_channel_of_fd fd role = let ch = cleartext_channel_of_fd fd role in return ( Channel . generic_of_cleartext_channel ch ) |
let connect hostname port = let socket = Lwt_unix . socket Lwt_unix . PF_INET Lwt_unix . SOCK_STREAM 0 in Lwt_unix . gethostbyname hostname >>= fun host_info -> let server_address = host_info . Lwt_unix . h_addr_list . ( 0 ) in Lwt . catch ( fun ( ) -> Lwt_unix . connect socket ( L... |
let init_tls_get_ctx ? curve ~ certfile ~ ciphersuites = Ssl_threads . init ( ) ; Ssl . init ( ) ; let mk_ctx role_ctx = Ssl . create_context Ssl . TLSv1_2 role_ctx in let ctx = mk_ctx Ssl . Server_context in Ssl . use_certificate ctx certfile certfile ; Ssl . set_cipher_list ctx ciphe... |
let with_block filename f = Block . connect filename >>= fun b -> Lwt . finalize ( fun ( ) -> f b ) ( fun ( ) -> Block . disconnect b ) |
let ignore_exn t ( ) = Lwt . catch t ( fun _ -> Lwt . return_unit ) |
let with_channel fd tls_role f = let clearchan = cleartext_channel_of_fd fd tls_role in Lwt . finalize ( fun ( ) -> f clearchan ) ( ignore_exn ( fun ( ) -> clearchan . close_clear ( ) ) ) |
let cpt = ref 0 |
let tot_time = ref 0 . |
let measure_time f s = let t0 = Unix . gettimeofday ( ) in let a = f ( ) in let t1 = Unix . gettimeofday ( ) in Printf . printf " % s time % d : % Fs \ n " %! s ! cpt ( t1 . - t0 ) ; tot_time := ! tot_time . + ( t1 . - t0 ) ; incr cpt ; a ; ; |
let devices = measure_time Spoc . Devices . init " init " |
let blockSize = ref 64l |
let softening = ref 1e - 9 mutable x : float32 ; mutable y : float32 ; mutable z : float32 ; w : float32 ; } |
let randomizeBodies data n = for i = 0 to n - 1 do let x = ( 2 . 0 . * ( Random . float 1 . ) . - 1 . ) ; and y = ( 2 . 0 . * ( Random . float 1 . ) . - 1 . ) ; and z = ( 2 . 0 . * ( Random . float 1 . ) . - 1 . ) ; and w = 0 ... |
let bodyForce = kern p v dt n -> let open Std in let open Math in let open Float32 in let i = block_idx_x * block_dim_x + thread_idx_x in if ( i < n ) then let mutable fx = zero in let mutable fy = zero in let mutable fz = zero in let dist = fun a b c -> let open Math in let open Float32 in add ( add (... |
let _ = let devid = ref 0 in let nBodies = ref 30_000 in let nIters = ref 10 in let arg1 = ( " - nBodies " , Arg . Int ( fun i -> nBodies := i ) , " number of bodies " ) and arg2 = ( " - nIters " , Arg . Int ( fun i -> nIters := i ) , " number of iteration " ) ... |
let cpt = ref 0 |
let tot_time = ref 0 . |
let measure_time f s = let t0 = Unix . gettimeofday ( ) in let a = f ( ) in let t1 = Unix . gettimeofday ( ) in Printf . printf " % s time % d : % Fs \ n " %! s ! cpt ( t1 . - t0 ) ; tot_time := ! tot_time . + ( t1 . - t0 ) ; incr cpt ; a ; ; |
let devices = measure_time ( Devices . init ) " init " lat : float32 ; lng : float32 ; } |
let euclid = kern locations distances numRecords lat lng -> let open Std in let open Math . Float32 in let globalId = block_dim_x * ( grid_dim_x * block_idx_y + block_idx_x ) + thread_idx_x in if ( globalId < numRecords ) then let latLong = locations . [ < globalId ] > in distances . [ <... |
type record = { recString : string ; mutable distance : float ; } |
let loadData fname records locations = let flist = open_in fname in let dbname = ref " " in let recNum = ref 0 in ( try while true do dbname := input_line flist ; if ! dbname = " " then raise End_of_file ; let fp = try ( open_in ! dbname ) with | _ -> failwith ( " Error opening a db ... |
let findLowest records distances numRecords topN = for i = 0 to topN - 1 do let minLoc = ref i in let tempRec = ref { recString " " ; = distance = 0 . ; } in let tempval = ref 0 . in for j = i to numRecords - 1 do tempval := Mem . unsafe_get distances j ; if ! tempval < Mem . uns... |
let _ = let filename = ref " " in let resultsCount = ref 10 in let lat = ref 0 . and lng = ref 0 . in let devId = ref ~- 1 in let arg0 = ( " - f " , Arg . String ( fun s -> filename := s ) , " the filename that lists the data input files " ) and arg1 = ( " - r " , ... |
type t = unit Code0 . t |
let create code_id ~ free_names_of_params_and_body ~ newer_version_of ~ params_arity ~ num_trailing_local_params ~ result_arity ~ result_types ~ contains_no_escaping_local_allocs ~ stub ~ inline ~ is_a_functor ~ recursive ~ cost_metrics ~ inlining_arguments ~ dbg ~ is_tupled ~ is_my_closure_used ~ inli... |
let print = Code0 . print ~ print_function_params_and_body : Unit . print |
let apply_renaming = Code0 . apply_renaming ~ apply_renaming_function_params_and_body ( : fun ( ) _ -> ( ) ) |
type pt = { x : float ; y : float ; z : float } let = { x = p1 . x - p2 . x ; y = p1 . y - p2 . y ; z = p1 . z - p2 . z } let = let dx = p1 . x - p2 . x and dy = p1 . y - p2 . y and dz = p1 . z - p2 . z in sqrt ( ( dx * dx ) + ( dy * dy ) + ( dz ... |
type tfo = { a : float ; b : float ; c : float ; d : float ; e : float ; f : float ; g : float ; h : float ; i : float ; tx : float ; ty : float ; tz : float } |
let tfo_id = { a = 1 . 0 ; b = 0 . 0 ; c = 0 . 0 ; d = 0 . 0 ; e = 1 . 0 ; f = 0 . 0 ; g = 0 . 0 ; h = 0 . 0 ; i = 1 . 0 ; tx = 0 . 0 ; ty = 0 . 0 ; tz = 0 . 0 } let = { x = ( ( p . x * t . a ) + ( p . y * t . ... |
type nuc_specific = A of pt * pt |
type variable = { id : int ; t : tfo ; n : nuc } |
let mk_var i t n = { id = i ; t = t ; n = n } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.