{"id":"recipe--compute-chain","name":"Example · Connect two compute passes","owner":"yeho","package":"recipes","kind":"recipe","signature":"start.yh · compute example","description":"Make a dependency between dispatches explicit.","context":"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.","parameters":[],"returns":"","members":[],"tags":["cpu","gpu","recipe"],"updated":"2026-09-09","source":{"repository":"demonhunterlabs","path":"app/lib/yeho-walkthrough.ts"},"status":"complete-program","notes":["Combine the two arithmetic expressions into one independent kernel and compare output. Measure only after confirming every value still matches."],"examples":[{"id":"program","title":"Example · Connect two compute passes","description":"Make a dependency between dispatches explicit.","code":"[auto]\ncompute Fill(buffer of int values)\n{\n    int index = compute.index\n    if index >= values.count { return }\n    values[index] = index + 1\n}\n[auto]\ncompute Double(buffer of int values)\n{\n    int index = compute.index\n    if index >= values.count { return }\n    values[index] = values[index] * 2\n}\n\nbuffer of int values\nvalues.Resize(4)\ncomputeTask first = dispatch Fill(values)\nwait first\nif first.failed { Console.Error(first.error.message) Process.Exit(1) }\ncomputeTask job = dispatch Double(values)\nwait job\nif job.failed { Console.Error(job.error.message) Process.Exit(1) }\nfor index from 0 < values.count { Console.Log(Text.From(values[index])) }","manifest":"manifestVersion = \"2\"\npackage = \"api.example.recipe__compute_chain\"\nversion = \"0.1.0\"\nlanguageEdition = \"yeho-core-2026.1\"\n\n[app]\nkind = \"headless\"\n","tags":["gpu","cpu"],"run":"metal","expected":"2\n4\n6\n8","verification":"type checked","sha256":"57e23332ae930b42814ed66335c60b49df21e2b13bc32145a55bf92c91c75600","checked":"2026-09-09","diagnostic":"","observedOutput":null,"checkedBackend":null}],"searchTerms":[],"url":"https://demonhunterlabs.com/academy/api?item=recipe--compute-chain","json":"https://demonhunterlabs.com/reference/items/recipe--compute-chain.json","markdown":"https://demonhunterlabs.com/reference/text/recipe--compute-chain.md"}
