runtime

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_TYPE_SIZE = 64

Variables

This section is empty.

Functions

func CreateStream

func CreateStream() (Stream, EIcicleError)

func GetActiveDevice

func GetActiveDevice() (*Device, EIcicleError)

func GetAvailableMemory

func GetAvailableMemory() (*AvailableMemory, EIcicleError)

func GetDeviceProperties

func GetDeviceProperties() (*DeviceProperties, EIcicleError)

func IsActiveDeviceMemory

func IsActiveDeviceMemory(ptr unsafe.Pointer) bool

func IsDeviceAvailable

func IsDeviceAvailable(device *Device) bool

func IsHostMemory

func IsHostMemory(ptr unsafe.Pointer) bool

func RunOnDevice

func RunOnDevice(device *Device, funcToRun func(args ...any), args ...any)

// This will always print "Inner goroutine device: 0" // go func () { // device, _ := runtime.GetActiveDevice() // fmt.Println("Inner goroutine device: ", device.Id) // }()

// To force the above goroutine to same device as the wrapping function: // RunOnDevice(i, func(arg ...any) { // device, _ := runtime.GetActiveDevice() // fmt.Println("Inner goroutine device: ", device.Id) // }) . . .

}, i)

Types

type AvailableMemory

type AvailableMemory struct {
	Total uint
	Free  uint
}

type Device

type Device struct {
	DeviceType [MAX_TYPE_SIZE]C.char
	Id         int32
}

func CreateDevice

func CreateDevice(deviceType string, id int) Device

func (*Device) GetDeviceType

func (self *Device) GetDeviceType() string

type DeviceProperties

type DeviceProperties struct {
	UsingHostMemory      bool
	NumMemoryRegions     int32
	SupportsPinnedMemory bool
}

type EIcicleError

type EIcicleError int

eIcicleError represents the error codes

const (
	Success                 EIcicleError = iota // Operation completed successfully
	InvalidDevice                               // The specified device is invalid
	OutOfMemory                                 // Memory allocation failed due to insufficient memory
	InvalidPointer                              // The specified pointer is invalid
	AllocationFailed                            // Memory allocation failed
	DeallocationFailed                          // Memory deallocation failed
	CopyFailed                                  // Data copy operation failed
	SynchronizationFailed                       // Device synchronization failed
	StreamCreationFailed                        // Stream creation failed
	StreamDestructionFailed                     // Stream destruction failed
	ApiNotImplemented                           // The API is not implemented for a device
	InvalidArgument                             // Invalid argument passed
	BackendLoadFailed                           // Failed to load the backend
	LicenseCheckError                           // Failed to check license or invalid license
	UnknownError                                // An unknown error occurred
)

func CopyFromDevice

func CopyFromDevice(hostDst, deviceSrc unsafe.Pointer, size uint) (unsafe.Pointer, EIcicleError)

func CopyFromDeviceAsync

func CopyFromDeviceAsync(hostDst, deviceSrc unsafe.Pointer, size uint, stream Stream) EIcicleError

func CopyToDevice

func CopyToDevice(deviceDst, hostSrc unsafe.Pointer, size uint) (unsafe.Pointer, EIcicleError)

func CopyToDeviceAsync

func CopyToDeviceAsync(deviceDst, hostSrc unsafe.Pointer, size uint, stream Stream) EIcicleError

func DestroyStream

func DestroyStream(stream Stream) EIcicleError

func DeviceSynchronize

func DeviceSynchronize() EIcicleError

func Free

func Free(devicePtr unsafe.Pointer) EIcicleError

func FreeAsync

func FreeAsync(devicePtr unsafe.Pointer, stream Stream) EIcicleError

func GetDeviceCount

func GetDeviceCount() (int, EIcicleError)

func GetRegisteredDevices

func GetRegisteredDevices() ([]string, EIcicleError)

func LoadBackend

func LoadBackend(path string, isRecursive bool) EIcicleError

func LoadBackendFromEnvOrDefault

func LoadBackendFromEnvOrDefault() EIcicleError

func Malloc

func Malloc(size uint) (unsafe.Pointer, EIcicleError)

func MallocAsync

func MallocAsync(size uint, stream Stream) (unsafe.Pointer, EIcicleError)

func MemSet

func MemSet(devicePtr unsafe.Pointer, value int, size uint) EIcicleError

func MemSetAsync

func MemSetAsync(devicePtr unsafe.Pointer, value int, size uint, stream Stream) EIcicleError

func SetDevice

func SetDevice(device *Device) EIcicleError

func SynchronizeStream

func SynchronizeStream(stream Stream) EIcicleError

type Stream

type Stream = unsafe.Pointer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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