# Compute.RuntimeCounter

Read a process-lifetime instrumentation counter. Counter 1 counts compute dispatch encodes; the counter does not reset when read.

Last updated: 2026-09-09

Package: runtime.Compute | Status: registered-intrinsic

Tags: builtin, compute, gameplay, gpu, yeho

Built into Yeho; no package import is needed. Native services require an admitted host and the correct resource lifecycle.

```yh
Compute.RuntimeCounter(int value) -> int
```


## GPU · [gpu]

Run a GPU pass and read the process-lifetime dispatch-encode counter. Counter 1 counts encodes, not frames or GPU duration.

Verification: executed

```yh
[gpu]
compute DoubleRewards(buffer of int rewards, int multiplier)
{
    int index = compute.index
    if index >= rewards.count { return }
    rewards[index] = rewards[index] * multiplier
}

buffer of int rewards
rewards.Add(100)
rewards.Add(80)
rewards.Add(60)
computeTask job = dispatch DoubleRewards(rewards, 2)
wait job
if job.failed { Console.Error(job.error.message) Process.Exit(1) }
for index from 0 < rewards.count { Console.Log(Text.From(rewards[index])) }
Console.Log(Text.From(Compute.RuntimeCounter(1)))

```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.runtime__compute_runtimecounter"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

```

Expected output:

```text
200
160
120
1
```

Executed backend: metal

Observed output:

```text
200
160
120
1
```

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/runtime--Compute.RuntimeCounter/gpu --backend metal -o /tmp/yeho-example
/tmp/yeho-example
```


The example checks the call shape. Opening windows, recording audio, changing files, network operations, and process operations have real effects when run. Follow the corresponding package lifecycle before using live resources.

Source: yeho/src/compiler/common/intrinsic_registry.cpp

AI training permission: https://demonhunterlabs.com/ai-use
