From 080cbfec94ecba073d3e1d3430efb0cbccf093d5 Mon Sep 17 00:00:00 2001 From: foreman Date: Tue, 10 Apr 2018 16:18:41 -0400 Subject: [PATCH] P4 to Git Change 1539108 by vsytchen@vsytchen-ocl-win10 on 2018/04/10 15:20:10 SWDEV-79445 - OCL generic changes and code clean-up 1. Replace std::list with std::unordered_set for resourceList_. ReviewBoardURL = http://ocltc.amd.com/reviews/r/14595/diff/ Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#82 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.hpp#25 edit --- rocclr/runtime/device/pal/paldevice.cpp | 2 +- rocclr/runtime/device/pal/paldevice.hpp | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/rocclr/runtime/device/pal/paldevice.cpp b/rocclr/runtime/device/pal/paldevice.cpp index edd90ef480..b523216b9c 100644 --- a/rocclr/runtime/device/pal/paldevice.cpp +++ b/rocclr/runtime/device/pal/paldevice.cpp @@ -762,7 +762,7 @@ bool Device::create(Pal::IDevice* device) { if (!amd::Device::create()) { return false; } - resourceList_ = new std::list(); + resourceList_ = new std::unordered_set(); if (nullptr == resourceList_) { return false; } diff --git a/rocclr/runtime/device/pal/paldevice.hpp b/rocclr/runtime/device/pal/paldevice.hpp index fc0640c917..da4dbdcae9 100644 --- a/rocclr/runtime/device/pal/paldevice.hpp +++ b/rocclr/runtime/device/pal/paldevice.hpp @@ -22,6 +22,8 @@ #include "acl.h" #include "memory" +#include + /*! \addtogroup PAL * @{ */ @@ -506,17 +508,17 @@ class Device : public NullDevice { //! Adds a resource to the global list void addResource(Resource* res) const { amd::ScopedLock lock(lockResources()); - auto findIt = std::find(resourceList_->begin(), resourceList_->end(), res); + auto findIt = resourceList_->find(res); res->resizeGpuEvents(numOfVgpus() - 1); if (resourceList_->end() == findIt) { - resourceList_->push_back(res); + resourceList_->insert(res); } } //! Removes a resource from the global list void removeResource(Resource* res) const { amd::ScopedLock lock(lockResources()); - resourceList_->remove(res); + resourceList_->erase(res); } //! Resizes global resource list to accumulate a new queue @@ -525,7 +527,7 @@ class Device : public NullDevice { // or other queues process a command, since the size of the TS array can change Device::ScopedLockVgpus v(*this); amd::ScopedLock r(lockResources()); - for (auto it : *resourceList_) { + for (const auto& it : *resourceList_) { it->resizeGpuEvents(index); } } @@ -533,7 +535,7 @@ class Device : public NullDevice { //! Erases an old queue from the list void eraseResoureList(uint index) const { amd::ScopedLock lock(lockResources()); - for (auto it : *resourceList_) { + for (const auto& it : *resourceList_) { it->eraseGpuEvents(index); } } @@ -603,7 +605,7 @@ class Device : public NullDevice { Pal::IDevice* device_; //!< PAL device object std::atomic freeMem[Pal::GpuHeap::GpuHeapCount]; //!< Free memory counter amd::Monitor* lockResourceOps_; //!< Lock to serialise resource access - std::list* resourceList_; //!< Active resource list + std::unordered_set* resourceList_; //!< Active resource list RgpCaptureMgr* rgpCaptureMgr_; //!< RGP capture manager };