cl

package
v0.0.0-...-9beaa40 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

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

View Source
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

View Source
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

View Source
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

View Source
var (
	// ErrUnknown is generally an unexpected result from an OpenCL function (e.g. CL_SUCCESS but null pointer)
	ErrUnknown = errors.New("cl: unknown error")
)
View Source
var ErrUnsupported = errors.New("cl: unsupported")

ErrUnsupported is the rror returned when some functionality is not support

Functions

func WaitForEvents

func WaitForEvents(events []*Event) error

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 CreateContext

func CreateContext(devices []*Device) (*Context, error)

CreateContext ..

func (*Context) CreateBuffer

func (ctx *Context) CreateBuffer(flags MemFlag, data []byte) (*MemObject, error)

CreateBuffer ..

func (*Context) CreateBufferFloat32

func (ctx *Context) CreateBufferFloat32(flags MemFlag, data []float32) (*MemObject, error)

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

func (ctx *Context) CreateEmptyBuffer(flags MemFlag, size int) (*MemObject, error)

CreateEmptyBuffer ..

func (*Context) CreateImage

func (ctx *Context) CreateImage(flags MemFlag, imageFormat ImageFormat, imageDesc ImageDescription, data []byte) (*MemObject, error)

CreateImage ..

func (*Context) CreateImageFromImage

func (ctx *Context) CreateImageFromImage(flags MemFlag, img image.Image) (*MemObject, error)

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

func (ctx *Context) CreateProgramWithSource(sources []string) (*Program, error)

CreateProgramWithSource ..

func (*Context) CreateUserEvent

func (ctx *Context) CreateUserEvent() (*Event, error)

CreateUserEvent ..

func (*Context) GetSupportedImageFormats

func (ctx *Context) GetSupportedImageFormats(flags MemFlag, imageType MemObjectType) ([]ImageFormat, error)

GetSupportedImageFormats ..

func (*Context) Release

func (ctx *Context) Release()

Release ..

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

func (d *Device) AddressBits() int

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

func (d *Device) Available() bool

Available returns true if the device is available. NOTE: this function returns true even for the invalid Apple cl_device_id 0xffffffff.

func (*Device) BuiltInKernels

func (d *Device) BuiltInKernels() []string

BuiltInKernels ..

func (*Device) CompilerAvailable

func (d *Device) CompilerAvailable() bool

CompilerAvailable ..

func (*Device) DoubleFPConfig

func (d *Device) DoubleFPConfig() FPConfig

DoubleFPConfig describes double precision floating-point capability of the OpenCL device

func (*Device) DriverVersion

func (d *Device) DriverVersion() string

DriverVersion ..

func (*Device) EndianLittle

func (d *Device) EndianLittle() bool

EndianLittle returns true if the device supports little endian encoding

func (*Device) ErrorCorrectionSupport

func (d *Device) ErrorCorrectionSupport() bool

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) Extensions

func (d *Device) Extensions() []string

Extensions is list of extensions

func (*Device) GlobalMemCacheType

func (d *Device) GlobalMemCacheType() MemCacheType

GlobalMemCacheType ..

func (*Device) GlobalMemCachelineSize

func (d *Device) GlobalMemCachelineSize() int

GlobalMemCachelineSize is the size of global memory cache line in bytes.

func (*Device) GlobalMemSize

func (d *Device) GlobalMemSize() int64

GlobalMemSize is the size of global device memory in bytes.

func (*Device) HalfFPConfig

func (d *Device) HalfFPConfig() FPConfig

HalfFPConfig describes the OPTIONAL half precision floating-point capability of the OpenCL device

func (*Device) HostUnifiedMemory

func (d *Device) HostUnifiedMemory() bool

HostUnifiedMemory ..

func (*Device) Image2DMaxHeight

func (d *Device) Image2DMaxHeight() int

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

func (d *Device) Image2DMaxWidth() int

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

func (d *Device) Image3DMaxDepth() int

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

func (d *Device) Image3DMaxHeight() int

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

func (d *Device) Image3DMaxWidth() int

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

func (d *Device) ImageMaxArraySize() int

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

