Documentation
¶
Overview ¶
Package cl provides a binding to the OpenCL api. It's mostly a low-level wrapper that avoids adding functionality while still making the interface a little more friendly and easy to use.
Resource life-cycle management:
For any CL object that gets created (buffer, queue, kernel, etc..) you should call object.Release() when finished with it to free the CL resources. This explicitely calls the related clXXXRelease method for the type. However, as a fallback there is a finalizer set for every resource item that takes care of it (eventually) if Release isn't called. In this way you can have better control over the life cycle of resources while having a fall back to avoid leaks. This is similar to how file handles and such are handled in the Go standard packages.
Index ¶
- Constants
- Variables
- func WaitForEvents(events []*Event) error
- type ChannelDataType
- type ChannelOrder
- type CommandQueue
- func (q *CommandQueue) EnqueueBarrierWithWaitList(eventWaitList []*Event) (*Event, error)
- func (q *CommandQueue) EnqueueCopyBuffer(srcBuffer, dstBuffer *MemObject, srcOffset, dstOffset, byteCount int, ...) (*Event, error)
- func (q *CommandQueue) EnqueueFillBuffer(buffer *MemObject, pattern unsafe.Pointer, patternSize, offset, size int, ...) (*Event, error)
- func (q *CommandQueue) EnqueueMapBuffer(buffer *MemObject, blocking bool, flags MapFlag, offset, size int, ...) (*MappedMemObject, *Event, error)
- func (q *CommandQueue) EnqueueMapImage(buffer *MemObject, blocking bool, flags MapFlag, origin, region [3]int, ...) (*MappedMemObject, *Event, error)
- func (q *CommandQueue) EnqueueMarkerWithWaitList(eventWaitList []*Event) (*Event, error)
- func (q *CommandQueue) EnqueueNDRangeKernel(kernel *Kernel, globalWorkOffset, globalWorkSize, localWorkSize []int, ...) (*Event, error)
- func (q *CommandQueue) EnqueueReadBuffer(buffer *MemObject, blocking bool, offset, dataSize int, dataPtr unsafe.Pointer, ...) (*Event, error)
- func (q *CommandQueue) EnqueueReadBufferFloat32(buffer *MemObject, blocking bool, offset int, data []float32, ...) (*Event, error)
- func (q *CommandQueue) EnqueueReadImage(image *MemObject, blocking bool, origin, region [3]int, ...) (*Event, error)
- func (q *CommandQueue) EnqueueUnmapMemObject(buffer *MemObject, mappedObj *MappedMemObject, eventWaitList []*Event) (*Event, error)
- func (q *CommandQueue) EnqueueWriteBuffer(buffer *MemObject, blocking bool, offset, dataSize int, dataPtr unsafe.Pointer, ...) (*Event, error)
- func (q *CommandQueue) EnqueueWriteBufferFloat32(buffer *MemObject, blocking bool, offset int, data []float32, ...) (*Event, error)
- func (q *CommandQueue) EnqueueWriteImage(image *MemObject, blocking bool, origin, region [3]int, ...) (*Event, error)
- func (q *CommandQueue) Finish() error
- func (q *CommandQueue) Flush() error
- func (q *CommandQueue) Release()
- type CommandQueueProperty
- type CommmandExecStatus
- type Context
- func (ctx *Context) CreateBuffer(flags MemFlag, data []byte) (*MemObject, error)
- func (ctx *Context) CreateBufferFloat32(flags MemFlag, data []float32) (*MemObject, error)
- func (ctx *Context) CreateBufferUnsafe(flags MemFlag, size int, dataPtr unsafe.Pointer) (*MemObject, error)
- func (ctx *Context) CreateCommandQueue(device *Device, properties CommandQueueProperty) (*CommandQueue, error)
- func (ctx *Context) CreateEmptyBuffer(flags MemFlag, size int) (*MemObject, error)
- func (ctx *Context) CreateImage(flags MemFlag, imageFormat ImageFormat, imageDesc ImageDescription, ...) (*MemObject, error)
- func (ctx *Context) CreateImageFromImage(flags MemFlag, img image.Image) (*MemObject, error)
- func (ctx *Context) CreateImageSimple(flags MemFlag, width, height int, channelOrder ChannelOrder, ...) (*MemObject, error)
- func (ctx *Context) CreateProgramWithSource(sources []string) (*Program, error)
- func (ctx *Context) CreateUserEvent() (*Event, error)
- func (ctx *Context) GetSupportedImageFormats(flags MemFlag, imageType MemObjectType) ([]ImageFormat, error)
- func (ctx *Context) Release()
- type Device
- func (d *Device) AddressBits() int
- func (d *Device) Available() bool
- func (d *Device) BuiltInKernels() []string
- func (d *Device) CompilerAvailable() bool
- func (d *Device) DoubleFPConfig() FPConfig
- func (d *Device) DriverVersion() string
- func (d *Device) EndianLittle() bool
- func (d *Device) ErrorCorrectionSupport() bool
- func (d *Device) ExecutionCapabilities() ExecCapability
- func (d *Device) Extensions() []string
- func (d *Device) GlobalMemCacheType() MemCacheType
- func (d *Device) GlobalMemCachelineSize() int
- func (d *Device) GlobalMemSize() int64
- func (d *Device) HalfFPConfig() FPConfig
- func (d *Device) HostUnifiedMemory() bool
- func (d *Device) Image2DMaxHeight() int
- func (d *Device) Image2DMaxWidth() int
- func (d *Device) Image3DMaxDepth() int
- func (d *Device) Image3DMaxHeight() int
- func (d *Device) Image3DMaxWidth() int
- func (d *Device) ImageMaxArraySize() int
- func (d *Device) ImageMaxBufferSize() int
- func (d *Device) ImageSupport() bool
- func (d *Device) LinkerAvailable() bool
- func (d *Device) LocalMemSize() int64
- func (d *Device) LocalMemType() LocalMemType
- func (d *Device) MaxClockFrequency() int
- func (d *Device) MaxComputeUnits() int
- func (d *Device) MaxConstantArgs() int
- func (d *Device) MaxConstantBufferSize() int64
- func (d *Device) MaxMemAllocSize() int64
- func (d *Device) MaxParameterSize() int
- func (d *Device) MaxReadImageArgs() int
- func (d *Device) MaxSamplers() int
- func (d *Device) MaxWorkGroupSize() int
- func (d *Device) MaxWorkItemDimensions() int
- func (d *Device) MaxWorkItemSizes() []int
- func (d *Device) MaxWriteImageArgs() int
- func (d *Device) MemBaseAddrAlign() int
- func (d *Device) Name() string
- func (d *Device) NativeVectorWidthChar() int
- func (d *Device) NativeVectorWidthDouble() int
- func (d *Device) NativeVectorWidthFloat() int
- func (d *Device) NativeVectorWidthHalf() int
- func (d *Device) NativeVectorWidthInt() int
- func (d *Device) NativeVectorWidthLong() int
- func (d *Device) NativeVectorWidthShort() int
- func (d *Device) OpenCLCVersion() string
- func (d *Device) ParentDevice() *Device
- func (d *Device) Profile() string
- func (d *Device) ProfilingTimerResolution() int
- func (d *Device) Type() DeviceType
- func (d *Device) Vendor() string
- func (d *Device) Version() string
- type DeviceType
- type ErrOther
- type ErrUnsupportedArgumentType
- type Event
- type ExecCapability
- type FPConfig
- type HostMem
- type ImageDescription
- type ImageFormat
- type Kernel
- func (k *Kernel) ArgName(index int) (string, error)
- func (k *Kernel) NumArgs() (int, error)
- func (k *Kernel) PreferredWorkGroupSizeMultiple(device *Device) (int, error)
- func (k *Kernel) Release()
- func (k *Kernel) SetArg(index int, arg interface{}) error
- func (k *Kernel) SetArgBuffer(index int, buffer *MemObject) error
- func (k *Kernel) SetArgLocal(index int, size int) error
- func (k *Kernel) SetArgNumber(index int, arg interface{}) error
- func (k *Kernel) SetArgUnsafe(index, argSize int, arg unsafe.Pointer) error
- func (k *Kernel) SetArgs(args ...interface{}) error
- func (k *Kernel) WorkGroupSize(device *Device) (int, error)
- type LocalBuffer
- type LocalMemType
- type MapFlag
- type MappedMemObject
- type MemCacheType
- type MemFlag
- type MemObject
- type MemObjectType
- type NumTyped
- type Platform
- type PrimitiveType
- type ProfilingInfo
- type Program
- type ProgramBuildError
- type SliceF32
Constants ¶
const ( ChannelDataTypeUNormInt24 ChannelDataType = C.CL_UNORM_INT24 ChannelOrderDepth ChannelOrder = C.CL_DEPTH ChannelOrderDepthStencil ChannelOrder = C.CL_DEPTH_STENCIL MemHostNoAccess MemFlag = C.CL_MEM_HOST_NO_ACCESS // OpenCL 1.2 MemHostReadOnly MemFlag = C.CL_MEM_HOST_READ_ONLY // OpenCL 1.2 MemHostWriteOnly MemFlag = C.CL_MEM_HOST_WRITE_ONLY // OpenCL 1.2 MemObjectTypeImage1D MemObjectType = C.CL_MEM_OBJECT_IMAGE1D MemObjectTypeImage1DArray MemObjectType = C.CL_MEM_OBJECT_IMAGE1D_ARRAY MemObjectTypeImage1DBuffer MemObjectType = C.CL_MEM_OBJECT_IMAGE1D_BUFFER MemObjectTypeImage2DArray MemObjectType = C.CL_MEM_OBJECT_IMAGE2D_ARRAY // MapFlagWriteInvalidateRegion specifies that the region being mapped in the memory object is being mapped for writing. // // The contents of the region being mapped are to be discarded. This is typically the case when the // region being mapped is overwritten by the host. This flag allows the implementation to no longer // guarantee that the pointer returned by clEnqueueMapBuffer or clEnqueueMapImage contains the // latest bits in the region being mapped which can be a significant performance enhancement. MapFlagWriteInvalidateRegion MapFlag = C.CL_MAP_WRITE_INVALIDATE_REGION )
Extra 1.2 flags
Variables ¶
var ( ErrHostMemWasEmpty = errors.New("HostMem slice was empty") ErrHostMemWasNil = errors.New("HostMem slice was nil") ErrHostMemInvalidData = errors.New("HostMem data was invalid") ErrInvalidNumType = errors.New("NewNumType invalid NumType") )
HostMem errors
var ( ErrDeviceNotFound = errors.New("cl: Device Not Found") ErrDeviceNotAvailable = errors.New("cl: Device Not Available") ErrCompilerNotAvailable = errors.New("cl: Compiler Not Available") ErrMemObjectAllocationFailure = errors.New("cl: Mem Object Allocation Failure") ErrOutOfResources = errors.New("cl: Out Of Resources") ErrOutOfHostMemory = errors.New("cl: Out Of Host Memory") ErrProfilingInfoNotAvailable = errors.New("cl: Profiling Info Not Available") ErrMemCopyOverlap = errors.New("cl: Mem Copy Overlap") ErrImageFormatMismatch = errors.New("cl: Image Format Mismatch") ErrImageFormatNotSupported = errors.New("cl: Image Format Not Supported") ErrBuildProgramFailure = errors.New("cl: Build Program Failure") ErrMapFailure = errors.New("cl: Map Failure") ErrMisalignedSubBufferOffset = errors.New("cl: Misaligned Sub Buffer Offset") ErrExecStatusErrorForEventsInWaitList = errors.New("cl: Exec Status Error For Events In Wait List") ErrCompileProgramFailure = errors.New("cl: Compile Program Failure") ErrLinkerNotAvailable = errors.New("cl: Linker Not Available") ErrLinkProgramFailure = errors.New("cl: Link Program Failure") ErrDevicePartitionFailed = errors.New("cl: Device Partition Failed") ErrKernelArgInfoNotAvailable = errors.New("cl: Kernel Arg Info Not Available") ErrInvalidValue = errors.New("cl: Invalid Value") ErrInvalidDeviceType = errors.New("cl: Invalid Device Type") ErrInvalidPlatform = errors.New("cl: Invalid Platform") ErrInvalidDevice = errors.New("cl: Invalid Device") ErrInvalidContext = errors.New("cl: Invalid Context") ErrInvalidQueueProperties = errors.New("cl: Invalid Queue Properties") ErrInvalidCommandQueue = errors.New("cl: Invalid Command Queue") ErrInvalidHostPtr = errors.New("cl: Invalid Host Ptr") ErrInvalidMemObject = errors.New("cl: Invalid Mem Object") ErrInvalidImageFormatDescriptor = errors.New("cl: Invalid Image Format Descriptor") ErrInvalidImageSize = errors.New("cl: Invalid Image Size") ErrInvalidSampler = errors.New("cl: Invalid Sampler") ErrInvalidBinary = errors.New("cl: Invalid Binary") ErrInvalidBuildOptions = errors.New("cl: Invalid Build Options") ErrInvalidProgram = errors.New("cl: Invalid Program") ErrInvalidProgramExecutable = errors.New("cl: Invalid Program Executable") ErrInvalidKernelName = errors.New("cl: Invalid Kernel Name") ErrInvalidKernelDefinition = errors.New("cl: Invalid Kernel Definition") ErrInvalidKernel = errors.New("cl: Invalid Kernel") ErrInvalidArgIndex = errors.New("cl: Invalid Arg Index") ErrInvalidArgValue = errors.New("cl: Invalid Arg Value") ErrInvalidArgSize = errors.New("cl: Invalid Arg Size") ErrInvalidKernelArgs = errors.New("cl: Invalid Kernel Args") ErrInvalidWorkDimension = errors.New("cl: Invalid Work Dimension") ErrInvalidWorkGroupSize = errors.New("cl: Invalid Work Group Size") ErrInvalidWorkItemSize = errors.New("cl: Invalid Work Item Size") ErrInvalidGlobalOffset = errors.New("cl: Invalid Global Offset") ErrInvalidEventWaitList = errors.New("cl: Invalid Event Wait List") ErrInvalidEvent = errors.New("cl: Invalid Event") ErrInvalidOperation = errors.New("cl: Invalid Operation") ErrInvalidGlObject = errors.New("cl: Invalid Gl Object") ErrInvalidBufferSize = errors.New("cl: Invalid Buffer Size") ErrInvalidMipLevel = errors.New("cl: Invalid Mip Level") ErrInvalidGlobalWorkSize = errors.New("cl: Invalid Global Work Size") ErrInvalidProperty = errors.New("cl: Invalid Property") ErrInvalidImageDescriptor = errors.New("cl: Invalid Image Descriptor") ErrInvalidCompilerOptions = errors.New("cl: Invalid Compiler Options") ErrInvalidLinkerOptions = errors.New("cl: Invalid Linker Options") ErrInvalidDevicePartitionCount = errors.New("cl: Invalid Device Partition Count") )
Errors that are returnable by OpenCL as integers
var ( // ErrUnknown is generally an unexpected result from an OpenCL function (e.g. CL_SUCCESS but null pointer) ErrUnknown = errors.New("cl: unknown error") )
var ErrUnsupported = errors.New("cl: unsupported")
ErrUnsupported is the rror returned when some functionality is not support
Functions ¶
func WaitForEvents ¶
WaitForEvents waits on the host thread for commands identified by event objects in events to complete. A command is considered complete if its execution status is CL_COMPLETE or a negative value. The events specified in event_list act as synchronization points.
If the cl_khr_gl_event extension is enabled, event objects can also be used to reflect the status of an OpenGL sync object. The sync object in turn refers to a fence command executing in an OpenGL command stream. This provides another method of coordinating sharing of buffers and images between OpenGL and OpenCL.
Types ¶
type ChannelDataType ¶
type ChannelDataType int
ChannelDataType ..
const ( ChannelDataTypeSNormInt8 ChannelDataType = C.CL_SNORM_INT8 ChannelDataTypeSNormInt16 ChannelDataType = C.CL_SNORM_INT16 ChannelDataTypeUNormInt8 ChannelDataType = C.CL_UNORM_INT8 ChannelDataTypeUNormInt16 ChannelDataType = C.CL_UNORM_INT16 ChannelDataTypeUNormShort565 ChannelDataType = C.CL_UNORM_SHORT_565 ChannelDataTypeUNormShort555 ChannelDataType = C.CL_UNORM_SHORT_555 ChannelDataTypeUNormInt101010 ChannelDataType = C.CL_UNORM_INT_101010 ChannelDataTypeSignedInt8 ChannelDataType = C.CL_SIGNED_INT8 ChannelDataTypeSignedInt16 ChannelDataType = C.CL_SIGNED_INT16 ChannelDataTypeSignedInt32 ChannelDataType = C.CL_SIGNED_INT32 ChannelDataTypeUnsignedInt8 ChannelDataType = C.CL_UNSIGNED_INT8 ChannelDataTypeUnsignedInt16 ChannelDataType = C.CL_UNSIGNED_INT16 ChannelDataTypeUnsignedInt32 ChannelDataType = C.CL_UNSIGNED_INT32 ChannelDataTypeHalfFloat ChannelDataType = C.CL_HALF_FLOAT ChannelDataTypeFloat ChannelDataType = C.CL_FLOAT )
ChannelDataType variants
func (ChannelDataType) String ¶
func (ct ChannelDataType) String() string
type ChannelOrder ¶
type ChannelOrder int
ChannelOrder ..
const ( ChannelOrderR ChannelOrder = C.CL_R ChannelOrderA ChannelOrder = C.CL_A ChannelOrderRG ChannelOrder = C.CL_RG ChannelOrderRA ChannelOrder = C.CL_RA ChannelOrderRGB ChannelOrder = C.CL_RGB ChannelOrderRGBA ChannelOrder = C.CL_RGBA ChannelOrderBGRA ChannelOrder = C.CL_BGRA ChannelOrderARGB ChannelOrder = C.CL_ARGB ChannelOrderIntensity ChannelOrder = C.CL_INTENSITY ChannelOrderLuminance ChannelOrder = C.CL_LUMINANCE ChannelOrderRx ChannelOrder = C.CL_Rx ChannelOrderRGx ChannelOrder = C.CL_RGx ChannelOrderRGBx ChannelOrder = C.CL_RGBx )
ChannelOrder variants
func (ChannelOrder) String ¶
func (co ChannelOrder) String() string
type CommandQueue ¶
type CommandQueue struct {
// contains filtered or unexported fields
}
CommandQueue is the cl_command_queue wrapping struct
func (*CommandQueue) EnqueueBarrierWithWaitList ¶
func (q *CommandQueue) EnqueueBarrierWithWaitList(eventWaitList []*Event) (*Event, error)
EnqueueBarrierWithWaitList enqueues a synchronization point that enqueues a barrier operation.
func (*CommandQueue) EnqueueCopyBuffer ¶
func (q *CommandQueue) EnqueueCopyBuffer(srcBuffer, dstBuffer *MemObject, srcOffset, dstOffset, byteCount int, eventWaitList []*Event) (*Event, error)
EnqueueCopyBuffer enqueues a command to copy a buffer object to another buffer object.
func (*CommandQueue) EnqueueFillBuffer ¶
func (q *CommandQueue) EnqueueFillBuffer(buffer *MemObject, pattern unsafe.Pointer, patternSize, offset, size int, eventWaitList []*Event) (*Event, error)
EnqueueFillBuffer enqueues a command to fill a buffer object with a pattern of a given pattern size.
func (*CommandQueue) EnqueueMapBuffer ¶
func (q *CommandQueue) EnqueueMapBuffer(buffer *MemObject, blocking bool, flags MapFlag, offset, size int, eventWaitList []*Event) (*MappedMemObject, *Event, error)
EnqueueMapBuffer enqueues a command to map a region of the buffer object given by buffer into the host address space and returns a pointer to this mapped region.
func (*CommandQueue) EnqueueMapImage ¶
func (q *CommandQueue) EnqueueMapImage(buffer *MemObject, blocking bool, flags MapFlag, origin, region [3]int, eventWaitList []*Event) (*MappedMemObject, *Event, error)
EnqueueMapImage enqueues a command to map a region of an image object into the host address space and returns a pointer to this mapped region.
func (*CommandQueue) EnqueueMarkerWithWaitList ¶
func (q *CommandQueue) EnqueueMarkerWithWaitList(eventWaitList []*Event) (*Event, error)
EnqueueMarkerWithWaitList enqueues a marker command which waits for either a list of events to complete, or all previously enqueued commands to complete.
func (*CommandQueue) EnqueueNDRangeKernel ¶
func (q *CommandQueue) EnqueueNDRangeKernel(kernel *Kernel, globalWorkOffset, globalWorkSize, localWorkSize []int, eventWaitList []*Event) (*Event, error)
EnqueueNDRangeKernel enqueues a command to execute a kernel on a device.
func (*CommandQueue) EnqueueReadBuffer ¶
func (q *CommandQueue) EnqueueReadBuffer(buffer *MemObject, blocking bool, offset, dataSize int, dataPtr unsafe.Pointer, eventWaitList []*Event) (*Event, error)
EnqueueReadBuffer enqueues commands to read from a buffer object to host memory.
func (*CommandQueue) EnqueueReadBufferFloat32 ¶
func (q *CommandQueue) EnqueueReadBufferFloat32(buffer *MemObject, blocking bool, offset int, data []float32, eventWaitList []*Event) (*Event, error)
EnqueueReadBufferFloat32 ..
func (*CommandQueue) EnqueueReadImage ¶
func (q *CommandQueue) EnqueueReadImage(image *MemObject, blocking bool, origin, region [3]int, rowPitch, slicePitch int, data []byte, eventWaitList []*Event) (*Event, error)
EnqueueReadImage enqueues a command to read from a 2D or 3D image object to host memory.
func (*CommandQueue) EnqueueUnmapMemObject ¶
func (q *CommandQueue) EnqueueUnmapMemObject(buffer *MemObject, mappedObj *MappedMemObject, eventWaitList []*Event) (*Event, error)
EnqueueUnmapMemObject enqueues a command to unmap a previously mapped region of a memory object.
func (*CommandQueue) EnqueueWriteBuffer ¶
func (q *CommandQueue) EnqueueWriteBuffer(buffer *MemObject, blocking bool, offset, dataSize int, dataPtr unsafe.Pointer, eventWaitList []*Event) (*Event, error)
EnqueueWriteBuffer enqueues commands to write to a buffer object from host memory.
func (*CommandQueue) EnqueueWriteBufferFloat32 ¶
func (q *CommandQueue) EnqueueWriteBufferFloat32(buffer *MemObject, blocking bool, offset int, data []float32, eventWaitList []*Event) (*Event, error)
EnqueueWriteBufferFloat32 ..
func (*CommandQueue) EnqueueWriteImage ¶
func (q *CommandQueue) EnqueueWriteImage(image *MemObject, blocking bool, origin, region [3]int, rowPitch, slicePitch int, data []byte, eventWaitList []*Event) (*Event, error)
EnqueueWriteImage enqueues a command to write from a 2D or 3D image object to host memory.
func (*CommandQueue) Finish ¶
func (q *CommandQueue) Finish() error
Finish blocks until all previously queued OpenCL commands in a command-queue are issued to the associated device and have completed.
func (*CommandQueue) Flush ¶
func (q *CommandQueue) Flush() error
Flush issues all previously queued OpenCL commands in a command-queue to the device associated with the command-queue.
func (*CommandQueue) Release ¶
func (q *CommandQueue) Release()
Release calls clReleaseCommandQueue on the CommandQueue. Using the CommandQueue after Release will cause a panic.
type CommandQueueProperty ¶
type CommandQueueProperty int
CommandQueueProperty ..
const ( CommandQueueOutOfOrderExecModeEnable CommandQueueProperty = C.CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE CommandQueueProfilingEnable CommandQueueProperty = C.CL_QUEUE_PROFILING_ENABLE )
CommandQueueProperty variants
type CommmandExecStatus ¶
type CommmandExecStatus int
CommmandExecStatus ..
const ( CommmandExecStatusComplete CommmandExecStatus = C.CL_COMPLETE CommmandExecStatusRunning CommmandExecStatus = C.CL_RUNNING CommmandExecStatusSubmitted CommmandExecStatus = C.CL_SUBMITTED CommmandExecStatusQueued CommmandExecStatus = C.CL_QUEUED )
CommmandExecStatus variants
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context ..
func (*Context) CreateBuffer ¶
CreateBuffer ..
func (*Context) CreateBufferFloat32 ¶
CreateBufferFloat32 ..
func (*Context) CreateBufferUnsafe ¶
func (ctx *Context) CreateBufferUnsafe(flags MemFlag, size int, dataPtr unsafe.Pointer) (*MemObject, error)
CreateBufferUnsafe ..
func (*Context) CreateCommandQueue ¶
func (ctx *Context) CreateCommandQueue(device *Device, properties CommandQueueProperty) (*CommandQueue, error)
CreateCommandQueue ..
func (*Context) CreateEmptyBuffer ¶
CreateEmptyBuffer ..
func (*Context) CreateImage ¶
func (ctx *Context) CreateImage(flags MemFlag, imageFormat ImageFormat, imageDesc ImageDescription, data []byte) (*MemObject, error)
CreateImage ..
func (*Context) CreateImageFromImage ¶
CreateImageFromImage ..
func (*Context) CreateImageSimple ¶
func (ctx *Context) CreateImageSimple(flags MemFlag, width, height int, channelOrder ChannelOrder, channelDataType ChannelDataType, data []byte) (*MemObject, error)
CreateImageSimple ..
func (*Context) CreateProgramWithSource ¶
CreateProgramWithSource ..
func (*Context) CreateUserEvent ¶
CreateUserEvent ..
func (*Context) GetSupportedImageFormats ¶
func (ctx *Context) GetSupportedImageFormats(flags MemFlag, imageType MemObjectType) ([]ImageFormat, error)
GetSupportedImageFormats ..
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device is a cl_device_id wrapping struct
func GetDevices ¶
func GetDevices(platform *Platform, deviceType DeviceType) ([]*Device, error)
GetDevices obtaisn the list of devices available on a platform. 'platform' refers to the platform returned by GetPlatforms or can be nil. If platform is nil, the behavior is implementation-defined.
func (*Device) AddressBits ¶
AddressBits is the default compute device address space size specified as an unsigned integer value in bits. Currently supported values are 32 or 64 bits.
func (*Device) Available ¶
Available returns true if the device is available. NOTE: this function returns true even for the invalid Apple cl_device_id 0xffffffff.
func (*Device) DoubleFPConfig ¶
DoubleFPConfig describes double precision floating-point capability of the OpenCL device
func (*Device) EndianLittle ¶
EndianLittle returns true if the device supports little endian encoding
func (*Device) ErrorCorrectionSupport ¶
ErrorCorrectionSupport is CL_TRUE if the device implements error correction for all accesses to compute device memory (global and constant) and is CL_FALSE if the device does not implement such error correction.
func (*Device) ExecutionCapabilities ¶
func (d *Device) ExecutionCapabilities() ExecCapability
ExecutionCapabilities describes the execution capabilities of the device. The mandated minimum capability is CL_EXEC_KERNEL.
func (*Device) GlobalMemCacheType ¶
func (d *Device) GlobalMemCacheType() MemCacheType
GlobalMemCacheType ..
func (*Device) GlobalMemCachelineSize ¶
GlobalMemCachelineSize is the size of global memory cache line in bytes.
func (*Device) GlobalMemSize ¶
GlobalMemSize is the size of global device memory in bytes.
func (*Device) HalfFPConfig ¶
HalfFPConfig describes the OPTIONAL half precision floating-point capability of the OpenCL device
func (*Device) Image2DMaxHeight ¶
Image2DMaxHeight returns the max height of 2D image in pixels. The minimum value is 8192 if CL_DEVICE_IMAGE_SUPPORT is CL_TRUE.
func (*Device) Image2DMaxWidth ¶
Image2DMaxWidth returns the max width of 2D image or 1D image not created from a buffer object in pixels. The minimum value is 8192 if CL_DEVICE_IMAGE_SUPPORT is CL_TRUE.
func (*Device) Image3DMaxDepth ¶
Image3DMaxDepth returns the max depth of 3D image in pixels. The minimum value is 2048 if CL_DEVICE_IMAGE_SUPPORT is CL_TRUE.
func (*Device) Image3DMaxHeight ¶
Image3DMaxHeight returns the max height of 3D image in pixels. The minimum value is 2048 if CL_DEVICE_IMAGE_SUPPORT is CL_TRUE.
func (*Device) Image3DMaxWidth ¶
Image3DMaxWidth returns the max width of 3D image in pixels. The minimum value is 2048 if CL_DEVICE_IMAGE_SUPPORT is CL_TRUE.
func (*Device) ImageMaxArraySize ¶
ImageMaxArraySize is the max number of images in a 1D or 2D image array. The minimum value is 2048 if CL_DEVICE_IMAGE_SUPPORT is CL_TRUE.
func (*Device) ImageMaxBufferSize ¶
ImageMaxBufferSize is the max number of pixels for a 1D image created from a buffer object. The minimum value is 65536 if CL_DEVICE_IMAGE_SUPPORT is CL_TRUE.
func (*Device) LinkerAvailable ¶
LinkerAvailable is false if the implementation does not have a linker available and is true if the linker is available. This can be false for the embedded platform profile only. This must be true if device.CompilerAvailable() is true.
func (*Device) LocalMemSize ¶
LocalMemSize returns the size of local memory arena in bytes. The minimum value is 32 KB for devices that are not of type CL_DEVICE_TYPE_CUSTOM.
func (*Device) LocalMemType ¶
func (d *Device) LocalMemType() LocalMemType
LocalMemType returns the type of local memory supported. This can be set to CL_LOCAL implying dedicated local memory storage such as SRAM, or CL_GLOBAL. For custom devices, CL_NONE can also be returned indicating no local memory support.
func (*Device) MaxClockFrequency ¶
MaxClockFrequency is the maximum configured clock frequency of the device in MHz.
func (*Device) MaxComputeUnits ¶
MaxComputeUnits returns the number of parallel compute units on the OpenCL device. A work-group executes on a single compute unit. The minimum value is 1.
func (*Device) MaxConstantArgs ¶
MaxConstantArgs returns the max number of arguments declared with the __constant qualifier in a kernel. The minimum value is 8 for devices that are not of type CL_DEVICE_TYPE_CUSTOM.
func (*Device) MaxConstantBufferSize ¶
MaxConstantBufferSize returns the max size in bytes of a constant buffer allocation. The minimum value is 64 KB for devices that are not of type CL_DEVICE_TYPE_CUSTOM.
func (*Device) MaxMemAllocSize ¶
MaxMemAllocSize returns the max size of memory object allocation in bytes. The minimum value is max (1/4th of CL_DEVICE_GLOBAL_MEM_SIZE, 128*1024*1024) for devices that are not of type CL_DEVICE_TYPE_CUSTOM.
func (*Device) MaxParameterSize ¶
MaxParameterSize returns the max size in bytes of the arguments that can be passed to a kernel. The minimum value is 1024 for devices that are not of type CL_DEVICE_TYPE_CUSTOM. For this minimum value, only a maximum of 128 arguments can be passed to a kernel.
func (*Device) MaxReadImageArgs ¶
MaxReadImageArgs returns the max number of simultaneous image objects that can be read by a kernel. The minimum value is 128 if CL_DEVICE_IMAGE_SUPPORT is CL_TRUE.
func (*Device) MaxSamplers ¶
MaxSamplers returns the maximum number of samplers that can be used in a kernel. The minimum value is 16 if CL_DEVICE_IMAGE_SUPPORT is CL_TRUE. (Also see sampler_t.)
func (*Device) MaxWorkGroupSize ¶
MaxWorkGroupSize returns the maximum number of work-items in a work-group executing a kernel on a single compute unit, using the data parallel execution model. (Refer to clEnqueueNDRangeKernel). The minimum value is 1.
func (*Device) MaxWorkItemDimensions ¶
MaxWorkItemDimensions returns the maximum dimensions that specify the global and local work-item IDs used by the data parallel execution model. (Refer to clEnqueueNDRangeKernel). The minimum value is 3 for devices that are not of type CL_DEVICE_TYPE_CUSTOM.
func (*Device) MaxWorkItemSizes ¶
MaxWorkItemSizes returns the maximum number of work-items that can be specified in each dimension of the work-group to clEnqueueNDRangeKernel.
Returns n size_t entries, where n is the value returned by the query for CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS.
The minimum value is (1, 1, 1) for devices that are not of type CL_DEVICE_TYPE_CUSTOM.
func (*Device) MaxWriteImageArgs ¶
MaxWriteImageArgs returns the max number of simultaneous image objects that can be written to by a kernel. The minimum value is 8 if CL_DEVICE_IMAGE_SUPPORT is CL_TRUE.
func (*Device) MemBaseAddrAlign ¶
MemBaseAddrAlign is the minimum size (in bits) of the largest OpenCL built-in data type supported by the device (long16 in FULL profile, long16 or int16 in EMBEDDED profile) for devices that are not of type CL_DEVICE_TYPE_CUSTOM.
func (*Device) NativeVectorWidthChar ¶
NativeVectorWidthChar ..
func (*Device) NativeVectorWidthDouble ¶
NativeVectorWidthDouble ..
func (*Device) NativeVectorWidthFloat ¶
NativeVectorWidthFloat ..
func (*Device) NativeVectorWidthHalf ¶
NativeVectorWidthHalf ..
func (*Device) NativeVectorWidthInt ¶
NativeVectorWidthInt ..
func (*Device) NativeVectorWidthLong ¶
NativeVectorWidthLong ..
func (*Device) NativeVectorWidthShort ¶
NativeVectorWidthShort ..
func (*Device) OpenCLCVersion ¶
OpenCLCVersion is version of the device's OpenCL compiler implementation
func (*Device) ProfilingTimerResolution ¶
ProfilingTimerResolution describes the resolution of device timer. This is measured in nanoseconds.
func (*Device) Type ¶
func (d *Device) Type() DeviceType
Type returns the specific DeviceType of the device e.g. DeviceTypeGPU
type DeviceType ¶
type DeviceType uint
DeviceType ..
const ( DeviceTypeCPU DeviceType = C.CL_DEVICE_TYPE_CPU DeviceTypeGPU DeviceType = C.CL_DEVICE_TYPE_GPU DeviceTypeAccelerator DeviceType = C.CL_DEVICE_TYPE_ACCELERATOR DeviceTypeDefault DeviceType = C.CL_DEVICE_TYPE_DEFAULT DeviceTypeAll DeviceType = C.CL_DEVICE_TYPE_ALL )
DeviceType variants
func (DeviceType) String ¶
func (dt DeviceType) String() string
type ErrOther ¶
type ErrOther int
ErrOther is an error that covers other-than-expected status code integers.
type ErrUnsupportedArgumentType ¶
type ErrUnsupportedArgumentType struct { Index int Value interface{} }
ErrUnsupportedArgumentType ..
func (ErrUnsupportedArgumentType) Error ¶
func (e ErrUnsupportedArgumentType) Error() string
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event is the cl_event wrapping struct
func NewWaitlist ¶
NewWaitlist turns variadric *cl.Event args into nil (if empty) or []*cl.Event (which is a Waitlist)
func (*Event) GetEventProfilingInfo ¶
func (e *Event) GetEventProfilingInfo(paramName ProfilingInfo) (int64, error)
GetEventProfilingInfo returns the profiliing value for the given ProfilingInfo. This info can be used to tune/benchmark execution.
func (*Event) Release ¶
func (e *Event) Release()
Release decrements the OpenCL atomic reference count for the underlying cl_event.
func (*Event) SetUserEventStatus ¶
SetUserEventStatus sets the execution status of a user event object.
`status` specifies the new execution status to be set and can be CL_COMPLETE or a negative integer value to indicate an error. A negative integer value causes all enqueued commands that wait on this user event to be terminated. clSetUserEventStatus can only be called once to change the execution status of event.
type ExecCapability ¶
type ExecCapability int
ExecCapability ..
const ( ExecCapabilityKernel ExecCapability = C.CL_EXEC_KERNEL // The OpenCL device can execute OpenCL kernels. ExecCapabilityNativeKernel ExecCapability = C.CL_EXEC_NATIVE_KERNEL // The OpenCL device can execute native kernels. )
ExecCapability variants
type FPConfig ¶
type FPConfig int
FPConfig ..
const ( FPConfigDenorm FPConfig = C.CL_FP_DENORM // denorms are supported FPConfigInfNaN FPConfig = C.CL_FP_INF_NAN // INF and NaNs are supported FPConfigRoundToNearest FPConfig = C.CL_FP_ROUND_TO_NEAREST // round to nearest even rounding mode supported FPConfigRoundToZero FPConfig = C.CL_FP_ROUND_TO_ZERO // round to zero rounding mode supported FPConfigRoundToInf FPConfig = C.CL_FP_ROUND_TO_INF // round to positive and negative infinity rounding modes supported FPConfigFMA FPConfig = C.CL_FP_FMA // IEEE754-2008 fused multiply-add is supported FPConfigSoftFloat FPConfig = C.CL_FP_SOFT_FLOAT // Basic floating-point operations (such as addition, subtraction, multiplication) are implemented in software )
FpConfig variants
const FPConfigCorrectlyRoundedDivideSqrt FPConfig = C.CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT
FPConfigCorrectlyRoundedDivideSqrt ..
type ImageDescription ¶
type ImageDescription struct { Type MemObjectType Width, Height, Depth int ArraySize, RowPitch, SlicePitch int NumMipLevels, NumSamples int Buffer *MemObject }
ImageDescription ..
type ImageFormat ¶
type ImageFormat struct { ChannelOrder ChannelOrder ChannelDataType ChannelDataType }
ImageFormat ..
type Kernel ¶
type Kernel struct {
// contains filtered or unexported fields
}
Kernel ..
func (*Kernel) ArgName ¶
ArgName is the argument name in source code of the argument at the given index.
func (*Kernel) PreferredWorkGroupSizeMultiple ¶
PreferredWorkGroupSizeMultiple ..
func (*Kernel) SetArgBuffer ¶
SetArgBuffer ..
func (*Kernel) SetArgNumber ¶
SetArgNumber ..
func (*Kernel) SetArgUnsafe ¶
SetArgUnsafe ..
type LocalMemType ¶
type LocalMemType int
LocalMemType ..
const ( LocalMemTypeNone LocalMemType = C.CL_NONE LocalMemTypeGlobal LocalMemType = C.CL_GLOBAL LocalMemTypeLocal LocalMemType = C.CL_LOCAL )
LocalMemType variants
type MapFlag ¶
type MapFlag int
MapFlag ..
const ( // This flag specifies that the region being mapped in the memory object is being mapped for reading. MapFlagRead MapFlag = C.CL_MAP_READ MapFlagWrite MapFlag = C.CL_MAP_WRITE )
MapFlag variants
type MappedMemObject ¶
type MappedMemObject struct {
// contains filtered or unexported fields
}
MappedMemObject ..
func (*MappedMemObject) ByteSlice ¶
func (mb *MappedMemObject) ByteSlice() []byte
ByteSlice of the MappedMemObject
func (*MappedMemObject) Ptr ¶
func (mb *MappedMemObject) Ptr() unsafe.Pointer
Ptr of the MappedMemObject.
func (*MappedMemObject) RowPitch ¶
func (mb *MappedMemObject) RowPitch() int
RowPitch of the MappedMemObject.
func (*MappedMemObject) SlicePitch ¶
func (mb *MappedMemObject) SlicePitch() int
SlicePitch of the MappedMemObject.
type MemCacheType ¶
type MemCacheType int
MemCacheType ..
const ( MemCacheTypeNone MemCacheType = C.CL_NONE MemCacheTypeReadOnlyCache MemCacheType = C.CL_READ_ONLY_CACHE MemCacheTypeReadWriteCache MemCacheType = C.CL_READ_WRITE_CACHE )
MemCacheType variants
type MemFlag ¶
type MemFlag int
MemFlag is the type for changing mutability and allocation of a MemObject upon creation.
const ( MemReadWrite MemFlag = C.CL_MEM_READ_WRITE MemWriteOnly MemFlag = C.CL_MEM_WRITE_ONLY MemReadOnly MemFlag = C.CL_MEM_READ_ONLY MemUseHostPtr MemFlag = C.CL_MEM_USE_HOST_PTR MemAllocHostPtr MemFlag = C.CL_MEM_ALLOC_HOST_PTR MemCopyHostPtr MemFlag = C.CL_MEM_COPY_HOST_PTR )
MemFlag variants. Note there are invalid combos.
type MemObjectType ¶
type MemObjectType int
MemObjectType ..
const ( MemObjectTypeBuffer MemObjectType = C.CL_MEM_OBJECT_BUFFER MemObjectTypeImage2D MemObjectType = C.CL_MEM_OBJECT_IMAGE2D MemObjectTypeImage3D MemObjectType = C.CL_MEM_OBJECT_IMAGE3D )
MemObjectType variants
type Platform ¶
type Platform struct {
// contains filtered or unexported fields
}
Platform is the cl_platform_id wrapping struct
func GetPlatforms ¶
GetPlatforms obtains the list of platforms available.
func (*Platform) Extensions ¶
Extensions is a list of extensions for the platform.
func (*Platform) GetDevices ¶
func (p *Platform) GetDevices(deviceType DeviceType) ([]*Device, error)
GetDevices gets a list of devices for the platform.
type PrimitiveType ¶
type PrimitiveType int
PrimitiveType is a runtime enum for supported Golang number types
const ( Int8 PrimitiveType = iota Uint8 Int16 Uint16 Int32 Uint32 Float32 Int64 Uint64 Float64 Uint )
PrimitiveType variants
func (PrimitiveType) ClSrc ¶
func (t PrimitiveType) ClSrc() string
ClSrc is the OpenCL src code type string for a given PrimitiveType
func (PrimitiveType) String ¶
func (t PrimitiveType) String() string
type ProfilingInfo ¶
type ProfilingInfo int
ProfilingInfo ..
const ( // ProfilingInfoCommandQueued is a 64-bit value that describes the current device time counter in // nanoseconds when the command identified by event is enqueued in // a command-queue by the host. ProfilingInfoCommandQueued ProfilingInfo = C.CL_PROFILING_COMMAND_QUEUED // ProfilingInfoCommandSubmit is a 64-bit value that describes the current device time counter in // nanoseconds when the command identified by event that has been // enqueued is submitted by the host to the device associated with the command-queue. ProfilingInfoCommandSubmit ProfilingInfo = C.CL_PROFILING_COMMAND_SUBMIT // ProfilingInfoCommandStart is a 64-bit value that describes the current device time counter in // nanoseconds when the command identified by event starts execution on the device. ProfilingInfoCommandStart ProfilingInfo = C.CL_PROFILING_COMMAND_START // ProfilingInfoCommandEnd is a 64-bit value that describes the current device time counter in // nanoseconds when the command identified by event has finished // execution on the device. ProfilingInfoCommandEnd ProfilingInfo = C.CL_PROFILING_COMMAND_END )
ProfilingInfo variants
type Program ¶
type Program struct {
// contains filtered or unexported fields
}
Program is the cl_program wrapping struct
func (*Program) BuildProgram ¶
BuildProgram compiles the source code of the program on the given devices.
func (*Program) CreateKernel ¶
CreateKernel returns the *Kernel of the given name.