driver

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package driver implements a GPU driver that interfaces the benchmarks with the simulator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

A Builder can build a driver.

func MakeBuilder

func MakeBuilder() Builder

MakeBuilder creates a driver builder with some default configuration parameters.

func (Builder) Build

func (b Builder) Build(name string) *Driver

Build creates a driver.

func (Builder) WithEngine

func (b Builder) WithEngine(e sim.Engine) Builder

WithEngine sets the engine to use.

func (Builder) WithFreq

func (b Builder) WithFreq(freq sim.Freq) Builder

WithFreq sets the frequency to use.

func (Builder) WithGlobalStorage

func (b Builder) WithGlobalStorage(storage *mem.Storage) Builder

WithGlobalStorage sets the global storage that the driver uses.

func (Builder) WithLog2PageSize

func (b Builder) WithLog2PageSize(log2PageSize uint64) Builder

WithLog2PageSize sets the page size used by all the devices in the system as a power of 2.

func (Builder) WithMagicMemoryCopyMiddleware

func (b Builder) WithMagicMemoryCopyMiddleware() Builder

WithMagicMemoryCopyMiddleware uses global storage as memory components

func (Builder) WithPageTable

func (b Builder) WithPageTable(pt vm.PageTable) Builder

WithPageTable sets the global page table.

type Command

type Command interface {
	GetID() string
	GetReqs() []sim.Msg
	AddReq(req sim.Msg)
	RemoveReq(req sim.Msg)
}

A Command is a task to execute later

type CommandHookInfo

type CommandHookInfo struct {
	Now     sim.VTimeInSec
	IsStart bool
	Queue   *CommandQueue
}

CommandHookInfo carries the information provided to hooks that are triggered by Comands.

type CommandQueue

type CommandQueue struct {
	IsRunning bool
	GPUID     int
	PID       vm.PID
	Context   *Context
	// contains filtered or unexported fields
}

A CommandQueue maintains a queue of command where the commands from the queue will executes in order.

func (*CommandQueue) Dequeue

func (q *CommandQueue) Dequeue() Command

Dequeue removes a command from the command queue

func (*CommandQueue) Enqueue

func (q *CommandQueue) Enqueue(c Command)

Enqueue adds a command to the command queue

func (*CommandQueue) NotifyAllSubscribers

func (q *CommandQueue) NotifyAllSubscribers()

NotifyAllSubscribers will wake up all the subscribers of the command queue

func (*CommandQueue) NumCommand

func (q *CommandQueue) NumCommand() int

NumCommand returns the number of commands currently in the command queue

func (*CommandQueue) Peek

func (q *CommandQueue) Peek() Command

Peek returns the first command in the command quee

func (*CommandQueue) Subscribe

func (q *CommandQueue) Subscribe() *CommandQueueStatusListener

Subscribe returns a CommandQueueStatusListener that listens to the update of the command queue

func (*CommandQueue) Unsubscribe

func (q *CommandQueue) Unsubscribe(listener *CommandQueueStatusListener)

Unsubscribe will unbind a listener to a command queue.

type CommandQueueStatusListener

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

A CommandQueueStatusListener can be notified when a queue updates its state

func (*CommandQueueStatusListener) Close

func (l *CommandQueueStatusListener) Close()

Close stops the listener from listening

func (*CommandQueueStatusListener) Notify

func (l *CommandQueueStatusListener) Notify()

Notify triggers the listener who waits for the command queue status update continue executing

func (*CommandQueueStatusListener) Wait

func (l *CommandQueueStatusListener) Wait()

Wait will block the execution until the command queue updates its status

type Context

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

Context is an opaque struct that carries the information used by the driver.

type DeviceProperties

type DeviceProperties struct {
	CUCount  int
	DRAMSize uint64
}

DeviceProperties defines the properties of a device

type Driver

type Driver struct {
	*sim.TickingComponent

	GPUs []sim.Port

	Log2PageSize uint64

	RemotePMCPorts []sim.Port
	// contains filtered or unexported fields
}

