| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Tile.Execution.Concurrent
Description
These functions interpret divergence schedules using lightweight
Haskell concurrency through channels and forked threads. A divergence
schedule has edges directed from root toward leaves; it is the form
produced by buildSchedule. Collectives that require
leaf-to-root message flow (reduce, gather) derive the convergence
schedule internally.
The run* forms return the observed result without tracing; the
run*WithTrace forms also report structured Trace events. Their
correctness contract is stated by the pure functions in
Tile.Execution.
Precondition shared by all functions: the schedule must be rooted at
the supplied root. Passing a disconnected schedule may leave worker
threads waiting for messages that never arrive.
Synopsis
- data Trace m msg
- runBroadcast :: Ord m => Schedule m -> m -> p -> IO (Map m p)
- runBroadcastWithTrace :: Ord m => (Trace m p -> IO ()) -> Schedule m -> m -> p -> IO (Map m p)
- runGather :: Ord m => Schedule m -> Map m a -> m -> IO [(m, a)]
- runGatherWithTrace :: Ord m => (Trace m [(m, a)] -> IO ()) -> Schedule m -> Map m a -> m -> IO [(m, a)]
- runReduce :: Ord m => Schedule m -> Map m v -> (v -> v -> v) -> m -> IO v
- runReduceWithTrace :: Ord m => (Trace m v -> IO ()) -> Schedule m -> Map m v -> (v -> v -> v) -> m -> IO v
- runScatter :: Ord m => Schedule m -> [(m, a)] -> m -> IO (Map m a)
- runScatterWithTrace :: Ord m => (Trace m [(m, a)] -> IO ()) -> Schedule m -> [(m, a)] -> m -> IO (Map m a)
- runAllReduce :: Ord m => Schedule m -> m -> Map m v -> (v -> v -> v) -> IO (Map m v)
- runAllReduceWithTrace :: Ord m => (Trace m v -> IO ()) -> Schedule m -> m -> Map m v -> (v -> v -> v) -> IO (Map m v)
Documentation
An observed event in the concurrent schedule interpreter.
runBroadcast :: Ord m => Schedule m -> m -> p -> IO (Map m p) Source #
Run a broadcast divergence schedule without tracing.
runBroadcastWithTrace :: Ord m => (Trace m p -> IO ()) -> Schedule m -> m -> p -> IO (Map m p) Source #
Run a broadcast divergence schedule, reporting each observed action.
Precondition: the schedule is rooted at root.
runGather :: Ord m => Schedule m -> Map m a -> m -> IO [(m, a)] Source #
Run a gather divergence schedule without tracing.
Takes a divergence schedule. Values are collected in preorder over
the divergence tree, matching the pure gatherResult.
runGatherWithTrace :: Ord m => (Trace m [(m, a)] -> IO ()) -> Schedule m -> Map m a -> m -> IO [(m, a)] Source #
Run a gather divergence schedule, reporting each observed action.
Values are accumulated in preorder over the divergence tree: each
node prepends its own value before appending children in tree order,
matching gatherResult. Each directed edge gets a
dedicated channel so arrival order does not affect the result.
Precondition: the schedule is rooted at root. The value map must
contain every member reachable from root.
runReduce :: Ord m => Schedule m -> Map m v -> (v -> v -> v) -> m -> IO v Source #
Run a reduce divergence schedule without tracing.
Takes a divergence schedule. Leaf values flow toward the root and
are combined at each node in tree order, matching the fold order of
the pure reduceResult. The combine function need
not be commutative.
runReduceWithTrace :: Ord m => (Trace m v -> IO ()) -> Schedule m -> Map m v -> (v -> v -> v) -> m -> IO v Source #
Run a reduce divergence schedule, reporting each observed action.
Children are folded in the same order as the pure
reduceResult: left-to-right over the divergence
tree. Each directed edge gets a dedicated channel, so arrival order
does not affect the result.
Precondition: the schedule is rooted at root. The value map must
contain every member reachable from root.
runScatter :: Ord m => Schedule m -> [(m, a)] -> m -> IO (Map m a) Source #
Run a scatter divergence schedule without tracing.
The root starts with a value for each destination. At each hop, the payload is partitioned by the routed subtree below each child.
runScatterWithTrace :: Ord m => (Trace m [(m, a)] -> IO ()) -> Schedule m -> [(m, a)] -> m -> IO (Map m a) Source #
Run a scatter divergence schedule, reporting each observed action.
Precondition: the schedule is rooted at root.
runAllReduce :: Ord m => Schedule m -> m -> Map m v -> (v -> v -> v) -> IO (Map m v) Source #
Run an all-reduce divergence schedule without tracing.
Takes a divergence schedule. Every member ends with the value
obtained by combining all member values with combine. Runs the
reduce phase to completion before starting the broadcast phase.
runAllReduceWithTrace :: Ord m => (Trace m v -> IO ()) -> Schedule m -> m -> Map m v -> (v -> v -> v) -> IO (Map m v) Source #
Run an all-reduce divergence schedule, reporting each observed action.
Both the reduce phase and the broadcast phase emit Trace events
through the same tracer. The reduce phase completes fully before
the broadcast phase begins.
Precondition: the schedule is rooted at root. The value map must
contain every member reachable from root.