Execution
FlowGeometries.Execution.BalancedThreads — Type
BalancedThreads(chunks_per_thread = 8)A threaded backend for loops whose indices cost unequal amounts — rows near a pole, a ragged mask, a ball query whose neighbour count varies: 1:n is split into chunks_per_thread contiguous chunks per Julia thread, and each thread takes the next chunk as it finishes one, so a thread that drew cheap chunks takes more of them. The partition depends on n and the thread count alone, so a reduction groups the same way on every run.
FlowGeometries.Execution.ByBlock — Type
ByBlock(m)Index k writes the m positions (k-1)m+1 : km: a column of m rows per index, in column-major storage.
FlowGeometries.Execution.ByIndex — Type
ByIndex()Index k writes linear position k.
FlowGeometries.Execution.ByOffsets — Type
ByOffsets(ptr)Index k writes positions ptr[k] : ptr[k+1]-1: row k of a CSR array with offsets ptr.
FlowGeometries.Execution.Written — Type
Written(array[, span = ByIndex()])An array a bulk loop writes, declared alongside the loop: the indices rng write the linear positions span(rng) of array, one contiguous range, and consecutive index ranges write consecutive ranges of positions. ByIndex, ByBlock and ByOffsets are the spans.
Within one process a loop writes array in place, and the declaration changes nothing. Under a DistributedBackend or an MPIBackend each process runs a share of the indices against its own copy of what the loop captures, and the declared spans are gathered into array: on the calling process for Distributed, on every rank for MPI. A write the loop does not declare stays on the process that made it.
FlowGeometries.Execution._endpoints — Method
_endpoints(x) -> (first, last)The first and last entries of a vector, read as two one-element copies where x is not host data, so a device array serves them without a scalar read.
FlowGeometries.Execution._host_array — Method
_host_array(a) -> AbstractArraya as data a builder walks element by element: itself where _on_host, and a copy in an Array otherwise, as a device array needs.
FlowGeometries.Execution._like — Method
_like(x, y) -> AbstractArrayThe host array y in the storage x is held in: y itself where x is host data, a copy into similar(x, …) otherwise. A builder that read x through _host_array returns its result through this.
FlowGeometries.Execution._on_host — Method
_on_host(a) -> BoolWhether a host loop can read a element by element as it is: an Array, a BitArray, a range, or a type that declares itself host data with a method of this. From the type alone.
FlowGeometries.Execution._reduce_chunks — Method
_reduce_chunks(f, op, n, backend)f(range) over a partition of 1:n, combined left to right with op.
Distinct from map_chunks because the serial path has nothing to collect: it hands f the whole range and returns that value directly, so a serial reduction allocates nothing.
FlowGeometries.Execution.allocate — Method
allocate(backend, T, dims...) -> AbstractArray{T}An uninitialised array of size dims the loops running under backend can write: an ordinary Array on a host backend and on each process of a distributed one, device memory on a GPUBackend.
A CSR build allocates its degree, offset and neighbour arrays through this, so the buffers land where the passes that fill them run.
FlowGeometries.Execution.chunk_ranges — Method
chunk_ranges(n, k) -> Vector{UnitRange{Int}}Partition 1:n into at most k contiguous ranges of near-equal length. Contiguity matters: each chunk then touches one span of every array the loop indexes.
FlowGeometries.Execution.exclusive_scan! — Function
exclusive_scan!(out, counts, backend = SerialBackend(); init = 1) -> outWrite the exclusive prefix sums of counts into out, which is one element longer: out[1] = init and out[i+1] = out[i] + counts[i].
This is a CSR offset array — out[k] is where row k starts and out[end] - init is the total — and every connectivity builder here calls it between its counting pass and its filling pass. Under a threaded backend it is two passes over counts plus a serial scan of one sum per chunk. Under a distributed one counts is whole on every process that holds it, the counting pass having gathered it, so each process scans it under its local_backend.
FlowGeometries.Execution.local_backend — Method
local_backend(backend) -> backendThe backend a process runs its own loops under: the inner backend of a DistributedBackend or an MPIBackend, and resolve(backend) otherwise. A pass over data every process already holds whole — a scan of gathered counts, a sum of them — runs under this, with nothing to exchange.
FlowGeometries.Execution.map_chunks — Method
map_chunks(f, n, backend) -> VectorApply f(range) over a partition of 1:n and collect one result per chunk, for a bulk operation that reduces. The caller combines them, so f needs no lock and the combining order is the caller's to fix, which keeps a parallel reduction independent of scheduling for an operation that is associative but not commutative.
f is called at least once, on an empty range when n == 0, since a reduction has to produce a value; run_chunks has nothing to write there and does not call f. Being callable on an empty range is part of the contract, and it is how the result's element type is known before the chunks run.
FlowGeometries.Execution.max_chunks — Method
max_chunks(backend) -> IntThe most chunks one call of run_numbered_chunks numbers under backend, so storage of that many entries serves every call: one serially, one per Julia thread threaded, chunks_per_thread per thread under BalancedThreads, and none where chunks run on other processes.
FlowGeometries.Execution.on_backend — Method
on_backend(backend, x) -> x, or x in `backend`'s memoryx — an array, or a value holding arrays — where backend's loops read it. x itself where they read host memory. On a GPUBackend wrapping a KernelAbstractions backend, Adapt.adapt(backend.backend, x): the array's own package decides what that backend's memory is, and a struct moves by its Adapt rules.
FlowGeometries.Execution.reduce_indices — Method
reduce_indices(f, op, init, n, backend)Reduce f(i) over i in 1:n with op, under the execution policy backend names.
The per-index counterpart of _reduce_chunks, and the reduction a device can run: f reads index i and nothing else, so the work splits without a chunk body. Every integral, norm and count over a grid goes through this. On a host or device backend f may also write what i determines, as in run_indices, so an update and a reduction of its result take one pass; a process backend runs f on other processes and keeps those writes there.
op must be associative and init its identity. init seeds each partial as well as the whole, so the partials combine in any grouping.
The grouping follows the partition, never the scheduling, so a parallel result is deterministic. It matches the serial left fold wherever op is exactly associative; floating-point + is not, so a parallel sum can differ from the serial one in its last bits.
FlowGeometries.Execution.resolve — Method
resolve(backend) -> backendThe backend a loop runs under: backend itself, and for an AutoBackend FlowGeometries' own policy, ThreadedBackend(), whose loops run as the serial ones when Julia runs one thread.
FlowGeometries.Execution.run_chunks — Method
run_chunks(f, n, backend, outputs::Written...)Apply f(range) over a partition of 1:n, under the execution policy backend names. outputs are the arrays f writes; see Written.
f must be safe to run on disjoint index ranges concurrently — every write it makes has to be determined by the index, never accumulated across chunks. A serial backend hands f the whole range in one call, so the serial path adds no partitioning at all; a threaded one runs one chunk per thread.
FlowGeometries.Execution.run_indices — Method
run_indices(f, n, backend, outputs::Written...)Apply f(i) for each i in 1:n, under the execution policy backend names. outputs are the arrays f writes; see Written. f must write only what i determines, with no accumulation across indices — the same contract as run_chunks, stated per index, the form a device launch expresses.
With KernelAbstractions loaded and a GPUBackend, f becomes the body of a launch over 1:n.
FlowGeometries.Execution.run_numbered_chunks — Method
run_numbered_chunks(f, n, backend, outputs::Written...)run_chunks with each chunk's number, f(c, range): on a serial or threaded backend c lies in 1:max_chunks(backend) and is distinct across the chunks of one call, so it indexes per-chunk storage the caller holds. Where chunks run on other processes every chunk is numbered 0, which indexes none.