Documentation ¶
Overview ¶
Package driver implements a GPU driver that interfaces the benchmarks with the simulator.
Index ¶
- type Builder
- func (b Builder) Build(name string) *Driver
- func (b Builder) WithEngine(e sim.Engine) Builder
- func (b Builder) WithFreq(freq sim.Freq) Builder
- func (b Builder) WithGlobalStorage(storage *mem.Storage) Builder
- func (b Builder) WithLog2PageSize(log2PageSize uint64) Builder
- func (b Builder) WithMagicMemoryCopyMiddleware() Builder
- func (b Builder) WithPageTable(pt vm.PageTable) Builder
- type Command
- type CommandHookInfo
- type CommandQueue
- func (q *CommandQueue) Dequeue() Command
- func (q *CommandQueue) Enqueue(c Command)
- func (q *CommandQueue) NotifyAllSubscribers()
- func (q *CommandQueue) NumCommand() int
- func (q *CommandQueue) Peek() Command
- func (q *CommandQueue) Subscribe() *CommandQueueStatusListener
- func (q *CommandQueue) Unsubscribe(listener *CommandQueueStatusListener)
- type CommandQueueStatusListener
- type Context
- type DeviceProperties
- type Driver
- func (d *Driver) AllocateMemory(ctx *Context, byteSize uint64) Ptr
- func (d *Driver) AllocateUnifiedMemory(ctx *Context, byteSize uint64) Ptr
- func (d *Driver) CreateCommandQueue(c *Context) *CommandQueue
- func (d *Driver) CreateUnifiedGPU(c *Context, gpuIDs []int) int
- func (d *Driver) Distribute(ctx *Context, addr Ptr, byteSize uint64, gpuIDs []int) []uint64
- func (d *Driver) DrainCommandQueue(q *CommandQueue)
- func (d *Driver) Enqueue(q *CommandQueue, c Command)
- func (d *Driver) EnqueueLaunchKernel(queue *CommandQueue, co *insts.HsaCo, gridSize [3]uint32, wgSize [3]uint16, ...)
- func (d *Driver) EnqueueMemCopyD2D(queue *CommandQueue, dst Ptr, src Ptr, num int)
- func (d *Driver) EnqueueMemCopyD2H(queue *CommandQueue, dst interface{}, src Ptr)
- func (d *Driver) EnqueueMemCopyH2D(queue *CommandQueue, dst Ptr, src interface{})
- func (d *Driver) FreeMemory(ctx *Context, ptr Ptr) error
- func (d *Driver) GetNumGPUs() int
- func (d *Driver) Init() *Context
- func (d *Driver) InitWithExistingPID(ctx *Context) *Context
- func (d *Driver) LaunchKernel(ctx *Context, co *insts.HsaCo, gridSize [3]uint32, wgSize [3]uint16, ...)
- func (d *Driver) MemCopyD2D(ctx *Context, dst Ptr, src Ptr, num int)
- func (d *Driver) MemCopyD2H(ctx *Context, dst interface{}, src Ptr)
- func (d *Driver) MemCopyH2D(ctx *Context, dst Ptr, src interface{})
- func (d *Driver) RegisterGPU(commandProcessorPort sim.Port, properties DeviceProperties)
- func (d *Driver) Remap(ctx *Context, addr, size uint64, deviceID int)
- func (d *Driver) Run()
- func (d *Driver) SelectGPU(c *Context, gpuID int)
- func (d *Driver) Terminate()
- func (d *Driver) Tick(now sim.VTimeInSec) bool
- type FlushCommand
- type KernelMemCopyArgs
- type LaunchKernelCommand
- type LaunchUnifiedMultiGPUKernelCommand
- type LocalPtr
- type MemCopyD2HCommand
- type MemCopyH2DCommand
- type Middleware
- type NoopCommand
- type Ptr
- type ReqHookInfo
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) WithEngine ¶
WithEngine sets the engine to use.
func (Builder) WithGlobalStorage ¶
WithGlobalStorage sets the global storage that the driver uses.
func (Builder) WithLog2PageSize ¶
WithLog2PageSize sets the page size used by all the devices in the system as a power of 2.
func (Builder) WithMagicMemoryCopyMiddleware ¶
WithMagicMemoryCopyMiddleware uses global storage as memory components
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
GetNumGPUs return the number of GPUs in the platform
func (*Driver) InitWithExistingPID ¶
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 ¶
MemCopyD2D copies a memory from a GPU device to another GPU device. num is the total number of bytes.
func (*Driver) MemCopyD2H ¶
MemCopyD2H copies a memory from a GPU device to the host
func (*Driver) MemCopyH2D ¶
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 ¶
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 ¶
SelectGPU requires the driver to perform the following APIs on a selected GPU
type FlushCommand ¶
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 ¶
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 ¶
func (c *LaunchUnifiedMultiGPUKernelCommand) AddReq(req sim.Msg)
AddReq adds a request to the request list associated with the command
func (*LaunchUnifiedMultiGPUKernelCommand) GetID ¶
func (c *LaunchUnifiedMultiGPUKernelCommand) GetID() string
GetID returns the ID of the command
func (*LaunchUnifiedMultiGPUKernelCommand) GetReqs ¶
func (c *LaunchUnifiedMultiGPUKernelCommand) GetReqs() []sim.Msg
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 ¶
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 ¶
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 ReqHookInfo ¶
type ReqHookInfo struct { CommandID string EventType string Now sim.VTimeInSec }
ReqHookInfo is the information that the driver send to the request hooks