Back to godoc.org

Package cuda

v0.9.14
Latest Go to latest

The highest tagged major version is .

Published: Sep 10, 2020 | License: Apache-2.0 | Module: gorgonia.org/gorgonia

Index

type Arena

type Arena interface {
	// Get returns a NoOpError when it cannot get a memory. Please allocate
	Get(size int64) (tensor.Memory, error)

	// Puts the memory back into arena
	Put(mem tensor.Memory, size int64)

	// ResetAllocator resets the allocator statisttics, but doesn't actually deallocate  real memory
	ResetAllocator()
}

Arena is a representation of a memory arena which is managed.

type Engine

type Engine struct {
	tensor.Engine
	sync.Mutex
	// contains filtered or unexported fields
}

Engine is a CUDA engine

func (*Engine) Accessible

func (e *Engine) Accessible(mem tensor.Memory) (tensor.Memory, error)

func (*Engine) Add

func (e *Engine) Add(a tensor.Tensor, b tensor.Tensor, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

Add implements tensor.Adder. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) AddScalar

func (e *Engine) AddScalar(a tensor.Tensor, b interface{}, leftTensor bool, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

AddScalar implements tensor.Adder. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) Alloc

func (e *Engine) Alloc(size int64) (tensor.Memory, error)

Alloc allocates a chunk of certain size from engine memory

func (*Engine) AllocAccessible

func (e *Engine) AllocAccessible() bool

AllocAccessible returns true because the engine return Go-accessible memory pointers

func (*Engine) AllocFlags

func (e *Engine) AllocFlags() (tensor.MemoryFlag, tensor.DataOrder)

AllocFlags returns allocation flags

func (*Engine) BLASContext

func (e *Engine) BLASContext() *cublas.Standard

BLASContext returns the cuBLAS context

func (*Engine) CUDNNContext

func (e *Engine) CUDNNContext() *cudnn.Context

CUDNNContext returns the cuDNN context

func (*Engine) Close

func (e *Engine) Close() error

Close cleans up the machine, and closes all available resources

func (*Engine) Context

func (e *Engine) Context() *cu.BatchedContext

Context returns the BatchedContext

func (*Engine) Div

func (e *Engine) Div(a tensor.Tensor, b tensor.Tensor, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

Div implements tensor.Diver. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) DivScalar

func (e *Engine) DivScalar(a tensor.Tensor, b interface{}, leftTensor bool, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

DivScalar implements tensor.Diver. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) DoWork

func (e *Engine) DoWork() error

DoWork sends a signal to the batched CUDA Context to actually do work

func (*Engine) ElEq

func (e *Engine) ElEq(a tensor.Tensor, b tensor.Tensor, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

ElEq implements tensor.ElEqer. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) ElNe

func (e *Engine) ElNe(a tensor.Tensor, b tensor.Tensor, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

ElNe implements tensor.ElNeer. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) ElemGridSize

func (e *Engine) ElemGridSize(n int) (gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ int)

ElemGridSize calculates the gridsize for elementwise operations. n is the number of elements

func (*Engine) EqScalar

func (e *Engine) EqScalar(a tensor.Tensor, b interface{}, leftTensor bool, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

EqScalar implements tensor.ElEqer. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) Errors

func (e *Engine) Errors() error

Errors returns an error message

func (*Engine) Free

func (e *Engine) Free(mem tensor.Memory, size int64) error

Free rees memory

func (*Engine) Functions

func (e *Engine) Functions() map[string]cu.Function

Functions returns the loaded functions indexed by name

func (*Engine) Get

func (e *Engine) Get(size int64) (tensor.Memory, error)

Get allocates memory of certain size and returns a pointer to it

func (*Engine) Gt

func (e *Engine) Gt(a tensor.Tensor, b tensor.Tensor, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

Gt implements tensor.Gter. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) GtScalar

func (e *Engine) GtScalar(a tensor.Tensor, b interface{}, leftTensor bool, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

GtScalar implements tensor.Gter. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) Gte

func (e *Engine) Gte(a tensor.Tensor, b tensor.Tensor, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

Gte implements tensor.Gteer. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) GteScalar

func (e *Engine) GteScalar(a tensor.Tensor, b interface{}, leftTensor bool, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

GteScalar implements tensor.Gteer. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) HasFunc

func (e *Engine) HasFunc(name string) bool

HasFunc returns true if the execution is external (cgo/cuda/openCL) AND the external device contains the function with the given name

func (*Engine) HasInf

func (e *Engine) HasInf(a tensor.Tensor) (bool, error)

InfChecker checks that the tensor contains a Inf

func (*Engine) HasNaN

func (e *Engine) HasNaN(a tensor.Tensor) (bool, error)

NaNChecker checks that the tensor contains a NaN

func (*Engine) Init

func (e *Engine) Init(device cu.Device, size int64) (err error)

Init creates a CUDA engine with the given size for the given device

func (*Engine) LoadCUDAFunc

func (e *Engine) LoadCUDAFunc(moduleName, data string, funcs []string) (err error)

LoadCUDAFunc loads a string representing a CUDA PTX file into the engine, giving it the universe of computing functions.

func (*Engine) Lt

func (e *Engine) Lt(a tensor.Tensor, b tensor.Tensor, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

Lt implements tensor.Lter. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) LtScalar

