Module Utils

Shared utilities of arrayjit: the global settings and configuration reading (command line, environment, config file, profiles) with its key registry and cache-identity classification, debug-artifact and log paths with their startup cleanup, routine-log capture, C-stderr and device-init safeguards, and small list, sexp and float-rendering helpers.

val count_backend_compile : Base.unit -> Base.unit

Counts one completed backend compile (code generation or deferred device compile) on this domain.

val backend_compiles : Base.unit -> Base.int

The number of backend compiles completed on this domain so far; see count_backend_compile.

type settings = {
  1. mutable log_level : Base.int;
  2. mutable debug_log_from_routines : Base.bool;
    (*

    If the debug_log_from_routines flag is true _and_ the flag log_level > 1, backends should generate code (e.g. fprintf statements) to log the execution, and arrange for the logs to be emitted via ppx_minidebug.

    *)
  3. mutable output_debug_files_in_build_directory : Base.bool;
    (*

    Writes compilation related files in the build_files subdirectory of the run directory (additional files, or files that would otherwise be in temp directory). When both output_debug_files_in_build_directory = true and log_level > 1, compilation should also preserve debug and line information for runtime debugging.

    *)
  4. mutable fixed_state_for_init : Base.int Base.option;
  5. mutable print_decimals_precision : Base.int;
    (*

    When rendering arrays etc., outputs this many decimal digits.

    *)
  6. mutable check_half_prec_constants_cutoff : Base.float Base.option;
    (*

    If given, generic code optimization should fail if a half precision FP16 constant exceeds the cutoff.

    *)
  7. mutable default_prng_variant : Base.string;
    (*

    The default variant of threefry4x32 PRNG to use. Options: "crypto" (20 rounds) or "light" (2 rounds). Defaults to "light" for better performance.

    *)
  8. mutable large_models : Base.bool;
    (*

    If true, use uint64 for indexing arithmetic. If false, use uint32 for indexing arithmetic. This affects all backends' kernel index parameters and local index variables, and gates the per-pool offset width (uint32 caps a pool at 4 GB; see the pool allocator). Decoupled in intent from element indexing within a single tensor, though both currently follow it.

    *)
}

Process-wide runtime settings, initialized from the configuration.

val sexp_of_settings : settings -> Sexplib0.Sexp.t
val settings : settings

The global settings record, set from the configuration at startup; see restore_settings.

val accessed_global_args : Base.String.t Base.Hash_set.t

The configuration keys this process has read through the configuration getters so far.

val known_config_keys : (Base.String.t, Base.String.comparator_witness) Base.Set.t

Every recognized configuration key; a source naming any other key is warned about.

type config_key_class =
  1. | Aggregate
    (*

    Selects values for other keys rather than acting itself; those keys carry the classification.

    *)
  2. | Code_borne
    (*

    Changes the lowered code or its placements, hence the canonical digest (Ir.Schedule_cache.digest, the "digest" key component) that every cache key starts with. Nothing to add: the code is the identity.

    *)
  3. | Keyed of Base.string
    (*

    Not fully captured by the lowered code, so it has to be carried explicitly — by this named component of Ir.Schedule_cache.key_components. This is the class gh-ocannl-568 was an omission from.

    *)
  4. | Search_shaping
    (*

    Shapes which schedule a search proposes, times or crowns, but not what a crowned one means or how fast it then runs: a saved schedule carries its own ops and replay re-derives nothing from these. Two processes differing only here may find different winners; each is a valid winner for the other.

    *)
  5. | Placement_shaping
    (*

    Steers Train.tune_placements above any single search: which placement programs it searches (each a different program, keyed on its own digest) and which of them ships. No single Autotune.tune call reads it, so it is neither in the cache key nor in the search trajectory's identity (config_class_fingerprint of Search_shaping): a search's timed record is the same record whatever the level above it was told (gh-ocannl-1192).

    *)
  6. | Untimed_model
    (*

    Steers the untuned regime's untimed pick: Autotune.model_default, the pick by the analytic cost model -- whether a recipe's untuned compile routes through it, and how widely it searches. It times nothing and neither replays nor stores a schedule-cache entry, and no Autotune.tune call reads these keys, so they are neither in the cache key nor in the search trajectory's identity (config_class_fingerprint of Search_shaping): a search's timed record is the same record whatever the untuned regime beside it was told (gh-ocannl-1241). Autotune.seeded_default's keys started here and are Search_shaping since the search seeds its plan first (gh-ocannl-1388).

    *)
  7. | Execution_neutral
    (*

    Host-side behavior only: logging, debug artifacts, directories, validation and error reporting, allocation layout, launch mechanics. Nothing a kernel does depends on it.

    *)

