driver

package
v1.10.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2021 License: MIT Imports: 27 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 Command

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

A Command is a task to execute later

type CommandHookInfo

type CommandHookInfo struct {
	Now     akita.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       ca.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 inforomation used by the driver.

type Driver

type Driver struct {
	*akita.TickingComponent

	GPUs []*mgpusim.GPU

	ToMMU akita.Port

	ToGPUs akita.Port

	Log2PageSize uint64

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

Driver is an Akita component that controls the simulated GPUs

func NewDriver

func NewDriver(
	engine akita.Engine,
	pageTable vm.PageTable,
	log2PageSize uint64,
) *Driver

NewDriver creates a new driver

func (*Driver) AllocateMemory

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

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,
) GPUPtr

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 GPUPtr,
	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 added in v1.9.0

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

EnqueueMemCopyD2D registers a MemCopyD2DCommand (LaunchKernelCommand) in the queue.

func (*Driver) EnqueueMemCopyD2H

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

EnqueueMemCopyD2H registers a MemCopyD2HCommand in the queue.

func (*Driver) EnqueueMemCopyH2D

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

EnqueueMemCopyH2D registers a MemCopyH2DCommand in the queue.

func (*Driver) FreeMemory

func (d *Driver) FreeMemory(ctx *Context, ptr GPUPtr) 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 added in v1.10.0

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 added in v1.9.0

func (d *Driver) MemCopyD2D(ctx *Context, dst GPUPtr, src GPUPtr, 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 GPUPtr)

MemCopyD2H copies a memory from a GPU device to the host

func (*Driver) MemCopyH2D

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

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

func (*Driver) RegisterGPU

func (d *Driver) RegisterGPU(gpu *mgpusim.GPU, dramSize uint64)

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 akita.VTimeInSec) bool

Tick ticks

type FlushCommand

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

A FlushCommand is a command triggers the GPU cache to flush

func (*FlushCommand) GetID

func (c *FlushCommand) GetID() string

GetID returns the ID of the command

func (*FlushCommand) GetReqs

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

GetReqs returns the request associated with the command

func (*FlushCommand) RemoveReq

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

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

type GPUPtr

type GPUPtr uint64

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

type KernelMemCopyArgs added in v1.9.0

type KernelMemCopyArgs struct {
	Src GPUPtr
	Dst GPUPtr
	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    GPUPtr
	Reqs       []akita.Msg
}

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

func (*LaunchKernelCommand) GetID

func (c *LaunchKernelCommand) GetID() string

GetID returns the ID of the command

func (*LaunchKernelCommand) GetReqs

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

GetReqs returns the request associated with the command

func (*LaunchKernelCommand) RemoveReq

func (c *LaunchKernelCommand) RemoveReq(req akita.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     GPUPtr
	RawData []byte
	Reqs    []akita.Msg
}

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

func (*MemCopyD2HCommand) GetID

func (c *MemCopyD2HCommand) GetID() string

GetID returns the ID of the command

func (*MemCopyD2HCommand) GetReqs

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

GetReqs returns the request associated with the command

func (*MemCopyD2HCommand) RemoveReq

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

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

type MemCopyH2DCommand

type MemCopyH2DCommand struct {
	ID   string
	Dst  GPUPtr
	Src  interface{}
	Reqs []akita.Msg
}

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

func (*MemCopyH2DCommand) GetID

func (c *MemCopyH2DCommand) GetID() string

GetID returns the ID of the command

func (*MemCopyH2DCommand) GetReqs

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

GetReqs returns the requests associated with the command

func (*MemCopyH2DCommand) RemoveReq

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

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

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) GetID

func (c *NoopCommand) GetID() string

GetID returns the ID of the command

func (*NoopCommand) GetReqs

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

GetReqs returns the request associated with the command

func (*NoopCommand) RemoveReq

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

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

type ReqHookInfo

type ReqHookInfo struct {
	CommandID string
	EventType string
	Now       akita.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