Bigstring.Slicelength t returns the number of elements in t.
slice ~i ~j array is a slice representing array[i..j).
sub ~i ~j slice is a slice representing slice[i..j).
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.
get t i reads the element at index i. Raises Invalid_arg if i is not in the range [0..length t).
unsafe_get t i unsafely reads the element at index i.
val extract :
'a t @ local ->
(Base.int ->
(('a -> 'b @ portable contended) @ local once portable ->
'b @ portable contended) @ local) @ localextract 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).
val unsafe_extract :
'a t @ local ->
(Base.int ->
(('a -> 'b @ portable contended) @ local once portable ->
'b @ portable contended) @ local) @ localunsafe_extract t i f applies f with the element unsafely read from index i.
val fork_join2 :
Parallel_kernel.t @ local ->
(?pivot:Base.int ->
('a t @ local ->
((Parallel_kernel.t @ local ->
('a t @ local ->
'b) @ local once) @ local once shareable ->
((Parallel_kernel.t @ local ->
('a t @ local ->
'c) @ local once) @ once shareable ->
#('b * 'c)) @ local once) @ local) @ local) @ localfork_join2 parallel ~pivot t f g splits the slice t into two sub-slices representing t[0..pivot) and t[pivot..length t), respectively. The sub-slices are passed to f and g, which run in parallel (refer to {Parallel_kernel.fork_join2}).
val for_ :
Parallel_kernel.t @ local ->
(pivots:Base.int Base.iarray ->
('a t @ local ->
(f:
(Parallel_kernel.t @ local -> ('a t @ local -> Base.unit) @ local) @ shareable ->
Base.unit) @ local) @ local) @ localfor_ parallel ~pivots t ~f splits the slice t into multiple sub-slices representing the ranges t[0..pivots[0]), t[pivots[i]..pivots[i+1]), etc. The function f is evaluated for each sub-slice in parallel. pivots must be non-decreasing, but may have duplicate elements, resulting in empty sub-slices.
val fori :
Parallel_kernel.t @ local ->
(pivots:Base.int Base.iarray ->
('a t @ local ->
(f:
(Parallel_kernel.t @ local ->
(Base.int ->
('a t @ local ->
Base.unit) @ local) @ local) @ shareable ->
Base.unit) @ local) @ local) @ localfori parallel ~pivots t ~f splits the slice t into multiple sub-slices representing the ranges t[0..pivots[0]), t[pivots[i]..pivots[i+1]), etc. The function f is evaluated for each sub-slice and its index in parallel. pivots must be non-decreasing, but may have duplicate elements.
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.
set t i a stores the element a at index i. Raises Invalid_arg if i is not in the range [0..length t).
unsafe_insert t i f unsafely stores f a at index i.