Module Spoc_core.Device

type t = Spoc_framework.Device_type.t = {
  1. id : int;
  2. backend_id : int;
  3. name : string;
  4. framework : string;
  5. capabilities : Spoc_framework.Framework_sig.capabilities;
}

Device type from SDK

val devices : t array Stdlib.ref

Device initialization state

val initialized : bool Stdlib.ref
val init : ?frameworks:string list -> unit -> t array

Initialize all available backends and enumerate devices

val all : unit -> t array

Get all initialized devices

val count : unit -> int

Get device count

val get : int -> t option

Get device by global ID

val first : unit -> t option

Get first available device (if any)

val by_framework : string -> t array

Filter devices by framework

val with_fp64 : unit -> t array

Filter devices by capability

val best : unit -> t option

Get the best device (first CUDA, then OpenCL, then Native)

val reset : unit -> unit

Reset initialization state (for testing)

val to_string : t -> string

Pretty-print device info

val print_all : unit -> unit

Print all devices

Phase 4: Extended Device Queries

Type Predicates

val is_cuda : t -> bool
val is_opencl : t -> bool
val is_native : t -> bool
val is_cpu : t -> bool
val is_gpu : t -> bool

Capability Queries

val allows_fp64 : t -> bool
val supports_atomics : t -> bool
val compute_capability : t -> int * int
val warp_size : t -> int
val max_threads_per_block : t -> int
val max_block_dims : t -> int * int * int
val max_grid_dims : t -> int * int * int
val shared_mem_per_block : t -> int
val total_memory : t -> int64
val multiprocessor_count : t -> int
val clock_rate_khz : t -> int
val max_registers_per_block : t -> int

Finders

val find_cuda : t array -> t option
val find_opencl : t array -> t option
val find_native : t array -> t option
val find_by_name : t array -> string -> t option
val find_by_id : t array -> int -> t option

Filters

val filter_cuda : unit -> t array
val filter_opencl : unit -> t array
val filter_native : unit -> t array
val with_atomics : unit -> t array
val with_min_memory : int64 -> t array
val with_compute_capability : major:int -> minor:int -> t array

Runtime Memory Query

val free_memory : t -> int64 option

Query current free memory on device (if supported by backend)

Synchronization

val synchronize : t -> unit
val set_current : t -> unit