What a configuration key does to the identity a compilation cache keys on.

val config_key_classification : (config_key_class * Base.string * Base.string Base.list) Base.list

The class of every known key, as (class, reason, keys) groups.

val classify_config_key : Base.string -> (config_key_class * Base.string) Base.option

The class and reason recorded for a key, or None when it is unclassified.

val bool_of_config_string : arg_name:Base.String.t -> Base.String.t -> Base.bool

Parses true/1 or false/0, any case, stripped; raises Invalid_argument naming arg_name.

type config_value_kind =
  1. | Flag
    (*

    bool_of_config_string: true/1 and false/0, any case, stripped

    *)
  2. | Integer
    (*

    Int.of_string of the stripped text

    *)
  3. | Float_number
    (*

    Float.of_string of the stripped text, NaN excluded

    *)
  4. | Keyword
    (*

    a mode name, stripped and lowercased, such as auto; which names are modes is the read site's ~parse (registered_keyword), so the kind itself refuses nothing

    *)
  5. | Text
    (*

    stripped text, such as a path

    *)
  6. | Positive_float_or_unset
    (*

    an override that only a positive float sets: empty and non-positive numbers mean "not overridden", as Autotune.peak_override reads it

    *)
  7. | Float_at_least of {
    1. floor : Base.float;
    }
    (*

    a float clamped up to floor, NaN excluded: every spelling the read site cannot tell apart from another canonicalizes alike, so the read (Sketch_families.pad_waste_max) and the fingerprint share one owner of the clamp

    *)

How a key's value parses: the one parse shared by the typed getters and the class fingerprint.

val canonical_config_value : config_value_kind -> Base.String.t -> Base.String.t Base.Option.t

The value's canonical spelling under the kind, or None when it does not parse as one.

val config_key_defaults : (Base.string * (config_value_kind * Base.string)) Base.list

The built-in default and value kind of each key whose resolved value an identity renders.

val registered_config_default : Base.string -> (config_value_kind * Base.string) Base.option

The key's config_key_defaults row, if it has one.

val log_config_sourcing : Base.bool Base.ref

Whether to trace each setting's source to stderr; unused in-tree, a switch a program may flip.

val log_config_json : Base.bool Base.ref

Whether to print each resolved setting to stderr as JSON; unused in-tree, a switch to flip.

val env_var_name : Base.String.t -> Base.String.t

The environment spelling of a config key: OCANNL_ followed by the key in uppercase.

val env_names_case_insensitive : Base.bool

Whether the runtime's getenv matches names case-insensitively (native Windows, not Cygwin).

type env_var_class =
  1. | Env_not_addressed
    (*

    not ocannl-prefixed: someone else's variable entirely

    *)
  2. | Env_reserved of Base.string
    (*

    in a reserved non-configuration namespace, named by its prefix

    *)
  3. | Env_config_key of Base.string
    (*

    a spelling read_env_var reads, of that key

    *)
  4. | Env_unread_spelling of Base.string
    (*

    a known key, spelled in a way nothing reads: dashed, or not fully uppercase where case matters. A configuration ERROR rather than a warning -- see unread_env_vars.

    *)
  5. | Env_unread_reserved of Base.string
    (*

    in a reserved namespace, in a casing its reader does not consult

    *)
  6. | Env_unknown_key of Base.string
    (*

    addressed to the configuration, naming no key

    *)

What an environment variable name is to OCANNL's configuration.

val classify_env_var : ?case_insensitive:Base.bool -> Base.String.t -> env_var_class

Classifies a variable name; case_insensitive defaults to env_names_case_insensitive.

val env_var_in_ambient_record : ?case_insensitive:Base.bool -> Base.String.t -> Base.bool

Whether the test suite's ambient record carries the variable: config-addressed, not the backend.

val unread_env_vars : Base.unit -> (Base.String.t * Base.bool * Base.String.t) Base.List.t

Non-empty config-addressed variables nothing reads, as sorted (name, is_fatal, reason).

val cmdline_var_names : ?qualified_only:Base.bool -> Base.String.t -> Base.String.t Base.List.t

