~/bend-docscommunity

bang.bend relies on unsafe/foreign

raw source on the hub · import bend-gpu-kernels@0.1.0.0/bang.bend as Bang

Data-parallel GPU kernels in plain Bend 2: one ! bang over a fork tree of up to 2^14 leaves (the runtime's 16,384 lanes), each leaf running items t, t + l, t + 2l, ... in flat loops over up to six shared arrays. F32 values live in Array<U32> cells as their bits (fv / uv). Arrays are shared between leaves through Base's @unsafe Array.fork: each leaf must write only its own items' cells. Call bang as its own IO step so it runs on the GPU.

3 imports
import Base
import bend-ml-tensor-array@0.1.20.0/main.bend as TA
import ./lanes.bend as L

Types

type AR source · line 21 · raw

Type

type G2 source · line 65 · raw

Type

Definitions

def one source · line 24 · raw

@u:Unit -> Array<U32>

def depth2 source · line 33 · raw

@big:Bool -> @+n:Nat -> Nat

def depth source · line 38 · raw

@+n:Nat -> Nat

def g2b source · line 68 · raw

@+x:U32 -> @r:Pair(Array<U32>, U32) -> G2

def g2a source · line 73 · raw

@+j:U32 -> @r:Pair(Array<U32>, U32) -> G2

def g2 source · line 78 · raw

@a:Array<U32> -> @+i:U32 -> @+j:U32 -> G2

Unsafe

unsafe fv source · line 10 · raw

@u:U32 -> F32

unsafe uv source · line 16 · raw

@x:F32 -> U32

unsafe join6 source · line 28 · raw

@x:AR -> @y:AR -> AR

unsafe items source · line 42 · raw

@-E:Data -> @-g:(@+i:U32 -> @+e:E -> @_:AR -> AR) -> @cnt:Nat -> @+i:U32 -> @+l:U32 -> @+e:E -> @r:AR -> AR

unsafe tree source · line 50 · raw

@-E:Data -> @-g:(@+i:U32 -> @+e:E -> @_:AR -> AR) -> @d:Nat -> @+t:U32 -> @+l:U32 -> @+n:U32 -> @+e:E -> @+x0:Array<U32> -> @+x1:Array<U32> -> @+x2:Array<U32> -> @+x3:Array<U32> -> @+x4:Array<U32> -> @+x5:Array<U32> -> AR

unsafe bang source · line 60 · raw

@-E:Data -> @-g:(@+i:U32 -> @+e:E -> @_:AR -> AR) -> @+n:Nat -> @+e:E -> @r:AR -> AR

n items over the six arrays, in one bang (call it as its own IO step so it runs on the GPU)