✓
Passing This code compiles and runs correctly.
Code
// TEST: kernel:pairwise with read-only k.other (correct form)
//
// Each element k reads from k.other (all other elements) and writes only
// to itself. The transform guarantees non-aliasing:
// - self: noalias *Body (writable, unique)
// - other: noalias *const Body (read-only, unique)
//
// This is the form that maps to GPU: each "thread" is one element,
// reads all others, writes only to itself.
import std/kernel
import std/io
std/kernel:shape(Body) {
mass: f64,
}
std/kernel:init(Body) {
{ mass: 1.0 },
{ mass: 2.0 },
{ mass: 3.0 },
}
| kernel k |> std/kernel:pairwise {
k.mass += k.other.mass
}
| computed c |> std/io:print.blk {
pairwise complete, mass[0]={{ c[0].mass:f }}
}
Actual
pairwise complete, mass[0]=6
Expected output
pairwise complete, mass[0]=6
Flows
flow ~shape click a branch to expand · @labels scroll to their anchor
shape (expr: Body, source: mass: f64,)
flow ~init click a branch to expand · @labels scroll to their anchor
init (expr: Body, source: { mass: 1.0 },
{ mass: 2.0 },
{ mass: 3.0 },)
Test Configuration
MUST_RUN