Driver is an Akita component that controls the simulated GPUs

func (*Driver) AllocateMemory

func (d *Driver) AllocateMemory(
	ctx *Context,
	byteSize uint64,
) Ptr

AllocateMemory allocates a chunk of memory of size byteSize in storage. It returns the pointer pointing to the newly allocated memory in the GPU memory space.

func (*Driver) AllocateUnifiedMemory

func (d *Driver) AllocateUnifiedMemory(
	ctx *Context,
	byteSize uint64,
) Ptr

AllocateUnifiedMemory allocates a unified memory. Allocation is done on CPU

func (*Driver) CreateCommandQueue

func (d *Driver) CreateCommandQueue(c *Context) *CommandQueue

CreateCommandQueue creates a command queue in the driver

func (*Driver) CreateUnifiedGPU

func (d *Driver) CreateUnifiedGPU(c *Context, gpuIDs []int) int

CreateUnifiedGPU can create a virtual GPU that bundles multiple GPUs together. It returns the DeviceID of the created unified multi-GPU device.

func (*Driver) Distribute

func (d *Driver) Distribute(
	ctx *Context,
	addr Ptr,
	byteSize uint64,
	gpuIDs []int,
) []uint64

Distribute rearranges a consecutive virtual memory space and re-allocate the memory on designated GPUs. This function returns the number of bytes allocated to each GPU.

func (*Driver) DrainCommandQueue

func (d *Driver) DrainCommandQueue(q *CommandQueue)

DrainCommandQueue will return when there is no command to execute

func (*Driver) Enqueue

func (d *Driver) Enqueue(q *CommandQueue, c Command)

Enqueue adds a command to a command queue and triggers GPUs to start to consume the command.

func (*Driver) EnqueueLaunchKernel

func (d *Driver) EnqueueLaunchKernel(
	queue *CommandQueue,
	co *insts.HsaCo,
	gridSize [3]uint32,
	wgSize [3]uint16,
	kernelArgs interface{},
)

EnqueueLaunchKernel schedules kernel to be launched later

func (*Driver) EnqueueMemCopyD2D

func (d *Driver) EnqueueMemCopyD2D(
	queue *CommandQueue,
	dst Ptr,
	src Ptr,
	num int,
)

EnqueueMemCopyD2D registers a MemCopyD2DCommand (LaunchKernelCommand) in the queue.

func (*Driver) EnqueueMemCopyD2H

func (d *Driver) EnqueueMemCopyD2H(
	queue *CommandQueue,
	dst interface{},
	src Ptr,
)

EnqueueMemCopyD2H registers a MemCopyD2HCommand in the queue.

func (*Driver) EnqueueMemCopyH2D

func (d *Driver) EnqueueMemCopyH2D(
	queue *CommandQueue,
	dst Ptr,
	src interface{},
)

EnqueueMemCopyH2D registers a MemCopyH2DCommand in the queue.

func (*Driver) FreeMemory

func (d *Driver) FreeMemory(ctx *Context, ptr Ptr) error

FreeMemory frees the memory pointed by ptr. The pointer must be allocated with the function AllocateMemory earlier. Error will be returned if the ptr provided is invalid.

func (*Driver) GetNumGPUs

func (d *Driver) GetNumGPUs() int

GetNumGPUs return the number of GPUs in the platform

func (*Driver) Init

func (d *Driver) Init() *Context

Init creates a context to be used in the following API calls.

func (*Driver) InitWithExistingPID

func (d *Driver) InitWithExistingPID(ctx *Context) *Context

InitWithExistingPID creates a new context that shares the same process ID with the given context.

func (*Driver) LaunchKernel

func (d *Driver) LaunchKernel(
	ctx *Context,
	co *insts.HsaCo,
	gridSize [3]uint32,
	wgSize [3]uint16,
	kernelArgs interface{},
)

LaunchKernel is an easy way to run a kernel on the GCN3 simulator. It launches the kernel immediately.

func (*Driver) MemCopyD2D

