GPUOcelot
|
#include <EmulatorDevice.h>
Classes | |
class | MemoryAllocation |
An interface to a managed memory allocation. More... | |
class | Module |
A class for holding the state associated with a module. More... | |
class | OpenGLResource |
A graphics resource with an opengl buffer and pointer. More... | |
Public Member Functions | |
EmulatorDevice (unsigned int flags=0) | |
Sets the device properties, bind this to the cuda id. | |
virtual | ~EmulatorDevice () |
Clears all state. | |
Device::MemoryAllocation * | getMemoryAllocation (const void *address, AllocationType type) const |
Get the allocation containing a pointer or 0. | |
Device::MemoryAllocation * | getGlobalAllocation (const std::string &module, const std::string &name) |
Get the address of a global by stream. | |
Device::MemoryAllocation * | allocate (size_t size) |
Allocate some new dynamic memory on this device. | |
Device::MemoryAllocation * | allocateHost (size_t size, unsigned int flags) |
Make this a host memory allocation. | |
Device::MemoryAllocation * | registerHost (void *pointer, size_t size, unsigned int flags) |
Register a host memory allocation. | |
void | free (void *pointer) |
Free an existing non-global allocation. | |
MemoryAllocationVector | getNearbyAllocations (void *pointer) const |
Get nearby allocations to a pointer. | |
MemoryAllocationVector | getAllAllocations () const |
Get all allocations, host, global, and device. | |
void | clearMemory () |
Wipe all memory allocations, but keep modules. | |
void * | glRegisterBuffer (unsigned int buffer, unsigned int flags) |
Registers an opengl buffer with a resource. | |
void * | glRegisterImage (unsigned int image, unsigned int target, unsigned int flags) |
Registers an opengl image with a resource. | |
void | unRegisterGraphicsResource (void *resource) |
Unregister a resource. | |
void | mapGraphicsResource (void **resource, int count, unsigned int stream) |
Map a graphics resource for use with this device. | |
void * | getPointerToMappedGraphicsResource (size_t &size, void *resource) |
Get a pointer to a mapped resource along with its size. | |
void | setGraphicsResourceFlags (void *resource, unsigned int flags) |
Change the flags of a mapped resource. | |
void | unmapGraphicsResource (void **resource, int count, unsigned int streamID) |
Unmap a mapped resource. | |
virtual void | load (const ir::Module *module) |
Load a module, must have a unique name. | |
void | unload (const std::string &name) |
Unload a module by name. | |
virtual ExecutableKernel * | getKernel (const std::string &module, const std::string &kernel) |
Get a translated kernel from the device. | |
unsigned int | createEvent (int flags) |
Create a new event. | |
void | destroyEvent (unsigned int event) |
Destroy an existing event. | |
bool | queryEvent (unsigned int event) |
Query to see if an event has been recorded (yes/no) | |
void | recordEvent (unsigned int event, unsigned int stream) |
Record something happening on an event. | |
void | synchronizeEvent (unsigned int event) |
Synchronize on an event. | |
float | getEventTime (unsigned int start, unsigned int end) |
Get the elapsed time in ms between two recorded events. | |
unsigned int | createStream () |
Create a new stream. | |
void | destroyStream (unsigned int stream) |
Destroy an existing stream. | |
bool | queryStream (unsigned int stream) |
Query the status of an existing stream (ready/not) | |
void | synchronizeStream (unsigned int stream) |
Synchronize a particular stream. | |
void | setStream (unsigned int stream) |
Sets the current stream. | |
void | bindTexture (void *pointer, const std::string &moduleName, const std::string &textureName, const textureReference &ref, const cudaChannelFormatDesc &desc, const ir::Dim3 &size) |
Binds a texture to a memory allocation at a pointer. | |
void | unbindTexture (const std::string &moduleName, const std::string &textureName) |
unbinds anything bound to a particular texture | |
void * | getTextureReference (const std::string &moduleName, const std::string &textureName) |
Get's a reference to an internal texture. | |
virtual void | launch (const std::string &module, const std::string &kernel, const ir::Dim3 &grid, const ir::Dim3 &block, size_t sharedMemory, const void *argumentBlock, size_t argumentBlockSize, const trace::TraceGeneratorVector &traceGenerators=trace::TraceGeneratorVector(), const ir::ExternalFunctionSet *externals=0) |
helper function for launching a kernel | |
cudaFuncAttributes | getAttributes (const std::string &module, const std::string &kernel) |
Get the function attributes of a specific kernel. | |
unsigned int | getLastError () |
Get the last error from this device. | |
void | synchronize () |
Wait until all asynchronous operations have completed. | |
virtual void | limitWorkerThreads (unsigned int threads) |
Limit the worker threads used by this device. | |
virtual void | setOptimizationLevel (translator::Translator::OptimizationLevel level) |
Set the optimization level for kernels in this device. | |
Protected Types | |
typedef std::unordered_map < std::string, Module * > | ModuleMap |
A map of registered modules. | |
typedef std::map< void *, MemoryAllocation * > | AllocationMap |
A map of memory allocations. | |
typedef std::unordered_set < unsigned int > | StreamSet |
A set of registered streams. | |
typedef std::unordered_map < unsigned int, hydrazine::Timer::Second > | EventMap |
A map of registered events. | |
typedef std::unordered_map < unsigned int, OpenGLResource > | GraphicsMap |
A set of registered graphics resourcs. | |
Protected Attributes | |
AllocationMap | _allocations |
A map of memory allocations in device/host space. | |
ModuleMap | _modules |
The modules that have been loaded. | |
StreamSet | _streams |
Registered streams. | |
EventMap | _events |
Registered events. | |
GraphicsMap | _graphics |
Registered graphics resources. | |
bool | _selected |
Has this device been selected? | |
unsigned int | _next |
The next handle to assign to an event, stream, etc. | |
hydrazine::Timer | _timer |
Global timer. |
Interface that should be bound to the ptx emulator
typedef std::map<void*, MemoryAllocation*> executive::EmulatorDevice::AllocationMap [protected] |
A map of memory allocations.
typedef std::unordered_map<unsigned int, hydrazine::Timer::Second> executive::EmulatorDevice::EventMap [protected] |
A map of registered events.
typedef std::unordered_map<unsigned int, OpenGLResource> executive::EmulatorDevice::GraphicsMap [protected] |
A set of registered graphics resourcs.
typedef std::unordered_map<std::string, Module*> executive::EmulatorDevice::ModuleMap [protected] |
A map of registered modules.
typedef std::unordered_set<unsigned int> executive::EmulatorDevice::StreamSet [protected] |
A set of registered streams.
executive::EmulatorDevice::EmulatorDevice | ( | unsigned int | flags = 0 | ) |
Sets the device properties, bind this to the cuda id.
executive::EmulatorDevice::~EmulatorDevice | ( | ) | [virtual] |
Clears all state.
Device::MemoryAllocation * executive::EmulatorDevice::allocate | ( | size_t | size | ) | [virtual] |
Allocate some new dynamic memory on this device.
Implements executive::Device.
Device::MemoryAllocation * executive::EmulatorDevice::allocateHost | ( | size_t | size, |
unsigned int | flags | ||
) | [virtual] |
Make this a host memory allocation.
Implements executive::Device.
void executive::EmulatorDevice::bindTexture | ( | void * | pointer, |
const std::string & | moduleName, | ||
const std::string & | textureName, | ||
const textureReference & | ref, | ||
const cudaChannelFormatDesc & | desc, | ||
const ir::Dim3 & | size | ||
) | [virtual] |
Binds a texture to a memory allocation at a pointer.
Implements executive::Device.
void executive::EmulatorDevice::clearMemory | ( | ) | [virtual] |
Wipe all memory allocations, but keep modules.
Implements executive::Device.
unsigned int executive::EmulatorDevice::createEvent | ( | int | flags | ) | [virtual] |
Create a new event.
Implements executive::Device.
unsigned int executive::EmulatorDevice::createStream | ( | ) | [virtual] |
Create a new stream.
Implements executive::Device.
void executive::EmulatorDevice::destroyEvent | ( | unsigned int | event | ) | [virtual] |
Destroy an existing event.
Implements executive::Device.
void executive::EmulatorDevice::destroyStream | ( | unsigned int | stream | ) | [virtual] |
Destroy an existing stream.
Implements executive::Device.
void executive::EmulatorDevice::free | ( | void * | pointer | ) | [virtual] |
Free an existing non-global allocation.
Implements executive::Device.
Device::MemoryAllocationVector executive::EmulatorDevice::getAllAllocations | ( | ) | const [virtual] |
Get all allocations, host, global, and device.
Implements executive::Device.
cudaFuncAttributes executive::EmulatorDevice::getAttributes | ( | const std::string & | module, |
const std::string & | kernel | ||
) | [virtual] |
Get the function attributes of a specific kernel.
Implements executive::Device.
float executive::EmulatorDevice::getEventTime | ( | unsigned int | start, |
unsigned int | end | ||
) | [virtual] |
Get the elapsed time in ms between two recorded events.
Implements executive::Device.
Device::MemoryAllocation * executive::EmulatorDevice::getGlobalAllocation | ( | const std::string & | module, |
const std::string & | name | ||
) | [virtual] |
Get the address of a global by stream.
Implements executive::Device.
ExecutableKernel * executive::EmulatorDevice::getKernel | ( | const std::string & | module, |
const std::string & | kernel | ||
) | [virtual] |
Get a translated kernel from the device.
Implements executive::Device.
Reimplemented in executive::MulticoreCPUDevice.
unsigned int executive::EmulatorDevice::getLastError | ( | ) | [virtual] |
Get the last error from this device.
Implements executive::Device.
Device::MemoryAllocation * executive::EmulatorDevice::getMemoryAllocation | ( | const void * | address, |
AllocationType | type | ||
) | const [virtual] |
Get the allocation containing a pointer or 0.
Implements executive::Device.
EmulatorDevice::MemoryAllocationVector executive::EmulatorDevice::getNearbyAllocations | ( | void * | pointer | ) | const [virtual] |
Get nearby allocations to a pointer.
Implements executive::Device.
void * executive::EmulatorDevice::getPointerToMappedGraphicsResource | ( | size_t & | size, |
void * | resource | ||
) | [virtual] |
Get a pointer to a mapped resource along with its size.
Implements executive::Device.
void * executive::EmulatorDevice::getTextureReference | ( | const std::string & | moduleName, |
const std::string & | textureName | ||
) | [virtual] |
Get's a reference to an internal texture.
Implements executive::Device.
void * executive::EmulatorDevice::glRegisterBuffer | ( | unsigned int | buffer, |
unsigned int | flags | ||
) | [virtual] |
Registers an opengl buffer with a resource.
Implements executive::Device.
void * executive::EmulatorDevice::glRegisterImage | ( | unsigned int | image, |
unsigned int | target, | ||
unsigned int | flags | ||
) | [virtual] |
Registers an opengl image with a resource.
Implements executive::Device.
void executive::EmulatorDevice::launch | ( | const std::string & | module, |
const std::string & | kernel, | ||
const ir::Dim3 & | grid, | ||
const ir::Dim3 & | block, | ||
size_t | sharedMemory, | ||
const void * | argumentBlock, | ||
size_t | argumentBlockSize, | ||
const trace::TraceGeneratorVector & | traceGenerators = trace::TraceGeneratorVector() , |
||
const ir::ExternalFunctionSet * | externals = 0 |
||
) | [virtual] |
helper function for launching a kernel
module | module name |
kernel | kernel name |
grid | grid dimensions |
block | block dimensions |
sharedMemory | shared memory size |
argumentBlock | array of bytes for parameter memory |
argumentBlockSize | number of bytes in parameter memory |
traceGenerators | vector of trace generators to add and remove from kernel |
Implements executive::Device.
Reimplemented in executive::MulticoreCPUDevice.
void executive::EmulatorDevice::limitWorkerThreads | ( | unsigned int | threads | ) | [virtual] |
Limit the worker threads used by this device.
Implements executive::Device.
Reimplemented in executive::MulticoreCPUDevice.
void executive::EmulatorDevice::load | ( | const ir::Module * | module | ) | [virtual] |
Load a module, must have a unique name.
Implements executive::Device.
Reimplemented in executive::MulticoreCPUDevice.
void executive::EmulatorDevice::mapGraphicsResource | ( | void ** | resource, |
int | count, | ||
unsigned int | stream | ||
) | [virtual] |
Map a graphics resource for use with this device.
Implements executive::Device.
bool executive::EmulatorDevice::queryEvent | ( | unsigned int | event | ) | [virtual] |
Query to see if an event has been recorded (yes/no)
Implements executive::Device.
bool executive::EmulatorDevice::queryStream | ( | unsigned int | stream | ) | [virtual] |
Query the status of an existing stream (ready/not)
Implements executive::Device.
void executive::EmulatorDevice::recordEvent | ( | unsigned int | event, |
unsigned int | stream | ||
) | [virtual] |
Record something happening on an event.
Implements executive::Device.
Device::MemoryAllocation * executive::EmulatorDevice::registerHost | ( | void * | pointer, |
size_t | size, | ||
unsigned int | flags | ||
) | [virtual] |
Register a host memory allocation.
Implements executive::Device.
void executive::EmulatorDevice::setGraphicsResourceFlags | ( | void * | resource, |
unsigned int | flags | ||
) | [virtual] |
Change the flags of a mapped resource.
Implements executive::Device.
void executive::EmulatorDevice::setOptimizationLevel | ( | translator::Translator::OptimizationLevel | level | ) | [virtual] |
Set the optimization level for kernels in this device.
Implements executive::Device.
Reimplemented in executive::MulticoreCPUDevice.
void executive::EmulatorDevice::setStream | ( | unsigned int | stream | ) | [virtual] |
Sets the current stream.
Implements executive::Device.
void executive::EmulatorDevice::synchronize | ( | ) | [virtual] |
Wait until all asynchronous operations have completed.
Implements executive::Device.
void executive::EmulatorDevice::synchronizeEvent | ( | unsigned int | event | ) | [virtual] |
Synchronize on an event.
Implements executive::Device.
void executive::EmulatorDevice::synchronizeStream | ( | unsigned int | stream | ) | [virtual] |
Synchronize a particular stream.
Implements executive::Device.
void executive::EmulatorDevice::unbindTexture | ( | const std::string & | moduleName, |
const std::string & | textureName | ||
) | [virtual] |
unbinds anything bound to a particular texture
Implements executive::Device.
void executive::EmulatorDevice::unload | ( | const std::string & | name | ) | [virtual] |
Unload a module by name.
Implements executive::Device.
void executive::EmulatorDevice::unmapGraphicsResource | ( | void ** | resource, |
int | count, | ||
unsigned int | streamID | ||
) | [virtual] |
Unmap a mapped resource.
Implements executive::Device.
void executive::EmulatorDevice::unRegisterGraphicsResource | ( | void * | resource | ) | [virtual] |
Unregister a resource.
Implements executive::Device.
AllocationMap executive::EmulatorDevice::_allocations [protected] |
A map of memory allocations in device/host space.
EventMap executive::EmulatorDevice::_events [protected] |
Registered events.
GraphicsMap executive::EmulatorDevice::_graphics [protected] |
Registered graphics resources.
ModuleMap executive::EmulatorDevice::_modules [protected] |
The modules that have been loaded.
unsigned int executive::EmulatorDevice::_next [protected] |
The next handle to assign to an event, stream, etc.
bool executive::EmulatorDevice::_selected [protected] |
Has this device been selected?
Reimplemented from executive::Device.
StreamSet executive::EmulatorDevice::_streams [protected] |
Registered streams.
hydrazine::Timer executive::EmulatorDevice::_timer [protected] |
Global timer.