GPUOcelot
|
#include <EmulatedKernel.h>
Public Types | |
typedef std::vector < ir::PTXInstruction > | PTXInstructionVector |
typedef std::map< int, std::string > | ProgramCounterBlockMap |
typedef std::unordered_map < std::string, int > | FunctionNameMap |
typedef std::map< std::string, std::pair< int, int > > | BlockRangeMap |
typedef std::unordered_map < int, const EmulatedKernel * > | PCToKernelMap |
typedef CooperativeThreadArray::RegisterFile | RegisterFile |
Public Member Functions | |
EmulatedKernel (ir::IRKernel *kernel, Device *d=0, bool initialize=true) | |
EmulatedKernel (Device *c) | |
EmulatedKernel () | |
virtual | ~EmulatedKernel () |
bool | executable () const |
Determines whether kernel is executable. | |
void | launchGrid (int width, int height, int depth) |
void | setKernelShape (int x, int y, int z) |
ir::Dim3 | getKernelShape () const |
void | setExternSharedMemorySize (unsigned int bytes) |
Changes the amount of external shared memory. | |
void | setWorkerThreads (unsigned int limit) |
void | updateArgumentMemory () |
Indicate that the kernels parameters have been updated. | |
void | updateMemory () |
Indicate that other memory has been updated. | |
TextureVector | textureReferences () const |
Get a vector of all textures references by the kernel. | |
void | setExternalFunctionSet (const ir::ExternalFunctionSet &s) |
void | clearExternalFunctionSet () |
void | initialize () |
Initialize the kernel. | |
void | initializeGlobalMemory () |
void | lazyLink (int callPC, const std::string &functionName) |
void | fixBranchTargets (size_t newPC) |
size_t | link (const std::string &functionName) |
const EmulatedKernel * | getKernel (int PC) const |
void | jumpToPC (int PC) |
RegisterFile | getCurrentRegisterFile () const |
const char * | getSharedMemory () const |
const char * | getLocalMemory (unsigned int threadId) const |
const char * | getGlobalLocalMemory (unsigned int threadId) const |
unsigned int | getCurrentFrameArgumentMemorySize () const |
unsigned int | getCurrentFrameLocalMemorySize () const |
unsigned int | getCurrentFrameParameterMemorySize () const |
const char * | getStackBase (unsigned int threadId) const |
unsigned int | getTotalStackSize (unsigned int threadId) const |
bool | checkMemoryAccess (const void *base, size_t size) const |
Check to see if a memory access is valid. | |
void | updateGlobals () |
std::string | toString () const |
std::string | fileName () const |
Get the file name that the kernel resides in. | |
std::string | location (unsigned int PC) const |
Get the nearest location to an instruction at a given PC. | |
std::string | getInstructionBlock (int PC) const |
gets the basic block label owning the instruction specified by the PC | |
std::pair< int, int > | getBlockRange (const std::string &label) const |
accessor for obtaining PCs of first and last instructions in a block | |
Public Attributes | |
ir::PTXKernel::RegisterMap | registerMap |
char * | ArgumentMemory |
char * | ConstMemory |
PTXInstructionVector | instructions |
ProgramCounterBlockMap | branchTargetsToBlock |
ProgramCounterBlockMap | basicBlockMap |
ProgramCounterBlockMap | basicBlockPC |
BlockRangeMap | blockPCRange |
TextureVector | textures |
Protected Member Functions | |
void | freeAll () |
void | registerAllocation () |
void | constructInstructionSequence () |
void | updateParamReferences () |
void | initializeArgumentMemory () |
void | initializeSharedMemory () |
void | initializeLocalMemory () |
void | initializeGlobalLocalMemory () |
void | initializeConstMemory () |
void | initializeGlobalSharedMemory () |
void | initializeStackMemory () |
void | initializeTextureMemory () |
void | initializeSymbolReferences () |
void | invalidateCallTargets () |
typedef std::map< std::string, std::pair<int, int> > executive::EmulatedKernel::BlockRangeMap |
typedef std::unordered_map<std::string, int> executive::EmulatedKernel::FunctionNameMap |
typedef std::unordered_map<int, const EmulatedKernel*> executive::EmulatedKernel::PCToKernelMap |
typedef std::map<int, std::string> executive::EmulatedKernel::ProgramCounterBlockMap |
typedef std::vector<ir::PTXInstruction> executive::EmulatedKernel::PTXInstructionVector |
executive::EmulatedKernel::EmulatedKernel | ( | ir::IRKernel * | kernel, |
Device * | d = 0 , |
||
bool | initialize = true |
||
) |
executive::EmulatedKernel::EmulatedKernel | ( | Device * | c | ) |
executive::EmulatedKernel::EmulatedKernel | ( | ) |
executive::EmulatedKernel::~EmulatedKernel | ( | ) | [virtual] |
bool executive::EmulatedKernel::checkMemoryAccess | ( | const void * | base, |
size_t | size | ||
) | const |
Check to see if a memory access is valid.
void executive::EmulatedKernel::clearExternalFunctionSet | ( | ) | [virtual] |
clear the external function table for the emulated kernel
Implements executive::ExecutableKernel.
void executive::EmulatedKernel::constructInstructionSequence | ( | ) | [protected] |
Produces a packed vector of instructions, updates each operand, and changes labels to indices.
bool executive::EmulatedKernel::executable | ( | ) | const [virtual] |
Determines whether kernel is executable.
Reimplemented from executive::ExecutableKernel.
std::string executive::EmulatedKernel::fileName | ( | ) | const |
Get the file name that the kernel resides in.
void executive::EmulatedKernel::fixBranchTargets | ( | size_t | newPC | ) |
Code that was linked in still uses absolute branch targets, they need to be updated now that the code is located in a different place.
void executive::EmulatedKernel::freeAll | ( | ) | [protected] |
Cleans up the EmulatedKernel instance
std::pair< int, int > executive::EmulatedKernel::getBlockRange | ( | const std::string & | label | ) | const |
accessor for obtaining PCs of first and last instructions in a block
unsigned int executive::EmulatedKernel::getCurrentFrameArgumentMemorySize | ( | ) | const |
unsigned int executive::EmulatedKernel::getCurrentFrameLocalMemorySize | ( | ) | const |
unsigned int executive::EmulatedKernel::getCurrentFrameParameterMemorySize | ( | ) | const |
executive::EmulatedKernel::RegisterFile executive::EmulatedKernel::getCurrentRegisterFile | ( | ) | const |
const char * executive::EmulatedKernel::getGlobalLocalMemory | ( | unsigned int | threadId | ) | const |
std::string executive::EmulatedKernel::getInstructionBlock | ( | int | PC | ) | const |
gets the basic block label owning the instruction specified by the PC
const executive::EmulatedKernel * executive::EmulatedKernel::getKernel | ( | int | PC | ) | const |
Finds the kernel beginning at the specified PC
ir::Dim3 executive::EmulatedKernel::getKernelShape | ( | ) | const |
const char * executive::EmulatedKernel::getLocalMemory | ( | unsigned int | threadId | ) | const |
const char * executive::EmulatedKernel::getSharedMemory | ( | ) | const |
const char * executive::EmulatedKernel::getStackBase | ( | unsigned int | threadId | ) | const |
unsigned int executive::EmulatedKernel::getTotalStackSize | ( | unsigned int | threadId | ) | const |
void executive::EmulatedKernel::initialize | ( | ) |
Initialize the kernel.
void executive::EmulatedKernel::initializeArgumentMemory | ( | ) | [protected] |
Allocate parameter memory
void executive::EmulatedKernel::initializeConstMemory | ( | ) | [protected] |
Maps identifiers to const memory allocations.
void executive::EmulatedKernel::initializeGlobalLocalMemory | ( | ) | [protected] |
Allocates arrays in globally scoped memory and maps identifiers to allocations.
void executive::EmulatedKernel::initializeGlobalMemory | ( | ) |
Maps identifiers to global memory allocations.
void executive::EmulatedKernel::initializeGlobalSharedMemory | ( | ) | [protected] |
Maps identifiers to global shared memory allocations.
void executive::EmulatedKernel::initializeLocalMemory | ( | ) | [protected] |
Allocates arrays in local memory and maps identifiers to allocations.
void executive::EmulatedKernel::initializeSharedMemory | ( | ) | [protected] |
Allocates arrays in shared memory and maps identifiers to allocations.
void executive::EmulatedKernel::initializeStackMemory | ( | ) | [protected] |
Determines stack memory size and maps identifiers to allocations
void executive::EmulatedKernel::initializeSymbolReferences | ( | ) | [protected] |
Setup symbols that are referenced in global variables.
void executive::EmulatedKernel::initializeTextureMemory | ( | ) | [protected] |
Scans the kernel and builds the set of textures using references in tex instructions
void executive::EmulatedKernel::invalidateCallTargets | ( | ) | [protected] |
Sets the target of call instructions to invalid pcs so that they can be lazily compiled and allocated
void executive::EmulatedKernel::jumpToPC | ( | int | PC | ) |
If the kernel is executing, jump to the specified PC
void executive::EmulatedKernel::launchGrid | ( | int | width, |
int | height, | ||
int | depth | ||
) | [virtual] |
Launch a kernel on a 2D grid
Implements executive::ExecutableKernel.
void executive::EmulatedKernel::lazyLink | ( | int | callPC, |
const std::string & | functionName | ||
) |
Lazily sets the target of a call instruction to the entry point of the specified function. This function will be inserted into the instruction sequence if it does not already exist
size_t executive::EmulatedKernel::link | ( | const std::string & | functionName | ) |
Looks up a named function in the module and inserts it into the instruction stream if it does not exist. Returns the PC of the function in the instruction stream.
std::string executive::EmulatedKernel::location | ( | unsigned int | PC | ) | const |
Get the nearest location to an instruction at a given PC.
void executive::EmulatedKernel::registerAllocation | ( | ) | [protected] |
On construction, allocates registers by computing live ranges
void executive::EmulatedKernel::setExternalFunctionSet | ( | const ir::ExternalFunctionSet & | s | ) | [virtual] |
sets an external function table for the emulated kernel
Implements executive::ExecutableKernel.
void executive::EmulatedKernel::setExternSharedMemorySize | ( | unsigned int | bytes | ) | [virtual] |
Changes the amount of external shared memory.
Implements executive::ExecutableKernel.
void executive::EmulatedKernel::setKernelShape | ( | int | x, |
int | y, | ||
int | z | ||
) | [virtual] |
Sets the shape of a kernel
Implements executive::ExecutableKernel.
void executive::EmulatedKernel::setWorkerThreads | ( | unsigned int | limit | ) | [virtual] |
Sets device used to execute the kernel
Implements executive::ExecutableKernel.
executive::ExecutableKernel::TextureVector executive::EmulatedKernel::textureReferences | ( | ) | const [virtual] |
Get a vector of all textures references by the kernel.
Implements executive::ExecutableKernel.
std::string executive::EmulatedKernel::toString | ( | ) | const |
Print out every instruction
void executive::EmulatedKernel::updateArgumentMemory | ( | ) | [virtual] |
Indicate that the kernels parameters have been updated.
Implements executive::ExecutableKernel.
void executive::EmulatedKernel::updateGlobals | ( | ) |
Copies data from global objects into const and global memory
void executive::EmulatedKernel::updateMemory | ( | ) | [virtual] |
Indicate that other memory has been updated.
Implements executive::ExecutableKernel.
void executive::EmulatedKernel::updateParamReferences | ( | ) | [protected] |
After emitting the instruction sequence, visit each memory move operation and replace references to parameters with offsets into parameter memory.
After emitting the instruction sequence, visit each memory move operation and replace references to parameters with offsets into parameter memory.
Data movement instructions: ld, st
Pointer to block of memory used to store argument data
maps the program counter of the terminating instructions to owning basic block
maps a PC to the basic block it starts
maps a block label to the PCs of the first and last instructions in the block
Maps program counters of header instructions to basic block label
Pointer to byte-addressable const memory
Packed and allocated vector of instructions
A map of register name to register number
Packed vector of mapped textures