func (d *Driver) MemCopyD2D(ctx *Context, dst Ptr, src Ptr, num int)

MemCopyD2D copies a memory from a GPU device to another GPU device. num is the total number of bytes.

func (*Driver) MemCopyD2H

func (d *Driver) MemCopyD2H(ctx *Context, dst interface{}, src Ptr)

MemCopyD2H copies a memory from a GPU device to the host

func (*Driver) MemCopyH2D

func (d *Driver) MemCopyH2D(ctx *Context, dst Ptr, src interface{})

MemCopyH2D copies a memory from the host to a GPU device.

func (*Driver) RegisterGPU

func (d *Driver) RegisterGPU(
	commandProcessorPort sim.Port,
	properties DeviceProperties,
)

RegisterGPU tells the driver about the existence of a GPU

func (*Driver) Remap

func (d *Driver) Remap(ctx *Context, addr, size uint64, deviceID int)

Remap keeps the virtual address unchanged and moves the physical address to another GPU

func (*Driver) Run

func (d *Driver) Run()

Run starts a new threads that handles all commands in the command queues

func (*Driver) SelectGPU

func (d *Driver) SelectGPU(c *Context, gpuID int)

SelectGPU requires the driver to perform the following APIs on a selected GPU

func (*Driver) Terminate

func (d *Driver) Terminate()

Terminate stops the driver thread execution.

func (*Driver) Tick

func (d *Driver) Tick(now sim.VTimeInSec) bool

Tick ticks

type FlushCommand

type FlushCommand struct {
	ID   string
	Reqs []sim.Msg
}

A FlushCommand is a command triggers the GPU cache to flush

func (*FlushCommand) AddReq

func (c *FlushCommand) AddReq(req sim.Msg)

AddReq adds a request to the request list associated with the command

func (*FlushCommand) GetID

func (c *FlushCommand) GetID() string

GetID returns the ID of the command

func (*FlushCommand) GetReqs

func (c *FlushCommand) GetReqs() []sim.Msg

GetReqs returns the request associated with the command

func (*FlushCommand) RemoveReq

func (c *FlushCommand) RemoveReq(req sim.Msg)

RemoveReq removes a request from the request list associated with the command.

type KernelMemCopyArgs

type KernelMemCopyArgs struct {
	Src Ptr
	Dst Ptr
	N   int64
}

KernelMemCopyArgs is the kernel struct for MemCopyD2D

type LaunchKernelCommand

type LaunchKernelCommand struct {
	ID         string
	CodeObject *insts.HsaCo
	GridSize   [3]uint32
	WGSize     [3]uint16
	KernelArgs interface{}
	Packet     *kernels.HsaKernelDispatchPacket
	DPacket    Ptr
	Reqs       []sim.Msg
}

A LaunchKernelCommand is a command will execute a kernel when it is processed.

func (*LaunchKernelCommand) AddReq

func (c *LaunchKernelCommand) AddReq(req sim.Msg)

AddReq adds a request to the request list associated with the command

func (*LaunchKernelCommand) GetID

func (c *LaunchKernelCommand) GetID() string

GetID returns the ID of the command

func (*LaunchKernelCommand) GetReqs

func (c *LaunchKernelCommand) GetReqs() []sim.Msg

GetReqs returns the request associated with the command

func (*LaunchKernelCommand) RemoveReq

func (c *LaunchKernelCommand) RemoveReq(req sim.Msg)

RemoveReq removes a request from the request list associated with the command.

type LaunchUnifiedMultiGPUKernelCommand

type LaunchUnifiedMultiGPUKernelCommand struct {
	ID           string
	CodeObject   *insts.HsaCo
	GridSize     [3]uint32
	WGSize       [3]uint16
	KernelArgs   interface{}
	PacketArray  []*kernels.HsaKernelDispatchPacket
	DPacketArray []Ptr
	Reqs         []sim.Msg
}

A LaunchUnifiedMultiGPUKernelCommand is a command that launches a kernel on multiple unified GPUs.

func (*LaunchUnifiedMultiGPUKernelCommand) AddReq

