当前位置: 首页>>代码示例>>C++>>正文


C++ OperandVector::begin方法代码示例

本文整理汇总了C++中OperandVector::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ OperandVector::begin方法的具体用法?C++ OperandVector::begin怎么用?C++ OperandVector::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OperandVector的用法示例。


在下文中一共展示了OperandVector::begin方法的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());
}
开发者ID:dougct,项目名称:ocelot-ufmg,代码行数:48,代码来源:ModuleLinkerPass.cpp

示例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;
					}
				}
			}
		}
	}
}
开发者ID:dougct,项目名称:ocelot-ufmg,代码行数:46,代码来源:ModuleLinkerPass.cpp

示例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};
//.........这里部分代码省略.........
开发者ID:AlexanderStohr,项目名称:gpuocelot,代码行数:101,代码来源:ATIExecutableKernel.cpp


注:本文中的OperandVector::begin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。