package spoc

  1. Overview
  2. Docs

Module Spoc.VectorSource

Manages Spoc vectors

Sourcetype device_vec
Sourcetype customarray
Sourcetype ('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

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

shortcuts

Sourceval int : (int, Bigarray.int_elt) kind
Sourceval int32 : (int32, Bigarray.int32_elt) kind
Sourceval int64 : (int64, Bigarray.int64_elt) kind
Sourceval float32 : (float, Bigarray.float32_elt) kind
Sourceval float64 : (float, Bigarray.float64_elt) kind
Sourcetype ('a, 'b) host_vec
Sourcetype ('a, 'b) spoc_vec =
  1. | Bigarray of ('a, 'b, Bigarray.c_layout) 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

Sourcetype vec_device =
  1. | No_dev
  2. | Dev of Devices.device
  3. | Transferring of Devices.device
Sourcetype ('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)

Sourceand ('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)

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

    a new vector.

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

    the length of a given vector

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

    the device where the given vector is located

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

checks if a vector is a subvector

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

    the kind of a vector

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

    the device id where the given vector is located

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

checks equality between two vectors

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

Innovation. Community. Security.