package spoc

  1. Overview
  2. Docs

Manages Spoc vectors

type device_vec
type customarray
type ('a, 'b) custom = {
  1. size : int;
    (*

    the size of an element when transferred to a gpgpu device

    *)
  2. get : customarray -> int -> 'a;
    (*

    a function to access elements from the vector

    *)
  3. set : customarray -> int -> 'a -> unit;
    (*

    a function to modify an element of the vector

    *)
}

Spoc offers many predefined vectors types. Custom vectors can contain any kind of data types.

Some predifined types

type ('a, 'b) couple = 'a * 'b
type ('a, 'b) kind =
  1. | Float32 of ('a, 'b) Stdlib.Bigarray.kind
  2. | Char of ('a, 'b) Stdlib.Bigarray.kind
  3. | Float64 of ('a, 'b) Stdlib.Bigarray.kind
  4. | Int32 of ('a, 'b) Stdlib.Bigarray.kind
  5. | Int64 of ('a, 'b) Stdlib.Bigarray.kind
  6. | Complex32 of ('a, 'b) Stdlib.Bigarray.kind
  7. | Custom of ('a, 'b) custom
  8. | Unit of ('a, 'b) couple
  9. | Dummy of ('a, 'b) couple

shortcuts

val int : (int, Stdlib.Bigarray.int_elt) kind
val int32 : (int32, Stdlib.Bigarray.int32_elt) kind
val char : (char, Stdlib.Bigarray.int8_unsigned_elt) kind
val int64 : (int64, Stdlib.Bigarray.int64_elt) kind
val float32 : (float, Stdlib.Bigarray.float32_elt) kind
val float64 : (float, Stdlib.Bigarray.float64_elt) kind
val complex32 : (Stdlib.Complex.t, Stdlib.Bigarray.complex32_elt) kind
type ('a, 'b) host_vec
type ('a, 'b) spoc_vec =
  1. | Bigarray of ('a, 'b, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t
  2. | CustomArray of customarray * ('a, 'b) custom
  3. | Host_vec of ('a, 'b) host_vec

a spoc_vector is a Bigarray or a custom vector

type vec_device =
  1. | No_dev
  2. | Dev of Spoc.Devices.device
  3. | Transferring of Spoc.Devices.device
type ('a, 'b) vector

a vector represents every information needed by Spoc to manage it It uses Bigarrays to manage data on the cpu side (see the OCaml Bigarray Module for more information)

and ('a, 'b) sub = int * int * int * int * ('a, 'b) vector

sub vectors are vector parts sharing memory space on cpu memory BUT not on gpu memory, allowing easy computation distribution over multiple GPUs. sub-vector : sub_vector depth * start * ok range * ko range * parent vector (see samples for more info)

val create : ('a, 'b) kind -> ?dev:Spoc.Devices.device -> int -> ('a, 'b) vector
  • returns

    a new vector.

val length : ('a, 'b) vector -> int
  • returns

    the length of a given vector

val dev : ('a, 'b) vector -> vec_device
  • returns

    the device where the given vector is located

val is_sub : ('a, 'b) vector -> ('a, 'b) sub option

checks if a vector is a subvector

val kind : ('a, 'b) vector -> ('a, 'b) kind
  • returns

    the kind of a vector

val device : ('a, 'b) vector -> int
  • returns

    the device id where the given vector is located

val equals : ('a, 'b) vector -> ('a, 'b) vector -> bool

checks equality between two vectors

val vseek : ('a, 'b) vector -> int -> unit
val get_seek : ('a, 'b) vector -> int
val unsafe_get : ('a, 'b) vector -> int -> 'a
val unsafe_set : ('a, 'b) vector -> int -> 'a -> unit
val sub_vector : ('a, 'b) vector -> int -> int -> int -> int -> ('a, 'b) vector
val device_vec : ('a, 'b) vector -> [< `Cuda | `OpenCL ] -> int -> device_vec
val copy_sub : ('a, 'b) vector -> ('a, 'b) vector -> unit
val of_bigarray_shr : ('a, 'b) kind -> ('a, 'b, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t -> ('a, 'b) vector
val to_bigarray_shr : ('a, 'b) vector -> ('a, 'b, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t
OCaml

Innovation. Community. Security.