internal

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package internal provides support for the driver implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllocatorType

type AllocatorType int

AllocatorType marks the type of memory allocator

const (
	AllocatorTypeDefault AllocatorType = iota
	AllocatorTypeBuddy
)

Defines supported allocation algorithms

var MemoryAllocatorType AllocatorType = AllocatorTypeDefault

MemoryAllocatorType global flag variable for setting the allocator type

type Device

type Device struct {
	ID            int
	Type          DeviceType
	UnifiedGPUIDs []int
	ActualGPUs    []*Device

	MemState DeviceMemoryState
	// contains filtered or unexported fields
}

Device is a CPU or GPU managed by the driver.

func (*Device) SetTotalMemSize

func (d *Device) SetTotalMemSize(size uint64)

SetTotalMemSize sets total memory size

type DeviceMemoryState

type DeviceMemoryState interface {
	// contains filtered or unexported methods
}

A DeviceMemoryState handles the internal memory allocation algorithms

func NewDeviceMemoryState

func NewDeviceMemoryState(log2pagesize uint64) DeviceMemoryState

NewDeviceMemoryState creates a new device memory state based on allocator type.

type DeviceType

type DeviceType int

DeviceType marks the type of a device.

const (
	DeviceTypeInvalid DeviceType = iota
	DeviceTypeCPU
	DeviceTypeGPU
	DeviceTypeUnifiedGPU
)

Defines supported devices.

type MemoryAllocator

type MemoryAllocator interface {
	RegisterDevice(device *Device)
	GetDeviceIDByPAddr(pAddr uint64) int
	Allocate(pid ca.PID, byteSize uint64, deviceID int) uint64
	AllocateUnified(pid ca.PID, byteSize uint64) uint64
	Free(vAddr uint64)
	Remap(pid ca.PID, pageVAddr, byteSize uint64, deviceID int)
	RemovePage(vAddr uint64)
	AllocatePageWithGivenVAddr(
		pid ca.PID,
		deviceID int,
		vAddr uint64,
		unified bool,
	) vm.Page
}

A MemoryAllocator can allocate memory on the CPU and GPUs

func NewMemoryAllocator

func NewMemoryAllocator(
	pageTable vm.PageTable,
	log2PageSize uint64,
) MemoryAllocator

NewMemoryAllocator creates a new memory allocator.

Jump to

Keyboard shortcuts

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