AddReq adds a request to the request list associated with the command

func (*LaunchUnifiedMultiGPUKernelCommand) GetID

GetID returns the ID of the command

func (*LaunchUnifiedMultiGPUKernelCommand) GetReqs

GetReqs returns the request associated with the command

func (*LaunchUnifiedMultiGPUKernelCommand) RemoveReq

func (c *LaunchUnifiedMultiGPUKernelCommand) RemoveReq(req sim.Msg)

RemoveReq removes a request from the request list associated with the command.

type LocalPtr

type LocalPtr uint32

LocalPtr is a type that represent a pointer to a region in the LDS memory

type MemCopyD2HCommand

type MemCopyD2HCommand struct {
	ID      string
	Dst     interface{}
	Src     Ptr
	RawData []byte
	Reqs    []sim.Msg
}

A MemCopyD2HCommand is a command that copies memory from the host to a GPU when the command is processed

func (*MemCopyD2HCommand) AddReq

func (c *MemCopyD2HCommand) AddReq(req sim.Msg)

AddReq adds a request to the request list associated with the command

func (*MemCopyD2HCommand) GetID

func (c *MemCopyD2HCommand) GetID() string

GetID returns the ID of the command

func (*MemCopyD2HCommand) GetReqs

func (c *MemCopyD2HCommand) GetReqs() []sim.Msg

GetReqs returns the request associated with the command

func (*MemCopyD2HCommand) RemoveReq

func (c *MemCopyD2HCommand) RemoveReq(req sim.Msg)

RemoveReq removes a request from the request list associated with the command.

type MemCopyH2DCommand

type MemCopyH2DCommand struct {
	ID   string
	Dst  Ptr
	Src  interface{}
	Reqs []sim.Msg
}

A MemCopyH2DCommand is a command that copies memory from the host to a GPU when the command is processed

func (*MemCopyH2DCommand) AddReq

func (c *MemCopyH2DCommand) AddReq(req sim.Msg)

AddReq adds a request to the request list associated with the command

func (*MemCopyH2DCommand) GetID

func (c *MemCopyH2DCommand) GetID() string

GetID returns the ID of the command

func (*MemCopyH2DCommand) GetReqs

func (c *MemCopyH2DCommand) GetReqs() []sim.Msg

GetReqs returns the requests associated with the command

func (*MemCopyH2DCommand) RemoveReq

func (c *MemCopyH2DCommand) RemoveReq(req sim.Msg)

RemoveReq removes a request from the request list associated with the command.

type Middleware

type Middleware interface {
	ProcessCommand(
		now sim.VTimeInSec,
		cmd Command,
		queue *CommandQueue,
	) (processed bool)
	Tick(now sim.VTimeInSec) (madeProgress bool)
}

A Middleware is a pluggable element of the driver that can take care of the handling of certain types of commands and parts of the driver-GPU communication.

type NoopCommand

type NoopCommand struct {
	ID string
}

A NoopCommand is a command that does not do anything. It is used for testing purposes.

func (*NoopCommand) AddReq

func (c *NoopCommand) AddReq(req sim.Msg)

AddReq adds a request to the request list associated with the command

func (*NoopCommand) GetID

func (c *NoopCommand) GetID() string

GetID returns the ID of the command

func (*NoopCommand) GetReqs

func (c *NoopCommand) GetReqs() []sim.Msg

GetReqs returns the request associated with the command

func (*NoopCommand) RemoveReq

func (c *NoopCommand) RemoveReq(req sim.Msg)

RemoveReq removes a request from the request list associated with the command.

type Ptr

type Ptr uint64

Ptr is the type that represent a pointer pointing into the GPU memory

type ReqHookInfo

type ReqHookInfo struct {
	CommandID string
	EventType string
	Now       sim.VTimeInSec
}

ReqHookInfo is the information that the driver send to the request hooks

Directories

Path Synopsis
Package internal provides support for the driver implementation.
Package internal provides support for the driver implementation.

Jump to

Keyboard shortcuts

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