scl

package
v0.0.0-...-f96ffc0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2015 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package scl is a set of bindings to make it easy to execute OpenCL kernels. It is inspired by the SimpleOpenCL C library by Oscar Amoros.

References:

http://github.com/go-gl/cl
http://code.google.com/p/simple-opencl/
http://www.khronos.org/opencl/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(h *Hardware, s *Software, workSizeX, workSizeY int, format string, args ...interface{}) error

The Run function launches a kernel with the given argument list. The format string has a printf style list describing the type of each argument:

%r	read only buffer: size in bytes + slice of values
%w	write only buffer: size in bytes + slice of values
%R	read and write buffer: size in bytes + slice of values
%a	pass by value argument: size in bytes + pointer to value
%b	buffer object: pointer to a scl.Buffer only
%N	null argument for local memory: size in bytes only

Types

type Buffer

type Buffer struct {
	Buf  cl.Mem
	Ptr  unsafe.Pointer
	Size uint64
}

Buffer type encapsulates a cl_mem structure to pass data between host and device

func NewBuffer

func NewBuffer(h *Hardware, mode cl.MemFlags, size int, data interface{}) *Buffer

NewBuffer allocates a new buffer with given mode and size in bytes. data may be nil in the case where we do not need to access the buffer from the host.

func (*Buffer) Clear

func (b *Buffer) Clear(h *Hardware)

Clear method clears contents of buffer to zero

func (*Buffer) Read

func (b *Buffer) Read(h *Hardware)

Read method reads memory back from device to host

func (*Buffer) Release

func (b *Buffer) Release()

Release method frees the buffer memory

func (*Buffer) String

func (b *Buffer) String() string

String method gives a dump of the contents of the buffer

func (*Buffer) Write

func (b *Buffer) Write(h *Hardware)

Write method writes host data to the device

type Device

type Device struct {
	Platform cl.PlatformID
	DeviceId cl.DeviceId
	Units    int
	Memory   uint64
	Type     cl.DeviceType
	Name     string
}

Device has information about the OpenCL platform and device.

func (*Device) String

func (d *Device) String() string

String formats a human readable hardware description of the device.

type DeviceList

type DeviceList []*Device

DeviceList is a list of devices

func Devices

func Devices() DeviceList

Devices function returns a list with all available devices.

func (DeviceList) Select

func (devs DeviceList) Select(devType cl.DeviceType) (h *Hardware)

Select method returns the "best" hardware of given type from list of devices.

type Hardware

type Hardware struct {
	*Device
	Context cl.Context
	Queue   cl.CommandQueue
}

Hardware is a struct with an OpenCL device and associated context and queue.

func (*Hardware) Release

func (h *Hardware) Release()

Release method frees any resources tied to the hardware.

type Software

type Software struct {
	Program    cl.Program
	Kernel     cl.Kernel
	KernelName string
}

Software is a struct encapulating program and kernel data.

func Compile

func Compile(h *Hardware, source, name string, opts string) (*Software, error)

Compile function compiles a kernel from source string and creates a new software object.

func CompileFile

func CompileFile(h *Hardware, source, name, opts string) (*Software, error)

CompileFile function compiles a kernel from source file and creates a new software object.

func (*Software) EnqueueKernel

func (s *Software) EnqueueKernel(h *Hardware, globalSize, localSize []uint64)

Enqueue kernel method runs an NDRange kernel

func (*Software) Release

func (s *Software) Release()

Release method frees any resources tied to the software object.

func (*Software) SetArg

func (s *Software) SetArg(argc uint32, size uint64, ptr unsafe.Pointer)

SetArg method sets an argument to the kernel

func (*Software) SetArgBuffer

func (s *Software) SetArgBuffer(argc uint32, b *Buffer)

Jump to

Keyboard shortcuts

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