Documentation
¶
Overview ¶
Package arena provides pooled, zero-allocation scratch storage for low-latency CUDA Driver API and cuBLAS calls (such as cuLaunchKernel kernelParams arrays and scalar argument buffers).
Index ¶
- Constants
- func PushValue[T any](k *KernelArgs, v T)
- func PutKernelArgs(ka *KernelArgs)
- func PutScratch(s *Scratch)
- type KernelArgs
- func (k *KernelArgs) Count() int
- func (k *KernelArgs) Next() *KernelArgs
- func (k *KernelArgs) ParamsPtr() unsafe.Pointer
- func (k *KernelArgs) PushBytes(b []byte)
- func (k *KernelArgs) PushFloat32(v float32)
- func (k *KernelArgs) PushFloat64(v float64)
- func (k *KernelArgs) PushInt32(v int32)
- func (k *KernelArgs) PushInt64(v int64)
- func (k *KernelArgs) PushUint32(v uint32)
- func (k *KernelArgs) PushUint64(v uint64)
- func (k *KernelArgs) Reset()
- func (k *KernelArgs) SetNext(n *KernelArgs)
- type Scratch
- type ScratchPools
Constants ¶
const (
// MaxKernelArgs is the maximum number of arguments supported in a single KernelArgs container.
MaxKernelArgs = 24
)
Variables ¶
This section is empty.
Functions ¶
func PushValue ¶
func PushValue[T any](k *KernelArgs, v T)
PushValue appends any plain-old-data value T (such as a fixed-size struct) by value.
func PutKernelArgs ¶
func PutKernelArgs(ka *KernelArgs)
PutKernelArgs returns a KernelArgs container to the per-P pool.
Types ¶
type KernelArgs ¶
type KernelArgs struct {
// contains filtered or unexported fields
}
KernelArgs packs cuLaunchKernel's void** kernelParams array and backing parameter bytes into a single pooled Go struct with zero heap allocations on the hot path.
Because ptrs holds Go-typed unsafe.Pointers into slab (within the same struct) and cuLaunchKernel synchronously copies parameter bytes before returning, passing ParamsPtr() followed by runtime.KeepAlive(args) is safe under Go's GC and -race/checkptr.
func GetKernelArgs ¶
func GetKernelArgs() *KernelArgs
GetKernelArgs acquires a reset KernelArgs container from the per-P pool.
func (*KernelArgs) Count ¶
func (k *KernelArgs) Count() int
Count returns the number of pushed arguments.
func (*KernelArgs) Next ¶
func (k *KernelArgs) Next() *KernelArgs
func (*KernelArgs) ParamsPtr ¶
func (k *KernelArgs) ParamsPtr() unsafe.Pointer
ParamsPtr returns the void** pointer suitable for cuLaunchKernel's kernelParams argument. Returns nil if no arguments have been pushed.
func (*KernelArgs) PushBytes ¶
func (k *KernelArgs) PushBytes(b []byte)
PushBytes appends an arbitrary by-value byte struct/array argument.
func (*KernelArgs) PushFloat32 ¶
func (k *KernelArgs) PushFloat32(v float32)
PushFloat32 appends a float32 argument.
func (*KernelArgs) PushFloat64 ¶
func (k *KernelArgs) PushFloat64(v float64)
PushFloat64 appends a float64 argument.
func (*KernelArgs) PushInt32 ¶
func (k *KernelArgs) PushInt32(v int32)
PushInt32 appends an int32 argument.
func (*KernelArgs) PushInt64 ¶
func (k *KernelArgs) PushInt64(v int64)
PushInt64 appends an int64 argument.
func (*KernelArgs) PushUint32 ¶
func (k *KernelArgs) PushUint32(v uint32)
PushUint32 appends a uint32 argument.
func (*KernelArgs) PushUint64 ¶
func (k *KernelArgs) PushUint64(v uint64)
PushUint64 appends a uint64 (or 64-bit CUdeviceptr) argument.
func (*KernelArgs) Reset ¶
func (k *KernelArgs) Reset()
Reset clears the argument list without freeing memory.
func (*KernelArgs) SetNext ¶
func (k *KernelArgs) SetNext(n *KernelArgs)
type Scratch ¶
type Scratch struct {
// contains filtered or unexported fields
}
Scratch is a pooled power-of-2 byte bump-allocator for transient host metadata buffers (modeled after go-xla/pjrt/arena.go).
func GetScratch ¶
GetScratch acquires a Scratch arena of at least minBytes bytes.
type ScratchPools ¶
type ScratchPools struct {
// contains filtered or unexported fields
}
ScratchPools manages power-of-2 pools of Scratch arenas.