P4 to Git Change 1536925 by vsytchen@vsytchen-ocl-win10 on 2018/04/04 17:20:38

SWDEV-79445 - OCL generic changes and code clean-up

	1. This change replaces the use of std::map with std::unordered_map to improve lookup/insert time.
	2. Replace the use of std::make_pair and std::pair constructor with uniform initialization for cleaner code.
	3. Replace the use of std::Container::iterator type with the auto keyword for cleaner code.
	4. Use range based for loops where needed.

	ReviewBoardURL = http://ocltc.amd.com/reviews/r/14517/diff/

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/hip/hip_platform.cpp#4 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_context.cpp#58 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_d3d10.cpp#16 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_d3d10_amd.hpp#9 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_d3d11.cpp#24 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_d3d11_amd.hpp#13 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_d3d9.cpp#34 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_d3d9_amd.hpp#17 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_gl.cpp#57 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_pipe.cpp#7 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_program.cpp#46 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_svm.cpp#23 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/appprofile.hpp#14 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/cpu/cpuprogram.cpp#72 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/cpu/cpuvirtual.cpp#27 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#216 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#297 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuappprofile.cpp#13 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpubinary.cpp#59 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpucompiler.cpp#158 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#587 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpukernel.cpp#322 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprintf.cpp#46 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.cpp#237 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.hpp#70 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuresource.cpp#242 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuvirtual.cpp#415 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuvirtual.hpp#143 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palappprofile.cpp#3 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palcompiler.cpp#22 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#79 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprintf.cpp#9 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprogram.cpp#59 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.cpp#60 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#84 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.hpp#46 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/CMakeLists.txt#11 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/pro/prodevice.cpp#4 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/pro/prodevice.hpp#5 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocbinary.hpp#6 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompiler.cpp#42 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccounters.cpp#3 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprintf.cpp#10 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#81 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/command.cpp#81 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/command.hpp#89 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/commandqueue.cpp#24 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/context.cpp#49 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/context.hpp#29 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/memory.cpp#129 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/memory.hpp#102 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/perfctr.hpp#7 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/program.cpp#91 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/program.hpp#43 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/sampler.hpp#9 edit
... //depot/stg/opencl/drivers/opencl/runtime/utils/flags.cpp#17 edit
Esse commit está contido em:
foreman
2018-04-04 18:00:17 -04:00
commit d09ca72f74
43 arquivos alterados com 254 adições e 322 exclusões
+14 -19
Ver Arquivo
@@ -370,11 +370,10 @@ void UnmapMemoryCommand::releaseResources() {
bool MigrateMemObjectsCommand::validateMemory() {
if (queue()->device().info().type_ & CL_DEVICE_TYPE_GPU) {
std::vector<amd::Memory*>::const_iterator itr;
for (itr = memObjects_.begin(); itr != memObjects_.end(); itr++) {
device::Memory* mem = (*itr)->getDeviceMemory(queue()->device());
for (const auto& it : memObjects_) {
device::Memory* mem = it->getDeviceMemory(queue()->device());
if (NULL == mem) {
LogPrintfError("Can't allocate memory size - 0x%08X bytes!", (*itr)->getSize());
LogPrintfError("Can't allocate memory size - 0x%08X bytes!", it->getSize());
return false;
}
}
@@ -434,11 +433,10 @@ cl_int NDRangeKernelCommand::validateMemory() {
bool ExtObjectsCommand::validateMemory() {
bool retVal = true;
if (queue()->device().info().type_ & CL_DEVICE_TYPE_GPU) {
for (std::vector<amd::Memory*>::const_iterator itr = memObjects_.begin();
itr != memObjects_.end(); itr++) {
device::Memory* mem = (*itr)->getDeviceMemory(queue()->device());
for (const auto& it : memObjects_) {
device::Memory* mem = it->getDeviceMemory(queue()->device());
if (NULL == mem) {
LogPrintfError("Can't allocate memory size - 0x%08X bytes!", (*itr)->getSize());
LogPrintfError("Can't allocate memory size - 0x%08X bytes!", it->getSize());
return false;
}
retVal = processGLResource(mem);
@@ -457,11 +455,10 @@ bool ReleaseExtObjectsCommand::processGLResource(device::Memory* mem) {
bool MakeBuffersResidentCommand::validateMemory() {
if (queue()->device().info().type_ & CL_DEVICE_TYPE_GPU) {
for (std::vector<amd::Memory*>::const_iterator itr = memObjects_.begin();
itr != memObjects_.end(); itr++) {
device::Memory* mem = (*itr)->getDeviceMemory(queue()->device());
for (const auto& it : memObjects_) {
device::Memory* mem = it->getDeviceMemory(queue()->device());
if (NULL == mem) {
LogPrintfError("Can't allocate memory size - 0x%08X bytes!", (*itr)->getSize());
LogPrintfError("Can't allocate memory size - 0x%08X bytes!", it->getSize());
return false;
}
}
@@ -471,16 +468,14 @@ bool MakeBuffersResidentCommand::validateMemory() {
}
bool ThreadTraceMemObjectsCommand::validateMemory() {
if (queue()->device().info().type_ & CL_DEVICE_TYPE_GPU) {
for (std::vector<amd::Memory*>::const_iterator itr = memObjects_.begin();
itr != memObjects_.end(); itr++) {
device::Memory* mem = (*itr)->getDeviceMemory(queue()->device());
for (auto& it = memObjects_.cbegin(); it != memObjects_.cend(); it++) {
device::Memory* mem = (*it)->getDeviceMemory(queue()->device());
if (NULL == mem) {
std::vector<amd::Memory*>::const_iterator tmpItr;
for (tmpItr = memObjects_.begin(); tmpItr != itr; tmpItr++) {
device::Memory* tmpMem = (*tmpItr)->getDeviceMemory(queue()->device());
for (auto& tmpIt = memObjects_.cbegin(); tmpIt != it; tmpIt++) {
device::Memory* tmpMem = (*tmpIt)->getDeviceMemory(queue()->device());
delete tmpMem;
}
LogPrintfError("Can't allocate memory size - 0x%08X bytes!", (*itr)->getSize());
LogPrintfError("Can't allocate memory size - 0x%08X bytes!", (*it)->getSize());
return false;
}
}
+17 -24
Ver Arquivo
@@ -720,10 +720,9 @@ class MigrateMemObjectsCommand : public Command {
const std::vector<amd::Memory*>& memObjects,
cl_mem_migration_flags flags)
: Command(queue, type, eventWaitList), migrationFlags_(flags) {
std::vector<amd::Memory*>::const_iterator itr;
for (itr = memObjects.begin(); itr != memObjects.end(); itr++) {
(*itr)->retain();
memObjects_.push_back(*itr);
for (const auto& it : memObjects) {
it->retain();
memObjects_.push_back(it);
}
}
@@ -731,9 +730,8 @@ class MigrateMemObjectsCommand : public Command {
//! Release all resources associated with this command
void releaseResources() {
std::vector<amd::Memory*>::const_iterator itr;
for (itr = memObjects_.begin(); itr != memObjects_.end(); itr++) {
(*itr)->release();
for (const auto& it : memObjects_) {
it->release();
}
Command::releaseResources();
}
@@ -837,18 +835,16 @@ class ExtObjectsCommand : public Command {
ExtObjectsCommand(HostQueue& queue, const EventWaitList& eventWaitList, cl_uint num_objects,
const std::vector<amd::Memory*>& memoryObjects, cl_command_type type)
: Command(queue, type, eventWaitList) {
for (std::vector<amd::Memory*>::const_iterator itr = memoryObjects.begin();
itr != memoryObjects.end(); itr++) {
(*itr)->retain();
memObjects_.push_back(*itr);
for (const auto& it : memoryObjects) {
it->retain();
memObjects_.push_back(it);
}
}
//! Release all resources associated with this command
void releaseResources() {
for (std::vector<amd::Memory*>::const_iterator itr = memObjects_.begin();
itr != memObjects_.end(); itr++) {
(*itr)->release();
for (const auto& it : memObjects_) {
it->release();
}
Command::releaseResources();
}
@@ -954,9 +950,8 @@ class ThreadTraceMemObjectsCommand : public Command {
//! Release all resources associated with this command
void releaseResources() {
threadTrace_.release();
for (std::vector<amd::Memory*>::const_iterator itr = memObjects_.begin();
itr != memObjects_.end(); itr++) {
(*itr)->release();
for (const auto& itr : memObjects_) {
itr->release();
}
Command::releaseResources();
}
@@ -1067,19 +1062,17 @@ class MakeBuffersResidentCommand : public Command {
const std::vector<amd::Memory*>& memObjects,
cl_bus_address_amd* busAddr)
: Command(queue, type, eventWaitList), busAddresses_(busAddr) {
std::vector<amd::Memory*>::const_iterator itr;
for (itr = memObjects.begin(); itr != memObjects.end(); itr++) {
(*itr)->retain();
memObjects_.push_back(*itr);
for (const auto& it : memObjects) {
it->retain();
memObjects_.push_back(it);
}
}
virtual void submit(device::VirtualDevice& device) { device.submitMakeBuffersResident(*this); }
void releaseResources() {
std::vector<amd::Memory*>::const_iterator itr;
for (itr = memObjects_.begin(); itr != memObjects_.end(); itr++) {
(*itr)->release();
for (const auto& it : memObjects_) {
it->release();
}
Command::releaseResources();
}
+3 -4
Ver Arquivo
@@ -96,15 +96,14 @@ void HostQueue::loop(device::VirtualDevice* virtualDevice) {
// Process the command's event wait list.
const Command::EventWaitList& events = command->eventWaitList();
Command::EventWaitList::const_iterator it;
bool dependencyFailed = false;
for (it = events.begin(); it != events.end(); ++it) {
for (const auto& it : events) {
// Only wait if the command is enqueued into another queue.
if ((*it)->command().queue() != this) {
if (it->command().queue() != this) {
virtualDevice->flush(head, true);
tail = head = NULL;
dependencyFailed |= !(*it)->awaitCompletion();
dependencyFailed |= !it->awaitCompletion();
}
}
+8 -11
Ver Arquivo
@@ -62,10 +62,9 @@ Context::~Context() {
// Dissociate OCL context with any external device
if (info_.flags_ & (GLDeviceKhr | D3D10DeviceKhr | D3D11DeviceKhr)) {
std::vector<Device*>::const_iterator it;
// Loop through all devices
for (it = devices_.begin(); it != devices_.end(); it++) {
(*it)->unbindExternalDevice(info_.flags_, info_.hDev_, info_.hCtx_, VALIDATE_ONLY);
for (const auto& it : devices_) {
it->unbindExternalDevice(info_.flags_, info_.hDev_, info_.hCtx_, VALIDATE_ONLY);
}
}
@@ -218,10 +217,9 @@ int Context::create(const intptr_t* properties) {
// Check if OCL context can be associated with any external device
if (info_.flags_ & (D3D10DeviceKhr | D3D11DeviceKhr | GLDeviceKhr | D3D9DeviceKhr |
D3D9DeviceEXKhr | D3D9DeviceVAKhr)) {
std::vector<Device*>::const_iterator it;
// Loop through all devices
for (it = devices_.begin(); it != devices_.end(); it++) {
if (!(*it)->bindExternalDevice(info_.flags_, info_.hDev_, info_.hCtx_, VALIDATE_ONLY)) {
for (const auto& it : devices_) {
if (!it->bindExternalDevice(info_.flags_, info_.hDev_, info_.hCtx_, VALIDATE_ONLY)) {
result = CL_INVALID_VALUE;
}
}
@@ -331,10 +329,9 @@ void Context::svmFree(void* ptr) const {
}
bool Context::containsDevice(const Device* device) const {
std::vector<Device*>::const_iterator it;
for (it = devices_.begin(); it != devices_.end(); ++it) {
if (device == *it || (*it)->isAncestor(device)) {
for (const auto& it : devices_) {
if (device == it || it->isAncestor(device)) {
return true;
}
}
@@ -342,8 +339,8 @@ bool Context::containsDevice(const Device* device) const {
}
DeviceQueue* Context::defDeviceQueue(const Device& dev) const {
std::map<const Device*, DeviceQueueInfo>::const_iterator it = deviceQueues_.find(&dev);
if (it != deviceQueues_.end()) {
const auto it = deviceQueues_.find(&dev);
if (it != deviceQueues_.cend()) {
return it->second.defDeviceQueue_;
} else {
return NULL;
+3 -3
Ver Arquivo
@@ -11,7 +11,7 @@
#include "platform/agent.hpp"
#include <vector>
#include <map>
#include <unordered_map>
namespace amd {
@@ -197,8 +197,8 @@ class Context : public RuntimeObject {
GLFunctions* glenv_; //!< OpenGL context
Device* customHostAllocDevice_; //!< Device responsible for host allocations
std::vector<Device*> svmAllocDevice_; //!< Devices can support SVM allocations
std::map<const Device*, DeviceQueueInfo> deviceQueues_; //!< Device queues mapping
mutable Monitor ctxLock_; //!< Lock for the context access
std::unordered_map<const Device*, DeviceQueueInfo> deviceQueues_; //!< Device queues mapping
mutable Monitor ctxLock_; //!< Lock for the context access
};
/*! @}
+2 -1
Ver Arquivo
@@ -18,6 +18,7 @@
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
namespace device {
class Memory;
@@ -124,7 +125,7 @@ class Memory : public amd::RuntimeObject {
DeviceMemory* deviceMemories_;
//! The device alloced state
std::map<const Device*, AllocState> deviceAlloced_;
std::unordered_map<const Device*, AllocState> deviceAlloced_;
//! Linked list of destructor callbacks.
std::atomic<DestructorCallBackEntry*> destructorCallbacks_;
+1 -1
Ver Arquivo
@@ -24,7 +24,7 @@ namespace amd {
*/
class PerfCounter : public RuntimeObject {
public:
typedef std::map<cl_perfcounter_property, ulong> Properties;
typedef std::unordered_map<cl_perfcounter_property, ulong> Properties;
//! Constructor of the performance counter object
PerfCounter(const Device& device, //!< device object
+46 -58
Ver Arquivo
@@ -21,13 +21,12 @@ namespace amd {
Program::~Program() {
// Destroy all device programs
deviceprograms_t::const_iterator it, itEnd;
for (it = devicePrograms_.begin(), itEnd = devicePrograms_.end(); it != itEnd; ++it) {
delete it->second;
for (const auto& it : devicePrograms_) {
delete it.second;
}
for (devicebinary_t::const_iterator IT = binary_.begin(), IE = binary_.end(); IT != IE; ++IT) {
const binary_t& Bin = IT->second;
for (const auto& it : binary_) {
const binary_t& Bin = it.second;
if (Bin.first) {
delete[] Bin.first;
}
@@ -43,8 +42,8 @@ const Symbol* Program::findSymbol(const char* kernelName) const {
return NULL;
}
symbols_t::const_iterator it = symbolTable_->find(kernelName);
return (it == symbolTable_->end()) ? NULL : &it->second;
const auto it = symbolTable_->find(kernelName);
return (it == symbolTable_->cend()) ? NULL : &it->second;
}
cl_int Program::addDeviceProgram(Device& device, const void* image, size_t length,
@@ -151,8 +150,8 @@ cl_int Program::addDeviceProgram(Device& device, const void* image, size_t lengt
}
device::Program* Program::getDeviceProgram(const Device& device) const {
deviceprograms_t::const_iterator it = devicePrograms_.find(&device.rootDevice());
if (it == devicePrograms_.end()) {
const auto it = devicePrograms_.find(&device.rootDevice());
if (it == devicePrograms_.cend()) {
return NULL;
}
return it->second;
@@ -198,16 +197,15 @@ cl_int Program::compile(const std::vector<Device*>& devices, size_t numHeaders,
}
// Compile the program programs associated with the given devices.
std::vector<Device*>::const_iterator it;
for (it = devices.begin(); it != devices.end(); ++it) {
device::Program* devProgram = getDeviceProgram(**it);
for (const auto& it : devices) {
device::Program* devProgram = getDeviceProgram(*it);
if (devProgram == NULL) {
const binary_t& bin = binary(**it);
retval = addDeviceProgram(**it, bin.first, bin.second, &parsedOptions);
const binary_t& bin = binary(*it);
retval = addDeviceProgram(*it, bin.first, bin.second, &parsedOptions);
if (retval != CL_SUCCESS) {
return retval;
}
devProgram = getDeviceProgram(**it);
devProgram = getDeviceProgram(*it);
}
if (devProgram->type() == device::Program::TYPE_INTERMEDIATE || language_ == SPIRV) {
@@ -277,8 +275,7 @@ cl_int Program::link(const std::vector<Device*>& devices, size_t numInputs,
}
// Link the program programs associated with the given devices.
std::vector<Device*>::const_iterator it;
for (it = devices.begin(); it != devices.end(); ++it) {
for (const auto& it : devices) {
// find the corresponding device program in each input program
std::vector<device::Program*> inputDevPrograms(numInputs);
bool found = false;
@@ -288,8 +285,8 @@ cl_int Program::link(const std::vector<Device*>& devices, size_t numInputs,
parsedOptions.oVariables->BinaryIsSpirv = true;
}
deviceprograms_t inputDevProgs = inputProgram.devicePrograms();
deviceprograms_t::const_iterator findIt = inputDevProgs.find(*it);
if (findIt == inputDevProgs.end()) {
const auto findIt = inputDevProgs.find(it);
if (findIt == inputDevProgs.cend()) {
if (found) break;
continue;
}
@@ -328,14 +325,14 @@ cl_int Program::link(const std::vector<Device*>& devices, size_t numInputs,
return CL_INVALID_VALUE;
}
device::Program* devProgram = getDeviceProgram(**it);
device::Program* devProgram = getDeviceProgram(*it);
if (devProgram == NULL) {
const binary_t& bin = binary(**it);
retval = addDeviceProgram(**it, bin.first, bin.second, &parsedOptions);
const binary_t& bin = binary(*it);
retval = addDeviceProgram(*it, bin.first, bin.second, &parsedOptions);
if (retval != CL_SUCCESS) {
return retval;
}
devProgram = getDeviceProgram(**it);
devProgram = getDeviceProgram(*it);
}
// We only build a Device-Program once
@@ -359,16 +356,14 @@ cl_int Program::link(const std::vector<Device*>& devices, size_t numInputs,
}
// Rebuild the symbol table
deviceprograms_t::iterator sit;
for (sit = devicePrograms_.begin(); sit != devicePrograms_.end(); ++sit) {
const Device& device = *sit->first;
const device::Program& program = *sit->second;
for (const auto& sit : devicePrograms_) {
const Device& device = *(sit.first);
const device::Program& program = *(sit.second);
const device::Program::kernels_t& kernels = program.kernels();
device::Program::kernels_t::const_iterator kit;
for (kit = kernels.begin(); kit != kernels.end(); ++kit) {
const std::string& name = kit->first;
const device::Kernel* devKernel = kit->second;
for (const auto& it : kernels) {
const std::string& name = it.first;
const device::Kernel* devKernel = it.second;
Symbol& symbol = (*symbolTable_)[name];
if (!symbol.setDeviceKernel(device, devKernel)) {
@@ -379,9 +374,8 @@ cl_int Program::link(const std::vector<Device*>& devices, size_t numInputs,
// Create a string with all kernel names from the program
if (kernelNames_.length() == 0) {
amd::Program::symbols_t::const_iterator it;
for (it = symbols().begin(); it != symbols().end(); ++it) {
if (it != symbols().begin()) {
for (auto it = symbols().cbegin(); it != symbols().cend(); ++it) {
if (it != symbols().cbegin()) {
kernelNames_.append(1, ';');
}
kernelNames_.append(it->first.c_str());
@@ -474,20 +468,19 @@ cl_int Program::build(const std::vector<Device*>& devices, const char* options,
}
// Build the program programs associated with the given devices.
std::vector<Device*>::const_iterator it;
for (it = devices.begin(); it != devices.end(); ++it) {
device::Program* devProgram = getDeviceProgram(**it);
for (const auto& it : devices) {
device::Program* devProgram = getDeviceProgram(*it);
if (devProgram == NULL) {
const binary_t& bin = binary(**it);
const binary_t& bin = binary(*it);
if (sourceCode_.empty() && (bin.first == NULL)) {
retval = false;
continue;
}
retval = addDeviceProgram(**it, bin.first, bin.second, &parsedOptions);
retval = addDeviceProgram(*it, bin.first, bin.second, &parsedOptions);
if (retval != CL_SUCCESS) {
return retval;
}
devProgram = getDeviceProgram(**it);
devProgram = getDeviceProgram(*it);
}
parsedOptions.oVariables->AssumeAlias = true;
@@ -518,16 +511,14 @@ cl_int Program::build(const std::vector<Device*>& devices, const char* options,
}
// Rebuild the symbol table
deviceprograms_t::iterator sit;
for (sit = devicePrograms_.begin(); sit != devicePrograms_.end(); ++sit) {
const Device& device = *sit->first;
const device::Program& program = *sit->second;
for (const auto& it : devicePrograms_) {
const Device& device = *(it.first);
const device::Program& program = *(it.second);
const device::Program::kernels_t& kernels = program.kernels();
device::Program::kernels_t::const_iterator kit;
for (kit = kernels.begin(); kit != kernels.end(); ++kit) {
const std::string& name = kit->first;
const device::Kernel* devKernel = kit->second;
for (const auto& kit : kernels) {
const std::string& name = kit.first;
const device::Kernel* devKernel = kit.second;
Symbol& symbol = (*symbolTable_)[name];
if (!symbol.setDeviceKernel(device, devKernel)) {
@@ -538,9 +529,8 @@ cl_int Program::build(const std::vector<Device*>& devices, const char* options,
// Create a string with all kernel names from the program
if (kernelNames_.length() == 0) {
amd::Program::symbols_t::const_iterator it;
for (it = symbols().begin(); it != symbols().end(); ++it) {
if (it != symbols().begin()) {
for (auto it = symbols().cbegin(); it != symbols().cend(); ++it) {
if (it != symbols().cbegin()) {
kernelNames_.append(1, ';');
}
kernelNames_.append(it->first.c_str());
@@ -555,12 +545,10 @@ cl_int Program::build(const std::vector<Device*>& devices, const char* options,
}
void Program::clear() {
deviceprograms_t::iterator sit;
// Destroy old programs if we have any
for (sit = devicePrograms_.begin(); sit != devicePrograms_.end(); ++sit) {
for (const auto& it : devicePrograms_) {
// Destroy device program
delete sit->second;
delete it.second;
}
devicePrograms_.clear();
@@ -631,13 +619,13 @@ bool Symbol::setDeviceKernel(const Device& device, const device::Kernel* func, b
const device::Kernel* Symbol::getDeviceKernel(const Device& device, bool noAlias) const {
const devicekernels_t* devKernels = (noAlias) ? &deviceKernels_ : &devKernelsNoOpt_;
devicekernels_t::const_iterator itEnd = devKernels->end();
devicekernels_t::const_iterator it = devKernels->find(&device);
const auto itEnd = devKernels->cend();
auto it = devKernels->find(&device);
if (it != itEnd) {
return it->second;
}
for (it = devKernels->begin(); it != itEnd; ++it) {
for (it = devKernels->cbegin(); it != itEnd; ++it) {
if (it->first->isAncestor(&device)) {
return it->second;
}
+4 -4
Ver Arquivo
@@ -35,7 +35,7 @@ namespace amd {
//! A kernel function symbol
class Symbol : public HeapObject {
public:
typedef std::map<const Device*, const device::Kernel*> devicekernels_t;
typedef std::unordered_map<const Device*, const device::Kernel*> devicekernels_t;
private:
devicekernels_t deviceKernels_; //! All device kernels objects.
@@ -68,9 +68,9 @@ class Program : public RuntimeObject {
public:
typedef std::pair<uint8_t*, size_t> binary_t;
typedef std::set<Device const*> devicelist_t;
typedef std::map<Device const*, binary_t> devicebinary_t;
typedef std::map<Device const*, device::Program*> deviceprograms_t;
typedef std::map<std::string, Symbol> symbols_t;
typedef std::unordered_map<Device const*, binary_t> devicebinary_t;
typedef std::unordered_map<Device const*, device::Program*> deviceprograms_t;
typedef std::unordered_map<std::string, Symbol> symbols_t;
enum Language {
Binary = 0,
+1 -1
Ver Arquivo
@@ -14,7 +14,7 @@ namespace amd {
//! Abstraction layer sampler class
class Sampler : public RuntimeObject {
public:
typedef std::map<Device const*, device::Sampler*> DeviceSamplers;
typedef std::unordered_map<Device const*, device::Sampler*> DeviceSamplers;
//! \note the sampler states must match the compiler's defines.
//! See amd_ocl_sys_predef.c