func (d *Device) ImageMaxBufferSize() int

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) ImageSupport

func (d *Device) ImageSupport() bool

ImageSupport ..

func (*Device) LinkerAvailable

func (d *Device) LinkerAvailable() bool

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

func (d *Device) LocalMemSize() int64

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

func (d *Device) MaxClockFrequency() int

MaxClockFrequency is the maximum configured clock frequency of the device in MHz.

func (*Device) MaxComputeUnits

func (d *Device) MaxComputeUnits() int

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

func (d *Device) MaxConstantArgs() int

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

func (d *Device) MaxConstantBufferSize() int64

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

func (d *Device) MaxMemAllocSize() int64

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

func (d *Device) MaxParameterSize() int

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

func (d *Device) MaxReadImageArgs() int

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

func (d *Device) MaxSamplers() int

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

func (d *Device) MaxWorkGroupSize() int

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

func (d *Device) MaxWorkItemDimensions() int

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

func (d *Device) MaxWorkItemSizes() []int

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

func (d *Device) MaxWriteImageArgs() int

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

func (d *Device) MemBaseAddrAlign() int

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) Name

func (d *Device) Name() string

Name is the name of the device

func (*Device) NativeVectorWidthChar

func (d *Device) NativeVectorWidthChar() int

NativeVectorWidthChar ..

func (*Device) NativeVectorWidthDouble

func (d *Device) NativeVectorWidthDouble() int

NativeVectorWidthDouble ..

func (*Device) NativeVectorWidthFloat

func (d *Device) NativeVectorWidthFloat() int

NativeVectorWidthFloat ..

func (*Device) NativeVectorWidthHalf

func (d *Device) NativeVectorWidthHalf() int

NativeVectorWidthHalf ..

func (*Device) NativeVectorWidthInt

func (d *Device) NativeVectorWidthInt() int

NativeVectorWidthInt ..

func (*Device) NativeVectorWidthLong

func (d *Device) NativeVectorWidthLong() int

NativeVectorWidthLong ..

func (*Device) NativeVectorWidthShort

func (d *Device) NativeVectorWidthShort() int

NativeVectorWidthShort ..

func (*Device) OpenCLCVersion

func (d *Device) OpenCLCVersion() string

OpenCLCVersion is version of the device's OpenCL compiler implementation

func (*Device) ParentDevice

func (d *Device) ParentDevice() *Device

ParentDevice ..

func (*Device) Profile

func (d *Device) Profile() string

Profile ..

func (*Device) ProfilingTimerResolution

func (d *Device) ProfilingTimerResolution() int

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

func (*Device) Vendor

func (d *Device) Vendor() string

Vendor is the vendor of the device e.g. "Intel"

func (*Device) Version

func (d *Device) Version() string

Version is the OpenCL device's version e.g. "OpenCL 1.2"

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.

func (ErrOther) Error

func (e ErrOther) Error() string

Error ..

type ErrUnsupportedArgumentType

type ErrUnsupportedArgumentType struct {
	Index int
	Value interface{}
}

ErrUnsupportedArgumentType ..

func (ErrUnsupportedArgumentType) Error

type Event

type Event struct {
	// contains filtered or unexported fields
}

Event is the cl_event wrapping struct

func NewWaitlist

func NewWaitlist(args ...*Event) []*Event

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

func (e *Event) SetUserEventStatus(status int) error

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

func (ExecCapability) String

func (ec ExecCapability) String() string

String for ExecCapability

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 ..

func (FPConfig) String

func (c FPConfig) String() string

type HostMem

type HostMem interface {
	Ptr() unsafe.Pointer
	Len() int
	NumType() NumTyped
	SizeofT() uintptr
}

HostMem ..

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

func (k *Kernel) ArgName(index int) (string, error)

ArgName is the argument name in source code of the argument at the given index.

func (*Kernel) NumArgs

func (k *Kernel) NumArgs() (int, error)

NumArgs is the number of args for a Kernel

func (*Kernel) PreferredWorkGroupSizeMultiple

func (k *Kernel) PreferredWorkGroupSizeMultiple(device *Device) (int, error)

