Documentation
¶
Index ¶
- Constants
- func NewMetalIndexImpl(cfg types.GPUConfig) (types.Index, error)
- type DoubleBuffer
- func (db *DoubleBuffer) ActiveSize() int
- func (db *DoubleBuffer) Capacity() int
- func (db *DoubleBuffer) CheckHeadroom(requiredBytes int64) error
- func (db *DoubleBuffer) GetActive() []byte
- func (db *DoubleBuffer) GetInactive() []byte
- func (db *DoubleBuffer) Reset()
- func (db *DoubleBuffer) Swap()
- func (db *DoubleBuffer) Write(data []byte) (int, error)
- type DoubleBufferOption
- type GPUBackend
- type GPUMemPool
- func (p *GPUMemPool) AllocateGPU(size int64) (unsafe.Pointer, error)
- func (p *GPUMemPool) Backend() GPUBackend
- func (p *GPUMemPool) Close() error
- func (p *GPUMemPool) DeviceID() int32
- func (p *GPUMemPool) FreeGPU(ptr unsafe.Pointer) error
- func (p *GPUMemPool) GetAvailableMemory() int64
- func (p *GPUMemPool) GetTotalMemory() int64
- func (p *GPUMemPool) GetUsedMemory() int64
- func (p *GPUMemPool) MemcpyDeviceToDevice(dstPtr, srcPtr unsafe.Pointer, size int64) error
- func (p *GPUMemPool) MemcpyDeviceToHost(hostPtr, devicePtr unsafe.Pointer, size int64) error
- func (p *GPUMemPool) MemcpyHostToDevice(devicePtr, hostPtr unsafe.Pointer, size int64) error
- func (p *GPUMemPool) Memset(ptr unsafe.Pointer, value int, size int64) error
- func (p *GPUMemPool) SetTotalMemory(total int64)
- type GPUPager
- type MTLBufferPool
- type PageID
- type PageInfo
- type PooledBuffer
Constants ¶
const ( BackendCPU = types.BackendCPU BackendCUDA = types.BackendCUDA BackendMetal = types.BackendMetal )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DoubleBuffer ¶
type DoubleBuffer struct {
// contains filtered or unexported fields
}
func NewDoubleBuffer ¶
func NewDoubleBuffer(capacity int, opts ...DoubleBufferOption) *DoubleBuffer
NewDoubleBuffer allocates two slabs of the given capacity with optional configuration.
func NewDoubleBufferWithHeadroom ¶
func NewDoubleBufferWithHeadroom(capacity int, memPool *GPUMemPool, minHeadroomBytes int64) (*DoubleBuffer, error)
NewDoubleBufferWithHeadroom allocates two slabs after validating that the GPU memory pool has sufficient headroom.
func (*DoubleBuffer) ActiveSize ¶
func (db *DoubleBuffer) ActiveSize() int
ActiveSize returns the current active size.
func (*DoubleBuffer) Capacity ¶
func (db *DoubleBuffer) Capacity() int
Capacity returns the total capacity of each buffer.
func (*DoubleBuffer) CheckHeadroom ¶
func (db *DoubleBuffer) CheckHeadroom(requiredBytes int64) error
CheckHeadroom validates that the attached GPU memory pool has sufficient headroom for an upcoming operation.
func (*DoubleBuffer) GetActive ¶
func (db *DoubleBuffer) GetActive() []byte
GetActive returns the current active buffer that can be written to by Go CPU code.
func (*DoubleBuffer) GetInactive ¶
func (db *DoubleBuffer) GetInactive() []byte
GetInactive returns the current inactive buffer that is currently being copied or processed on the GPU.
func (*DoubleBuffer) Swap ¶
func (db *DoubleBuffer) Swap()
Swap toggles the active and inactive buffers, resetting the active buffer size.
type DoubleBufferOption ¶
type DoubleBufferOption func(*DoubleBuffer)
DoubleBufferOption defines functional configuration for DoubleBuffer.
func WithMemPool ¶
func WithMemPool(pool *GPUMemPool, minHeadroomBytes int64) DoubleBufferOption
WithMemPool attaches a GPUMemPool to validate device memory headroom.
type GPUBackend ¶
type GPUBackend = types.GPUBackend
Re-export common types from types subpackage for convenience
type GPUMemPool ¶
type GPUMemPool struct {
// contains filtered or unexported fields
}
func NewGPUMemPool ¶
func NewGPUMemPool(backend types.GPUBackend, deviceID int32) (*GPUMemPool, error)
NewGPUMemPool creates a new GPU memory pool. totalBytes should be set after creation via SetTotalMemory once the device limit is known.
func (*GPUMemPool) AllocateGPU ¶
func (p *GPUMemPool) AllocateGPU(size int64) (unsafe.Pointer, error)
func (*GPUMemPool) Backend ¶
func (p *GPUMemPool) Backend() GPUBackend
func (*GPUMemPool) Close ¶
func (p *GPUMemPool) Close() error
func (*GPUMemPool) DeviceID ¶
func (p *GPUMemPool) DeviceID() int32
func (*GPUMemPool) GetAvailableMemory ¶
func (p *GPUMemPool) GetAvailableMemory() int64
func (*GPUMemPool) GetTotalMemory ¶
func (p *GPUMemPool) GetTotalMemory() int64
func (*GPUMemPool) GetUsedMemory ¶
func (p *GPUMemPool) GetUsedMemory() int64
func (*GPUMemPool) MemcpyDeviceToDevice ¶
func (p *GPUMemPool) MemcpyDeviceToDevice(dstPtr, srcPtr unsafe.Pointer, size int64) error
func (*GPUMemPool) MemcpyDeviceToHost ¶
func (p *GPUMemPool) MemcpyDeviceToHost(hostPtr, devicePtr unsafe.Pointer, size int64) error
func (*GPUMemPool) MemcpyHostToDevice ¶
func (p *GPUMemPool) MemcpyHostToDevice(devicePtr, hostPtr unsafe.Pointer, size int64) error
func (*GPUMemPool) SetTotalMemory ¶
func (p *GPUMemPool) SetTotalMemory(total int64)
SetTotalMemory sets the total memory limit for this pool (from GPUConfig.MaxMemory or device query).
type GPUPager ¶
type GPUPager struct{}
Stub for non-GPU builds. GPU paging is only available on CUDA Linux.
func NewGPUPager ¶
func NewGPUPager(pool *GPUMemPool, maxVRAM, pageSize int64) *GPUPager
type MTLBufferPool ¶
type MTLBufferPool struct{}
MTLBufferPool stubs for non-Metal platforms
func GetMTLBufferPool ¶
func GetMTLBufferPool(_ interface{}) *MTLBufferPool
func (*MTLBufferPool) Get ¶
func (p *MTLBufferPool) Get(_ int) interface{}
func (*MTLBufferPool) Put ¶
func (p *MTLBufferPool) Put(_ interface{})
func (*MTLBufferPool) Stats ¶
func (p *MTLBufferPool) Stats() (int64, int64)
type PooledBuffer ¶
type PooledBuffer struct{}
func NewPooledBuffer ¶
func NewPooledBuffer(_ interface{}, _ int, _ *MTLBufferPool) (*PooledBuffer, error)
func (*PooledBuffer) Buffer ¶
func (pb *PooledBuffer) Buffer() interface{}
func (*PooledBuffer) Release ¶
func (pb *PooledBuffer) Release()