Module Sarek_ppx_lib.Sarek_ppx_registry

type type_info = {
  1. ti_name : string;
    (*

    Type name, e.g., "float32"

    *)
  2. ti_device : Spoc_core.Device.t -> string;
    (*

    Device type string, e.g., "float"

    *)
  3. ti_size : int;
    (*

    Size in bytes

    *)
  4. ti_sarek_type : Sarek_types.typ;
    (*

    Sarek type representation

    *)
}

Type information for registered types (like float32, int64, etc.)

type intrinsic_info = {
  1. ii_name : string;
    (*

    Function name, e.g., "sin"

    *)
  2. ii_qualified_name : string;
    (*

    Qualified name, e.g., "Float32.sin"

    *)
  3. ii_type : Sarek_types.typ;
    (*

    Type signature

    *)
  4. ii_device : Spoc_core.Device.t -> string;
    (*

    Device code generator - more generic than storing cuda/opencl separately

    *)
  5. ii_module : string list;
    (*

    Module path, e.g., "Sarek_stdlib"; "Float32"

    *)
}

Intrinsic function information

type const_info = {
  1. ci_name : string;
    (*

    Constant name

    *)
  2. ci_qualified_name : string;
    (*

    Qualified name

    *)
  3. ci_type : Sarek_types.typ;
    (*

    Type

    *)
  4. ci_device : Spoc_core.Device.t -> string;
    (*

    Device code generator

    *)
  5. ci_module : string list;
    (*

    Module path

    *)
}

Intrinsic constant information (like thread_idx_x)

type module_item_info = {
  1. mi_name : string;
    (*

    Function/constant name

    *)
  2. mi_qualified_name : string;
    (*

    Qualified name, e.g., "Registered_defs.add_vec"

    *)
  3. mi_module : string;
    (*

    Module name, e.g., "Registered_defs"

    *)
  4. mi_item : Sarek_ast.module_item;
    (*

    The parsed AST item (MFun or MConst)

    *)
}

Module item information for @sarek.module functions and constants. Unlike intrinsics, these are user-defined functions that get inlined into the generated GPU code.

type record_type_info = {
  1. rti_name : string;
    (*

    Type name

    *)
  2. rti_qualified_name : string;
    (*

    Qualified name

    *)
  3. rti_module : string;
    (*

    Module name

    *)
  4. rti_decl : Sarek_ast.type_decl;
    (*

    The type declaration

    *)
}

Record type information for @sarek.type records

val types : (string, type_info) Stdlib.Hashtbl.t

The registries - populated at PPX load time

val intrinsics : (string, intrinsic_info) Stdlib.Hashtbl.t
val consts : (string, const_info) Stdlib.Hashtbl.t
val module_items : (string, module_item_info) Stdlib.Hashtbl.t
val record_types : (string, record_type_info) Stdlib.Hashtbl.t
val register_type : type_info -> unit

Register a type

val register_intrinsic : intrinsic_info -> unit

Register an intrinsic function

val register_const : const_info -> unit

Register an intrinsic constant

val register_module_item : module_item_info -> unit

Register a module item (@sarek.module function or constant)

val register_record_type : record_type_info -> unit

Register a record type (@sarek.type)

val find_type : string -> type_info option

Find a type by name

val find_intrinsic : string -> intrinsic_info option

Find an intrinsic by name (short or qualified)

val find_const : string -> const_info option

Find a constant by name (short or qualified)

val is_intrinsic : string -> bool

Check if a name is a registered intrinsic

val is_const : string -> bool

Check if a name is a registered constant

val find_module_item : string -> module_item_info option

Find a module item by name (short or qualified)

val find_record_type : string -> record_type_info option

Find a record type by name (short or qualified)

val is_module_item : string -> bool

Check if a name is a registered module item

val is_record_type : string -> bool

Check if a name is a registered record type

val all_types : unit -> type_info list

Get all registered types

val all_intrinsics : unit -> intrinsic_info list

Get all registered intrinsics

val all_consts : unit -> const_info list

Get all registered constants

val all_module_items : unit -> module_item_info list

Get all registered module items

val all_record_types : unit -> record_type_info list

Get all registered record types

val make_type_info : name:string -> device:(Spoc_core.Device.t -> string) -> size:int -> sarek_type:Sarek_types.typ -> type_info

Helper: create type_info for a numeric type

val make_intrinsic_info : name:string -> module_path:string list -> typ:Sarek_types.typ -> device:(Spoc_core.Device.t -> string) -> intrinsic_info

Helper: create intrinsic_info

val make_const_info : name:string -> module_path:string list -> typ:Sarek_types.typ -> device:(Spoc_core.Device.t -> string) -> const_info

Helper: create const_info

val make_module_item_info : name:string -> module_name:string -> item:Sarek_ast.module_item -> module_item_info

Helper: create module_item_info

val make_record_type_info : name:string -> module_name:string -> decl:Sarek_ast.type_decl -> record_type_info

Helper: create record_type_info

val debug_print : unit -> unit

Debug: print registered items