func (e *Engine) LtScalar(a tensor.Tensor, b interface{}, leftTensor bool, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

LtScalar implements tensor.Lter. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) Lte

func (e *Engine) Lte(a tensor.Tensor, b tensor.Tensor, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

Lte implements tensor.Lteer. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) LteScalar

func (e *Engine) LteScalar(a tensor.Tensor, b interface{}, leftTensor bool, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

LteScalar implements tensor.Lteer. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) MatMul

func (e *Engine) MatMul(a, b, prealloc tensor.Tensor) (err error)

MatMul performs matrix multiplication

func (*Engine) MatVecMul

func (e *Engine) MatVecMul(a, b, prealloc tensor.Tensor) (err error)

MatVecMul performs matrix vector multiplication

func (*Engine) Memclr

func (e *Engine) Memclr(mem tensor.Memory)

func (*Engine) Memcpy

func (e *Engine) Memcpy(dst tensor.Memory, src tensor.Memory) error

Memcpy is part of the implementation of tensor.Engine. It is eager, and will signal the context to actually do work. The memory that will be copied is up to the smallest of sizes between dst and src. i.e. if dst is 8 bytes and src is 16 bytes, only the first 8 bytes of src will be copied. Likewise, if dst is 20 bytes and src is 3 bytes, only 3 bytes will be copied.

func (*Engine) Memset

func (e *Engine) Memset(mem tensor.Memory, val interface{}) error

func (*Engine) Mod

func (e *Engine) Mod(a tensor.Tensor, b tensor.Tensor, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

Mod implements tensor.Moder. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) ModScalar

func (e *Engine) ModScalar(a tensor.Tensor, b interface{}, leftTensor bool, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

ModScalar implements tensor.Moder. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) Modules

func (e *Engine) Modules() map[string]cu.Module

Modules returns the loaded modules indexed by name

func (*Engine) Mul

func (e *Engine) Mul(a tensor.Tensor, b tensor.Tensor, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

Mul implements tensor.Muler. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) MulScalar

func (e *Engine) MulScalar(a tensor.Tensor, b interface{}, leftTensor bool, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

MulScalar implements tensor.Muler. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) NeScalar

func (e *Engine) NeScalar(a tensor.Tensor, b interface{}, leftTensor bool, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

NeScalar implements tensor.ElNeer. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) NonStdAlloc

func (e *Engine) NonStdAlloc()

NonStdAlloc nothing instead of running the default built in allocator

func (*Engine) Outer

func (e *Engine) Outer(a, b, prealloc tensor.Tensor) (err error)

Outer performs outer product (kronecker) multiplication

func (*Engine) Pow

func (e *Engine) Pow(a tensor.Tensor, b tensor.Tensor, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

Pow implements tensor.Power. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) PowScalar

func (e *Engine) PowScalar(a tensor.Tensor, b interface{}, leftTensor bool, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

PowScalar implements tensor.Power. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) Put

func (e *Engine) Put(mem tensor.Memory, size int64)

Put releases a chunk of memory of certain size

func (*Engine) ResetAllocator

func (e *Engine) ResetAllocator()

ResetAllocator releases used memory of the engine

func (*Engine) Run

func (e *Engine) Run()

Run initialises and starts the engine

func (*Engine) Signal

func (e *Engine) Signal()

Signal signals the machine to do work

func (*Engine) Sub

func (e *Engine) Sub(a tensor.Tensor, b tensor.Tensor, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

Sub implements tensor.Suber. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) SubScalar

func (e *Engine) SubScalar(a tensor.Tensor, b interface{}, leftTensor bool, opts ...tensor.FuncOpt) (retVal tensor.Tensor, err error)

SubScalar implements tensor.Suber. It does not support safe or increment operation options and will return an error if those options are passed in

func (*Engine) Sync

func (e *Engine) Sync() chan struct{}

Sync returns a channel of sync signals

func (*Engine) WorksWith

func (e *Engine) WorksWith(order tensor.DataOrder) bool

WorksWith returns true because the data order can be directly worked with

type External

type External interface {
	// Arena implies that the machine has to be able to manage its own memory
	Arena

	// Engine implies that the machine is able to allocate and free memory
	tensor.Engine

	// HasFunc checks if a function exists within this machine
	HasFunc(string) bool

	// Sync returns a channel of sync signals
	Sync() chan struct{}

	// Signal signals the machine to do work
	Signal()

	// Context returns the Context (the default implementation returns a *cu.BatchedContext)
	Context() *cu.BatchedContext

	// CUDNNContext returns the cuDNN context
	CUDNNContext() *cudnn.Context

	// BLASContext returns the cuBLAS context
	BLASContext() *cublas.Standard

	// Modules returns the loaded modules. It is indexed by name
	Modules() map[string]cu.Module

	// Functions returns the loaded functions. It is indexed by name
	Functions() map[string]cu.Function

	// ElemGridSize calculates the grid sizes for elementwise operations
	ElemGridSize(n int) (gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ int)

	// Init initializes the machine
	Init(device cu.Device, size int64) error

	// Close cleans up the machine, and closes all available resources
	Close() error

	// DoWork sends a signal to the batched CUDA Context to actually do work
	DoWork() error
}

External is a representation of an external device, conceptually modelled as a machine

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier