opencl

package module
v0.0.0-...-aa773b0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2017 License: MIT Imports: 5 Imported by: 2

README

go-opencl

go-opencl is a wrapper around the C OpenCL 1.2 API for Go. It aims to be close to the C API while adding Go features (object orientation, []string instead of space delimited extension list, etc.).

It is mainly developed and tested on Linux and with Intel and Nvidia GPUs. It should work with AMD GPUs and, at least in theory, it should work on Windows and macOS.

Features

  • querying platforms
    • enumerate platforms
    • query info
  • querying devices
    • enumerate devices of a platform
    • querying info
  • subdevices (not planned for now)
  • context
    • creating and releasing contexts
    • querying info
  • command queues
    • creating and releasing command queues
    • querying info
  • buffers
    • [*] creating and releasing buffers
    • writing buffers (blocking only for now)
    • reading buffers (blocking only for now)
    • querying info
  • program objects
    • creating and releasing program objects
    • building program executables
    • separate compiling and linking (not planned for now)
    • unloading the compiler
    • querying program (build) info
  • kernel objects
    • creating and releasing kernels
    • setting arguments
    • querying kernel, work group and argument info
    • executing kernels
  • event objects
    • creating and releasing user events (not planned for now)
    • query event info
    • flush and finish
    • wait for events
    • event callbacks (not planned for now)
    • markers and barriers (not planned for now)
    • profiling info (not planned for now)
  • images (not planned for now)
    • write detailed todo for images
  • Direct3D sharing (not planned for now)
  • OpenGL sharing (not planned for now)
  • DX9 Media Surface sharing (not planned for now)
  • Direct3D 11 sharing (not planned for now)

Documentation

There isn't too much documentation in this project, however the API mimics the C API (with some object orientation thrown in), so by taking a look at the official OpenCL 1.2 documentation it should be easy enough to understand. Take a look at the included go-opencl-info utility to see how to use this API.

Documentation

Overview

Code generated go generate DO NOT EDIT.

Code generated go generate DO NOT EDIT.

Index

Constants