A key's dash-led command-line spellings: prefixed, then prefix-free unless qualified_only.

val cmdline_var_prefixes : ?qualified_only:Base.bool -> Base.String.t -> Base.String.t Base.List.t

Argument prefixes: each cmdline_var_names spelling followed by _, -, = or nothing.

type config_token_shape =
  1. | Command_line_token
  2. | Environment_assignment_token
  3. | Documentation_assignment_token
    (*

    The grammatical shape of a configuration token, independent of the key registry.

    *)
type config_token = {
  1. token_shape : config_token_shape;
  2. token_key : Base.string;
}

A configuration token's shape and its normalized key.

val config_token_command_line_prefixes : Base.String.t Base.List.t

The prefixes that can begin a qualified command-line configuration token.

type config_token_rejection =
  1. | Not_configuration_syntax
  2. | Empty_qualified_key
  3. | Invalid_command_line_key
  4. | Invalid_environment_key
  5. | Invalid_documentation_key
    (*

    Why a token has no configuration reading; syntax only, never registry membership.

    *)
type config_token_parse =
  1. | Accepted of config_token
  2. | Ambiguous of {
    1. explicit : config_token Base.option;
    2. candidates : config_token Base.list;
    3. fallback : config_token;
    }
  3. | Rejected of {
    1. reason : config_token_rejection;
    2. qualified : config_token Base.option;
    }
    (*

    A lexed token: one reading, longest-first candidate readings, or a rejection.

    *)
val parse_config_token : ?documentation:Base.bool -> Base.String.t -> config_token_parse

Lexes a token without consulting known_config_keys; documentation admits bare assignments.

val qualified_only_config_keys : (Base.String.t, Base.String.comparator_witness) Base.Set.t

Keys whose prefix-free command-line spellings are never claimed, such as profile.

val cmdline_arg_value : ?qualified_only:Base.bool -> Base.String.t -> Base.String.t -> Base.String.t Base.option

cmdline_arg_value n arg is arg's value for key n, unless a longer registered key owns arg.

val read_cmdline_var : ?qualified_only:Base.bool -> Base.String.t -> (Base.String.t * Base.String.t) Base.option

The first command-line value for a key, with the Sys.argv element it came from.

val cmdline_arg_is_config_key : Base.String.t -> Base.bool

Whether a raw command-line argument addresses some known key under any spelling read.

val read_env_var : Base.String.t -> (Base.String.t * Base.String.t) Base.option

The environment value for a key, with the variable's name; an empty value counts as unset.

type config_level =
  1. | Cmdline_level
  2. | Env_level
  3. | Config_file_level
    (*

    The source levels a setting can come from, in decreasing priority.

    *)
val describe_config_level : config_level -> Base.string

A level's name in prose, such as "the commandline".

type config_source =
  1. | From_cmdline of Base.string
    (*

    the matching Sys.argv element

    *)
  2. | From_env of Base.string
    (*

    the matching environment variable

    *)
  3. | From_config_file
  4. | From_profile of config_level * Base.string
    (*

    the level that picked the profile, and its name

    *)
  5. | From_default
    (*

    Where get_global_arg found a value.

    *)
val config_source_label : config_source -> Base.string

A short provenance tag, such as "environment" or "profile 'reproducible' via the commandline".

val describe_config_source : value:Base.string -> default:Base.string -> config_source -> Base.string

The sourcing-trace line for a resolved value, or for the default used when nothing set it.

val resolve_config_value : cmdline:('a -> ('b * Base.string) Base.Option.t) -> env:('a -> ('b * Base.string) Base.Option.t) -> file:('a -> 'b Base.Option.t) -> profile:(config_level * Base.string * ('a -> 'b Base.Option.t)) Base.option -> default:'b -> arg_name:'a -> 'b * config_source

The precedence walk: each level's explicit value, then the profile picked there, else default.

val parse_config_lines : source:Base.String.t -> Base.String.t Base.List.t -> (Base.String.t * Base.String.t) Base.List.t

Parses ocannl_config-syntax lines into (key, value) pairs; source names them in errors.

val config_file_args : (Base.String.t, Base.String.t) Base.Hashtbl.t

The settings of the ocannl_config file found up from the working directory, if any.

val config_file_path : Base.string

The path of the config file read, or "" when none was.

val profile_payloads : (Base.string * Base.string) Base.list

The embedded profile payloads by name, each a partial ocannl_config text.

val parse_profile_payload : name:Base.string -> Base.String.t -> (Base.String.t, Base.String.t) Base.Hashtbl.t

Parses a profile payload into a table; fails on an unknown or profile-ineligible key.

val resolve_profile_selection : cmdline:(Base.string -> (Base.String.t * Base.string) Base.Option.t) -> env:(Base.string -> (Base.String.t * Base.string) Base.Option.t) -> file:(Base.string -> Base.String.t Base.Option.t) -> Base.String.t * config_source

The normalized profile name picked by ordinary source precedence, with its source.

val active_profile : (config_level * Base.String.t * (Base.String.t, Base.String.t) Base.Hashtbl.t) Base.Option.t

The profile picked for this run, if any: its level, name and parsed payload.

type config_record = {
  1. key : Base.string;
  2. value : Base.string;
  3. source : config_source;
}

One resolution of one setting: the key, the raw value settled on, and where it came from.

val json_string_literal : Base.String.t -> Base.string

A JSON string literal: quote, backslash and control characters escaped, other bytes as they are.

val config_record_to_json : config_record -> Base.string

The one-line JSON object (schema version 1) the log_config_json stream prints for a record.

val resolved_config : Base.unit -> config_record Base.List.t

Every setting this process has resolved so far, in first-resolution order.

val registered_getter_of_kind : config_value_kind -> Base.string

The name of the typed getter reading keys of a kind, such as "registered_int".

val get_global_arg_with_source : default:Base.String.t -> arg_name:Base.string -> Base.String.t * config_source

get_global_arg with the value's source; refuses a key with a config_key_defaults row.

val get_global_arg : default:Base.String.t -> arg_name:Base.string -> Base.String.t

The value of config key arg_name from the command line, environment, config file or profile, else default.

exception Invalid_config_value of {
  1. key : Base.string;
  2. value : Base.string;
  3. expected : Base.string;
}

Raised by a typed getter when a setting's value does not parse as its key's kind.

val registered_flag : arg_name:Base.string -> Base.bool

A registered Flag key's value, defaulting to its config_key_defaults row.

val registered_int : arg_name:Base.string -> Base.Int.t

A registered Integer key's value; raises Invalid_config_value on unparsable text.

val registered_float : arg_name:Base.string -> Base.Float.t

A registered Float_number key's value; raises Invalid_config_value on unparsable text.

val registered_text : arg_name:Base.string -> Base.String.t

A registered Text key's stripped value.

val registered_positive_float_or_unset : arg_name:Base.string -> Base.Float.t Base.option

A registered Positive_float_or_unset key's value; None when empty or not positive.

val registered_float_at_least : arg_name:Base.string -> Base.Float.t

A registered Float_at_least key's value, clamped up to its floor.

