Module Advanced.Graph

Computation graph for capturing and replaying operations. Note: Full implementation requires deep backend integration.

type node_id = int
type node_type =
  1. | Kernel of {
    1. name : string;
    }
  2. | Transfer of [ `H2D | `D2H ]
  3. | Sync
type node = {
  1. id : node_id;
  2. node_type : node_type;
  3. dependencies : node_id list;
}
type t = {
  1. mutable nodes : node list;
  2. mutable next_id : node_id;
}
val create : unit -> t

Create empty graph

val add_kernel : t -> name:string -> deps:node_id list -> node_id

Add kernel node

val add_transfer : t -> direction:[ `D2H | `H2D ] -> deps:node_id list -> node_id

Add transfer node

val add_sync : t -> deps:node_id list -> node_id

Add sync node

type executable = {
  1. graph : t;
  2. device : Device.t;
}

Executable graph (compiled for specific device)

val instantiate : t -> Device.t -> executable

Instantiate graph for device

val launch : executable -> unit

Launch executable graph

val node_count : t -> int

Get node count

val print : t -> unit

Print graph for debugging