Module Parallel_arrays.BigarraySource

Sourcemodule Kind : sig ... end
Sourcemodule Layout : sig ... end
Sourcemodule Spec : sig ... end
Sourcetype ('a : any) t =
  1. | T : ('a, 'b, 'c) Bigarray.Array1.t -> 'a t
Sourceval of_bigarray : ('a : any) ('b : any) ('c : any). ('a, 'b, 'c) Bigarray.Array1.t -> 'a t

Wraps a Bigarray.Array1.t as a parallel bigarray.

Sourceval kind : ('a, _) Kind.t -> _ Layout.t -> 'a Spec.t

Wraps a Bigarray.kind and Bigarray.layout as a parallel bigarray spec.

Sourceval length : 'a t @ contended -> Base.int

length t returns the number of elements in t.

To read a value from a parallel array, we must prove that it does not escape its capsule. This is the case if its type crosses contention, or if it is manipulated within a portable function.

Sourceval get : ('a : value_or_null mod contended portable separable). 'a t -> Base.int -> 'a @@ portable

get t i reads the element at index i. Raises Invalid_arg if i is not in the range [0..length t).

Sourceval unsafe_get : ('a : value_or_null mod contended portable separable). 'a t -> Base.int -> 'a @@ portable

unsafe_get t i unsafely reads the element at index i.

Sourceval extract : ('a : value_or_null mod portable separable). 'a t -> Base.int -> ('a -> 'b @ portable contended) @ local once portable -> 'b @ portable contended @@ portable

extract t i f applies f with the element read from index i. Raises Invalid_arg if i is not in the range [0..length t).

Sourceval unsafe_extract : ('a : value_or_null mod portable separable). 'a t -> Base.int -> ('a -> 'b @ portable contended) @ local once portable -> 'b @ portable contended @@ portable

unsafe_extract t i f applies f with the element unsafely read from index i.

To read a value from a parallel array, we must prove that it does not escape its capsule. This is the case if its type crosses contention, or if it is manipulated within a portable function.

To store a value in a parallel array, we must prove that it does not share unsynchronized state with any other elements. This is the case if its type crosses contention or it lives in a fresh capsule.

Sourceval set : ('a : value_or_null mod contended portable separable). 'a t -> Base.int -> 'a -> Base.unit @@ portable

set t i a stores the element a at index i. Raises Invalid_arg if i is not in the range [0..length t).

Sourceval unsafe_set : ('a : value_or_null mod contended portable separable). 'a t -> Base.int -> 'a -> Base.unit @@ portable

unsafe_set t i a unsafely stores the element a at index i.

Sourceval insert : ('a : value_or_null mod portable separable). 'a t -> Base.int -> (Base.unit -> 'a) @ local once portable -> Base.unit @@ portable

insert t i f stores f () at index i. Raises Invalid_arg if i is not in the range [0..length t).

Sourceval unsafe_insert : ('a : value_or_null mod portable separable). 'a t -> Base.int -> (Base.unit -> 'a) @ local once portable -> Base.unit @@ portable

unsafe_insert t i f unsafely stores f () at index i.

Sourcemodule Slice : Slice with type ('a : any) array := 'a t
Sourceval of_slice : 'a Slice.t @ local -> 'a t
val init : Parallel_kernel.t @ local -> ('a Spec.t * Base.int) -> (f:(Parallel_kernel.t @ local -> Base.int -> 'a) @ shareable -> 'a t) @ local @@ portable

init parallel n ~f initializes an array with the result of f applied to the integers 0..n-1.

If t is array or iarray, f is not allowed to return boxed floats, as this would break the float array optimization. Prefer float# t.

val fold : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t @ shared -> init:(Base.unit -> 'acc) @ portable -> f:(Parallel_kernel.t @ local -> 'acc -> 'a @ shared -> 'acc) @ shareable -> combine:(Parallel_kernel.t @ local -> 'acc -> 'acc -> 'acc) @ shareable -> 'acc @@ portable

fold parallel t ~init ~f ~combine folds combine over the result of map parallel t ~f. combine must be associative and combine init x must equal x.

val foldi : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t @ shared -> init:(Base.unit -> 'acc) @ portable -> f: (Parallel_kernel.t @ local -> Base.int -> 'acc -> 'a @ shared -> 'acc) @ shareable -> combine:(Parallel_kernel.t @ local -> 'acc -> 'acc -> 'acc) @ shareable -> 'acc @@ portable

foldi parallel t ~init ~f ~combine folds combine over the result of mapi parallel t ~f. combine must be associative and combine init x must equal x.

val iter : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t -> f:(Parallel_kernel.t @ local -> 'a -> Base.unit) @ shareable -> Base.unit @@ portable

iter parallel t ~f applies f to each element of t.

val iteri : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t -> f:(Parallel_kernel.t @ local -> Base.int -> 'a -> Base.unit) @ shareable -> Base.unit @@ portable

iteri parallel t ~f applies f to each element of t and its index.

val find : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t -> f:(Parallel_kernel.t @ local -> 'a -> Base.bool) @ shareable -> 'a Unboxed_datatypes.Option_u.t @@ portable

find parallel t ~f returns the first element of t for which f returns true, if it exists.

val findi : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t -> f:(Parallel_kernel.t @ local -> Base.int -> 'a -> Base.bool) @ shareable -> 'a Unboxed_datatypes.Option_u.t @@ portable

findi parallel t ~f returns the first element of t for which f returns true, if it exists.

val reduce : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t -> f:(Parallel_kernel.t @ local -> 'a @ shared -> 'a @ shared -> 'a) @ shareable -> 'a Unboxed_datatypes.Option_u.t @@ portable

reduce parallel t ~f folds f over the elements of t. f must be associative. If t is empty, reduce returns None.

val min_elt : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t -> compare: (Parallel_kernel.t @ local -> 'a @ local shared -> 'a @ local shared -> Base.int) @ shareable -> 'a Unboxed_datatypes.Option_u.t @@ portable

min_elt parallel t ~compare is the minimum element of t according to compare. If t is empty, returns None.

val max_elt : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t -> compare: (Parallel_kernel.t @ local -> 'a @ local shared -> 'a @ local shared -> Base.int) @ shareable -> 'a Unboxed_datatypes.Option_u.t @@ portable

max_elt parallel t ~compare is the maximum element of t according to compare. If t is empty, returns None.

val sort : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t -> compare: (Parallel_kernel.t @ local -> 'a @ local shared -> 'a @ local shared -> Base.int) @ shareable -> 'a t @@ portable

sort parallel t ~compare initializes an array with the contents of t unstably sorted with respect to compare.

val stable_sort : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t -> compare: (Parallel_kernel.t @ local -> 'a @ local shared -> 'a @ local shared -> Base.int) @ shareable -> 'a t @@ portable

stable_sort parallel t ~compare initializes an array with the contents of t stably sorted with respect to compare.

val scan : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t -> init:'a -> f:(Parallel_kernel.t @ local -> 'a @ shared -> 'a @ shared -> 'a) @ shareable -> #('a t * 'a) @@ portable

scan parallel t ~init ~f initialises an array containing the exclusive prefix sums of t with respect to f. The first element is init and the full reduction of t is returned separately. f must be associative and f init x must equal x.

val scan_inclusive : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t -> init:'a -> f:(Parallel_kernel.t @ local -> 'a @ shared -> 'a @ shared -> 'a) @ shareable -> 'a t @@ portable

scan_inclusive parallel t ~init ~f initialises an array containing the inclusive prefix sums of t with respect to f. The first element is the first element of t. f must be associative and f init x must equal x.

val filter : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t -> f:(Parallel_kernel.t @ local -> 'a -> Base.bool) @ shareable -> 'a t @@ portable

filter parallel t ~f initialises an array containing the elements of t that satisfy the predicate f.

val filteri : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t -> f:(Parallel_kernel.t @ local -> Base.int -> 'a -> Base.bool) @ shareable -> 'a t @@ portable

filteri parallel t ~f initialises an array containing the elements of t that, alongside their index, satisfy the predicate f.

val map_inplace : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t -> f:(Parallel_kernel.t @ local -> 'a -> 'a) @ shareable -> Base.unit @@ portable

map_inplace parallel t ~f overwrites an array with the result of f applied to each of its elements.

val mapi_inplace : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t -> f:(Parallel_kernel.t @ local -> Base.int -> 'a -> 'a) @ shareable -> Base.unit @@ portable

mapi_inplace parallel t ~f overwrites an array with the result of f applied to each of its elements and their indices.

val init_inplace : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t -> f:(Parallel_kernel.t @ local -> Base.int -> 'a) @ shareable -> Base.unit @@ portable

init_inplace parallel t ~f overwrites an array with the result of f applied to each array index. This can be much faster than using mapi_inplace since it does not need to read the array.

val sort_inplace : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t -> compare: (Parallel_kernel.t @ local -> 'a @ local shared -> 'a @ local shared -> Base.int) @ shareable -> Base.unit @@ portable

sort_inplace parallel t ~compare unstably sorts t with respect to compare.

val stable_sort_inplace : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t -> compare: (Parallel_kernel.t @ local -> 'a @ local shared -> 'a @ local shared -> Base.int) @ shareable -> Base.unit @@ portable

stable_sort_inplace parallel t ~compare stably sorts t with respect to compare.

val scan_inplace : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t -> init:'a -> f:(Parallel_kernel.t @ local -> 'a @ shared -> 'a @ shared -> 'a) @ shareable -> 'a @@ portable

scan_inplace parallel t ~init ~f overwrites t to contain the its exclusive prefix sums with respect to f. The first element becomes init and the full reduction of t is returned. f must be associative and f init x must equal x.

val scan_inclusive_inplace : ('a : value_or_null mod portable separable). Parallel_kernel.t @ local -> 'a t -> init:'a -> f:(Parallel_kernel.t @ local -> 'a @ shared -> 'a @ shared -> 'a) @ shareable -> Base.unit @@ portable

scan_inclusive_inplace parallel t ~init ~f overwrites t to contain its inclusive prefix sums with respect to f. The first element is unchanged. f must be associative and f init x must equal x.