Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/content/goal.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,12 @@ A key design feature of Goal is that it always _transpiles directly to Go_ in a

Goal can also be used in conjunction with [[gosl]] to build programs that transparently run on GPU hardware in addition to standard CPUs (as standard Go programs).

## Install

```shell
go install cogentcore.org/lab/goal/cmd/goal@latest
```


## Goal pages

4 changes: 2 additions & 2 deletions gosl/gotosl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ type Config struct {
// accessing variables that have multiple buffers.
// It is compiled into the kernel code as a constant,
// and must fit in a uint32 number.
// For web, the number is 134217728 = 128 MiB.
MaxBufferSize uint32 `default:"2147483648"`
// The default is 32 byte aligned down version of 2147483647 max for nvidia
MaxBufferSize uint32 `default:"2147483616"`
}

//cli:cmd -root
Expand Down
36 changes: 18 additions & 18 deletions gosl/gotosl/testdata/Compute.golden
Original file line number Diff line number Diff line change
Expand Up @@ -31,91 +31,91 @@ fn Index2D(s0: u32, s1: u32, i0: u32, i1: u32) -> u32 {
}

fn BigGet(ix: u32) -> f32 {
let ii = ix / 536870912;
let ii = ix / 536870904;
switch ii {
case u32(0): {
return Big0[ix];
}
case u32(1): {
return Big1[ix - 536870912];
return Big1[ix - 536870904];
}
default: {
return Big2[ix - 1073741824];
return Big2[ix - 1073741808];
}
}
}

fn BigSet(vl: f32, ix: u32) {
let ii = ix / 536870912;
let ii = ix / 536870904;
switch ii {
case u32(0): {
Big0[ix] = vl;
}
case u32(1): {
Big1[ix - 536870912] = vl;
Big1[ix - 536870904] = vl;
}
default: {
Big2[ix - 1073741824] = vl;
Big2[ix - 1073741808] = vl;
}
}
}

fn BigSetAdd(vl: f32, ix: u32) {
let ii = ix / 536870912;
let ii = ix / 536870904;
switch ii {
case u32(0): {
Big0[ix] += vl;
}
case u32(1): {
Big1[ix - 536870912] += vl;
Big1[ix - 536870904] += vl;
}
default: {
Big2[ix - 1073741824] += vl;
Big2[ix - 1073741808] += vl;
}
}
}

fn BigSetSub(vl: f32, ix: u32) {
let ii = ix / 536870912;
let ii = ix / 536870904;
switch ii {
case u32(0): {
Big0[ix] -= vl;
}
case u32(1): {
Big1[ix - 536870912] -= vl;
Big1[ix - 536870904] -= vl;
}
default: {
Big2[ix - 1073741824] -= vl;
Big2[ix - 1073741808] -= vl;
}
}
}

fn BigSetMul(vl: f32, ix: u32) {
let ii = ix / 536870912;
let ii = ix / 536870904;
switch ii {
case u32(0): {
Big0[ix] *= vl;
}
case u32(1): {
Big1[ix - 536870912] *= vl;
Big1[ix - 536870904] *= vl;
}
default: {
Big2[ix - 1073741824] *= vl;
Big2[ix - 1073741808] *= vl;
}
}
}

fn BigSetDiv(vl: f32, ix: u32) {
let ii = ix / 536870912;
let ii = ix / 536870904;
switch ii {
case u32(0): {
Big0[ix] /= vl;
}
case u32(1): {
Big1[ix - 536870912] /= vl;
Big1[ix - 536870904] /= vl;
}
default: {
Big2[ix - 1073741824] /= vl;
Big2[ix - 1073741808] /= vl;
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions gosl/gotosl/testdata/gosl.golden
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func ToGPU(vars ...GPUVars) {
v, _ := syVars.ValueByIndex(1, "Data", 0)
gpu.SetValueFrom(v, Data.Values)
case BigVar:
bsz := 536870912
bsz := 536870904
n := Big.Len()
nb := int(math.Ceil(float64(n) / float64(bsz)))
for bi := range nb {
Expand Down Expand Up @@ -277,7 +277,7 @@ func ReadFromGPU(vars ...GPUVars) {
v, _ := syVars.ValueByIndex(1, "Data", 0)
v.GPUToRead(sy.CommandEncoder)
case BigVar:
bsz := 536870912
bsz := 536870904
n := Big.Len()
nb := int(math.Ceil(float64(n) / float64(bsz)))
for bi := range nb {
Expand Down Expand Up @@ -307,7 +307,7 @@ func SyncFromGPU(vars ...GPUVars) {
v.ReadSync()
gpu.ReadToBytes(v, Data.Values)
case BigVar:
bsz := 536870912
bsz := 536870904
n := Big.Len()
nb := int(math.Ceil(float64(n) / float64(bsz)))
for bi := range nb {
Expand Down