View Source
const (
	DeviceTypeCPU         = DeviceType(C.CL_DEVICE_TYPE_CPU)
	DeviceTypeGPU         = DeviceType(C.CL_DEVICE_TYPE_GPU)
	DeviceTypeAccelerator = DeviceType(C.CL_DEVICE_TYPE_ACCELERATOR)
	DeviceTypeCustom      = DeviceType(C.CL_DEVICE_TYPE_CUSTOM)
	DeviceTypeDefault     = DeviceType(C.CL_DEVICE_TYPE_DEFAULT)
	DeviceTypeAll         = DeviceType(C.CL_DEVICE_TYPE_ALL)
)
View Source
const (
	MemReadWrite     = MemoryFlags(C.CL_MEM_READ_WRITE)
	MemWriteOnly     = MemoryFlags(C.CL_MEM_WRITE_ONLY)
	MemReadOnly      = MemoryFlags(C.CL_MEM_READ_ONLY)
	MemUseHostPtr    = MemoryFlags(C.CL_MEM_USE_HOST_PTR)
	MemAllocHostPtr  = MemoryFlags(C.CL_MEM_ALLOC_HOST_PTR)
	MemCopyHostPtr   = MemoryFlags(C.CL_MEM_COPY_HOST_PTR)
	MemHostWriteOnly = MemoryFlags(C.CL_MEM_HOST_WRITE_ONLY)
	MemHostReadOnly  = MemoryFlags(C.CL_MEM_READ_ONLY)
	MemHostNoAccess  = MemoryFlags(C.CL_MEM_HOST_NO_ACCESS)
)
View Source
const (
	CacheNone = MemCacheType(iota)
	CacheReadOnly
	CacheReadWrite
)
View Source
const (
	LocalMemNone = LocalMemType(iota)
	LocalMemLocal
	LocalMemGlobal
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandQueue

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

func (CommandQueue) EnqueueNDRangeKernel

func (q CommandQueue) EnqueueNDRangeKernel(kernel Kernel, globalWorkOffset, globalWorkSize, localWorkSize []uintptr, waitList []Event) (*Event, error)

func (CommandQueue) EnqueueReadBuffer

func (q CommandQueue) EnqueueReadBuffer(memory Memory, offset uintptr, buffer []byte, waitList []Event) error

func (CommandQueue) EnqueueWriteBuffer

func (q CommandQueue) EnqueueWriteBuffer(memory Memory, offset uintptr, buffer []byte, waitList []Event) error

func (CommandQueue) Release

func (q CommandQueue) Release() error

type CommandQueueProperties

type CommandQueueProperties struct {
	OutOfOrderExec bool
	Profiling      bool
}

func (CommandQueueProperties) String

func (p CommandQueueProperties) String() string

type Context

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

func CreateContext

func CreateContext(properties *ContextProperties, devices []*Device, notify func(string, unsafe.Pointer, uintptr, interface{}), userdata interface{}) (*Context, error)

func (Context) CreateBuffer

func (c Context) CreateBuffer(flags MemoryFlags, size uintptr, hostPtr unsafe.Pointer) (*Memory, error)

func (Context) CreateCommandQueue

func (c Context) CreateCommandQueue(device Device, properties *CommandQueueProperties) (*CommandQueue, error)

func (Context) CreateProgramWithSource

func (c Context) CreateProgramWithSource(source []string) (*Program, error)

func (Context) Devices

func (c Context) Devices() []*Device

func (Context) Release

func (c Context) Release() error

type ContextProperties

type ContextProperties struct {
}

type Device

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

func (Device) Available

func (d Device) Available() (bool, error)

func (Device) BuiltInKernels

func (d Device) BuiltInKernels() ([]string, error)

func (Device) CompilerAvailable

func (d Device) CompilerAvailable() (bool, error)

func (Device) DoubleFPConfig

func (d Device) DoubleFPConfig() (FPConfig, error)

func (Device) DriverVersion

func (d Device) DriverVersion() (string, error)

func (Device) EndianLittle

func (d Device) EndianLittle() (bool, error)

func (Device) ErrorCorrectionSupport

func (d Device) ErrorCorrectionSupport() (bool, error)

func (Device) GlobalMemCacheSize

func (d Device) GlobalMemCacheSize() (uint64, error)

func (Device) GlobalMemCacheType

func (d Device) GlobalMemCacheType() (MemCacheType, error)

func (Device) GlobalMemCachelineSize

func (d Device) GlobalMemCachelineSize() (uint, error)

func (Device) GlobalMemSize

func (d Device) GlobalMemSize() (uint64, error)

func (Device) HostUnifiedMemory

func (d Device) HostUnifiedMemory() (bool, error)

func (Device) Image2DMaxHeight

func (d Device) Image2DMaxHeight() (uintptr, error)

func (Device) Image2DMaxWidth

func (d Device) Image2DMaxWidth() (uintptr, error)

func (Device) Image3DMaxDepth

func (d Device) Image3DMaxDepth() (uintptr, error)

func (Device) Image3DMaxHeight

func (d Device) Image3DMaxHeight() (uintptr, error)

func (Device) Image3DMaxWidth

func (d Device) Image3DMaxWidth() (uintptr, error)

func (Device) ImageMaxArraySize

func (d Device) ImageMaxArraySize() (uintptr, error)

func (Device) ImageMaxBufferSize

func (d Device) ImageMaxBufferSize() (uintptr, error)

func (Device) ImageSupport

func (d Device) ImageSupport() (bool, error)

func (Device) LinkerAvailable

func (d Device) LinkerAvailable() (bool, error)

func (Device) LocalMemSize

func (d Device) LocalMemSize() (uint64, error)

func (Device) LocalMemType

func (d Device) LocalMemType() (LocalMemType, error)

func (Device) MaxClockFrequency

func (d Device) MaxClockFrequency() (uint, error)

func (Device) MaxComputeUnits

func (d Device) MaxComputeUnits() (uint, error)

func (Device) MaxConstantArgs

func (d Device) MaxConstantArgs() (uint, error)

func (Device) MaxConstantBufferSize

func (d Device) MaxConstantBufferSize() (uint64, error)

func (Device) MaxMemAllocSize

func (d Device) MaxMemAllocSize() (uint64, error)

func (Device) MaxParameterSize

func (d Device) MaxParameterSize() (uintptr, error)

func (Device) MaxReadImageArgs

func (d Device) MaxReadImageArgs() (uint, error)

func (Device) MaxSamplers

func (d Device) MaxSamplers() (uint, error)

func (Device) MaxWorkGroupSize

func (d Device) MaxWorkGroupSize() (uintptr, error)

func (Device) MaxWorkItemDimensions

func (d Device) MaxWorkItemDimensions() (uint, error)

func (Device) MaxWorkItemSizes

func (d Device) MaxWorkItemSizes() ([]uintptr, error)

func (Device) MaxWriteImageArgs

func (d Device) MaxWriteImageArgs() (uint, error)

func (Device) MemBaseAddrAlign

func (d Device) MemBaseAddrAlign() (uint, error)

func (Device) Name

func (d Device) Name() (string, error)

func (Device) NativeVectorWidthChar

func (d Device) NativeVectorWidthChar() (uint, error)

func (Device) NativeVectorWidthDouble

func (d Device) NativeVectorWidthDouble() (uint, error)

func (Device) NativeVectorWidthFloat

func (d Device) NativeVectorWidthFloat() (uint, error)

func (Device) NativeVectorWidthHalf

func (d Device) NativeVectorWidthHalf() (uint, error)

func (Device) NativeVectorWidthInt

func (d Device) NativeVectorWidthInt() (uint, error)

func (Device) NativeVectorWidthLong

func (d Device) NativeVectorWidthLong() (uint, error)

func (Device) NativeVectorWidthShort

func (d Device) NativeVectorWidthShort() (uint, error)

func (Device) PreferredVectorWidthChar

func (d Device) PreferredVectorWidthChar() (uint, error)

func (Device) PreferredVectorWidthDouble

func (d Device) PreferredVectorWidthDouble() (uint, error)

func (Device) PreferredVectorWidthFloat

func (d Device) PreferredVectorWidthFloat() (uint, error)

func (Device) PreferredVectorWidthHalf

func (d Device) PreferredVectorWidthHalf() (uint, error)

func (Device) PreferredVectorWidthInt

func (d Device) PreferredVectorWidthInt() (uint, error)

func (Device) PreferredVectorWidthLong

func (d Device) PreferredVectorWidthLong() (uint, error)

func (Device) PreferredVectorWidthShort

func (d Device) PreferredVectorWidthShort() (uint, error)

func (Device) Profile

func (d Device) Profile() (string, error)

func (Device) ProfilingTimerResolution

func (d Device) ProfilingTimerResolution() (uintptr, error)

func (Device) QueueProperties

func (d Device) QueueProperties() (CommandQueueProperties, error)

func (Device) SingleFPConfig

func (d Device) SingleFPConfig() (FPConfig, error)

func (Device) Type

func (d Device) Type() (DeviceType, error)

func (Device) Vendor

func (d Device) Vendor() (string, error)

func (Device) VendorID

func (d Device) VendorID() (uint, error)

func (Device) Version

func (d Device) Version() (string, error)

type DeviceType

type DeviceType C.cl_device_type

func (DeviceType) String

func (t DeviceType) String() string

type Event

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

func (Event) Release

func (e Event) Release() error

type FPConfig

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

func (FPConfig) CorrectlyRoundedDivideSqrt

func (c FPConfig) CorrectlyRoundedDivideSqrt() bool

func (FPConfig) Denorm

func (c FPConfig) Denorm() bool

func (FPConfig) FMA

func (c FPConfig) FMA() bool

func (FPConfig) InfNaN

func (c FPConfig) InfNaN() bool

func (FPConfig) RoundToInf

func (c FPConfig) RoundToInf() bool

func (FPConfig) RoundToNearest

func (c FPConfig) RoundToNearest() bool

func (FPConfig) RoundToZero

func (c FPConfig) RoundToZero() bool

func (FPConfig) SoftFloat

func (c FPConfig) SoftFloat() bool

func (FPConfig) String

func (c FPConfig) String() string

type Kernel

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

func (Kernel) Release

func (k Kernel) Release() error

func (Kernel) SetArg

func (k Kernel) SetArg(index uint, size uintptr, value unsafe.Pointer) error

func (Kernel) SetArgBuffer

func (k Kernel) SetArgBuffer(index uint, buffer Memory) error

type LocalMemType

type LocalMemType int

func (LocalMemType) Name

func (t LocalMemType) Name() string

func (LocalMemType) String

func (t LocalMemType) String() string

type MemCacheType

type MemCacheType int

func (MemCacheType) Name

func (t MemCacheType) Name() string

func (MemCacheType) String

func (t MemCacheType) String() string

type Memory

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

func (Memory) Release

func (m Memory) Release() error

type MemoryFlags

type MemoryFlags int

type Platform

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

func GetPlatforms

func GetPlatforms() ([]Platform, error)

func (Platform) Devices

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

func (Platform) Extension

func (p Platform) Extension() ([]string, error)

func (Platform) Name

func (p Platform) Name() (string, error)

func (Platform) Profile

func (p Platform) Profile() (string, error)

func (Platform) Vendor

func (p Platform) Vendor() (string, error)

func (Platform) Version

func (p Platform) Version() (string, error)

type Program

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

func (Program) Build

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

func (Program) BuildLog

func (p Program) BuildLog(device Device) (string, error)

func (Program) CreateKernel

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

func (Program) Release

func (p Program) Release() error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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