dagga 🌿

A crate for scheduling directed acyclic graphs.

Features

Example uses

Example

```rust use dagga::*;

// Create names/values for our resources. // // These represent the types of the resources that get created, passed through // and consumed by each node. let [a, b, c, d]: [usize; 4] = [0, 1, 2, 3];

// Add the nodes with their dependencies and build the schedule. // The order they are added should not matter (it may cause differences in // scheduling, but always result in a valid schedule). let dag = Dag::<(), usize>::default() .withnode({ // This node results in the creation of an a. Node::new(()).withname("create-a").withresult(a) }) .withnode({ // This node creates a b. Node::new(()).withname("create-b").withresult(b) }) .withnode({ // This node reads a and b and results in c Node::new(()) .withname("create-c") .withread(a) .withread(b) .withresult(c) }) .withnode({ // This node modifies a, but for reasons outside of the scope of the types // expressed here (just as an example), it must be run before // "create-c". There is no result of this node beside the side-effect of // modifying a. Node::new(()) .withname("modify-a") .withwrite(a) .withread(b) .runbefore("create-c") }) .withnode({ // This node consumes a, b, c and results in d. Node::new(()) .withname("reduce-abc-to-d") .withmove(a) .withmove(b) .withmove(c) .withresult(d) });

dagga::assert_batches( &[ "create-a, create-b", /* each batch can be run in parallel w/o violating * exclusive borrows */ "modify-a", "create-c", "reduce-abc-to-d", ], dag.clone(), ); ```

You can also have dagga create a dot graph file to visualize the schedule (using graphiz or similar): dagga example schedule