Documentation
¶
Overview ¶
Package device provides device abstraction and memory allocation interfaces.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Allocator ¶
type Allocator interface {
// Allocate allocates a block of memory of the given size in bytes.
// For the CPU, this will be a Go slice. For a GPU, it would be a device pointer.
Allocate(size int) (any, error)
// Free releases the allocated memory.
// For the CPU allocator, this is a no-op as Go's garbage collector manages memory.
Free(ptr any) error
}
Allocator defines the interface for a memory allocator. It is responsible for allocating and freeing memory on a specific device.
func NewCPUAllocator ¶
func NewCPUAllocator() Allocator
NewCPUAllocator creates a new CPU memory allocator.
func NewCUDAAllocator ¶
NewCUDAAllocator creates a new CUDA device memory allocator bound to the given device.
type Device ¶
type Device interface {
// ID returns the unique identifier for the device (e.g., "cpu", "cuda:0").
ID() string
// GetAllocator returns the memory allocator associated with this device.
GetAllocator() Allocator
// Type returns the type of the device
Type() Type
}
Device represents a physical or logical compute device (e.g., CPU, GPU). It provides access to the device's properties and its memory allocator.
type Type ¶
type Type int
Type is an enum for the kind of device.
const ( // CPU represents the Central Processing Unit device type. CPU Type = iota // CUDA represents the NVIDIA GPU device type. CUDA // ROCm represents the AMD GPU device type via HIP/ROCm. ROCm // OpenCL represents a GPU device accessed via OpenCL. OpenCL // Metal represents an Apple GPU device accessed via Metal. Metal // FPGA represents a Field-Programmable Gate Array accelerator device. FPGA // SYCL represents a device accessed via the SYCL runtime (Intel oneAPI). SYCL )
Click to show internal directories.
Click to hide internal directories.