API Reference
This page is organized by concept rather than one flat symbol list.
Effects
Parables.Effect — Type
EffectAbstract supertype for task access effects.
Effects describe how a task interacts with a region of an object and are used to derive dependency edges in the DAG.
Parables.Read — Type
Read() <: Effect
Write() <: Effect
ReadWrite() <: EffectEffect markers used in access declarations.
Read()means the task only reads a region.Write()means the task overwrites or mutates a region.ReadWrite()means the task both reads and mutates a region.
Parables.Reduce — Type
Reduce(op) <: EffectReduction effect carrying the operator op.
Arguments
op: Associative reduction operator, commonly+or*.
Notes
- Parallel reduction behavior depends on execution strategy.
- When using privatized reduction execution, task bodies should update through
reduce_add!.
Parables.is_reduce — Method
is_reduce(eff::Effect) -> BoolPredicate that returns true only for Reduce(...) effects.
Parables.is_writeish — Method
is_writeish(eff::Effect) -> BoolReturn whether eff should be treated as mutating for conflict analysis.
Returns
falseforRead()trueforWrite(),ReadWrite(), andReduce(...)
Parables.reduce_op — Method
reduce_op(r::Reduce)Return the reduction operator stored in r.
Regions
Parables.Block — Type
Block(r::UnitRange{Int}) <: RegionOne-dimensional contiguous index range.
Parables.IndexSet — Type
IndexSet(idxs::AbstractVector{Int}) <: RegionSparse set of explicit indices.
Parables.Key — Type
Key(k) <: RegionRegion representing a single logical key k, typically used for map-like containers or keyed partitions.
Parables.Region — Type
RegionAbstract supertype for region descriptors used by access declarations.
A region scopes an effect to a subset of an object so Parables can distinguish independent accesses from conflicting ones.
Parables.Tile — Type
Tile(I::UnitRange{Int}, J::UnitRange{Int}) <: RegionTwo-dimensional rectangular tile defined by row range I and column range J.
Parables.Whole — Type
Whole() <: RegionRegion representing an entire object.
Parables.overlaps — Method
overlaps(a::IndexSet, b::IndexSet) -> BoolConservative overlap check for sparse index sets.
Currently returns true to avoid missed dependencies.
Parables.overlaps — Method
overlaps(a::Region, b::Region) -> BoolReturn whether regions a and b may overlap.
Semantics
Whole()overlaps everything.Key(k1)overlapsKey(k2)only whenk1 == k2.BlockandTileuse range intersection checks.IndexSetcurrently uses a conservative overlap policy forIndexSetpairs.- Unknown region combinations default to conservative
true.
Parables.ranges_overlap — Method
ranges_overlap(a::UnitRange{Int}, b::UnitRange{Int}) -> BoolReturn true when integer ranges a and b intersect.
Access And Tasks
Parables.Access — Type
AccessAccess metadata used for dependency analysis.
Fields
objid::UInt64: Stable object identity (objectid(obj)).obj::Any: Original object reference (kept for diagnostics).eff::Effect: Access effect (Read,Write,ReadWrite,Reduce).reg::Region: Region descriptor over the object.
Parables.access — Method
access(obj, eff::Effect, reg::Region) -> AccessConstruct an Access record from an object, effect, and region.
Parables.objkey — Method
objkey(obj) -> (UInt64, Any)Return (objectid(obj), obj) for reuse in access construction and debugging.
Parables.TaskSpec — Type
TaskSpecExecutable task plus declarative access metadata.
Fields
name::String: Human-readable task label.accesses::Vector{Access}: Access declarations used for dependency analysis.thunk::Function: Zero-argument function containing task work.
Parables.TaskSpec — Method
TaskSpec(name::String, thunk::Function) -> TaskSpecConstruct a task with an empty access list.
Parables.add_access! — Method
add_access!(task::TaskSpec, obj, eff::Effect, reg::Region) -> TaskSpecAppend one access declaration to task and return the same task.
Conflicts And DAG Construction
Parables.conflicts — Method
conflicts(a::Access, b::Access; can_parallel_reduce::Bool=false) -> BoolReturn whether two accesses require an ordering dependency.
Arguments
a,b: Access declarations to compare.can_parallel_reduce: Iftrue, allowsReduce(op)pairs with identicalopto proceed in parallel.
Rules
- Different objects never conflict.
- Non-overlapping regions never conflict.
- Any write-like effect conflicts, except optional compatible reductions.
Parables.task_conflicts — Method
task_conflicts(ti::TaskSpec, tj::TaskSpec; can_parallel_reduce::Bool=false) -> BoolReturn true if any access pair across ti and tj conflicts.
Parables.DAG — Type
DAGDependency graph over TaskSpec nodes.
Fields
tasks::Vector{TaskSpec}: Tasks in insertion order.edges::Vector{Vector{Int}}: Adjacency list (i -> successors).indeg::Vector{Int}: Indegree count for each task.
Notes
- A newly created
DAG()contains tasks only afterpush!. - Call
finalize!to constructedgesandindeg.
Parables.DAG — Method
DAG() -> DAGCreate an empty DAG builder with no tasks and no computed edges.
Base.push! — Method
push!(dag::DAG, task::TaskSpec) -> DAGAppend task to dag and return the same DAG.
Notes
- This does not recompute dependencies. Call
finalize!after appending tasks.
Parables.finalize! — Method
finalize!(dag::DAG; can_parallel_reduce::Bool=false) -> DAGBuild dependency edges and indegrees for dag using pairwise task conflict checks while preserving insertion order.
Arguments
can_parallel_reduce: Iftrue, compatibleReduce(op)tasks may execute concurrently.
Complexity
O(T^2)over number of tasks.
Execution
Parables.execute! — Method
execute!(
dag::DAG;
backend=:threads,
nworkers::Integer=Threads.nthreads(),
reduce_strategy=:serialize,
) -> DAGExecute a finalized DAG with the selected backend and reduction strategy.
Arguments
backend::threadsor:serial.nworkers: Number of worker tasks whenbackend=:threads.reduce_strategy::serialize(default) or:privatize.
Returns
- The executed
dag.
Parables.execute_serial! — Method
execute_serial!(dag::DAG) -> DAGExecute dag in topological order on the current thread.
Useful for debugging and correctness baselines.
Parables.execute_threads! — Method
execute_threads!(dag::DAG; nworkers::Integer=Threads.nthreads()) -> DAGExecute dag using Julia threads with a ready-queue scheduler.
Arguments
nworkers: Number of worker tasks spawned to process ready nodes.
Notes
- Assumes
daghas validedges/indegfromfinalize!. - Rethrows the first task error after workers complete.
Parables.ReducerKey — Method
ReducerKey(objid, reg, op)Internal key identifying a reduction target by object identity, region, and operator.
Parables._reduce_identity — Method
_reduce_identity(op::Function, ::Type{T}) where {T}Internal helper that returns identity elements for supported operators.
Parables.alloc_reducers — Method
alloc_reducers(dag::DAG; nthreads::Integer=Threads.maxthreadid()) -> ReduceContextAllocate per-thread reduction buffers for all Reduce(...) accesses in dag.
Supported targets
AbstractVectorwith regionsWhole()andBlock(...).
Parables.combine! — Method
combine!(ctx::ReduceContext)Internal helper that folds thread-local reduction buffers into destination objects.
Parables.execute_privatize! — Method
execute_privatize!(
dag::DAG;
backend=:threads,
nworkers::Integer=Threads.nthreads(),
) -> DAGExecute dag with reduction privatization enabled.
Arguments
backend::threadsor:serial.nworkers: Worker count for threaded backend.
Behavior
- Re-finalizes with
can_parallel_reduce=true. - Allocates reducer buffers for declared
Reduceaccesses. - Executes the DAG.
- Combines per-thread buffers into real reduction targets.
Parables.reduce_add! — Method
reduce_add!(
obj::AbstractVector,
op::Function,
reg::Region,
idx::Int,
value,
) -> AbstractVectorAccumulate value into obj[idx] using reduction operator op.
Arguments
obj: Destination vector being reduced into.op: Reduction operator (for example+).reg: Declared reduction region (Whole()orBlock(...)).idx: Global index inobjto update.value: Contribution to combine atidx.
Behavior
- In normal execution, updates
objdirectly. - In privatized execution, updates a thread-local reduction buffer.
Notes
regandopmust match a declaredReduce(op)access for the task.
Macros
Parables.@access — Macro
@access obj eff regDeclare one access inside a @task body.
Arguments
obj: Object being accessed.eff: Effect instance (Read(),Write(),ReadWrite(),Reduce(op)).reg: Region instance (Whole(),Block(...),Key(...), ...).
Notes
- Valid only inside
@task.
Parables.@accesses — Macro
@accesses begin
(obj1, eff1, reg1)
(obj2, eff2, reg2)
...
endDeclare multiple accesses inside a @task body.
Each entry must be a 3-tuple (obj, eff, reg).
Parables.@dag — Macro
@dag begin
...
endCreate a DAG builder context, collect tasks appended via @spawn, and return a finalized DAG.
Example
dag = Parables.@dag begin
Parables.@spawn Parables.@task "t1" begin
...
end
endParables.@spawn — Macro
@spawn exprAppend task expression expr to the current @dag builder.
Notes
exprshould evaluate to aTaskSpec(or compatible value accepted bypush!onDAG).- Valid only within
@dag.
Parables.@task — Macro
@task name begin
...
endCreate a TaskSpec from a task body.
Behavior
- Collects
@access obj eff regand@accesses begin ... enddeclarations intoTaskSpec.accesses. - Removes those access declarations from the runtime thunk so they are metadata only.
- Stores remaining statements as the task's zero-argument thunk.
Arguments
name: Task name expression that must evaluate to aString.begin ... end: Task body containing access declarations and work.
Example
Parables.@task "scale" begin
Parables.@access x Read() Whole()
Parables.@access y Write() Whole()
y .= 2 .* x
endConvenience Builders
Parables.eachblock — Method
eachblock(data::AbstractArray, block_size::Integer) -> Vector{UnitRange{Int}}Convenience overload equivalent to eachblock(length(data), block_size).
Parables.eachblock — Method
eachblock(n::Integer, block_size::Integer) -> Vector{UnitRange{Int}}Split 1:n into contiguous blocks of size block_size (last block may be shorter).
Arguments
n: Number of logical elements.block_size: Positive block size.
Parables.parables_foreach! — Method
parables_foreach!(dag::DAG, blocks, task_builder::Function) -> DAGAppend tasks produced by task_builder(r, i) directly to an existing DAG.
Parables.parables_foreach! — Method
parables_foreach!(dag::DAG, task_builder::Function, blocks) -> DAGDo-block friendly overload for parables_foreach!.
Parables.parables_foreach — Method
parables_foreach(blocks, task_builder::Function; finalize::Bool=true) -> DAGBuild a DAG by applying task_builder(r, i) to each block.
Arguments
blocks: Block collection (commonly ranges fromeachblock).task_builder: Function returning aTaskSpecor collection ofTaskSpec.finalize: Iftrue, callsfinalize!before returning.
Parables.parables_foreach — Method
parables_foreach(task_builder::Function, blocks; finalize::Bool=true) -> DAGDo-block friendly overload:
parables_foreach(blocks) do r, i
...
endParables.parables_map! — Method
parables_map!(
dest::AbstractVector,
data::AbstractVector,
blocks,
f::Function;
finalize::Bool=true,
name_prefix::String="map",
) -> DAGCreate block tasks that apply f elementwise to data and write into dest.
Arguments
dest,data: Equal-length vectors.blocks: Index ranges defining task partitions.f: Elementwise transform.finalize: Whether to finalize the returned DAG.name_prefix: Task name prefix.
Parables.parables_map — Method
parables_map(
data::AbstractVector,
blocks,
f::Function;
finalize::Bool=true,
name_prefix::String="map",
) -> Tuple{DAG, AbstractVector}Allocate an output vector, build a block map DAG, and return (dag, dest).
Parables.parables_mapreduce — Function
parables_mapreduce(
data::AbstractVector,
blocks,
op::Function,
mapf::Function=identity;
finalize::Bool=true,
name_prefix::String="mapreduce",
) -> Tuple{DAG, Vector}Build a block map-reduce DAG over data.
Arguments
data: Input vector.blocks: Index ranges for per-task work.op: Reduction operator used byReduce(op)andreduce_add!.mapf: Per-element transform before reduction.finalize: Whether to finalize the returned DAG.name_prefix: Task name prefix.
Returns
(dag, acc)whereaccis a length-1 vector storing the reduced value.
Parables.task_from_accesses — Method
task_from_accesses(
name::String,
accesses::AbstractVector,
thunk::Function,
) -> TaskSpecBuild a TaskSpec from a list of access tuples and a zero-arg thunk.
Arguments
name: Task name.accesses: Iterable of(obj, eff, reg)tuples.thunk: Task body.
Diagnostics
Parables.explain_conflict — Method
explain_conflict(
ti::TaskSpec,
tj::TaskSpec;
can_parallel_reduce::Bool=false,
) -> Union{Nothing, Tuple{Access,Access}}Return the first conflicting access pair between ti and tj, or nothing when no conflict is found.
Parables.print_dag — Method
print_dag(dag::DAG; io::IO=stdout)Print adjacency and levelized structure for a finalized DAG.
Notes
- If
dagis not finalized, prints a message and returns. - Also warns when remaining indegrees suggest a cycle.