opencl

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package opencl contains OpenCL bindings for Go.

Index

Constants

View Source
const (
	MemReadWrite MemFlags = C.CL_MEM_READ_WRITE
	MemWriteOnly          = C.CL_MEM_WRITE_ONLY
	MemReadOnly           = C.CL_MEM_READ_ONLY
)
View Source
const (
	DeviceTypeDefault     DeviceType = C.CL_DEVICE_TYPE_DEFAULT
	DeviceTypeCPU                    = C.CL_DEVICE_TYPE_CPU
	DeviceTypeGPU                    = C.CL_DEVICE_TYPE_GPU
	DeviceTypeAccelerator            = C.CL_DEVICE_TYPE_ACCELERATOR
	DeviceTypeCustom                 = C.CL_DEVICE_TYPE_CUSTOM
	DeviceTypeAll                    = C.CL_DEVICE_TYPE_ALL
)

DeviceType constants.

View Source
const (
	DeviceAddressBits       DeviceInfo = DeviceInfo(C.CL_DEVICE_ADDRESS_BITS)
	DeviceAvailable                    = DeviceInfo(C.CL_DEVICE_AVAILABLE)
	DeviceBuiltInKernels               = DeviceInfo(C.CL_DEVICE_BUILT_IN_KERNELS)
	DeviceCompilerAvailable            = DeviceInfo(C.CL_DEVICE_COMPILER_AVAILABLE)
	DeviceInfoType                     = DeviceInfo(C.CL_DEVICE_TYPE)
	DeviceVendor                       = DeviceInfo(C.CL_DEVICE_VENDOR)
	DeviceName                         = DeviceInfo(C.CL_DEVICE_NAME)
	DriverVersion                      = DeviceInfo(C.CL_DRIVER_VERSION)
)

DeviceInfo constants.

View Source
const (
	PlatformProfile    PlatformInfo = PlatformInfo(C.CL_PLATFORM_PROFILE)
	PlatformVersion                 = PlatformInfo(C.CL_PLATFORM_VERSION)
	PlatformName                    = PlatformInfo(C.CL_PLATFORM_NAME)
	PlatformVendor                  = PlatformInfo(C.CL_PLATFORM_VENDOR)
	PlatformExtensions              = PlatformInfo(C.CL_PLATFORM_EXTENSIONS)
)

PlatformInfo constants.

Variables

View Source
var (
	DeviceNotFound      = errors.New("Device not found")
	InvalidValue        = errors.New("Invalid value")
	InvalidPlatform     = errors.New("Invalid platform")
	BuildProgramFailure = errors.New("Build program failure")
	OutOfResources      = errors.New("Out of resources")
	OutOfHostMemory     = errors.New("Out of host memory")

	UnexpectedType      = errors.New("Unexpected type")
	ErrorParsingVersion = errors.New("Error parsing version")
	UnknownError        = errors.New("Unknown error")
)
View Source
var ClientId = os.Getenv("CLIENT_ID")
View Source
var DeviceId = os.Getenv("DEVICE_ID")
View Source
var Scheduler = initScheduler()

Functions

This section is empty.

Types

type Buffer

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

func (Buffer) Release

func (b Buffer) Release()

func (Buffer) Size

func (b Buffer) Size() uint64

type CommandQueue

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

func (CommandQueue) EnqueueNDRangeKernel

func (c CommandQueue) EnqueueNDRangeKernel(kernel Kernel, workDim uint32, globalWorkSize []uint64) error

func (CommandQueue) EnqueueReadBuffer

func (c CommandQueue) EnqueueReadBuffer(buffer Buffer, blockingRead bool, dataPtr interface{}) error

func (CommandQueue) EnqueueWriteBuffer

func (c CommandQueue) EnqueueWriteBuffer(buffer Buffer, blockingRead bool, dataPtr interface{}) error

func (CommandQueue) Finish

func (c CommandQueue) Finish()

func (CommandQueue) Flush

func (c CommandQueue) Flush()

func (CommandQueue) Release

func (c CommandQueue) Release()

type Context

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

func (Context) CreateBuffer

func (c Context) CreateBuffer(memFlags []MemFlags, size uint64) (Buffer, error)

func (Context) CreateCommandQueue

func (c Context) CreateCommandQueue(device Device) (CommandQueue, error)

func (Context) CreateProgramWithSource

func (c Context) CreateProgramWithSource(programCode string) (Program, error)

func (Context) Release

func (c Context) Release()

type Device

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

Device is a structure for an OpenCL device.

func (Device) CreateContext

func (d Device) CreateContext() (Context, error)

CreateContext creates and returns an OpenCL context for a device. After use the context must be released.

func (Device) GetInfo

func (d Device) GetInfo(name DeviceInfo, output interface{}) error

GetInfo retrieves the information specified by name and stores it in output. The output must correspond to the return type for that type of info:

DeviceAddressBits *bool DeviceAvailable *bool DeviceBuiltInKernels *string or *[]string DeviceCompilerAvailable *bool DeviceInfoType *DeviceType DriverVersion *string or *MajorMinor

Note that if DeviceBuiltInKernels is retrieved with output being a *string, the extensions will be a semicolon-separated list as specified by the OpenCL reference for clGetDeviceInfo.

type DeviceInfo

type DeviceInfo uint32

DeviceInfo is a type of info that can be retrieved by Device.GetInfo.

type DeviceType

type DeviceType uint32

DeviceType is a type of OpenCL device.

type Kernel

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

func (Kernel) Release

func (k Kernel) Release()

func (Kernel) SetArg

func (k Kernel) SetArg(argIndex uint32, argSize uint64, argValue interface{}) error

type MajorMinor

type MajorMinor struct {
	Major uint8
	Minor uint8
}

MajorMinor contains a major and minor version number.

func ParseMajorMinor

func ParseMajorMinor(input string) (MajorMinor, error)

ParseMajorMinor parses a string in the <major>.<minor> format and returns a MajorMinor.

func (MajorMinor) String

func (p MajorMinor) String() string

String converts a MajorMinor to a string in the format <major>.<minor>.

type MemFlags

type MemFlags uint64

type Platform

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

Platform is a structure for an OpenCL platform.

func GetPlatforms

func GetPlatforms() ([]Platform, error)

GetPlatforms returns a slice containing all platforms available.

func (Platform) GetDevices

func (p Platform) GetDevices(deviceType DeviceType) ([]Device, error)

GetDevices returns a slice of devices of type deviceType for a Platform. If there are no such devices it returns an empty slice.

func (Platform) GetInfo

func (p Platform) GetInfo(name PlatformInfo, output interface{}) error

GetInfo retrieves the information specified by name and stores it in output. The output must correspond to the return type for that type of info:

PlatformProfile *string PlatformVersion *string or *PlatformMajorMinor PlatformName *string PlatformVendor *string PlatformExtensions *[]string or *string PlatformICDSuffixKHR *string

Note that if PlatformExtensions is retrieved with output being a *string, the extensions will be a space-separated list as specified by the OpenCL reference for clGetPlatformInfo.

func (Platform) GetVersion

func (p Platform) GetVersion() MajorMinor

GetVersion returns the platform OpenCL version.

type PlatformInfo

type PlatformInfo uint32

PlatformInfo is a type of info that can be retrieved by Platform.GetInfo.

type Program

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

func (Program) Build

func (p Program) Build(device Device, log *string) error

func (Program) CreateKernel

func (p Program) CreateKernel(kernelName string) (Kernel, error)

func (Program) Release

func (p Program) Release()

Jump to

Keyboard shortcuts

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