diff --git a/gosl/examples/rand/main.go b/gosl/examples/rand/main.go index 2ba4f181..a224be59 100644 --- a/gosl/examples/rand/main.go +++ b/gosl/examples/rand/main.go @@ -25,8 +25,8 @@ func main() { GPUInit() // n := 10 - // n := 16_000_000 // max for macbook M* - n := 200_000 + n := 16_000_000 // max for macbook M* + // n := 200_000 UseGPU = false @@ -53,6 +53,7 @@ func main() { gpuFullTmr := timer.Time{} gpuFullTmr.Start() + ToGPUTensorStrides() ToGPU(SeedVar, FloatsVar, UintsVar) gpuTmr := timer.Time{} diff --git a/gosl/examples/rand/shaders/Compute.wgsl b/gosl/examples/rand/shaders/Compute.wgsl index 3108cf97..8154553c 100644 --- a/gosl/examples/rand/shaders/Compute.wgsl +++ b/gosl/examples/rand/shaders/Compute.wgsl @@ -42,13 +42,13 @@ fn RndGen(counter: su64, idx: u32) { var floats11 = RandFloat32Range11Vec2(counter, u32(2), idx); var gauss = RandFloat32NormVec2(counter, u32(3), idx); Uints[Index2D(TensorStrides[10], TensorStrides[11], u32(idx), u32(0))] = uints.x; - Uints[Index2D(TensorStrides[10], TensorStrides[11], u32(idx), u32(1))] = uints.Y; - Floats[Index2D(TensorStrides[0], TensorStrides[1], u32(idx), u32(FloatX))] = floats.X; - Floats[Index2D(TensorStrides[0], TensorStrides[1], u32(idx), u32(FloatY))] = floats.Y; - Floats[Index2D(TensorStrides[0], TensorStrides[1], u32(idx), u32(Float11X))] = floats11.X; - Floats[Index2D(TensorStrides[0], TensorStrides[1], u32(idx), u32(Float11Y))] = floats11.Y; - Floats[Index2D(TensorStrides[0], TensorStrides[1], u32(idx), u32(GaussX))] = gauss.X; - Floats[Index2D(TensorStrides[0], TensorStrides[1], u32(idx), u32(GaussY))] = gauss.Y; + Uints[Index2D(TensorStrides[10], TensorStrides[11], u32(idx), u32(1))] = uints.y; + Floats[Index2D(TensorStrides[0], TensorStrides[1], u32(idx), u32(FloatX))] = floats.x; + Floats[Index2D(TensorStrides[0], TensorStrides[1], u32(idx), u32(FloatY))] = floats.y; + Floats[Index2D(TensorStrides[0], TensorStrides[1], u32(idx), u32(Float11X))] = floats11.x; + Floats[Index2D(TensorStrides[0], TensorStrides[1], u32(idx), u32(Float11Y))] = floats11.y; + Floats[Index2D(TensorStrides[0], TensorStrides[1], u32(idx), u32(GaussX))] = gauss.x; + Floats[Index2D(TensorStrides[0], TensorStrides[1], u32(idx), u32(GaussY))] = gauss.y; } fn Compute(i: u32) { //gosl:kernel RndGen(Seed[0].Seed, i); @@ -219,4 +219,4 @@ fn Uint32ToFloat32Range11Vec2(val: vec2) -> vec2 { r.x = Uint32ToFloat32Range11(val.x); r.y = Uint32ToFloat32Range11(val.y); return r; -} +} \ No newline at end of file diff --git a/gosl/gotosl/nodes.go b/gosl/gotosl/nodes.go index eff43267..70d12a38 100644 --- a/gosl/gotosl/nodes.go +++ b/gosl/gotosl/nodes.go @@ -1542,7 +1542,11 @@ func (p *printer) selectorExpr(x *ast.SelectorExpr, depth int) (wasIndented bool return true } p.setPos(x.Sel.Pos()) - p.print(x.Sel) + if x.Sel.Name == "X" || x.Sel.Name == "Y" || x.Sel.Name == "Z" || x.Sel.Name == "W" { + p.print(strings.ToLower(x.Sel.Name)) + } else { + p.print(x.Sel) + } return false }