vulkan

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

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

Go to latest
Published: Jul 4, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

README

Vulkan back-end for Gorgonia

GoDoc GitHub version Go with Vulkan codecov Go Report Card experimental

This project is in the early development stage.

Licence

This package can be used under the same license as the main Gorgonia package:
https://github.com/gorgonia/gorgonia#licence

Dependencies

Package Used For Vitality Notes Licence
vulkan-go/vulkan Making calls to Vulkan Vital MIT
google/swiftshader Testing Vulkan in Github Actions without GPU Only used for testing. A computer or server with GPU can also be used Apache-2.0

These are the packages and libraries which inspired and were adapted from in the process of writing this package:

Source How it's Used Licence
Vulkan Kompute Used as a reference for Vulkan code.
The Swiftshader docker image used in the CI pipeline is based on one of its docker images.
Apache-2.0

Documentation

Index

Constants

View Source
const MaxInt = int(MaxUint >> 1)
View Source
const MaxUint = ^uint(0)
View Source
const MinInt = -MaxInt - 1
View Source
const MinUint = 0

Variables

View Source
var ErrMemoryManagedByOtherEngine = errors.New("this tensor's memory is not managed by Gorgonia's Vulkan engine")
View Source
var ErrNoCompatiblePhysicalDevices = errors.New("failed to find GPUs with Vulkan support that satisfy Gorgonia's requirements")
View Source
var ErrNoMatchingPhysicalDeviceMemory = errors.New("could not find a memory type that matches the requirements")
View Source
var ErrNoVulkanPhysicalDevices = errors.New("failed to find GPUs with Vulkan support")
View Source
var ErrPartialMemoryFreeNotSupported = errors.New("freeing only a part, or more than the size of memory is not supported")
View Source
var ErrQueueFamilyNotFound = errors.New("could not find required queue family on this device")
View Source
var ErrSpirvDataNotMultipleOf4Bytes = errors.New("the loaded SPIR-V data must have a length that is a multiple of 4 bytes")
View Source
var ErrUnknownMemory = errors.New("the memory is not known to this engine")

Functions

func Init

func Init() (err error)

Init the bindings with the Vulkan library. It must be called *once* before any other calls. If your application initializes its own bindings through vulkan-go, this call can be skipped. This can be the case when the app makes use of Vulkan for other purposes like a game graphics alongside the use of Vulkan for computing through Gorgonia

func VulkanError

func VulkanError(res vk.Result) error

Types

type Device

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

Device represents a physical device such as a GPU

func (*Device) ApiVersion

func (d *Device) ApiVersion() vk.Version

ApiVersion returns the Vulkan API version supported by the device

func (*Device) Name

func (d *Device) Name() string

Name of the physical device

func (*Device) SatisfiesRequirements

func (d *Device) SatisfiesRequirements() bool

SatisfiesRequirements returns true if the device satisfies the minimum requirements for Gorgonia

type Engine

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

func NewEngine

func NewEngine(pd *Device) (*Engine, error)

func (*Engine) Accessible

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

func (*Engine) Alloc

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

func (*Engine) AllocAccessible

func (e *Engine) AllocAccessible() bool

func (*Engine) Destroy

func (e *Engine) Destroy()

func (*Engine) Free

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

func (*Engine) FreeTensor

func (e *Engine) FreeTensor(t tensor.Tensor) error

func (*Engine) MatMul

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

func (*Engine) Memclr

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

func (*Engine) Memcpy

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

func (*Engine) Memset

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

func (*Engine) NonStdAlloc

func (e *Engine) NonStdAlloc()

NonStdAlloc nothing instead of running the default built in allocator

func (Engine) WorksWith

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

WorksWith returns false because I haven't looked at this yet

type Manager

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

Manager stores the Vulkan instance of the application and allows creation of devices and inspection of the requirements

func NewManager

func NewManager(opts ...ManagerOpts) (*Manager, error)

NewManager creates a Manager that has a Vulkan instance configured with Gorgonia's requirements and the requirements specified through opts

func NewManagerFromInstance

func NewManagerFromInstance(instance vk.Instance) *Manager

NewManagerFromInstance allows you to create a manager while providing your own Vulkan instance. Registering validation layers and debugging callbacks is your own responsibility

func (*Manager) AllPhysicalDevices

func (m *Manager) AllPhysicalDevices() ([]*Device, error)

AllPhysicalDevices lists all available Vulkan devices. Note that the returned devices do not necessarily fulfill all Gorgonia's requirements. If you need only supported devices, use CompatiblePhysicalDevices instead

func (*Manager) CompatiblePhysicalDevices

func (m *Manager) CompatiblePhysicalDevices() ([]*Device, error)

CompatiblePhysicalDevices lists all available Vulkan devices which satisfy the requirements of Gorgonia

func (*Manager) DefaultPhysicalDevice

func (m *Manager) DefaultPhysicalDevice() (*Device, error)

DefaultPhysicalDevice returns a computing device/gpu that looks most promising for use with Gorgonia. If you need to make a manual choice or want to use multiple GPUs at once, use AllPhysicalDevices() or CompatiblePhysicalDevices() instead

func (*Manager) Destroy

func (m *Manager) Destroy()

type ManagerOpts

type ManagerOpts func(*Manager)

func WithDebug

func WithDebug() ManagerOpts

type Op

type Op interface {
	Init(params []tensor.Tensor) error
	Destroy()
	Record() error
}

type PointerWrapper

type PointerWrapper uintptr

func (PointerWrapper) MemSize

func (p PointerWrapper) MemSize() uintptr

func (PointerWrapper) Uintptr

func (p PointerWrapper) Uintptr() uintptr

Uintptr returns the wrapped uintptr

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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