val registered_keyword : arg_name:Base.string -> expected:Base.string -> parse:(Base.String.t -> 'a Base.option) -> 'a

A registered Keyword key's mode by parse of the lowercased value; expected lists the modes.

val profile_key_source : Base.String.t -> (Base.String.t * config_source) Base.option

A key's resolved value and source, None when nothing sets it; neither logged nor recorded.

val config_class_fingerprint : ?resolve:(key:Base.String.t -> Base.String.t -> Base.string) -> ?reads:(Base.string -> Base.bool) -> config_key_class -> Base.String.t

key=value; for each read key of the class resolved off its default: the class's identity.

val profile_payload_sources : Base.String.t -> (Base.String.t * (Base.String.t * config_source) Base.option) Base.List.t

Each key of the named profile's payload with its profile_key_source resolution.

val inherited_env_key_sources : Base.unit -> (Base.String.t * Base.string * (Base.String.t * config_source) Base.option) Base.List.t

Each environment variable spelling a key, with the key and where it actually resolved from.

val get_global_flag : default:Base.bool -> arg_name:Base.String.t -> Base.bool

A boolean setting: get_global_arg parsed by bool_of_config_string.

val os_process_id : Base.unit -> Base.int

The operating system's id of this process (unlike Unix.getpid on Windows).

module Artifacts_lock : sig ... end

The advisory lock that keeps a sibling's startup cleanup off this process's artifacts.

val build_files_dir : Base.unit -> Base.String.t

The debug-artifact directory build_files/<prefix>/, created if missing.

val build_file : Base.String.t -> Base.String.t

The path of an artifact in build_files_dir; shields this process's artifacts from cleanups.

val dynamic_library_extension : Base.string

The file extension of a dynamically loaded library on this platform.

val lock_holder_pid : Unix.file_descr -> Base.int

The OS id of a process blocking an exclusive lock on the file: 0 if none, -1 if unknown.

val process_alive : Base.int -> Base.bool

Whether a process with this OS id is running; one that cannot be queried counts as running.

val process_nonce : Base.unit -> Base.string

A random token drawn once per process, telling apart processes that report the same OS id.

val library_kernel_name_limit : Base.int

The most bytes of a kernel name that an owner-recording artifact's file name carries.

val library_kernel_name : Base.String.t -> Base.String.t

The cleaned kernel name, cut at a UTF-8 boundary with a digest suffix if over the limit.

val kept_library_name : pid:Base.int -> nonce:Base.string -> run_id:Base.int -> Base.String.t -> Base.string

The owner- and run-recording file name of a library kept in the build directory.

type kept_library = {
  1. kernel_name : Base.string;
  2. owner_pid : Base.int;
  3. owner_nonce : Base.string;
  4. library_run_id : Base.int;
}

The owner and the compile a library's file name records.

val temp_library_marker : Base.string

The prefix every OCANNL temporary library's file name opens with.

val temp_library_prefix : pid:Base.int -> nonce:Base.string -> run_id:Base.int -> Base.String.t -> Base.string

The owner- and run-recording Filename.temp_file prefix of a temporary library.

val temp_library_sweep_min_age : Base.float

Seconds since its last write before a startup removes a gone owner's temporary library.

val parse_kept_library_name : Base.String.t -> kept_library Base.option

Inverts kept_library_name; None for any other file name.

val parse_temp_library_name : Base.String.t -> kept_library Base.option

The owner and compile of a temp_library_prefix-named library; None for any other name.

val owned_artifact_file : run_id:Base.int -> extension:Base.string -> Base.String.t -> Base.String.t

Where this process keeps an artifact of a kernel's compile run_id, under an owner-recording name.

val kept_library_file : run_id:Base.int -> Base.String.t -> Base.String.t

Where this process keeps the library of a kernel's compile run_id.

val log_files_dir : Base.unit -> Base.String.t

The log directory log_files/<prefix>/, created if missing, prefixed as build_files_dir.

val diagn_log_file : Base.String.t -> Base.String.t

The path of a log in log_files_dir; shields this process's logs from sibling cleanups.

val get_local_debug_runtime : Base.unit -> (module Minidebug_runtime.Debug_runtime)

The ppx_minidebug runtime, configured from the debug-logging settings.

val set_log_level : Base.int -> Base.unit

Sets settings.log_level and the debug runtime's log level.

val restore_settings : Base.unit -> Base.unit

Resets settings to the values the configuration gives.

val with_runtime_debug : Base.unit -> Base.bool

Whether compilation keeps debug information: debug files on and log_level > 1.

val debug_log_from_routines : Base.unit -> Base.bool

Whether kernels log their execution: debug_log_from_routines on and log_level > 1.

val detach_c_stderr : Base.unit -> Base.bool

Points C stderr at its own dup of the real stderr; the stub behind c_stderr_detached, unused in-tree, so a caller that took over fd 2 can redo the detachment.

val c_stderr_detached : Base.bool

Whether C stderr was detached at startup, so foreign C chatter skips a later fd 2 redirect.

val c_stderr_replaceable : Base.unit -> Base.bool

Whether this C runtime's stderr can be replaced at all (glibc, Darwin).

val host_is_darwin : Base.bool

Whether the host is macOS (Darwin), as this library's build target says (gh-ocannl-1741): the one predicate behind the cc backend's kernel link flags and the tests gating on Darwin, read without shelling out to uname.

val host_is_darwin_arm64 : Base.bool

Whether the host is arm64 macOS, which refuses to map unsigned code (gh-ocannl-1741).

val collapse_c_stderr_noise : Base.unit -> Base.bool

Collapses ROCm's per-event C stderr lines into a count; the stub behind c_stderr_noise_collapsed, unused in-tree.

val c_stderr_noise_collapsed : Base.bool lazy_t

Whether ROCm's per-event C stderr chatter is collapsed, installing the filter when forced.

type exit_teardown_outcome =
  1. | Torn_down
  2. | Disabled
    (*

    exit_stream_teardown_timeout is 0 or negative.

    *)
  3. | Still_busy
    (*

    Not idle within the bound: left to the driver, never waited on further.

    *)
  4. | Failed of Base.exn
    (*

    is_idle or teardown raised; the exception is swallowed.

    *)

What bounded_exit_teardown did with one resource.

val default_exit_stream_teardown_timeout : Base.float

The exit_stream_teardown_timeout used when the setting is absent or not a finite number.

type exit_teardown_resource = {
  1. what : Base.string;
  2. is_idle : Base.unit -> Base.bool;
  3. teardown : Base.unit -> Base.unit;
}

One resource for bounded_exit_teardown; what names it in diagnostics.

val bounded_exit_teardown : exit_teardown_resource Base.list -> exit_teardown_outcome Base.list

Tears down each resource once idle, all under one exit timeout; never raises.

val device_init_deadline_supported : Base.unit -> Base.bool

Whether this build can arm the device-init deadline at all (not on Windows).

val device_init_deadline_tag : Base.string

The fixed start of the diagnostic the device-init deadline writes.

val device_init_test_stall : (Base.unit -> Base.unit) Base.option Base.ref

Test-only: run inside with_device_init_deadline's guarded region, before the guarded call.

val driver_init_test_stall : (Base.unit -> Base.unit) Base.option Base.ref

Test-only: run right before a GPU backend's one-time driver initialization call.

val with_device_init_deadline : backend_name:Base.string -> (Base.unit -> 'a) -> 'a

Runs a device init or query under device_init_deadline seconds, dying by SIGALRM past it.

val get_global_run_id : Base.unit -> Base.Int.t

A fresh run id per call, unique across the process's backends.

val union_find : equal:('a -> 'a -> Base.bool) -> ('a, 'a, 'b) Base.Map.t -> key:'a -> rank:Base.Int.t -> 'a * Base.Int.t

The root of key in a parent-pointer map, with rank plus the number of steps taken.

val union_add : equal:('a -> 'a -> Base.bool) -> ('a, 'a, 'b) Base.Map.t -> 'a -> 'a -> ('a, 'a, 'b) Base.Map.t

Merges the classes of two elements in a parent-pointer map.

val unique_keep_first : equal:('a -> 'a -> Base.bool) -> 'a Base.list -> 'a Base.List.t

Filters the list keeping the first occurrence of each element.

val sorted_diff : compare:('a -> 'b -> Base.int) -> 'a Base.List.t -> 'b Base.list -> 'a Base.List.t

The multiset difference of two lists sorted in increasing order.

val remove_elem : equal:('a -> 'b -> Base.bool) -> 'a -> 'b Base.list -> 'b Base.List.t

Removes the first element of the list equal to the given one.

type atomic_bool = Base.bool Stdlib.Atomic.t

An atomic boolean.

val sexp_of_atomic_bool : Base.bool Stdlib.Atomic.t -> Base.Sexp.t

The current value as a sexp.

type atomic_int = Base.int Stdlib.Atomic.t

An atomic integer.

val sexp_of_atomic_int : Base.int Stdlib.Atomic.t -> Base.Sexp.t

The current value as a sexp.

val sexp_append : elem:Base.Sexp.t -> Base.Sexp.t -> Base.Sexp.t

Prepends elem to a sexp list, or pairs it with an atom.

val sexp_mem : elem:Base.Sexp.t -> Base.Sexp.t -> Base.bool

Whether elem equals the atom, or is a member of the list.

val normalize_exponent : Base.String.t -> Base.String.t

Strips leading zeros from a float rendering's exponent, so it does not depend on the C runtime.

val decimal_float_literal : Base.Float.t -> Base.String.t

A decimal floating literal that parses back to exactly the double; non-finite ones as words.

module Lazy : sig ... end

Base.Lazy plus ppx_minidebug's sexp converters.

type requirement =
  1. | Skip
  2. | Required
  3. | Optional of {
    1. callback_if_missing : Base.unit -> Base.unit;
    }

Whether something is skipped, required, or optional with a callback for when it is missing.

val sexp_of_requirement : requirement -> Sexplib0.Sexp.t
val output_to_build_file : fname:Base.String.t -> (PPrint.ToChannel.document -> Base.unit) Base.option

When debug files are on, truncates the build file fname and returns a printer appending to it.

exception User_error of Base.string

An error the user's program or configuration caused, rather than a bug.

type build_file_channel = {
  1. f_path : Base.string;
  2. oc : Stdlib.out_channel;
  3. finalize : Base.unit -> Base.unit;
}

An open file for generated code: its path, its channel, and the flush-and-close.

val open_build_file : base_name:Base.String.t -> extension:Base.String.t -> build_file_channel

Opens base_name ^ extension in the build directory when debug files are on, else a temp file.

val captured_log_prefix : Base.string Base.ref

The prefix marking a routine log line on stdout for capture_stdout_logs to collect.

type captured_log_processor = {
  1. log_processor_prefix : Base.string;
  2. process_logs : Base.string Base.list -> Base.unit;
}

A handler of the captured log lines carrying its prefix.

val add_log_processor : prefix:Base.string -> (Base.string Base.list -> Base.unit) -> Base.unit

Registers a handler of the captured lines carrying prefix (prefix removed).

val flush_c_streams : Base.unit -> Base.unit

Flushes the C runtime's stdio streams.

val capture_stdout_logs : (Base.unit -> 'a) -> 'a

Runs f, handing stdout's log lines to the registered processors, then clearing them.

val routine_log_window : drain:(Base.unit -> Base.unit) -> (Base.unit -> Base.unit) -> Base.unit

Runs a logged GPU launch (then drain) in a capture window when stream-file logs need one.

val log_debug_routine_logs : log_contents:Base.string Base.List.t -> stream_name:Base.String.t -> Base.unit

Appends routine log lines to the stream's log file, or to the debug trace when that is off.

val log_debug_routine_file : log_file_name:Base.string -> stream_name:Base.String.t -> Base.unit

log_debug_routine_logs of a file's lines, then removes the file.

val gcd : Base.Int.t -> Base.Int.t -> Base.Int.t

The greatest common divisor of the absolute values.

val macos_platform_uuid : Base.String.t -> Base.string Base.option

The digest of a well-formed, nonzero IOPlatformUUID found in ioreg output.

val macos_timing_environment : (Base.string * Base.String.t Base.option) Base.Option.t lazy_t

On macOS, the host's hashed platform UUID and, if available, the OS build version.

val included_headers : Base.String.t -> Base.String.t Base.List.t

The headers a C or C++ text includes by #include <...>, in order.

val capability_dir : requires:Base.string Base.List.t -> Base.String.t Base.option -> Base.String.t

A found directory as a capability record: resolved path, plus missing headers or their digest.

Re-exports the shared datatypes: Set_O, safe_lazy, Tree_map, map-ref helpers, ...

module Set_O : sig ... end
val no_ints : (Base.Int.t, Base.Int.comparator_witness) Base.Set.t
val mref_add : ('a, 'b, 'c) Base.Map.t Base.ref -> key:'a -> data:'b -> or_:('b -> Base.unit) -> Base.unit
val mref_add_missing : ('a, 'b, 'c) Base.Map.t Base.ref -> 'a -> f:(unit -> 'b) -> Base.unit
type 'a safe_lazy = {
  1. mutable value : [ `Callback of Base.unit -> 'a | `Value of 'a ];
  2. unique_id : Base.string;
}

A lazy value that can be safely forced and compared by unique ID.

val safe_lazy : Base.string -> (Base.unit -> 'a) -> 'a safe_lazy
val safe_force : 'a safe_lazy -> 'a
val is_safe_val : 'a safe_lazy -> bool
val safe_map : upd:Base.String.t -> f:('a -> 'b) -> 'a safe_lazy -> 'b safe_lazy
val equal_safe_lazy : ('a -> 'b -> bool) -> 'a safe_lazy -> 'b safe_lazy -> bool
val compare_safe_lazy : ('a -> 'b -> int) -> 'a safe_lazy -> 'b safe_lazy -> int
val hash_fold_safe_lazy : 'a -> Base__.Ppx_hash_lib.Std.Hash.state -> 'b safe_lazy -> Base__.Ppx_hash_lib.Std.Hash.state
val sexp_of_safe_lazy : ('a -> Base.Sexp.t) -> 'a safe_lazy -> Base.Sexp.t
module Tree_map : sig ... end

A persistent map implemented as a balanced binary tree. The sexp_of function preserves and displays the tree structure.

module Cpu_topology : sig ... end

CPU topology facts for the worker-pool uniformity policy.

module Atomic_file : sig ... end

Publishing a file so that no reader ever observes a half-written one.

module Host_load : sig ... end

Host CPU accounting, telling a co-tenant apart from a routine's own variance.