Module Tolk.Jit
Captured schedules.
A captured schedule is every call a function makes, in order, over the buffers it was given. Lowering it once gives a schedule that runs again on other buffers: its inputs become parameters, which each run binds, its intermediates share a few arenas, and its kernels are compiled. The engine links the result once and runs it on each call.
val width : ?beam:int -> unit -> intwidth ~beam () is the width jit_lower ~beam searches at: beam, or else the setting JITBEAM's, or else BEAM's.
val shaping : ?beam:int -> unit -> (string * string) listshaping ~beam () is Setting.shaping as jit_lower ~beam compiles under it: with BEAM at the width the lowering searches, and JITBEAM, which the lowering has read by then, unset (Setting.shaping_under). Two lowerings whose shaping is equal compile alike, whatever BEAM and JITBEAM were. It binds no setting.
val jit_lower :
?beam:int ->
?search:(int -> Postrange.Scheduler.t -> Postrange.Scheduler.t) ->
targets:(string -> Helpers.Target.t) ->
held_bufs:Ops.t list ->
inputs:Ops.t list ->
input_vars:(string * int) list ->
Ops.t ->
Ops.tjit_lower ~beam ~search ~targets ~held_bufs ~inputs ~input_vars linear is the captured schedule linear, an Op.t.Linear of calls, ready to link:
- the
ith buffer ofinputsis replaced whereverlinearreaches it by the parameter of sloti(Shape.param), of its type, device, size, alignment and phase (Shape.storage_phase); - each variable named in
input_vars, the variables of the capture, is unbound whereverlinearbinds it: a run binds it. A variable bound under another name keeps its binding; - its buffers are placed in arenas (
Memory.memory_plan_rewrite), exceptheld_bufs, whose contents outlive a run, such as the buffers a caller keeps or that hold constants; - each buffer not in
held_bufs, which holds only what one run computes, becomes storage of the program (Shape.alloc) of its size, type and device, which the program's link allocates; - it is compiled (
Realize.compile_linear, withsearchandtargets), with the beam widthbeam, or elseSetting.jitbeam's, or elseSetting.beam's, asBEAM, andJITBEAMunset.
Raises as Realize.compile_linear does.
val source_digest : stringsource_digest is the digest of this library's sources, which a key of what they make depends on.