Documentation
¶
Overview ¶
Package opencl provides Go wrappers for the OpenCL 2.0 runtime API. The runtime is loaded dynamically via dlopen; no build tags required.
Index ¶
- func Available() bool
- func GetDeviceCount() (int, error)
- type Context
- func (c *Context) CLContext() unsafe.Pointer
- func (c *Context) CLDevice() unsafe.Pointer
- func (c *Context) CLQueue() unsafe.Pointer
- func (c *Context) CreateStream() (*Stream, error)
- func (c *Context) Destroy() error
- func (c *Context) DeviceID() int
- func (c *Context) Free(ptr unsafe.Pointer) error
- func (c *Context) Malloc(size int) (unsafe.Pointer, error)
- func (c *Context) Memcpy(dst, src unsafe.Pointer, count int, kind MemcpyKind) error
- func (c *Context) SetDevice(deviceID int) error
- type MemcpyKind
- type OpenCLLib
- type Stream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Available ¶
func Available() bool
Available returns true if libOpenCL can be loaded on this machine. The result is cached after the first call.
func GetDeviceCount ¶
GetDeviceCount returns the total number of OpenCL GPU devices.
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context holds an OpenCL context, device, and default command queue.
func NewContext ¶
NewContext creates an OpenCL context on the specified device. If deviceID is -1, the first available GPU device is used.
func (*Context) CreateStream ¶
CreateStream creates a new command queue (stream equivalent).
func (*Context) Malloc ¶
Malloc allocates a device buffer of the given size. Returns the cl_mem handle cast to unsafe.Pointer.
type MemcpyKind ¶
type MemcpyKind int
MemcpyKind specifies the direction of a memory copy.
const ( // MemcpyHostToDevice copies from host to device. MemcpyHostToDevice MemcpyKind = iota // MemcpyDeviceToHost copies from device to host. MemcpyDeviceToHost // MemcpyDeviceToDevice copies from device to device. MemcpyDeviceToDevice )
type OpenCLLib ¶
type OpenCLLib struct {
// contains filtered or unexported fields
}
OpenCLLib holds dlopen handles and resolved function pointers for OpenCL runtime functions. All function pointers are resolved at Open() time via dlsym. Calls go through the platform-specific ccall from the cuda package (which is a general-purpose zero-CGo C function caller, not CUDA-specific).
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream wraps an OpenCL command queue.
func (*Stream) Synchronize ¶
Synchronize waits for all commands in the command queue to complete.