# Example · Connect two compute passes

Make a dependency between dispatches explicit.

Last updated: 2026-09-09

Package: recipes | Status: complete-program

Tags: cpu, gpu, recipe

A larger compute effect often has several passes. One creates data and another transforms it. The second pass must receive the completed result of the first. Here Fill writes a short ramp and Double multiplies it by two. We wait and check failure after each dispatch. This makes the dependency obvious even before you look at a profiler.

```yh
start.yh · compute example
```


## Example · Connect two compute passes

Make a dependency between dispatches explicit.

Verification: type checked

```yh
[auto]
compute Fill(buffer of int values)
{
    int index = compute.index
    if index >= values.count { return }
    values[index] = index + 1
}
[auto]
compute Double(buffer of int values)
{
    int index = compute.index
    if index >= values.count { return }
    values[index] = values[index] * 2
}

buffer of int values
values.Resize(4)
computeTask first = dispatch Fill(values)
wait first
if first.failed { Console.Error(first.error.message) Process.Exit(1) }
computeTask job = dispatch Double(values)
wait job
if job.failed { Console.Error(job.error.message) Process.Exit(1) }
for index from 0 < values.count { Console.Log(Text.From(values[index])) }
```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.recipe__compute_chain"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

```

Expected output:

```text
2
4
6
8
```

Extract the example archive beside the yeho and dolphin checkouts. This example requires those source dependencies and a current developer compiler.

```sh
./yeho/build/dolphin-metal/yehoc ./api-examples/recipe--compute-chain/program --backend metal -o /tmp/yeho-example
/tmp/yeho-example
```


Combine the two arithmetic expressions into one independent kernel and compare output. Measure only after confirming every value still matches.

Source: demonhunterlabs/app/lib/yeho-walkthrough.ts

AI training permission: https://demonhunterlabs.com/ai-use
