Expand description
Synchronous data-parallel operators and free functions. Synchronous data-parallel operators over the unified scheduler.
§Safety
The mutable operators split a buffer across worker tasks through Melinoe’s
WriterShard /
ParChunks, which own the disjoint-partition
contract and the range math once; each operator brands the caller’s slice in
place (MelinoeCell::from_mut_slice)
and vends one partition per task. One
executor contract makes every such access sound, and each per-site SAFETY
comment appeals to it:
- Disjoint partition.
global().for_each_indexed(count, f)invokesfwith each index in0..countexactly once — the same guaranteeParChunks::get_unchecked_chunkrequires of its caller. The operators map that index (or achunk_size-strided range derived from it) to a disjoint slice of the buffer, so no two concurrent tasks ever form&mutto the same element. Multi-buffer operators additionally rely on the caller’s distinct&mut [_]arguments being non-aliasing (guaranteed by the borrow checker at the call site). - All-or-error collect. The
map_collect_*helpers build aVec<MaybeUninit<R>>,set_lenit (sound —MaybeUninitneeds no initialization), fill every slot through the disjoint-partition contract, then reinterpret it asVec<R>.for_each_indexedreturnsOkonly after writing every index, so the reinterpretation is reached only when all slots are initialized; a task panic instead surfaces asErr, which.expect()turns into a propagating panic that unwinds with the buffer still typedMaybeUninit<R>(its contents are not dropped — a leak of the written values on panic, never a use of uninitialized memory).
Structs§
- Scope
- Borrowing scope for spawning parallel sub-tasks that may capture non-
'staticreferences.
Enums§
- Chunk
Buffers Error - Failure to partition a fixed set of mutable buffers into matching chunks.
Constants§
- UNIT_
TASK_ BYTES - Bytes of work one scheduled task carries.
Functions§
- enumerate_
mut_ with - Apply
f(index, &mut element)to every element ofdatain place, scheduled by policyP. - enumerate_
with - Apply
f(index, &element)to every element ofdata, scheduled by policyP. - fold_
reduce_ with - Parallel fold-reduce over the index domain
0..len, scheduled by policyP. - for_
each_ chunk_ buffers_ mut_ enumerated_ with - Apply
f(index, chunks)to matching chunks from a fixed set of distinct mutable buffers, scheduled by policyP. - for_
each_ chunk_ mut_ enumerated_ with - Like
for_each_chunk_mut_withbut also passes the zero-based chunk index tof(synchronous equivalent ofdata.par_chunks_mut(chunk_size).enumerate().for_each(f)). - for_
each_ chunk_ mut_ with - Apply
fto each consecutivechunk_size-element mutable chunk ofdatain parallel, scheduled by policyP. The final chunk may be shorter. - for_
each_ chunk_ mut_ with_ state - Apply
f(state, chunk)to each consecutive mutable chunk, creating one reusable state value per scheduled worker shard. - for_
each_ chunk_ pair_ mut_ enumerated_ with - Apply
f(index, a_chunk, b_chunk)to pairedchunk_size-element mutable chunks of two distinct buffers in parallel, scheduled by policyP. - for_
each_ chunk_ quad_ mut_ enumerated_ with - Apply
f(index, a_chunk, b_chunk, c_chunk, d_chunk)to four distinct mutable buffers chunked identically, scheduled by policyP. - for_
each_ chunk_ triple_ mut_ enumerated_ with - Apply
f(index, a_chunk, b_chunk, c_chunk)to three distinct mutable buffers chunked identically, scheduled by policyP. - for_
each_ index_ with - Apply
fto every index in0..lenin parallel, scheduled by policyP. - for_
each_ mut_ with - Apply
fto every element ofdatain place, scheduled by policyP. - for_
each_ unit_ task_ many_ mut_ with crate::for_each_unit_task_mut_withoverKbuffers of one type, split in lockstep.- for_
each_ unit_ task_ mut_ with - Apply
f(state, first_unit, units)to consecutive runs of whole units ofdata, each run sized to aboutcrate::UNIT_TASK_BYTESof work. - for_
each_ unit_ task_ pair_ mut_ with - Apply
f(state, first_unit, a_units, b_units)to aligned runs of whole units of two mutable buffers, each run sized to aboutcrate::UNIT_TASK_BYTESof work. - for_
each_ unit_ task_ range_ with - Apply
f(state, first_unit, units)to consecutive runs of whole units of a pass that addresses its own data, each run sized to aboutcrate::UNIT_TASK_BYTESof work. - for_
each_ unit_ task_ triple_ mut_ with - Apply
f(state, first_unit, a_units, b_units, c_units)to aligned runs of whole units of three mutable buffers, each run sized to aboutcrate::UNIT_TASK_BYTESof work. - for_
each_ with - Apply
fto every element ofdata, scheduled by policyP. - join
- Adaptive Rayon-style two-closure join.
- join_
with - Run two closures to completion and return both results.
- map_
collect_ index_ with - Parallel map over the index domain
0..len, collecting into aVec<R>in order, scheduled by policyP. - map_
collect_ mut_ with - Map each element of
datain place withf(index, &mut element), collecting each returned value into aVec<R>in order, scheduled by policyP. - map_
collect_ with - Map each element of
datawithf, collecting into aVec<R>in order, scheduled by policyP. - map_
reduce_ with - Map-reduce over
data, scheduled by policyP. - reduce_
index_ with - Parallel reduction over the index domain
0..len, scheduled by policyP. - scope
- Create a borrowing scope for parallel sub-tasks.
- units_
per_ task - Units one task carries when each unit moves
unit_bytes, never fewer than one: a unit at or aboveUNIT_TASK_BYTESis a task on its own.