PreferredWorkGroupSizeMultiple ..

func (*Kernel) Release

func (k *Kernel) Release()

Release ..

func (*Kernel) SetArg

func (k *Kernel) SetArg(index int, arg interface{}) error

SetArg sets the given arg at the given index on the Kernel

func (*Kernel) SetArgBuffer

func (k *Kernel) SetArgBuffer(index int, buffer *MemObject) error

SetArgBuffer ..

func (*Kernel) SetArgLocal

func (k *Kernel) SetArgLocal(index int, size int) error

SetArgLocal ..

func (*Kernel) SetArgNumber

func (k *Kernel) SetArgNumber(index int, arg interface{}) error

SetArgNumber ..

func (*Kernel) SetArgUnsafe

func (k *Kernel) SetArgUnsafe(index, argSize int, arg unsafe.Pointer) error

SetArgUnsafe ..

func (*Kernel) SetArgs

func (k *Kernel) SetArgs(args ...interface{}) error

SetArgs ..

func (*Kernel) WorkGroupSize

func (k *Kernel) WorkGroupSize(device *Device) (int, error)

WorkGroupSize ..

type LocalBuffer

type LocalBuffer int

LocalBuffer ..

type LocalMemType

type LocalMemType int

LocalMemType ..

const (
	LocalMemTypeNone   LocalMemType = C.CL_NONE
	LocalMemTypeGlobal LocalMemType = C.CL_GLOBAL
	LocalMemTypeLocal  LocalMemType = C.CL_LOCAL
)

LocalMemType variants

func (LocalMemType) String

func (t LocalMemType) String() string

String for LocalMemType

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) Size

func (mb *MappedMemObject) Size() int

Size 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

func (MemCacheType) String

func (ct MemCacheType) String() string

String for MemCacheType

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 MemObject

type MemObject struct {
	// contains filtered or unexported fields
}

MemObject ..

func (*MemObject) Release

func (b *MemObject) Release()

Release ..

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 NumTyped

type NumTyped interface {
	SizeofT() uintptr
	ClSrc() string
}

NumTyped is the interface for Buffers and HostMem that store types of numbers.

type Platform

type Platform struct {
	// contains filtered or unexported fields
}

Platform is the cl_platform_id wrapping struct

func GetPlatforms

func GetPlatforms() ([]*Platform, error)

GetPlatforms obtains the list of platforms available.

func (*Platform) Extensions

func (p *Platform) Extensions() []string

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.

func (*Platform) Name

func (p *Platform) Name() string

Name is the name of the platform e.g. "Apple"

func (*Platform) Profile

func (p *Platform) Profile() string

Profile ..

func (*Platform) Vendor

func (p *Platform) Vendor() string

Vendor is the name of the vendor of the platform e.g. "Apple"

func (*Platform) Version

func (p *Platform) Version() string

Version is the OpenCL version of 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) SizeofT

func (t PrimitiveType) SizeofT() uintptr

SizeofT ..

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) BuildLogs

func (p Program) BuildLogs() ([]string, error)

BuildLogs ..

func (*Program) BuildProgram

func (p *Program) BuildProgram(devices []*Device, options string) error

BuildProgram compiles the source code of the program on the given devices.

func (*Program) CreateKernel

func (p *Program) CreateKernel(name string) (*Kernel, error)

CreateKernel returns the *Kernel of the given name.

func (*Program) Release

func (p *Program) Release()

Release decrements the OpenCL atomic reference count of the underlying program pointer.

type ProgramBuildError

type ProgramBuildError string

ProgramBuildError ..

func (ProgramBuildError) Error

func (e ProgramBuildError) Error() string

Error ..

type SliceF32

type SliceF32 []float32

SliceF32 ..

func (SliceF32) Len

func (h SliceF32) Len() int

Len ..

func (SliceF32) NumType

func (h SliceF32) NumType() NumTyped

NumType ..

func (SliceF32) Ptr

func (h SliceF32) Ptr() unsafe.Pointer

Ptr ..

func (SliceF32) SizeofT

func (h SliceF32) SizeofT() uintptr

SizeofT ..

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL