gocudart

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

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

Go to latest
Published: Jul 7, 2017 License: MIT Imports: 3 Imported by: 0

README

Go CUDA Runtime API

Easy access to CUDA devices. You need the CUDA toolkit.

This is super unstable. This code is so alpha it went back to omega.

You'll probably need to configure CGO paths.

Take a look at examples/goside, while examples/goandc is meh-code.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CudaErrorString

func CudaErrorString(res C.CUresult) string

func GetDevicesCount

func GetDevicesCount() int

func GetNVRTCVersion

func GetNVRTCVersion() (major, minor int)

func GetVersion

func GetVersion() int

func Init

func Init()

func NvrtcErrorString

func NvrtcErrorString(res C.nvrtcResult) string

func StartProfiler

func StartProfiler()

func StopProfiler

func StopProfiler()

Types

type Buffer

type Buffer struct {
	Id C.CUdeviceptr
	// contains filtered or unexported fields
}

func AllocManaged

func AllocManaged(size int) (*Buffer, unsafe.Pointer)

Allocate raw memory

func AllocManagedFloat32

func AllocManagedFloat32(size int) (*Buffer, []float32)

Allocates an array of float32 using unified memory

func AllocManagedFloat64

func AllocManagedFloat64(size int) (*Buffer, []float64)

func AllocManagedInt32

func AllocManagedInt32(size int) (*Buffer, []int32)

func NewBuffer

func NewBuffer(size int) *Buffer

func (*Buffer) FromDevice

func (buf *Buffer) FromDevice(dest unsafe.Pointer)

func (*Buffer) FromDeviceN

func (buf *Buffer) FromDeviceN(dest unsafe.Pointer, size int)

func (*Buffer) FromDoubleC

func (buf *Buffer) FromDoubleC(v C.double)

func (*Buffer) FromFloat32

func (buf *Buffer) FromFloat32(v float32)

func (*Buffer) FromFloat64

func (buf *Buffer) FromFloat64(v float64)

func (*Buffer) FromFloatC

func (buf *Buffer) FromFloatC(v C.float)

func (*Buffer) FromHost

func (buf *Buffer) FromHost(source unsafe.Pointer)

func (*Buffer) FromHostN

func (buf *Buffer) FromHostN(source unsafe.Pointer, size int)

func (*Buffer) FromInt32

func (buf *Buffer) FromInt32(v int32)

func (*Buffer) FromInt64

func (buf *Buffer) FromInt64(v int64)

func (*Buffer) FromIntC

func (buf *Buffer) FromIntC(v C.int)

Convenience functions to read/copy single variables

func (*Buffer) MemSet16

func (buf *Buffer) MemSet16(v uint16, num int)

func (*Buffer) MemSet32

func (buf *Buffer) MemSet32(v uint32, num int)

func (*Buffer) MemSet8

func (buf *Buffer) MemSet8(v uint8, num int)

func (*Buffer) ToFloat32

func (buf *Buffer) ToFloat32() float32

func (*Buffer) ToFloat64

func (buf *Buffer) ToFloat64() float64

func (*Buffer) ToInt32

func (buf *Buffer) ToInt32() int32

func (*Buffer) ToInt64

func (buf *Buffer) ToInt64() int64

type Context

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

func Create

func Create(dev *Device, flags uint) *Context

WARNING: The created context is bound to a CPU thread, therefore use runtime.LockOSThread()

func PopCurrent

func PopCurrent() *Context

func (*Context) Destroy

func (ctx *Context) Destroy()

func (*Context) GetApiVersion

func (ctx *Context) GetApiVersion() uint

func (*Context) PushCurrent

func (ctx *Context) PushCurrent()

func (*Context) Synchronize

func (ctx *Context) Synchronize()

type Device

type Device struct {
	Name     string
	TotalMem uint
	// contains filtered or unexported fields
}

func GetDevice

func GetDevice(ordinal int) *Device

func GetDevices

func GetDevices() []*Device

func (*Device) GetAttribute

func (dev *Device) GetAttribute(attrib C.CUdevice_attribute) int

func (*Device) GetMaxBlockDim

func (dev *Device) GetMaxBlockDim() (x, y, z int)

func (*Device) GetMaxGridDim

func (dev *Device) GetMaxGridDim() (x, y, z int)

type Function

type Function struct {
	Id C.CUfunction
}

func (*Function) Launch1D

func (fun *Function) Launch1D(gx, bx, shmem int, buffs ...*Buffer)

Passing scalars is not supported yet: create a buffer and put a single element in it

type Module

type Module struct {
	Id C.CUmodule
}

func CreateModule

func CreateModule() *Module

func (*Module) GetFunction

func (mod *Module) GetFunction(name string) *Function

func (*Module) LoadData

func (mod *Module) LoadData(prog *Program)

type Program

type Program struct {

	//Source  Source
	//Headers []Source
	PTX []byte
	// contains filtered or unexported fields
}

func CreateProgram

func CreateProgram(src Source, headers ...Source) *Program

func (*Program) Compile

func (prog *Program) Compile(opts ...string)

func (*Program) Destroy

func (prog *Program) Destroy()

func (*Program) GetLog

func (prog *Program) GetLog() string

type Source

type Source struct {
	Source string
	Name   string
}

type Stream

type Stream struct {
	Id C.CUstream
}

func NewStream

func NewStream(flags uint) *Stream

func (*Stream) Destroy

func (str *Stream) Destroy()

func (*Stream) Query

func (str *Stream) Query() bool

func (*Stream) Symchronize

func (str *Stream) Symchronize()

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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