PartList

vault class PartList<T>

The PartList type is a mutable, fixed-size list with machinery for splitting up computations across multiple threads.

PartList is in the Prelude, meaning it is always available and does not need to be imported.

API Reference

Constructors

Methods

read() -> ReadPartIntent<T>

Returns a ReadPartIntent that can be passed to runParted to indicate read-only access to this PartList.


write() -> WritePartIntent<T>

Returns a WritePartIntent that can be passed to runParted to indicate write-only access to this PartList.


readWrite() -> ReadWritePartIntent<T>

Returns a ReadWritePartIntent that can be passed to runParted to indicate read-write access to this PartList. If a ReadWritePartIntent is passed to runParted, the number of ghost zones must be 0.


reduceParted<O>(nParts: int, partTask: (ReadPartView<T>) -> Fut<O>) -> Fut<O>

Produces a single value of type O by running the given partTask in parallel across nParts parts then combining the intermediate results with partTask again.

Static Methods

of<T>(size: int, fillFunction: (int) -> T) -> PartList<T>

Returns a new PartList with the given size and initialized by the fillFunction. The int passed to the fillFunction is the index of the element being initialized.

This is the standard way to create a PartList.


runParted<T...>(nChunks: int, ?nGhosts: int, partIntents: PartIntent<T>..., chunkTask: (PartView<T>...) -> void) -> Fut<void>

Runs the given chunkTask in parallel across nChunks chunks, each with nGhosts ghost zones. Returns a future that completes when all chunks have finished.

While a PartList is implicated in a runParted computation, calls to runParted with the same PartList will still succeed; the tasks will be enqueued and run asynchronously.

The PartIntents passed to runParted indicate which PartLists are being read or written. The arguments to chunkTask are views into the PartLists, and are one of ReadPartView, WritePartView, or ReadWritePartView according to the PartIntents.

When nGhosts is zero, read and write views have the same range. Indexing a view is always relative to the current chunk. That is, partView[0] is the first element in the current chunk.

When nGhosts is non-zero, read and write views have different ranges. Write views behave the same as always, but read views have an additional nGhosts elements at the beginning and end of the range. For example, partView[0] always corresponds to the first writable element in the current chunk, and partView[-nGhosts] always corresponds to the first readable element in the current chunk.

runParted<T...>(ranges: ValueArray<(int, int)>, ?nGhosts: int, partIntents: PartIntent<T>..., chunkTask: (PartView<T>...) -> void) -> Fut<void>

Works like runParted, but takes a list of [start, end) ranges instead of a fixed number of chunks.