Documentation
¶
Overview ¶
Package cuda runs compute kernels on an NVIDIA GPU through the CUDA driver API, loaded at run time (no cgo, no CUDA toolkit: the driver compiles the kernels' PTX for the GPU it has).
A Context is the GPU's: device memory, modules of kernels, launches, all in order on the context's one stream. Its methods may be called from any goroutine, one at a time (the context is made current on the calling thread for each).
Index ¶
- Variables
- type Buffer
- type Context
- func (c *Context) Alloc(n int) (*Buffer, error)
- func (c *Context) Close()
- func (c *Context) Copy(dst *Buffer, do int, src *Buffer, so, n int) error
- func (c *Context) Download(dst []float32, src *Buffer) error
- func (c *Context) DownloadBytes(dst []byte, src *Buffer) error
- func (c *Context) Free(b *Buffer)
- func (c *Context) Load(image []byte) (*Module, error)
- func (c *Context) Sync() error
- func (c *Context) Upload(dst *Buffer, src []float32) error
- func (c *Context) UploadBytes(dst *Buffer, off int, src []byte) error
- func (c *Context) UploadU64(dst *Buffer, src []uint64) error
- func (c *Context) Zero(b *Buffer) error
- type Dim
- type Kernel
- type Module
Constants ¶
This section is empty.
Variables ¶
ErrUnavailable says there is no CUDA here: no driver, no NVIDIA GPU, or a system the package does not run on.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
Size int // bytes
// contains filtered or unexported fields
}
Buffer is device memory.
type Context ¶
type Context struct {
Name string // the GPU's
Mem int64 // its memory, in bytes
SMs int // its multiprocessors
// contains filtered or unexported fields
}
Context is a CUDA context on a GPU.
func (*Context) Download ¶
Download copies the start of src to dst (once the kernels before have run).
func (*Context) DownloadBytes ¶
DownloadBytes copies the start of src to dst (once the kernels before have run).
func (*Context) Load ¶
Load loads a module from its PTX (or a cubin), compiled by the driver for the GPU.
func (*Context) Sync ¶
Sync waits for every kernel launched to have run, and reports a failure of any.
func (*Context) UploadBytes ¶
UploadBytes copies src to dst at byte offset off.
type Kernel ¶
type Kernel struct {
Name string
// contains filtered or unexported fields
}
Kernel is a module's kernel.
func (*Kernel) Launch ¶
Launch queues a kernel: its grid of blocks, each of block threads, with shared bytes of dynamic shared memory. The arguments are *Buffer (its address), uintptr (an address), int (as a 32-bit int), int32, uint32, float32, float64, int64 or []uint64 (a struct of so many 64-bit fields, passed by value: device addresses, say), in the kernel's order.