本文整理汇总了C++中OperandVector::end方法的典型用法代码示例。如果您正苦于以下问题:C++ OperandVector::end方法的具体用法?C++ OperandVector::end怎么用?C++ OperandVector::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OperandVector
的用法示例。
在下文中一共展示了OperandVector::end方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getAllSymbolsUsedByThisKernel
static StringVector getAllSymbolsUsedByThisKernel(
const std::string& kernelName, ir::Module* module)
{
auto kernel = module->kernels().find(kernelName);
if(kernel == module->kernels().end()) return StringVector();
StringSet encountered;
for(auto block = kernel->second->cfg()->begin();
block != kernel->second->cfg()->end(); ++block)
{
for(auto instruction = block->instructions.begin();
instruction != block->instructions.end(); ++instruction)
{
typedef std::vector<ir::PTXOperand*> OperandVector;
auto ptx = static_cast<ir::PTXInstruction*>(*instruction);
OperandVector operands;
operands.push_back(&ptx->a);
operands.push_back(&ptx->b);
operands.push_back(&ptx->pg);
operands.push_back(&ptx->pq);
operands.push_back(&ptx->d);
if(ptx->opcode != ir::PTXInstruction::Call)
{
operands.push_back(&ptx->c);
}
for(auto operand = operands.begin();
operand != operands.end(); ++operand)
{
if((*operand)->addressMode != ir::PTXOperand::Address &&
(*operand)->addressMode != ir::PTXOperand::FunctionName)
{
continue;
}
encountered.insert((*operand)->identifier);
}
}
}
return StringVector(encountered.begin(), encountered.end());
}
示例2: replaceInstances
static void replaceInstances(ir::Module& module, const std::string& oldName,
const std::string& newName)
{
for(auto kernel = module.kernels().begin();
kernel != module.kernels().end(); ++kernel)
{
for(auto block = kernel->second->cfg()->begin();
block != kernel->second->cfg()->end(); ++block)
{
for(auto instruction = block->instructions.begin();
instruction != block->instructions.end(); ++instruction)
{
typedef std::vector<ir::PTXOperand*> OperandVector;
auto ptx = static_cast<ir::PTXInstruction*>(*instruction);
OperandVector operands;
operands.push_back(&ptx->a);
operands.push_back(&ptx->b);
operands.push_back(&ptx->pg);
operands.push_back(&ptx->pq);
operands.push_back(&ptx->d);
if(ptx->opcode != ir::PTXInstruction::Call)
{
operands.push_back(&ptx->c);
}
for(auto operand = operands.begin();
operand != operands.end(); ++operand)
{
if((*operand)->addressMode != ir::PTXOperand::Address)
{
continue;
}
if((*operand)->identifier == oldName)
{
(*operand)->identifier = newName;
}
}
}
}
}
}
示例3: initializeSharedMemory
void ATIExecutableKernel::initializeSharedMemory()
{
report("Allocating shared memory");
typedef std::unordered_map<std::string, size_t> AllocationMap;
typedef std::unordered_set<std::string> StringSet;
typedef std::deque<ir::PTXOperand*> OperandVector;
typedef std::unordered_map<std::string,
ir::Module::GlobalMap::const_iterator> GlobalMap;
AllocationMap map;
GlobalMap sharedGlobals;
StringSet external;
OperandVector externalOperands;
unsigned int externalAlignment = 1;
size_t sharedSize = 0;
assert(module != 0);
// global shared variables
ir::Module::GlobalMap globals = module->globals();
ir::Module::GlobalMap::const_iterator global;
for (global = globals.begin() ; global != globals.end() ; global++)
{
ir::PTXStatement statement = global->second.statement;
if (statement.directive == ir::PTXStatement::Shared)
{
if (statement.attribute == ir::PTXStatement::Extern)
{
report("Found global external shared variable \""
<< statement.name << "\"");
assertM(external.count(statement.name) == 0,
"External global \"" << statement.name
<< "\" declared more than once.");
external.insert(statement.name);
externalAlignment = std::max(externalAlignment,
(unsigned int)statement.alignment);
externalAlignment = std::max(externalAlignment,
ir::PTXOperand::bytes(statement.type));
} else {
report("Found global shared variable \""
<< statement.name << "\"");
sharedGlobals.insert(
std::make_pair(statement.name, global));
}
}
}
// local shared variables
LocalMap::const_iterator local;
for (local = locals.begin() ; local != locals.end() ; local++)
{
if (local->second.space == ir::PTXInstruction::Shared)
{
if (local->second.attribute == ir::PTXStatement::Extern)
{
report("Found local external shared variable \""
<< local->second.name << "\"");
assertM(external.count(local->second.name) == 0,
"External local \"" << local->second.name
<< "\" declared more than once.");
external.insert(local->second.name);
externalAlignment = std::max(externalAlignment,
(unsigned int)local->second.alignment);
externalAlignment = std::max(externalAlignment,
ir::PTXOperand::bytes(local->second.type));
} else
{
report("Allocating local shared variable \""
<< local->second.name << "\" of size "
<< local->second.getSize());
_pad(sharedSize, local->second.alignment);
map.insert(std::make_pair(local->second.name, sharedSize));
sharedSize += local->second.getSize();
}
}
}
ir::ControlFlowGraph::iterator block;
for (block = cfg()->begin() ; block != cfg()->end() ; block++)
{
ir::ControlFlowGraph::InstructionList insts = block->instructions;
ir::ControlFlowGraph::InstructionList::iterator inst;
for (inst = insts.begin() ; inst != insts.end() ; inst++)
{
ir::PTXInstruction& ptx =
static_cast<ir::PTXInstruction&>(**inst);
if (ptx.opcode == ir::PTXInstruction::Mov ||
ptx.opcode == ir::PTXInstruction::Ld ||
ptx.opcode == ir::PTXInstruction::St)
{
ir::PTXOperand* operands[] = {&ptx.d, &ptx.a, &ptx.b,
&ptx.c};
//.........这里部分代码省略.........