# buffer.Resize

Set a scalar buffer's logical element count, preserving existing elements and zero-filling growth.

Last updated: 2026-09-09

Package: runtime | Status: experimental

Tags: compute, cpu, gameplay, gpu, yeho

CPU and GPU data processing with explicit ownership and completion.

```yh
buffer.Resize
```


## GPU · [gpu]

Double a batch of reward values on native Metal. The [gpu] tag requires an accelerator backend; CPU oracle cannot silently satisfy it.

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.Resize(3)
rewards[0] = 100
rewards[1] = 80
rewards[2] = 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])) }

```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.runtime__buffer_resize"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

```

Expected output:

```text
200
160
120
```

Executed backend: metal

Observed output:

```text
200
160
120
```

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--buffer.Resize/gpu --backend metal -o /tmp/yeho-example
/tmp/yeho-example
```




Source: yeho/docs/runtime/execution-boundaries.md; docs/runtime/metal-compute-v1.md

AI training permission: https://demonhunterlabs.com/ai-use
